SCons D support
Russel Winder
russel at winder.org.uk
Thu May 10 10:27:20 PDT 2012
On Thu, 2012-05-10 at 08:04 -0700, H. S. Teoh wrote:
[...]
> I can't speak for dmd, but for gdc and ldc, I think it makes sense to
> use the system linker to do the linking. The current dmd tool is very
> broken, it keeps insisting on appending "-lgphobos -lgphobos -lgphobos"
> (yes it repeats thrice) to the link command for some mysterious reason.
> That's why I have to rewrite LINKCOM in my environment
I recollect seeing this and fixing it, but mayhap only for Linux and
OSX, 32-bit and 64-bit. Are you on Windows?
> OTOH, with languages like C++ and D, I find that sometimes the most
> painless way to link is to invoke the compiler itself, so that any
> hidden special libraries are automatically pulled in. For example,
> instead of:
>
> gdc -c src1.d src2.d
> ld -o prog src1.o src2.o -L/usr/share/lib/gdc/... -lgphobos2 -l<whatever else>
> # have to explicitly specify all language support libraries
> # including search paths
>
> just run:
>
> gdc -c src1.d src2.d
> gdc -o prog src1.o src2.o
> # magically pulls in phobos, druntime, whatever else it needs
> # no need to figure out search paths
Currently for reasons I don't fully understand, but I think deleting
most of the code might help, the dmd, gdc and ldc tools all use gcc as
the linker. I haven't worried about this till now as it worked. Now
though is the time to attack these sorts of issue.
> DMD works the same way, except that any linker options need to be
> escaped with a "-L" prefix (so -lncurses becomes -L-lncurses, etc.).
>
> For D projects that also have C code:
>
> gdc -c src1.d src2.d
> gcc -c src3.c
> gdc -o prog src1.o src2.o src3.o
This would indicate that gdc and gcc are effectively interchangeable as
the linker. But then given gdc is gdc this is sort of not surprising.
> Things get tricky if you start having more than 2 languages, though, so
> explicit linking may be unavoidable in those cases.
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120510/c5cad468/attachment.pgp>
More information about the Digitalmars-d
mailing list