From 51ae9734a26720c303d230b43e393450951e969b Mon Sep 17 00:00:00 2001 From: Stella Stamenova Date: Thu, 11 Feb 2021 09:32:20 -0800 Subject: [PATCH] Support multi-configuration generators correctly in several config files Multi-configuration generators (such as Visual Studio and Xcode) allow the specification of a build flavor at build time instead of config time, so the lit configuration files need to support that - and they do for the most part. There are several places that had one of two issues (or both!): 1) Paths had %(build_mode)s set up, but then not configured, resulting in values that would not work correctly e.g. D:/llvm-build/%(build_mode)s/bin/dsymutil.exe 2) Paths did not have %(build_mode)s set up, but instead contained $(Configuration) (which is the value for Visual Studio at configuration time, for Xcode they would have had the equivalent) e.g. "D:/llvm-build/$(Configuration)/lib". This seems to indicate that we still have a lot of fragility in the configurations, but also that a number of these paths are never used (at least on Windows) since the errors appear to have been there a while. This patch fixes the configurations and it has been tested with Ninja and Visual Studio to generate the correct paths. We should consider removing some of these settings altogether. Reviewed By: JDevlieghere, mehdi_amini Differential Revision: https://reviews.llvm.org/D96427 --- cmake/modules/AddLLVM.cmake | 4 ++-- test/CMakeLists.txt | 2 +- test/Unit/lit.site.cfg.py.in | 1 + test/lit.site.cfg.py.in | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index 09de62ac3f5..f276d57ca9f 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -1586,11 +1586,11 @@ function(configure_lit_site_cfg site_in site_out) set_llvm_build_mode() - # They below might not be the build tree but provided binary tree. + # The below might not be the build tree but provided binary tree. set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR}) set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR}) string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}") - string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_LIBS_DIR "${LLVM_LIBRARY_DIR}") + string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLVM_LIBS_DIR "${LLVM_LIBRARY_DIR}") # SHLIBDIR points the build tree. string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 691a7e14b8c..7c4fa2e9033 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -29,7 +29,7 @@ configure_lit_site_cfg( "LLVM_SOURCE_DIR" "LLVM_BINARY_DIR" "LLVM_TOOLS_DIR" - "LLVM_LIBRARY_DIR" + "LLVM_LIBS_DIR" "SHLIBDIR" ) configure_lit_site_cfg( diff --git a/test/Unit/lit.site.cfg.py.in b/test/Unit/lit.site.cfg.py.in index f9fe421e2aa..7fc93b40363 100644 --- a/test/Unit/lit.site.cfg.py.in +++ b/test/Unit/lit.site.cfg.py.in @@ -14,6 +14,7 @@ config.shlibdir = path(r"@SHLIBDIR@") try: config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params config.llvm_build_mode = config.llvm_build_mode % lit_config.params + config.shlibdir = config.shlibdir % lit_config.params except KeyError: e = sys.exc_info()[1] key, = e.args diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in index 9765d498b50..94e11050ff5 100644 --- a/test/lit.site.cfg.py.in +++ b/test/lit.site.cfg.py.in @@ -7,7 +7,7 @@ config.target_triple = "@TARGET_TRIPLE@" config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@") config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@") config.llvm_tools_dir = path(r"@LLVM_TOOLS_DIR@") -config.llvm_lib_dir = path(r"@LLVM_LIBRARY_DIR@") +config.llvm_lib_dir = path(r"@LLVM_LIBS_DIR@") config.llvm_shlib_dir = path(r"@SHLIBDIR@") config.llvm_shlib_ext = "@SHLIBEXT@" config.llvm_exe_ext = "@EXEEXT@" @@ -56,6 +56,7 @@ config.expensive_checks = @LLVM_ENABLE_EXPENSIVE_CHECKS@ # used when we can't determine the tool dir at configuration time. try: config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params + config.llvm_lib_dir = config.llvm_lib_dir % lit_config.params config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params except KeyError: e = sys.exc_info()[1]