-
-
Notifications
You must be signed in to change notification settings - Fork 234
Description
Make sure you completed the following tasks
- I searched the discussions
- I searched the closed and open issues
- I read the contribution guidelines
Environment and version details
- Operating System+version: RHEL 10
- Compiler+version: GCC 15
- Shell: bash
- B2 Version: the one embedded in boost 1.89 beta
Brief problem description
In boost recently there was some modular work. One of the nasty consequences of this is that now there are more dependencies in the generated libboost_XXX.so, more than before, and actually more than necessary. See for example these cases:
- Remove dependency on Boost.random. boostorg/iostreams#186
- Stop delivering a linkable library as this is header only since some time boostorg/regex#253
- Shall the stub library libboost_system.so be removed now ? boostorg/system#132
Technically, this is a boost issue, to be fixed in each boost library. Yet, I was trying to workaround it globally in an easy way, by using the linker flag --as-needed which would fix issues in most cases. I tried passing this argument as part of the b2 linkflags but... -Wl,--as-needed is passed at the end of the command line. Indeed, looking here:
We seem to pass $(OPTIONS) $(USER_OPTIONS) at the end. -Wl,--as-needed is an argument whose position on the command line matters: if passed at the end, it affects only the "implicit" libraries the linker will add automatically (things like -lstdc++, -lgcc or -lc). Looking at the equivalent C/CXXFLAGS for the compile command lines, we seem to pass $(OPTIONS) $(USER_OPTIONS) at the beginning of the command line. So shouldn't be the same for the link/link.dll rules too ? Or, if it's at the right place, how shall people like use pass correctly arguments like -Wl,--as-needed that some distros define by default (for example Fedora) in their build system ?
Looking a bit in the history, it seems 20 years ago it was moved at the end on purpose: d636a71 Is it time to "revert" this ?