Bug 12754 – MAC link error for template to static value

Status
NEW
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Mac OS X
Creation time
2014-05-16T10:57:14Z
Last change time
2024-12-13T18:20:38Z
Assigned to
No Owner
Creator
monarchdodra
Moved to GitHub: dmd#18828 →

Comments

Comment #0 by monarchdodra — 2014-05-16T10:57:14Z
Currently blocking https://github.com/D-Programming-Language/phobos/pull/2172/files#r12711667 Reproducible only on MAC. Requires 2 "library" files, and a "client" file. We'll call the library "foo": //----- //foo/traits.d module foo.traits; template lvalueInit(T) { static lvalueInit = immutable(T).init; } //----- //----- //foo/file.d module foo.file; import foo.traits; struct Impl { } struct F { Impl i; this(int) { i = lvalueInit!Impl; } } //----- That's it for the "library". We compile it as such: dmd -lib foo/traits.d foo/file.d -ofmylib From there, create a simple main.d: //----- //main.d module main; import foo.file; void main() { auto f = F(5); } //----- Then build... dmd mylib.a -run main.d Undefined symbols for architecture x86_64: "_D3foo6traits32__T10lvalueInitTS3foo4file4ImplZ10lvalueInityS3foo4file4Impl", referenced from: _D3foo4file1F6__ctorMFNciZS3foo4file1F in mylib.a(file_3_46.o) ld: symbol(s) not found for architecture x86_64
Comment #1 by monarchdodra — 2014-05-19T18:17:18Z
For what it's worth, I tried with/without "-allinst", but it didn't seem to make a difference (but I'm not really sure how that option works anyways...)
Comment #2 by monarchdodra — 2014-07-18T19:19:33Z
Has anybody from the DMD team seen this report? I don't need a fix asap or anything, but just confirmation that someone knows about it would be nice.
Comment #3 by hsteoh — 2014-07-18T21:17:05Z
You might want to post this on the newsgroup/forum. I appear to be the only other user on the Cc list for this bug. :-P
Comment #4 by deadalnix — 2014-08-10T21:14:01Z
Undefined symbols for architecture x86_64: "_D1d3ast10expression52__T15UnaryExpressionTC1d2ir10expression10ExpressionZ15UnaryExpression11__invariantMxFZv", referenced from: _D1d3ast10expression52__T15UnaryExpressionTC1d2ir10expression10ExpressionZ15UnaryExpression69__T6__ctorTS1d3ast8qualtype30__T8QualTypeTC1d2ir4type4TypeZ8QualTypeZ6__ctorMFS1d8location8LocationS1d3ast8qualtype30__T8QualTypeTC1d2ir4type4TypeZ8QualTypeE1d3ast10expression7UnaryOpC1d2ir10expression10ExpressionZC1d3ast10expression52__T15UnaryExpressionTC1d2ir10expression10ExpressionZ15UnaryExpression in libd.a(symbol.o) This look like this is a blocker for SDC.
Comment #5 by dlang-bugzilla — 2014-08-15T14:36:25Z
If this is a regression, can you indicate a version when this worked? I'm getting the same error with 2.065.
Comment #6 by monarchdodra — 2014-08-15T17:37:30Z
(In reply to Vladimir Panteleev from comment #5) > If this is a regression, can you indicate a version when this worked? I'm > getting the same error with 2.065. AFAIK, it's not a reg. I remember having had since since long ago, but reduced it only now. I don't have access to a mac anymore either, so I wouldn't even be able to check...
Comment #7 by dlang-bugzilla — 2014-08-15T17:39:17Z
OK, let's get it off the http://wiki.dlang.org/Beta_Testing regression list unless someone can confirm otherwise.
Comment #8 by deadalnix — 2014-08-16T00:20:55Z
(In reply to monarchdodra from comment #6) > (In reply to Vladimir Panteleev from comment #5) > > If this is a regression, can you indicate a version when this worked? I'm > > getting the same error with 2.065. > > AFAIK, it's not a reg. I remember having had since since long ago, but > reduced it only now. > > I don't have access to a mac anymore either, so I wouldn't even be able to > check... It compile in 2.065, do not in the rc. It is not because it has been broken for a while in trunck that this isn't a regression.
Comment #9 by dlang-bugzilla — 2014-08-16T00:26:16Z
(In reply to deadalnix from comment #8) > (In reply to monarchdodra from comment #6) > > (In reply to Vladimir Panteleev from comment #5) > > > If this is a regression, can you indicate a version when this worked? I'm > > > getting the same error with 2.065. > > > > AFAIK, it's not a reg. I remember having had since since long ago, but > > reduced it only now. > > > > I don't have access to a mac anymore either, so I wouldn't even be able to > > check... > > It compile in 2.065, do not in the rc. Not for me: bash-3.2$ dmd | head -1 DMD64 D Compiler v2.065 bash-3.2$ dmd -lib foo/traits.d foo/file.d -ofmylib bash-3.2$ dmd -run main.d mylib.a Undefined symbols for architecture x86_64: "_D3foo4file1F6__ctorMFNciZS3foo4file1F", referenced from: __Dmain in main.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status --- errorlevel 1 Please provide a test case which works in 2.065 but not in master or the RC. > It is not because it has been broken for a while in trunck that this isn't a > regression. I don't know how you got the impression that we made the conclusion based on whether something "has been broken for a while in trunck".
Comment #10 by dlang-bugzilla — 2014-08-16T00:33:52Z
(In reply to Vladimir Panteleev from comment #9) > bash-3.2$ dmd -run main.d mylib.a No, that's not right. I was trying different things but this is clearly wrong. But the point stands: bash-3.2$ dmd main.d mylib.a Undefined symbols for architecture x86_64: "_D3foo6traits32__T10lvalueInitTS3foo4file4ImplZ10lvalueInityS3foo4file4Impl", referenced from: _D3foo4file1F6__ctorMFNciZS3foo4file1F in mylib.a(file_3_46.o) ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status --- errorlevel 1
Comment #11 by deadalnix — 2014-08-18T21:30:50Z
I did some investigation and I have better: The problem is due to an update in OSX's linker. That indeed not a regression( not a DMD regression anyway). That is why is is now failing with previous version of DMD as well. LLVM had a recent update to fix this, but I can't find the commit that did it.
Comment #12 by r.sagitario — 2014-10-31T09:39:19Z
Comment #13 by robert.schadek — 2024-12-13T18:20:38Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18828 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB