From ab11b9eefa16661017c2c7b3b34c46b069f43fb7 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 2 Apr 2020 14:58:44 -0400 Subject: [PATCH] Revert "Make it possible for lit.site.cfg to contain relative paths, and use it for llvm and clang" This reverts commit fb80b6b2d58c476747a3206bd4371b787108591b and follow-up 631ee8b24adf36359b61ecb47484e8e82de35be8. Seems to not work on Windows: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/31684 http://lab.llvm.org:8011/builders/llvm-clang-win-x-aarch64/builds/6512 Let's revert while I investigate. --- clang/test/CMakeLists.txt | 17 --------- clang/test/Unit/lit.site.cfg.py.in | 15 ++++---- clang/test/lit.site.cfg.py.in | 21 ++++++----- llvm/cmake/modules/AddLLVM.cmake | 55 ++--------------------------- llvm/test/CMakeLists.txt | 11 ------ llvm/test/Unit/lit.site.cfg.py.in | 11 +++--- llvm/test/lit.site.cfg.py.in | 15 ++++---- llvm/utils/gn/secondary/clang/test/BUILD.gn | 5 +-- llvm/utils/gn/secondary/llvm/test/BUILD.gn | 5 +-- 9 files changed, 34 insertions(+), 121 deletions(-) diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt index ca326fe..d453074 100644 --- a/clang/test/CMakeLists.txt +++ b/clang/test/CMakeLists.txt @@ -35,16 +35,6 @@ configure_lit_site_cfg( ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py MAIN_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py - PATHS - "LLVM_SOURCE_DIR" - "LLVM_BINARY_DIR" - "LLVM_TOOLS_DIR" - "LLVM_LIBS_DIR" - "SHLIBDIR" - "LLVM_LIT_TOOLS_DIR" - "CLANG_BINARY_DIR" - "CLANG_SOURCE_DIR" - "CLANG_TOOLS_DIR" ) configure_lit_site_cfg( @@ -52,13 +42,6 @@ configure_lit_site_cfg( ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py MAIN_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py - PATHS - "LLVM_SOURCE_DIR" - "LLVM_BINARY_DIR" - "LLVM_TOOLS_DIR" - "LLVM_LIBS_DIR" - "CLANG_BINARY_DIR" - "SHLIBDIR" ) option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF) diff --git a/clang/test/Unit/lit.site.cfg.py.in b/clang/test/Unit/lit.site.cfg.py.in index 400a9c0..715b4d9 100644 --- a/clang/test/Unit/lit.site.cfg.py.in +++ b/clang/test/Unit/lit.site.cfg.py.in @@ -2,14 +2,14 @@ import sys -config.llvm_src_root = path("@LLVM_SOURCE_DIR@") -config.llvm_obj_root = path("@LLVM_BINARY_DIR@") -config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@") -config.llvm_libs_dir = path("@LLVM_LIBS_DIR@") +config.llvm_src_root = "@LLVM_SOURCE_DIR@" +config.llvm_obj_root = "@LLVM_BINARY_DIR@" +config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" +config.llvm_libs_dir = "@LLVM_LIBS_DIR@" config.llvm_build_mode = "@LLVM_BUILD_MODE@" -config.clang_obj_root = path("@CLANG_BINARY_DIR@") +config.clang_obj_root = "@CLANG_BINARY_DIR@" config.enable_shared = @ENABLE_SHARED@ -config.shlibdir = path("@SHLIBDIR@") +config.shlibdir = "@SHLIBDIR@" config.target_triple = "@TARGET_TRIPLE@" # Support substitution of the tools_dir, libs_dirs, and build_mode with user @@ -25,5 +25,4 @@ except KeyError: lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) # Let the main config do the real work. -lit_config.load_config( - config, os.path.join(path("@CLANG_SOURCE_DIR@"), "test/Unit/lit.cfg.py")) +lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/Unit/lit.cfg.py") diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index 84dd0f8..62616d9 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -2,16 +2,16 @@ import sys -config.llvm_src_root = path("@LLVM_SOURCE_DIR@") -config.llvm_obj_root = path("@LLVM_BINARY_DIR@") -config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@") -config.llvm_libs_dir = path("@LLVM_LIBS_DIR@") -config.llvm_shlib_dir = path("@SHLIBDIR@") +config.llvm_src_root = "@LLVM_SOURCE_DIR@" +config.llvm_obj_root = "@LLVM_BINARY_DIR@" +config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" +config.llvm_libs_dir = "@LLVM_LIBS_DIR@" +config.llvm_shlib_dir = "@SHLIBDIR@" config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@" -config.lit_tools_dir = path("@LLVM_LIT_TOOLS_DIR@") -config.clang_obj_root = path("@CLANG_BINARY_DIR@") -config.clang_src_dir = path("@CLANG_SOURCE_DIR@") -config.clang_tools_dir = path("@CLANG_TOOLS_DIR@") +config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" +config.clang_obj_root = "@CLANG_BINARY_DIR@" +config.clang_src_dir = "@CLANG_SOURCE_DIR@" +config.clang_tools_dir = "@CLANG_TOOLS_DIR@" config.host_triple = "@LLVM_HOST_TRIPLE@" config.target_triple = "@TARGET_TRIPLE@" config.host_cxx = "@CMAKE_CXX_COMPILER@" @@ -50,5 +50,4 @@ if not "@CLANG_DEFAULT_LINKER@": config.available_features.add('platform-linker') # Let the main config do the real work. -lit_config.load_config( - config, os.path.join(config.clang_src_dir, "test/lit.cfg.py")) +lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/lit.cfg.py") diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 0732ca6..238aa3e 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1396,14 +1396,8 @@ endmacro() # variables needed for the 'lit.site.cfg' files. This function bundles the # common variables that any Lit instance is likely to need, and custom # variables can be passed in. -# The keyword PATHS is followed by a list of cmake variable names that are -# mentioned as `path("@varname@")` in the lit.cfg.py.in file. Variables in that -# list are treated as paths that are relative to the directory the generated -# lit.cfg.py file is in, and the `path()` function converts the relative -# path back to absolute form. This makes it possible to move a build directory -# containing lit.cfg.py files from one machine to another. function(configure_lit_site_cfg site_in site_out) - cmake_parse_arguments(ARG "" "" "MAIN_CONFIG;OUTPUT_MAPPING;PATHS" ${ARGN}) + cmake_parse_arguments(ARG "" "" "MAIN_CONFIG;OUTPUT_MAPPING" ${ARGN}) if ("${ARG_MAIN_CONFIG}" STREQUAL "") get_filename_component(INPUT_DIR ${site_in} DIRECTORY) @@ -1453,17 +1447,12 @@ function(configure_lit_site_cfg site_in site_out) set(HOST_CXX "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}") set(HOST_LDFLAGS "${CMAKE_EXE_LINKER_FLAGS}") - set(LIT_SITE_CFG_IN_HEADER "# Autogenerated from ${site_in}\n# Do not edit!") - - string(CONCAT LIT_SITE_CFG_IN_HEADER "${LIT_SITE_CFG_IN_HEADER}\n\n" - "# Allow generated lit.site.cfg.py to be relocatable.\n" - "def path(p): return os.path.join(os.path.dirname(__file__), p) if p else ''\n" - ) + set(LIT_SITE_CFG_IN_HEADER "## Autogenerated from ${site_in}\n## Do not edit!") # Override config_target_triple (and the env) if(LLVM_TARGET_TRIPLE_ENV) # This is expanded into the heading. - string(CONCAT LIT_SITE_CFG_IN_HEADER "${LIT_SITE_CFG_IN_HEADER}" + string(CONCAT LIT_SITE_CFG_IN_HEADER "${LIT_SITE_CFG_IN_HEADER}\n\n" "import os\n" "target_env = \"${LLVM_TARGET_TRIPLE_ENV}\"\n" "config.target_triple = config.environment[target_env] = os.environ.get(target_env, \"${TARGET_TRIPLE}\")\n" @@ -1473,45 +1462,7 @@ function(configure_lit_site_cfg site_in site_out) set(TARGET_TRIPLE "\"+config.target_triple+\"") endif() - if (ARG_PATHS) - # Walk ARG_PATHS and collect the current value of the variables in there. - foreach(path ${ARG_PATHS}) - list(APPEND ARG_PATH_VALUES "${${path}}") - endforeach() - - # Compute paths relative to the directory containing output lit.site.cfg.py. - # Passing ARG_PATH_VALUES as-is to execute_process() makes cmake strip - # empty list entries. So escape the ;s in the list and do the splitting - # outselves. cmake has no relpath function, so use Python for that. - string(REPLACE ";" "\\;" ARG_PATH_VALUES_ESCAPED "${ARG_PATH_VALUES}") - get_filename_component(OUTPUT_DIR ${site_out} DIRECTORY) - execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" - "import os, sys; sys.stdout.write(';'.join(os.path.relpath(p, sys.argv[1]) if p else '' for p in sys.argv[2].split(';')))" - ${OUTPUT_DIR} - ${ARG_PATH_VALUES_ESCAPED} - OUTPUT_VARIABLE ARG_PATH_VALUES_RELATIVE) - - list(LENGTH ARG_PATHS len_paths) - list(LENGTH ARG_PATH_VALUES len_path_values) - list(LENGTH ARG_PATH_VALUES_RELATIVE len_path_value_rels) - if ((NOT ${len_paths} EQUAL ${len_path_values}) OR - (NOT ${len_paths} EQUAL ${len_path_value_rels})) - message(SEND_ERROR "PATHS lengths got confused") - endif() - - # Transform variables mentioned in ARG_PATHS to relative paths for - # the configure_file() call. Variables are copied to subscopeds by cmake, - # so this only modifies the local copy of the variables. - math(EXPR arg_path_limit "${len_paths} - 1") - foreach(i RANGE ${arg_path_limit}) - list(GET ARG_PATHS ${i} val1) - list(GET ARG_PATH_VALUES_RELATIVE ${i} val2) - set(${val1} ${val2}) - endforeach() - endif() - configure_file(${site_in} ${site_out} @ONLY) - if (EXISTS "${ARG_MAIN_CONFIG}") set(PYTHON_STATEMENT "map_config('${ARG_MAIN_CONFIG}', '${site_out}')") get_property(LLVM_LIT_CONFIG_MAP GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP) diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt index 330a352..d1bc970 100644 --- a/llvm/test/CMakeLists.txt +++ b/llvm/test/CMakeLists.txt @@ -22,23 +22,12 @@ configure_lit_site_cfg( ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py MAIN_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py - PATHS - "LLVM_SOURCE_DIR" - "LLVM_BINARY_DIR" - "LLVM_TOOLS_DIR" - "LLVM_LIBRARY_DIR" - "SHLIBDIR" ) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py MAIN_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py - PATHS - "LLVM_SOURCE_DIR" - "LLVM_BINARY_DIR" - "LLVM_TOOLS_DIR" - "SHLIBDIR" ) # Set the depends list as a variable so that it can grow conditionally. diff --git a/llvm/test/Unit/lit.site.cfg.py.in b/llvm/test/Unit/lit.site.cfg.py.in index 3358ccf..1fef001 100644 --- a/llvm/test/Unit/lit.site.cfg.py.in +++ b/llvm/test/Unit/lit.site.cfg.py.in @@ -2,12 +2,12 @@ import sys -config.llvm_src_root = path("@LLVM_SOURCE_DIR@") -config.llvm_obj_root = path("@LLVM_BINARY_DIR@") -config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@") +config.llvm_src_root = "@LLVM_SOURCE_DIR@" +config.llvm_obj_root = "@LLVM_BINARY_DIR@" +config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.llvm_build_mode = "@LLVM_BUILD_MODE@" config.enable_shared = @ENABLE_SHARED@ -config.shlibdir = path("@SHLIBDIR@") +config.shlibdir = "@SHLIBDIR@" # Support substitution of the tools_dir and build_mode with user parameters. # This is used when we can't determine the tool dir at configuration time. @@ -20,5 +20,4 @@ except KeyError: lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) # Let the main config do the real work. -lit_config.load_config( - config, os.path.join(config.llvm_src_root, "test/Unit/lit.cfg.py")) +lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/Unit/lit.cfg.py") diff --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in index 2af0ec3..6f4d5f7 100644 --- a/llvm/test/lit.site.cfg.py.in +++ b/llvm/test/lit.site.cfg.py.in @@ -4,14 +4,14 @@ import sys config.host_triple = "@LLVM_HOST_TRIPLE@" config.target_triple = "@TARGET_TRIPLE@" -config.llvm_src_root = path("@LLVM_SOURCE_DIR@") -config.llvm_obj_root = path("@LLVM_BINARY_DIR@") -config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@") -config.llvm_lib_dir = path("@LLVM_LIBRARY_DIR@") -config.llvm_shlib_dir = path("@SHLIBDIR@") +config.llvm_src_root = "@LLVM_SOURCE_DIR@" +config.llvm_obj_root = "@LLVM_BINARY_DIR@" +config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" +config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@" +config.llvm_shlib_dir = "@SHLIBDIR@" config.llvm_shlib_ext = "@SHLIBEXT@" config.llvm_exe_ext = "@EXEEXT@" -config.lit_tools_dir = path("@LLVM_LIT_TOOLS_DIR@") +config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.python_executable = "@PYTHON_EXECUTABLE@" config.gold_executable = "@GOLD_EXECUTABLE@" config.ld64_executable = "@LD64_EXECUTABLE@" @@ -63,5 +63,4 @@ import lit.llvm lit.llvm.initialize(lit_config, config) # Let the main config do the real work. -lit_config.load_config( - config, os.path.join(config.llvm_src_root, "test/lit.cfg.py")) +lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/lit.cfg.py") diff --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn b/llvm/utils/gn/secondary/clang/test/BUILD.gn index 84ac2e8..874891e 100644 --- a/llvm/utils/gn/secondary/clang/test/BUILD.gn +++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn @@ -12,10 +12,7 @@ template("write_lit_config") { input = invoker.input output = invoker.output values = [ - # FIXME: Write relative paths for path()s. - "LIT_SITE_CFG_IN_HEADER=" + - "## Autogenerated from $input, do not edit\n\n" + - "def path(p): return p if p else \"\"", + "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit", "CLANG_BINARY_DIR=" + rebase_path(get_label_info("//clang", "target_out_dir")), "CLANG_SOURCE_DIR=" + rebase_path("//clang"), diff --git a/llvm/utils/gn/secondary/llvm/test/BUILD.gn b/llvm/utils/gn/secondary/llvm/test/BUILD.gn index c7740ac..0f7d90d 100644 --- a/llvm/utils/gn/secondary/llvm/test/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/test/BUILD.gn @@ -14,10 +14,7 @@ template("write_lit_config") { input = invoker.input output = invoker.output values = [ - # FIXME: Write relative paths for path()s. - "LIT_SITE_CFG_IN_HEADER=" + - "## Autogenerated from $input, do not edit\n\n" + - "def path(p): return p if p else \"\"", + "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit", "ENABLE_SHARED=0", "LLVM_BINARY_DIR=" + rebase_path(get_label_info("//llvm", "target_out_dir")), -- 2.7.4