Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-286

Support additional custom compiler and linker options when invoking scons (e.g. rpath)

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • legacy-1.0.0-rc4
    • 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

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            kevinoid Kevin Locke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: