D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19304 - [Reg 2.081.0] Linker arguments order changed in issue 15574 hinders using --whole-archive linker directive
Summary: [Reg 2.081.0] Linker arguments order changed in issue 15574 hinders using --w...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 regression
Assignee: No Owner
URL:
Keywords: link-failure
Depends on:
Blocks:
 
Reported: 2018-10-13 03:40 UTC by Ludovit Lucenic
Modified: 2018-10-26 22:00 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ludovit Lucenic 2018-10-13 03:40:20 UTC
As I mentioned in my comment to the commit fixing issue 15574:

https://github.com/dlang/dmd/commit/fbaeeaee1cac009d9f7157b7d63ea22dee1d3b0e#commitcomment-30878590

the change of linker arguments order merged there by that commit disallows the use of --whole-archive linker directive effectively from version 2.081.0 of DMD.
The changed order of arguments causes linker error:

> /usr/local/bin/ld: error: ext/arinas/bin/libarinas.a(core.o): multiple definition of '_D6arinas4core12__ModuleInfoZ'
> /usr/local/bin/ld: ext/arinas/.dub/build/library-debug-linux.posix-x86_64-dmd_2082-9AC63FE218354D87B48C0AED4255478E/libarinas.a(core.o): previous definition here
I assume the original implementation positioned the (in dub.sdl defined lflags "--whole-archive" "ext/arinas/bin/libarinas.a" "--no-whole-archive") directive before the *.a libraries built as dub project's dependecies on the linker command line.

I am not aware of any means how to pass this directive on to the linker being placed before static libraries other than changing the dmd/link.d code for branches 2.081 and 2.082.

I have fixed the code of DMD for my specific purpose assuming also not interfering with the original intention of the fix for issue 15574. I am going to propose my change on github as PR for review to ensure my understanding of the touched code is correct.
Comment 1 github-bugzilla 2018-10-26 22:00:24 UTC
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/4407069051197b6af2df3699b3c5a1488fe45eab
Fix issue 19304 - [Reg 2.081.0] Linker arguments order changed in issue 15574 hinders using --whole-archive linker directive

Proposed change enables again using --whole-archive linker directive. Please review that it also does not ruin the intention of Fix for issue 15574.

https://github.com/dlang/dmd/commit/fd37b6e3658cae54fc850eabe44797e1b5312166
Merge pull request #8828 from llucenic/patch-1

Fix issue 19304 - [Reg 2.081.0] Linker arguments order changed in issue 15574 hinders using --whole-archive linker directive
merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>