[Lldb-commits] [lldb] b22965d - [lldb] Pass CMAKE_SYSROOT through to LLDB shell tests
Daniel Thornburgh via lldb-commits
lldb-commits at lists.llvm.org
Fri May 26 11:30:39 PDT 2023
Author: Daniel Thornburgh
Date: 2023-05-26T11:30:33-07:00
New Revision: b22965df1304a752af2724f7c2c3c58347532e71
URL: https://github.com/llvm/llvm-project/commit/b22965df1304a752af2724f7c2c3c58347532e71
DIFF: https://github.com/llvm/llvm-project/commit/b22965df1304a752af2724f7c2c3c58347532e71.diff
LOG: [lldb] Pass CMAKE_SYSROOT through to LLDB shell tests
This allows the LLDB Shell tests to succeed in (e.g. CI) environments where
system libraries are provided hermetically as a sysroot.
Reviewed By: JDevlieghere
Differential Revision: https://reviews.llvm.org/D151269
Added:
Modified:
lldb/test/Shell/helper/build.py
lldb/test/Shell/helper/toolchain.py
lldb/test/Shell/lit.site.cfg.py.in
Removed:
################################################################################
diff --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index 21e5d2f22316c..2a04967c89bc3 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -73,6 +73,14 @@
help="Include and link GNUstep libobjc2 (Windows and Linux only)",
)
+parser.add_argument(
+ "--sysroot",
+ metavar="directory",
+ dest="sysroot",
+ required=False,
+ help="If specified, a sysroot to be passed via --sysroot",
+)
+
if sys.platform == "darwin":
parser.add_argument(
"--apple-sdk",
@@ -305,6 +313,7 @@ def __init__(self, toolchain_type, args, obj_ext):
if args.objc_gnustep_dir
else None
)
+ self.sysroot = args.sysroot
def _exe_file_name(self):
assert self.mode != "compile"
@@ -761,6 +770,8 @@ def _get_compilation_command(self, source, obj):
args.extend(
["-Xclang", "-gcodeview", "-Xclang", "--dependent-lib=msvcrtd"]
)
+ elif self.sysroot:
+ args.extend(["--sysroot", self.sysroot])
if self.std:
args.append("-std={0}".format(self.std))
@@ -797,6 +808,8 @@ def _get_link_command(self):
args.extend(
["-fuse-ld=lld-link", "-g", "-Xclang", "--dependent-lib=msvcrtd"]
)
+ elif self.sysroot:
+ args.extend(["--sysroot", self.sysroot])
return ("linking", self._obj_file_names(), self._exe_file_name(), None, args)
diff --git a/lldb/test/Shell/helper/toolchain.py b/lldb/test/Shell/helper/toolchain.py
index 31d3f1295fb4e..8b56c659b13bf 100644
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -47,6 +47,8 @@ def use_lldb_substitutions(config):
build_script_args.append(
'--objc-gnustep-dir="{0}"'.format(config.objc_gnustep_dir)
)
+ if config.cmake_sysroot:
+ build_script_args.append("--sysroot={0}".format(config.cmake_sysroot))
lldb_init = _get_lldb_init_path(config)
@@ -160,6 +162,9 @@ def use_support_substitutions(config):
# The clang module cache is used for building inferiors.
host_flags += ["-fmodules-cache-path={}".format(config.clang_module_cache)]
+ if config.cmake_sysroot:
+ host_flags += ["--sysroot={}".format(config.cmake_sysroot)]
+
host_flags = " ".join(host_flags)
config.substitutions.append(("%clang_host", "%clang " + host_flags))
config.substitutions.append(("%clangxx_host", "%clangxx " + host_flags))
diff --git a/lldb/test/Shell/lit.site.cfg.py.in b/lldb/test/Shell/lit.site.cfg.py.in
index f84cb60ff9404..736dfc335732b 100644
--- a/lldb/test/Shell/lit.site.cfg.py.in
+++ b/lldb/test/Shell/lit.site.cfg.py.in
@@ -13,6 +13,7 @@ config.lldb_tools_dir = lit_config.substitute("@LLDB_TOOLS_DIR@")
# Since it comes from the command line, it may have backslashes which
# should not need to be escaped.
config.lldb_lit_tools_dir = lit_config.substitute(r"@LLDB_LIT_TOOLS_DIR@")
+config.cmake_sysroot = lit_config.substitute("@CMAKE_SYSROOT@")
config.target_triple = "@LLVM_TARGET_TRIPLE@"
config.python_executable = "@Python3_EXECUTABLE@"
config.have_zlib = @LLVM_ENABLE_ZLIB@
More information about the lldb-commits
mailing list