-
Type: Improvement
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: legacy-0.0-26compat-2.6.3
-
Component/s: Build
I have been unable to find a way to build the C++ driver with additional custom linker options. I am currently attempting to build libmongoclient with Wl,-z,origin,-rpath=\$ORIGIN,-rpath-link=$(pwd) for a non-system-wide installation. I can almost accomplish this with the option -ld="clang++ -Wl,-z,origin,-rpath=\$\$ORIGIN,-rpath-link=$(pwd), but the string is evaluated for variables multiple times at different depths resulting in error messages such as the following:
scons: *** [build/linux2/c++11/cc_clang/cxx_clang++/ld_clang++ -Wl_-z_origin_-rpath=$ORIGIN_-rpath-link=_tmp_dependencies_lib/use-system-boost/libmongoclient.so] Implicit dependency `build/linux2/c+11/cc_clang/cxx_clang/ld_clang+ -Wl_-z_origin_-rpath=-rpath-link=_tmp_dependencies_lib/use-system-boost/third_party/libshim_boost.a' not found, needed by target `build/linux2/c+11/cc_clang/cxx_clang/ld_clang+ -Wl-z_origin_-rpath=$ORIGIN_-rpath-link=_tmp_dependencies_lib/use-system-boost/libmongoclient.so'.
Note the mismatch where sometimes $ORIGIN follows -rpath and other times it doesn't. Although this may be a bug, passing linker options as part of the linker command seems like a hack that may not be worth supporting.
Although my current use-case could be addressed by adding some rpath options to SConstruct, I suspect the issue may be better addressed with an approach that would allow any custom linker options rather than rewriting every linker option users may need as a scons option.
As a better solution, would it be possible to support $LDFLAGS from the environment (as autotools- and cmake-based build systems do) for passing custom linker options? Possibly protected by an option similar to -cc-use-shell-environment such as -ldflags-use-shell-environment?
I think this may be useful for $CFLAGS and $CXXFLAGS as well, but I can file that as another issue if it is worth considering separately.
Thanks for considering,
Kevin
- depends on
-
SERVER-16663 options requested in top-level SConstruct to support non-default libraries and includes
- Closed
- is duplicated by
-
CXX-104 Option to add flags to client build
- Closed