diff --git a/bolt/CMakeLists.txt b/bolt/CMakeLists.txt --- a/bolt/CMakeLists.txt +++ b/bolt/CMakeLists.txt @@ -9,16 +9,33 @@ set(BOLT_ENABLE_RUNTIME ON) endif() +set(BOLT_CLANG_EXE "" CACHE FILEPATH "Path to clang executable for the target \ +architecture for use in BOLT tests") +set(BOLT_LLD_EXE "" CACHE FILEPATH "Path to lld executable for the target \ +architecture for use in BOLT tests") + set(BOLT_INCLUDE_TESTS OFF) if (LLVM_INCLUDE_TESTS) - if ("clang" IN_LIST LLVM_ENABLE_PROJECTS) - if ("lld" IN_LIST LLVM_ENABLE_PROJECTS) + if ("clang" IN_LIST LLVM_ENABLE_PROJECTS OR BOLT_CLANG_EXE) + if ("clang" IN_LIST LLVM_ENABLE_PROJECTS AND BOLT_CLANG_EXE) + message(WARNING "BOLT_CLANG_EXE is set and clang project is enabled. \ + BOLT_CLANG_EXE will be used for BOLT tests.") + endif() + if ("lld" IN_LIST LLVM_ENABLE_PROJECTS OR BOLT_LLD_EXE) + if ("lld" IN_LIST LLVM_ENABLE_PROJECTS AND BOLT_LLD_EXE) + message(WARNING "BOLT_LLD_EXE is set and lld project is enabled. \ + BOLT_LLD_EXE will be used for BOLT tests.") + endif() set(BOLT_INCLUDE_TESTS ON) else() - message(WARNING "Not including BOLT tests since lld is disabled") + message(WARNING "Not including BOLT tests since lld is disabled. \ + Enable lld in LLVM_ENABLE_PROJECTS or provide a path to lld binary \ + in BOLT_LLD_EXE.") endif() else() - message(WARNING "Not including BOLT tests since clang is disabled") + message(WARNING "Not including BOLT tests since clang is disabled. \ + Enable clang in LLVM_ENABLE_PROJECTS or provide a path to clang \ + binary in BOLT_CLANG_EXE.") endif() endif() diff --git a/bolt/test/CMakeLists.txt b/bolt/test/CMakeLists.txt --- a/bolt/test/CMakeLists.txt +++ b/bolt/test/CMakeLists.txt @@ -13,6 +13,16 @@ bolt_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg ) +if (BOLT_CLANG_EXE AND NOT "clang" IN_LIST LLVM_ENABLE_PROJECTS) + add_executable(clang IMPORTED GLOBAL) + set_property(TARGET clang PROPERTY IMPORTED_LOCATION "${BOLT_CLANG_EXE}") +endif() + +if (BOLT_LLD_EXE AND NOT "lld" IN_LIST LLVM_ENABLE_PROJECTS) + add_executable(lld IMPORTED GLOBAL) + set_property(TARGET lld PROPERTY IMPORTED_LOCATION "${BOLT_LLD_EXE}") +endif() + list(APPEND BOLT_TEST_DEPS clang count diff --git a/bolt/test/lit.cfg.py b/bolt/test/lit.cfg.py --- a/bolt/test/lit.cfg.py +++ b/bolt/test/lit.cfg.py @@ -55,8 +55,8 @@ llvm_config.use_default_substitutions() -llvm_config.use_clang() -llvm_config.use_lld() +llvm_config.use_clang(additional_tool_dirs=[os.path.dirname(config.bolt_clang)]) +llvm_config.use_lld(additional_tool_dirs=[os.path.dirname(config.bolt_lld)]) config.substitutions.append(('%cflags', '-no-pie')) config.substitutions.append(('%cxxflags', '-no-pie')) diff --git a/bolt/test/lit.site.cfg.py.in b/bolt/test/lit.site.cfg.py.in --- a/bolt/test/lit.site.cfg.py.in +++ b/bolt/test/lit.site.cfg.py.in @@ -19,6 +19,8 @@ config.host_arch = "@HOST_ARCH@" config.enable_abi_breaking_checks = "@LLVM_ENABLE_ABI_BREAKING_CHECKS@" config.python_executable = "@PYTHON_EXECUTABLE@" +config.bolt_clang = "@BOLT_CLANG_EXE@" +config.bolt_lld = "@BOLT_LLD_EXE@" # Support substitution of the tools and libs dirs with user parameters. This is # used when we can't determine the tool dir at configuration time.