Details
Description
By default gnu-ld only links to used symbols of an archive file. But sometimes one would want to include the whole library as is. This can be achieved by enclosing the archive into two linker flags:
g++ ... lib1.a lib2.a -Wl--whole-archive lib3.a -Wl,--no-whole-archive ...
The no-whole-archive flag is important as whole-archive affects all subsequent libraries. For llvm the flag -force_load has a similar effect but applies only to the following archive.
This feature could be controlled by a property in the cpp module:
Product { // ... Depends { name : "staticlib" } cpp.staticLibraries : [ "extlib1", "extlib2" ] cpp.wholeArchive : [ "staticlib", "extlib1" ] } }
Attachments
Issue Links
For Gerrit Dashboard: QBS-701 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
110551,1 | WIP: Add linking of whole static library | master | qbs/qbs | Status: ABANDONED | -2 | 0 |
194679,9 | Introduce dependency parameter cpp.linkWholeArchive | master | qbs/qbs | Status: MERGED | -2 | 0 |