www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - link errors with 0.149, templates, and writefln

reply Kevin Bealer <Kevin_member pathlink.com> writes:
When I try to compile the following two files, I get a working program, but if
the unused function "quux" is removed, the compile fails with a symbol error at
link time.  It looks like the writefln() in quux brings in the necessary symbols
but the similar writefln() in the template does not do so.

This does not seem to be related to IFTI -- if I change that the error still
seems to happen.

NOTE: this is on a 64 bit machine in Linux, so I need to manually link with gcc
using a slight variant of the "gcc" command that dmd uses.  I can provide more
data on this if needed.

The compiler is DMD 0.149 for Linux.

The errors look like this:

/home/marlon/src/dscript/trydmd1.d:8: undefined reference to `_arguments_Aad'
/home/marlon/src/dscript/trydmd1.d:8: undefined reference to `_arguments_Aad'

 autotmp.d


: import std.stdio; : : template foo(f1) : { : void foo(f1 x) : { : writefln("no dice, chicago, %s.", x); : } : } : :
 trydmd1.d


: import std.stdio; : import autotmp; : : // removal of the quux function breaks the compile : //void quux(int x) : //{ : // double foo = x + 4; : // writefln("no dice %s.", foo); : //} : : int main(char[][] args) : { : foo(-29.0); : : if (args.length > 1) { : writefln("%s", args[1]); : } : return 0; : } : Kevin Bealer
Mar 12 2006
next sibling parent reply Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kevin Bealer schrieb am 2006-03-13:
 NOTE: this is on a 64 bit machine in Linux, so I need to manually link with gcc
 using a slight variant of the "gcc" command that dmd uses.  I can provide more
 data on this if needed.

Hint: add "-L-m32" do the dmd command line. If your system needs gcc32: 1) create a new dir 2) add the file "gcc" with the the following content to the new dir #!/bin/bash gcc32 $* 3) prepend the new dir to your path when you call dmd PATH=/the_new_dir:$PATH dmd ... Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEFTrl3w+/yD4P9tIRAgAeAJ9NOra+SQ7nEItPndUi+GQXMoHfSACghYLY gYKYvxUS6FcaLNC6q1IVvRg= =sO5l -----END PGP SIGNATURE-----
Mar 13 2006
next sibling parent Kevin Bealer <Kevin_member pathlink.com> writes:
In article <agqfe3-uh8.ln1 birke.kuehne.cn>, Thomas Kuehne says...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kevin Bealer schrieb am 2006-03-13:
 NOTE: this is on a 64 bit machine in Linux, so I need to manually link with gcc
 using a slight variant of the "gcc" command that dmd uses.  I can provide more
 data on this if needed.

Hint: add "-L-m32" do the dmd command line. If your system needs gcc32: 1) create a new dir 2) add the file "gcc" with the the following content to the new dir #!/bin/bash gcc32 $* 3) prepend the new dir to your path when you call dmd PATH=/the_new_dir:$PATH dmd ... Thomas

Thank you; I have tried this, and it didn't work. Although, I don't know whether I need gcc32 or indeed what it is for. But the following Makefile is what I am using to build instead, and it seems to work fine.
 Makefile


: : # Project configuration : : OBJ=hello.o : D_OPTS=-debug -g : BINARY=hello : : : # Machinery : : D_LIBS=-lphobos -lpthread -lm : C_OPTS=-m32 : : TARGET: ${BINARY} : : ${BINARY}: ${OBJ} : gcc ${OBJ} -o $ ${C_OPTS} ${D_LIBS} : : clean: : rm -vf ${BINARY} *.o : : %.o: %.d ${SRC} : dmd -c ${D_OPTS} $^ : This works fine for most of my D projects, but unless there is link time magic in DMD for template instantiations, I don't think this is directly connected to the linking issue I was reporting. Some C++ compilers have such a thing but I don't know if DMD does. Thanks, Kevin
Mar 13 2006
prev sibling parent reply "Unknown W. Brackets" <unknown simplemachines.org> writes:
Couldn't you do this with dmd.conf easier?  Or does dmd not respect that 
when calling gcc?

-[Unknown]


 PATH=/the_new_dir:$PATH dmd ...
 
 Thomas

Mar 14 2006
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Unknown W. Brackets schrieb am 2006-03-15:
 Couldn't you do this with dmd.conf easier?  Or does dmd not respect that 
 when calling gcc?

 -[Unknown]


 PATH=/the_new_dir:$PATH dmd ...
 
 Thomas


