From a866b6d21638f353bd03801fa239d0fd7d35f4f2 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Fri, 19 Jul 2019 22:27:20 -0400 Subject: [PATCH] Add support for a option which points at runtime to the root directory of the gcc installation which clang uses at its backend. This is mainly for clang targeting gcc on Windows where multiple versions of mingw(-64)/gcc can be installed. On Linux clang will normally use the version of gcc in the PATH, so this option is normally not used in Linux. The idea is that the toolset command is a script, which sets the PATH for clang and gcc before invoking clang++, and then the option points to the gcc installation at runtime so that any shared libraries will be found. --- src/tools/clang-linux.jam | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/tools/clang-linux.jam b/src/tools/clang-linux.jam index 8f9fec1cc..2e781a832 100644 --- a/src/tools/clang-linux.jam +++ b/src/tools/clang-linux.jam @@ -62,6 +62,31 @@ rule init ( version ? : command * : options * ) { common.handle-options clang-linux : $(condition) : $(command) : $(options) ; clang.init-cxxstd-flags clang-linux : $(condition) : $(version) ; + # Support for gcc root as the backend, this is mainly useful for clang/gcc on Windows + # since on Linux gcc will be the default compiler already located on the PATH. + # On Windows it is possible to have multiple versions of mingw(-64)/gcc installed + # in different paths. The option can be given so that the gcc backend + # can be found at runtime, while the $(command) can be a script that sets the + # PATH for both the clang directory and the backende gcc directory + # before calling clang++ when compiling/linking. + + local root = [ feature.get-values : $(options) ] ; + + if $(root) + { + # On multilib 64-bit boxes, there are both 32-bit and 64-bit libraries + # and all must be added to LD_LIBRARY_PATH. The linker will pick the + # right onces. Note that we do not provide a clean way to build a 32-bit + # binary using a 64-bit compiler, but user can always pass -m32 + # manually. + local lib_path = $(root)/bin $(root)/lib $(root)/lib32 $(root)/lib64 ; + if $(.debug-configuration) + { + ECHO "notice:" using gcc libraries with clang"::" $(condition) "::" $(lib_path) ; + } + toolset.flags clang-linux.link RUN_PATH $(condition) : $(lib_path) ; + } + # - Ranlib. local ranlib = [ feature.get-values : $(options) ] ; toolset.flags clang-linux.archive .RANLIB $(condition) : $(ranlib[1]) ;