Thread overview
[Issue 15531] dmd.conf linker flags should be prepended instead of appended to subsequent linker flags
Jan 09, 2016
Mike Wey
Sep 29, 2017
Heromyth
Dec 17, 2022
Iain Buclaw
January 09, 2016
https://issues.dlang.org/show_bug.cgi?id=15531

Mike Wey <mike@mikewey.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mike@mikewey.eu

--- Comment #1 from Mike Wey <mike@mikewey.eu> ---
While pretending would solve the problems for the library paths, it will cause problems with the actual libraries. (at leased with GNU ld).

This because libraries are only searched once for undefined symbols and in the order in which they appear on the command line.

So if you are linking to a D library -lphobos should appear on the command line after the d library and libraries phobos depends on after that.

One option around this is to use --start-group and --end group. The OSX version of ld doesn't have these options, the OSX man page does say the placement of the -l flag is significant.

--
September 29, 2017
https://issues.dlang.org/show_bug.cgi?id=15531

Heromyth <bitworld@qq.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bitworld@qq.com

--- Comment #2 from Heromyth <bitworld@qq.com> ---

Running this command on Linux:

dmd -g -ofunittest/debug/thrift/server/transport/ssl -unittest -w -wi -I../../lib/d/src src/thrift/server/transport/ssl.d libthriftd-event.a libthriftd-ssl.a libthriftd.a -L-L/usr/bin/dmd -L-levent -L-lcrypto -L-lssl unittest/emptymain.d

Would get some error messages like:

libthriftd-ssl.a(ssl_2a8_3af.o): In function `_D6thrift9transport3ssl10TSSLSocket6isOpenMFNdZb': src/thrift/transport/ssl.d:(.text._D6thrift9transport3ssl10TSSLSocket6isOpenMFNdZb+0x69): undefined reference to `SSL_get_shutdown'


The underlying command line is:

cc unittest/debug/thrift/server/transport/ssl.o -o unittest/debug/thrift/server/transport/ssl -g -m64 **-levent -lcrypto -lssl** -L/usr/lib/x86_64-linux-gnu -Xlinker --export-dynamic libthriftd-event.a libthriftd-ssl.a libthriftd.a -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lrt -ldl

The correct command line should be:

cc unittest/debug/thrift/server/transport/ssl.o -o unittest/debug/thrift/server/transport/ssl -g -m64 -L/usr/lib/x86_64-linux-gnu -Xlinker --export-dynamic libthriftd-event.a libthriftd-ssl.a libthriftd.a **-levent -lcrypto -lssl** -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lrt -ldl

The difference is that

   -levent -lcrypto -lssl

is behind *.a.

The order of custom linker flags seem wrong.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=15531

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
December 13
https://issues.dlang.org/show_bug.cgi?id=15531

--- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17742

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--