[lld] Make lit files relocatable

2700da5fe2 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 fb80b6b2d5 for background.

Differential Revision: https://reviews.llvm.org/D152885
This commit is contained in:
Nico Weber 2023-06-13 19:53:21 -07:00
parent e777da468c
commit 0cb977dda1
3 changed files with 36 additions and 28 deletions

View File

@ -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

View File

@ -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"))

View File

@ -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.