I never tried that - dmd only looks for /etc/dmd.conf not for ~/.dmd.conf or dmd.conf in the same dir as the binary. (having multiple dmd versions or a non-root installation in that setting is a pitta) This doesn't work: /etc/dmd.conf: PATH=/opt/dmd/cage:$PATH This does work /etc/dmd.conf: PATH=/opt/dmd/cage:%PATH% A mixed Linux-Windows notation in a Linux config file :D Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEGIWW3w+/yD4P9tIRAgvAAKDGAJxcm1D58aIYTGCciGHPbR/q8wCgoiPM But7ystBb7PZojQl/8Voq9M= =OGQC -----END PGP SIGNATURE-----
Mar 15 2006
prev sibling parent reply Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kevin Bealer schrieb am 2006-03-13:
 When I try to compile the following two files, I get a working program, but if
 the unused function "quux" is removed, the compile fails with a symbol error at
 link time.  It looks like the writefln() in quux brings in the necessary
symbols
 but the similar writefln() in the template does not do so.

 This does not seem to be related to IFTI -- if I change that the error still
 seems to happen.

 NOTE: this is on a 64 bit machine in Linux, so I need to manually link with gcc
 using a slight variant of the "gcc" command that dmd uses.  I can provide more
 data on this if needed.

 The compiler is DMD 0.149 for Linux.

 The errors look like this:

 /home/marlon/src/dscript/trydmd1.d:8: undefined reference to `_arguments_Aad'
 /home/marlon/src/dscript/trydmd1.d:8: undefined reference to `_arguments_Aad'

 autotmp.d


: import std.stdio; : : template foo(f1) : { : void foo(f1 x) : { : writefln("no dice, chicago, %s.", x); : } : } : :
 trydmd1.d


: import std.stdio; : import autotmp; : : // removal of the quux function breaks the compile : //void quux(int x) : //{ : // double foo = x + 4; : // writefln("no dice %s.", foo); : //} : : int main(char[][] args) : { : foo(-29.0); : : if (args.length > 1) { : writefln("%s", args[1]); : } : return 0; : } :

FAIL: dmd -c autotmp.d dmd -c trydmd1.d dmd autotmp.o trydmd1.o PASS: dmd autotmp.d trydmd1.d Added to DStress as http://dstress.kuehne.cn/complex/arguments (It's a "complex" target due to its multistage build process.) Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEFzbn3w+/yD4P9tIRAnQ2AJ4zzHnyhJVk4YrsPltMELI0JWDy1QCfaQKC 4QtePXTq+7sodj+t6+YMq7I= =cSmb -----END PGP SIGNATURE-----
Mar 14 2006
parent Kevin Bealer <Kevin_member pathlink.com> writes:
In article <8gpje3-v6b.ln1 birke.kuehne.cn>, Thomas Kuehne says...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kevin Bealer schrieb am 2006-03-13:
 When I try to compile the following two files, I get a working program, but if
 the unused function "quux" is removed, the compile fails with a symbol error at
 link time.  It looks like the writefln() in quux brings in the necessary
symbols
 but the similar writefln() in the template does not do so.

 This does not seem to be related to IFTI -- if I change that the error still
 seems to happen.

 NOTE: this is on a 64 bit machine in Linux, so I need to manually link with gcc
 using a slight variant of the "gcc" command that dmd uses.  I can provide more
 data on this if needed.

 The compiler is DMD 0.149 for Linux.

 The errors look like this:

 /home/marlon/src/dscript/trydmd1.d:8: undefined reference to `_arguments_Aad'
 /home/marlon/src/dscript/trydmd1.d:8: undefined reference to `_arguments_Aad'

 autotmp.d


: import std.stdio; : : template foo(f1) : { : void foo(f1 x) : { : writefln("no dice, chicago, %s.", x); : } : } : :
 trydmd1.d


: import std.stdio; : import autotmp; : : // removal of the quux function breaks the compile : //void quux(int x) : //{ : // double foo = x + 4; : // writefln("no dice %s.", foo); : //} : : int main(char[][] args) : { : foo(-29.0); : : if (args.length > 1) { : writefln("%s", args[1]); : } : return 0; : } :

FAIL: dmd -c autotmp.d dmd -c trydmd1.d dmd autotmp.o trydmd1.o PASS: dmd autotmp.d trydmd1.d Added to DStress as http://dstress.kuehne.cn/complex/arguments (It's a "complex" target due to its multistage build process.) Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEFzbn3w+/yD4P9tIRAnQ2AJ4zzHnyhJVk4YrsPltMELI0JWDy1QCfaQKC 4QtePXTq+7sodj+t6+YMq7I= =cSmb -----END PGP SIGNATURE-----

Thanks. I didn't realize that multistage compilation was the trigger. Kevin
Mar 14 2006