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" ] } }