[Bug ada/81104] New: gnattools: LDFLAGS=-Wl,--as-needed has no effect after the libraries
nicolas.boulenguez at free dot fr
gcc-bugzilla@gcc.gnu.org
Thu Jun 15 15:48:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81104
Bug ID: 81104
Summary: gnattools: LDFLAGS=-Wl,--as-needed has no effect after
the libraries
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: nicolas.boulenguez at free dot fr
Target Milestone: ---
Created attachment 41556
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41556&action=edit
Short and tested but ugly workaround
Gnatlink moves GCC_LINK linker options after other options, probably so that
standard libraries come after user libraries in case --as-needed is activated.
However, if --as-needed is activated via LDFLAGS, it is appended via GCC_LINK
and comes too late on the eventual command line.
All GCC_LINKS expansions but one are followed by an expansion of TOOLS_LIBS, so
TOOLS_LIBS seems to be the right place for LDFLAGS.
The attached patch attempts not to be intrusive, but I suggest replacing each
$(TOOLS_LIBS) with $(LDFLAGS) $(TOOLS_LIBS) for a more logic and readable
solution.
More information about the Gcc-bugs
mailing list