Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lldb/packages/Python/lldbsuite/test/builders/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ def getLibCxxArgs(self):
def getLLDBObjRoot(self):
return ["LLDB_OBJ_ROOT={}".format(configuration.lldb_obj_root)]

def getResourceDirArgs(self):
if configuration.resource_dir:
return ["RESOURCE_DIR={}".format(configuration.resource_dir)]
Comment thread
DavidSpickett marked this conversation as resolved.
Outdated
return []

def _getDebugInfoArgs(self, debug_info):
if debug_info is None:
return []
Expand Down Expand Up @@ -298,6 +303,7 @@ def getBuildCommand(
self.getModuleCacheSpec(),
self.getLibCxxArgs(),
self.getLLDBObjRoot(),
self.getResourceDirArgs(),
self.getCmdLine(dictionary),
]
command = list(itertools.chain(*command_parts))
Expand Down
3 changes: 3 additions & 0 deletions lldb/packages/Python/lldbsuite/test/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
# Allow specifying a triple for cross compilation.
triple = None

# Clang resource directory for cross compilation.
resource_dir = None

# The overriden dwarf verison.
# Don't use this to test the current compiler's
# DWARF version, as this won't be set if the
Expand Down
2 changes: 2 additions & 0 deletions lldb/packages/Python/lldbsuite/test/dotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ def parseOptionsAndInitTestdirs():
configuration.dsymutil = seven.get_command_output(
"xcrun -find -toolchain default dsymutil"
)
if args.resource_dir:
configuration.resource_dir = args.resource_dir
if args.llvm_tools_dir:
configuration.llvm_tools_dir = args.llvm_tools_dir
configuration.filecheck = shutil.which("FileCheck", path=args.llvm_tools_dir)
Expand Down
9 changes: 9 additions & 0 deletions lldb/packages/Python/lldbsuite/test/dotest_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ def create_parser():
dest="dsymutil",
help=textwrap.dedent("Specify which dsymutil to use."),
)
group.add_argument(
"--resource-dir",
metavar="dir",
dest="resource_dir",
default="",
help=textwrap.dedent(
"Specify the clang resource directory for cross-compiling test inferiors."
),
)
group.add_argument(
"--llvm-tools-dir",
metavar="dir",
Expand Down
19 changes: 18 additions & 1 deletion lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,24 @@ def finalize_build_dictionary(dictionary):

if dictionary is None:
dictionary = {}
if target_is_android():

if configuration.triple:
# When cross-compiling with an explicit triple, derive OS from it
# rather than from the selected platform.
triple_os = (
configuration.triple.split("-")[1] if "-" in configuration.triple else ""
)
if triple_os.startswith("wasi"):
dictionary["OS"] = "Wasm"
Comment thread
DavidSpickett marked this conversation as resolved.
Outdated
elif triple_os == "linux" or triple_os.startswith("linux"):
dictionary["OS"] = "Linux"
elif triple_os == "windows" or triple_os.startswith("windows"):
dictionary["OS"] = "Windows_NT"
elif triple_os == "apple":
dictionary["OS"] = "Darwin"
else:
dictionary["OS"] = triple_os
elif target_is_android():
dictionary["OS"] = "Android"
dictionary["PIE"] = 1
elif platformIsDarwin():
Expand Down
2 changes: 1 addition & 1 deletion lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def setUpCommands(cls):

# Set any user-overridden settings.
for setting, value in configuration.settings:
commands.append("setting set %s %s" % (setting, value))
commands.append("settings set -- %s %s" % (setting, value))

# Make sure that a sanitizer LLDB's environment doesn't get passed on.
if (
Expand Down
10 changes: 9 additions & 1 deletion lldb/packages/Python/lldbsuite/test/make/Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ ifeq "$(OS)" "Android"
include $(THIS_FILE_DIR)/Android.rules
endif

ifeq "$(OS)" "Wasm"
include $(THIS_FILE_DIR)/Wasm.rules
endif

ifeq "$(TRIPLE)" ""
ifeq "$(ARCH)" ""
# No triple, no arch: query the compiler for its default triple.
Expand Down Expand Up @@ -172,7 +176,11 @@ ifeq "$(OS)" "Darwin"
else
ifneq "$(SDKROOT)" ""
SYSROOT_FLAGS := --sysroot "$(SDKROOT)"
GCC_TOOLCHAIN_FLAGS := --gcc-toolchain="$(SDKROOT)/usr"
ifeq "$(OS)" "Wasm"
GCC_TOOLCHAIN_FLAGS :=
Comment thread
DavidSpickett marked this conversation as resolved.
else
GCC_TOOLCHAIN_FLAGS := --gcc-toolchain="$(SDKROOT)/usr"
endif
else
# Do not set up these options if SDKROOT was not specified.
# This is a regular build in that case (or Android).
Expand Down
14 changes: 14 additions & 0 deletions lldb/packages/Python/lldbsuite/test/make/Wasm.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
USE_SYSTEM_STDLIB = 1

ifneq "$(RESOURCE_DIR)" ""
ARCH_CFLAGS += -resource-dir $(RESOURCE_DIR)
Comment thread
DavidSpickett marked this conversation as resolved.
Outdated
endif

ARCH_CXXFLAGS += \
-fno-exceptions

ARCH_LDFLAGS += \
$(if $(RESOURCE_DIR),-resource-dir $(RESOURCE_DIR)) \
-Wl,--export-all \
-Wl,--no-entry \
-Wl,--allow-undefined
2 changes: 2 additions & 0 deletions lldb/test/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ set(LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb exec
set(LLDB_TEST_COMPILER "${LLDB_DEFAULT_TEST_COMPILER}" CACHE PATH "C Compiler to use for building LLDB test inferiors")
set(LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil used for generating dSYM bundles")
set(LLDB_TEST_MAKE "${LLDB_DEFAULT_TEST_MAKE}" CACHE PATH "make tool used for building test executables")
set(LLDB_TEST_RESOURCE_DIR "" CACHE PATH "Clang resource directory for cross-compiling test inferiors")
set(LLDB_TEST_SYSROOT "" CACHE PATH "Sysroot for cross-compiling test inferiors")

if ("${LLDB_TEST_COMPILER}" STREQUAL "")
message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.")
Expand Down
2 changes: 2 additions & 0 deletions lldb/test/API/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ def delete_module_cache(path):
dotest_cmd += ["--platform-working-dir", config.lldb_platform_working_dir]
if is_configured("cmake_sysroot"):
dotest_cmd += ["--sysroot", config.cmake_sysroot]
if is_configured("test_resource_dir"):
dotest_cmd += ["--resource-dir", config.test_resource_dir]

if is_configured("dotest_user_args_str"):
dotest_cmd.extend(config.dotest_user_args_str.split(";"))
Expand Down
1 change: 1 addition & 0 deletions lldb/test/API/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ config.libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
config.libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@"
config.libcxx_include_target_dir = "@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@"
config.lldb_launcher = "@LLDB_LAUNCHER@"
config.test_resource_dir = "@LLDB_TEST_RESOURCE_DIR@"
config.lldb_enable_mte = @LLDB_ENABLE_MTE@
config.lldb_enable_arm64e_debugserver = @LLDB_USE_ARM64E_DEBUGSERVER@
# The API tests use their own module caches.
Expand Down