www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - std.boxer linker error

reply Brad Roberts <braddr puremagic.com> writes:
On linux with dmd 0.148, I'm seeing some odd linking issues that I haven't 
tracked down just yet.

$ cat test_box.d
import std.boxer;

int main()
{
    Box foo = box(1);
    int bar = unbox!(int)(foo);

    return 0;
}

$ dmd -g -v 
test_box.d
parse     test_box
semantic  test_box
semantic2 test_box
semantic3 test_box
code      test_box
generating code for function 'main'
generating code for function 'unbox'
generating code for function 'unboxCastInteger'
gcc test_box.o -o test_box -g -lphobos -lpthread -lm -Xlinker
-L/workplace/bradrob/dmd-0.148/dmd/lib 
test_box.o(.gnu.linkonce.t_D3std5boxer24__T16unboxCastIntegerTiZ16unboxCastIntegerFS3st
5boxer3BoxZi+0x18): In function
`_D3std5boxer24__T16unboxCastIntegerTiZ16unboxCastIntegerFS3std5boxer3BoxZi':
/workplace/bradrob/d-playground/test_box.d:5: undefined reference to
`_assert_3std5boxer'
collect2: ld returned 1 exit status
--- errorlevel 1


Commenting out the assert in std/boxer.d inside unboxCastInteger(T) at 
line 429 allows the link to succeed.

Similarly, if I use something other than an int and hit one of the other 
unboxCast[pick a type] templates I get the same problem.

Thoughts?

Thanks,
Brad
Mar 02 2006
parent reply Derek Parnell <derek psych.ward> writes:
On Thu, 2 Mar 2006 17:38:00 -0800, Brad Roberts wrote:

 On linux with dmd 0.148, I'm seeing some odd linking issues that I haven't 
 tracked down just yet.
On Windows, you have to compile anything that imports std.boxer with the "-release" switch to get the linker happy. -- Derek (skype: derek.j.parnell) Melbourne, Australia "Down with mediocracy!" 3/03/2006 3:18:27 PM
Mar 02 2006
next sibling parent Brad Roberts <braddr puremagic.com> writes:
On Fri, 3 Mar 2006, Derek Parnell wrote:

 On Thu, 2 Mar 2006 17:38:00 -0800, Brad Roberts wrote:
 
 On linux with dmd 0.148, I'm seeing some odd linking issues that I haven't 
 tracked down just yet.
On Windows, you have to compile anything that imports std.boxer with the "-release" switch to get the linker happy. -- Derek (skype: derek.j.parnell) Melbourne, Australia "Down with mediocracy!" 3/03/2006 3:18:27 PM
Not a bad temporary work around, but only temporary since that disables all asserts. Thanks, Brad
Mar 02 2006
prev sibling parent reply Don Clugston <dac nospam.com.au> writes:
Derek Parnell wrote:
 On Thu, 2 Mar 2006 17:38:00 -0800, Brad Roberts wrote:
 
 On linux with dmd 0.148, I'm seeing some odd linking issues that I haven't 
 tracked down just yet.
On Windows, you have to compile anything that imports std.boxer with the "-release" switch to get the linker happy.
Do we know the reason for that? Has it been reduced to a minimal test case?
Mar 03 2006
parent reply Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Don Clugston schrieb am 2006-03-03:
 Derek Parnell wrote:
 On Thu, 2 Mar 2006 17:38:00 -0800, Brad Roberts wrote:
 
 On linux with dmd 0.148, I'm seeing some odd linking issues that I haven't 
 tracked down just yet.
On Windows, you have to compile anything that imports std.boxer with the "-release" switch to get the linker happy.
Do we know the reason for that?
DMD generates different symbols depending on the state of the "-release" switch.
 Has it been reduced to a minimal test case?
Not as far as I know. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFECzFA3w+/yD4P9tIRAg+SAKCX8uLcK8qzpxIETpaKfFrwlkHXIwCdEUqq m0jI3bOzWWovyFAqoAKvjA0= =8x9Q -----END PGP SIGNATURE-----
Mar 05 2006
parent Brad Roberts <braddr puremagic.com> writes:
On Sun, 5 Mar 2006, Thomas Kuehne wrote:

 Don Clugston schrieb am 2006-03-03:
 Derek Parnell wrote:
 On Thu, 2 Mar 2006 17:38:00 -0800, Brad Roberts wrote:
 
 On linux with dmd 0.148, I'm seeing some odd linking issues that I haven't 
 tracked down just yet.
On Windows, you have to compile anything that imports std.boxer with the "-release" switch to get the linker happy.
Do we know the reason for that?
DMD generates different symbols depending on the state of the "-release" switch.
 Has it been reduced to a minimal test case?
Not as far as I know. Thomas
I tried a little bit to reduce the problem. If you're looking for a single file contained test case then I'm not sure that's doable. I suspect this might relate to the other threads going on right now about symbols changing visibility based on compiler options. Random thought: Now that dmd can produce .di files, THOSE are what should be used now rather than the full .d's during subsequent compilation. I haven't checked their output, but I assume that the unused paths around version, debug, release, etc are omitted such that the .di file _exactly_ matches the .o/.obj files produced. Later, Brad
Mar 05 2006