Bug 19123 – -allinst gives undefined reference linker errors

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-07-27T23:13:03Z
Last change time
2022-12-20T20:42:12Z
Assigned to
No Owner
Creator
JR

Comments

Comment #0 by zorael — 2018-07-27T23:13:03Z
Manjaro/Arch x86_64, dmd 2.081.1, ldc 1.10.0. run.dlang.io also shows the same behaviour "since 2.080.1". Reduced example, fails to link with -allinst but works without (dmd and ldc): void main() { import std.stdio; import std.datetime; writefln("%s", Clock.currTime); } > $ dmd -allinst test.d > /dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d:273: error: undefined reference to '_D3std6format__T11hasToStringTSQBd8datetime7systime7SysTimeTaZ9__lambda2MFZ1S3putMFNaNbNiNfaZv' > /dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d:273: error: undefined reference to '_D3std6format__T11hasToStringTSQBd8datetime7systime7SysTimeTaZ9__lambda2MFZ1S3putMFNaNbNiNfaZv' > /dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d:273: error: undefined reference to '_D3std6format__T11hasToStringTSQBd8datetime7systime7SysTimeTaZ9__lambda2MFZ1S3putMFNaNbNiNfaZv' > /dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d:273: error: undefined reference to '_D3std6format__T11hasToStringTSQBd8datetime7systime7SysTimeTaZ9__lambda2MFZ1S3putMFNaNbNiNfaZv' > collect2: error: ld returned 1 exit status > Error: linker exited with status 1
Comment #1 by b2.temp — 2018-07-27T23:42:44Z
actually it's a 2.080.0 regression.
Comment #2 by slavo5150 — 2018-08-06T11:34:02Z
According to digger it was https://github.com/dlang/phobos/pull/6190 that caused this regression.
Comment #3 by slavo5150 — 2018-08-06T11:42:33Z
(In reply to Mike Franklin from comment #2) > According to digger it was https://github.com/dlang/phobos/pull/6190 that > caused this regression. ...though it may have just revealed a bug in DMD.
Comment #4 by slavo5150 — 2018-08-07T00:47:32Z
I've narrowed this down somewhat. What's happening is `-allinst` causes symbols to be emitted to the object file that otherwise wouldn't be. Those symbols, however, call other symbols, and it's those other symbols that aren't being emitted for some reason, resulting in linker errors.
Comment #5 by slavo5150 — 2018-08-08T02:12:33Z
_D3std6format__T11hasToStringTSQBd8datetime7systime7SysTimeTaZ9__lambda2MFZ1S3putMFNaNbNiNfaZv ... demangles to... pure nothrow @nogc @safe void std.format.hasToString!(std.datetime.systime.SysTime, char).__lambda2().S.put(char) When logging semantic in the compiler, I don't see it in the AST either.
Comment #6 by goalitium — 2019-11-11T01:42:12Z
I recently hit a bug similar to this one, if not the same one, with this following code: import std.variant; import std.typecons; struct S {} void main() { alias T = Typedef!(S, S.init); Variant v = T(); } > /dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d:276: error: undefined reference to '_D3std6format__T11hasToStringTSQBd8typecons__T7TypedefTS9onlineapp1SVQoS0VAyanZQBhTaZ9__lambda1MFZQBg3putMFNaNbNiNfaZv' > /dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d:276: error: undefined reference to '_D3std6format__T11hasToStringTSQBd8typecons__T7TypedefTS9onlineapp1SVQoS0VAyanZQBhTaZ9__lambda1MFZQBg3putMFNaNbNiNfaZv' > /dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d:276: error: undefined reference to '_D3std6format__T11hasToStringTSQBd8typecons__T7TypedefTS9onlineapp1SVQoS0VAyanZQBhTaZ9__lambda1MFZQBg3putMFNaNbNiNfaZv' > collect2: error: ld returned 1 exit status > Error: linker exited with status 1
Comment #7 by ibuclaw — 2022-12-20T20:42:12Z
This has been fixed since originally reported. Can't point at what might have fixed it, changes like the PR linked below likely helped though. https://github.com/dlang/dmd/pull/13578