[Issue 15574] wrong order of linker arguments

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 17 19:07:56 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=15574

--- Comment #5 from github-bugzilla at puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/fbaeeaee1cac009d9f7157b7d63ea22dee1d3b0e
Fix issue 15574 - wrong order of link arguments

This essentially places *.a arguments before the -l and -L switches in
the linker command line.

This allows to link applications that link against a static archive *.a
that depends on -l lib switches.
Such dependency scheme is typical of the following situation:
  - have a D package that contains binding to a C library.
  - this D package is itself built as a static library (libdpackage.a).
  - the C library is built in the same build process as a static library
    (pathtoClib/libclib.a)
  - dmd is invoked in the following way:

  $ dmd ... libdpackage.a -L-LpathtoClib -L-lclib

Currently dmd reorders arguments and places *.a after -l linker switches
which causes link errors if the -l points to a static library.

This is especially useful with Dub, which can be configured to probe for
the C library, and build it as a static lib if not found system-wide.
In both cases, the C library is provided with "libs" json entry.

So this is not about keeping relative order of linker arguments, it is
about providing an order of linker arguments that is more sound than
the current one.

https://github.com/dlang/dmd/commit/10c8fa536879536b4fa339d8325b7a3ab0990d51
add test for issue 15574

https://github.com/dlang/dmd/commit/6371942b1bf26dc6c65cc7e0668bc82e1974c18d
Merge pull request #8172 from rtbo/linker_arg_order

Fix issue 15574 - wrong order of link arguments
merged-on-behalf-of: Razvan Nitu <RazvanN7 at users.noreply.github.com>

--


More information about the Digitalmars-d-bugs mailing list