[llvm] 0cb977d - [lld] Make lit files relocatable
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 20 10:17:03 PDT 2023
Author: Nico Weber
Date: 2023-06-20T13:16:20-04:00
New Revision: 0cb977dda1809182786ad7f8fb14a9af08d37918
URL: https://github.com/llvm/llvm-project/commit/0cb977dda1809182786ad7f8fb14a9af08d37918
DIFF: https://github.com/llvm/llvm-project/commit/0cb977dda1809182786ad7f8fb14a9af08d37918.diff
LOG: [lld] Make lit files relocatable
2700da5fe28d8 added lld/test/Unit/lit.site.cfg.py.in in a state
that half-supports relocatable lld lit tests.
Make them fully relocatable.
See description of fb80b6b2d58c47 for background.
Differential Revision: https://reviews.llvm.org/D152885
Added:
Modified:
lld/test/CMakeLists.txt
lld/test/lit.site.cfg.py.in
llvm/utils/gn/secondary/lld/test/BUILD.gn
Removed:
################################################################################
diff --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt
index f1cfacba9dd16..8d70903076a41 100644
--- a/lld/test/CMakeLists.txt
+++ b/lld/test/CMakeLists.txt
@@ -14,7 +14,18 @@ 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"
+ "LLD_BINARY_DIR"
+ "CURRENT_LIBS_DIR"
+ "CURRENT_TOOLS_DIR"
+ "LLD_SOURCE_DIR"
+ )
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
diff --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in
index 39b54924f4a19..bb99976005543 100644
--- a/lld/test/lit.site.cfg.py.in
+++ b/lld/test/lit.site.cfg.py.in
@@ -3,18 +3,18 @@
import lit.util
config.have_dia_sdk = lit.util.pythonize_bool("@LLVM_ENABLE_DIA_SDK@")
-config.llvm_src_root = "@LLVM_SOURCE_DIR@"
-config.llvm_obj_root = "@LLVM_BINARY_DIR@"
-config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
-config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
-config.llvm_shlib_dir = "@SHLIBDIR@"
+config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@")
+config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@")
+config.llvm_tools_dir = lit_config.substitute(path(r"@LLVM_TOOLS_DIR@"))
+config.llvm_libs_dir = lit_config.substitute(path(r"@LLVM_LIBS_DIR@"))
+config.llvm_shlib_dir = path(r"@SHLIBDIR@")
config.llvm_shlib_ext = "@SHLIBEXT@"
-config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
+config.lit_tools_dir = path(r"@LLVM_LIT_TOOLS_DIR@")
config.enable_backtrace = @ENABLE_BACKTRACES@
config.errc_messages = "@LLVM_LIT_ERRC_MESSAGES@"
-config.lld_obj_root = "@LLD_BINARY_DIR@"
-config.lld_libs_dir = lit_config.substitute("@CURRENT_LIBS_DIR@")
-config.lld_tools_dir = lit_config.substitute("@CURRENT_TOOLS_DIR@")
+config.lld_obj_root = path(r"@LLD_BINARY_DIR@")
+config.lld_libs_dir = lit_config.substitute(path(r"@CURRENT_LIBS_DIR@"))
+config.lld_tools_dir = lit_config.substitute(path(r"@CURRENT_TOOLS_DIR@"))
config.host_triple = "@LLVM_HOST_TRIPLE@"
config.target_triple = "@LLVM_TARGET_TRIPLE@"
config.python_executable = "@Python3_EXECUTABLE@"
@@ -31,4 +31,5 @@ import lit.llvm
lit.llvm.initialize(lit_config, config)
# Let the main config do the real work.
-lit_config.load_config(config, "@LLD_SOURCE_DIR@/test/lit.cfg.py")
+lit_config.load_config(
+ config, os.path.join(path(r"@LLD_SOURCE_DIR@"), "test/lit.cfg.py"))
diff --git a/llvm/utils/gn/secondary/lld/test/BUILD.gn b/llvm/utils/gn/secondary/lld/test/BUILD.gn
index d6c15608124e3..356d93bf052a6 100644
--- a/llvm/utils/gn/secondary/lld/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/lld/test/BUILD.gn
@@ -11,13 +11,20 @@ template("write_lit_cfg") {
write_cmake_config(target_name) {
input = invoker.input
output = invoker.output
+ dir = get_path_info(output, "dir")
values = [
"LIT_SITE_CFG_IN_HEADER=" +
"## Autogenerated from $input, do not edit\n\n" + lit_path_function,
"LLD_BINARY_DIR=" +
- rebase_path(get_label_info("//lld", "target_out_dir")),
- "LLD_SOURCE_DIR=" + rebase_path("//lld"),
+ rebase_path(get_label_info("//lld", "target_out_dir"), dir),
+ "LLD_SOURCE_DIR=" + rebase_path("//lld", dir),
]
+ if (host_os == "win") {
+ # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
+ values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]
+ } else {
+ values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
+ }
values += invoker.extra_values
}
}
@@ -30,15 +37,15 @@ write_lit_cfg("lit_site_cfg") {
extra_values = [
"CURRENT_LIBS_DIR=", # FIXME: for shared builds only (?)
- "CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
+ "CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir),
"ENABLE_BACKTRACES=1",
"LLVM_BINARY_DIR=" +
- rebase_path(get_label_info("//llvm", "target_out_dir")),
+ rebase_path(get_label_info("//llvm", "target_out_dir"), dir),
"LLVM_HOST_TRIPLE=$llvm_current_triple",
"LLVM_LIBS_DIR=", # needed only for shared builds
"LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build.
- "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
- "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
+ "LLVM_SOURCE_DIR=" + rebase_path("//llvm", dir),
+ "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir),
"Python3_EXECUTABLE=$python_path",
"LLVM_TARGET_TRIPLE=$llvm_target_triple",
@@ -53,15 +60,11 @@ write_lit_cfg("lit_site_cfg") {
"LLVM_LIT_ERRC_MESSAGES=no such file or directory;is a directory;" +
"invalid argument;permission denied",
"LLVM_ENABLE_PLUGINS=0",
-
- # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
- "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir),
]
} else {
extra_values += [
"LLVM_LIT_ERRC_MESSAGES=",
"LLVM_ENABLE_PLUGINS=1",
- "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir),
]
}
@@ -104,13 +107,6 @@ write_lit_cfg("lit_unit_site_cfg") {
input = "//lld/test/Unit/lit.site.cfg.py.in"
output = lld_lit_unit_site_cfg_file
extra_values = [ "LLVM_BUILD_MODE=." ]
- dir = get_path_info(output, "dir")
- if (host_os == "win") {
- # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
- extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]
- } else {
- extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
- }
}
# This target should contain all dependencies of check-lld.
More information about the llvm-commits
mailing list