Author: Jonas Devlieghere Date: 2026-06-16T07:51:02-07:00 New Revision: 639556c9f690f94b4df7d2ca9a53b797161b27a2
URL: https://github.com/llvm/llvm-project/commit/639556c9f690f94b4df7d2ca9a53b797161b27a2 DIFF: https://github.com/llvm/llvm-project/commit/639556c9f690f94b4df7d2ca9a53b797161b27a2.diff LOG: Reland "[lldb][test] Add support for building Wasm test inferiors" (#204030) This relands #192872, reverted in #193493 for breaking the Windows LLDB bots. The original PR changed finalize_build_dictionary to derive the inferior OS by parsing configuration.triple, which misfired on the Windows bots' x86_64-pc-windows-msvc. However, that's unnecessary when specifying the platform with --platform-name, in which case getPlatform return wasip1, correctly mapping to OS=WASI. Added: lldb/packages/Python/lldbsuite/test/make/WASI.rules Modified: lldb/packages/Python/lldbsuite/test/builders/builder.py lldb/packages/Python/lldbsuite/test/configuration.py lldb/packages/Python/lldbsuite/test/dotest.py lldb/packages/Python/lldbsuite/test/dotest_args.py lldb/packages/Python/lldbsuite/test/make/Makefile.rules lldb/test/API/CMakeLists.txt lldb/test/API/lit.cfg.py lldb/test/API/lit.site.cfg.py.in Removed: ################################################################################ diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py index 40db227607ee5..93ce4cc732bd3 100644 --- a/lldb/packages/Python/lldbsuite/test/builders/builder.py +++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py @@ -245,7 +245,14 @@ def getLibCxxArgs(self): return [] def getLLDBObjRoot(self): - return ["LLDB_OBJ_ROOT={}".format(configuration.lldb_obj_root)] + if configuration.lldb_obj_root: + return [f"LLDB_OBJ_ROOT={configuration.lldb_obj_root}"] + return [] + + def getResourceDirArgs(self): + if configuration.resource_dir: + return [f"RESOURCE_DIR={configuration.resource_dir}"] + return [] def _getDebugInfoArgs(self, debug_info): if debug_info is None: @@ -299,6 +306,7 @@ def getBuildCommand( self.getModuleCacheSpec(), self.getLibCxxArgs(), self.getLLDBObjRoot(), + self.getResourceDirArgs(), self.getCmdLine(dictionary), ] command = list(itertools.chain(*command_parts)) diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py index 8347565dc26a4..4beb1f873e6ea 100644 --- a/lldb/packages/Python/lldbsuite/test/configuration.py +++ b/lldb/packages/Python/lldbsuite/test/configuration.py @@ -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 diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 252d02c9b6d72..b1857780f1680 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -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) diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py index c9d91718b3339..8995fe57e93a0 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest_args.py +++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py @@ -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", diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index 1e23d3fb0e883..51729959fdf62 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -124,6 +124,10 @@ ifeq "$(OS)" "Android" include $(THIS_FILE_DIR)/Android.rules endif +ifeq "$(OS)" "WASI" + include $(THIS_FILE_DIR)/WASI.rules +endif + ifeq "$(TRIPLE)" "" ifeq "$(ARCH)" "" # No triple, no arch: query the compiler for its default triple. @@ -178,7 +182,11 @@ ifeq "$(OS)" "Darwin" else ifneq "$(SDKROOT)" "" SYSROOT_FLAGS := --sysroot "$(SDKROOT)" - GCC_TOOLCHAIN_FLAGS := --gcc-toolchain="$(SDKROOT)/usr" + ifeq "$(OS)" "WASI" + GCC_TOOLCHAIN_FLAGS := + 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). diff --git a/lldb/packages/Python/lldbsuite/test/make/WASI.rules b/lldb/packages/Python/lldbsuite/test/make/WASI.rules new file mode 100644 index 0000000000000..190a9e423c5ff --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/make/WASI.rules @@ -0,0 +1,14 @@ +USE_SYSTEM_STDLIB = 1 + +ifneq "$(RESOURCE_DIR)" "" + ARCH_CFLAGS += -resource-dir $(RESOURCE_DIR) +endif + +ARCH_CXXFLAGS += \ + -fno-exceptions + +ARCH_LDFLAGS += \ + $(if $(RESOURCE_DIR),-resource-dir $(RESOURCE_DIR)) \ + -Wl,--export-all \ + -Wl,--no-entry \ + -Wl,--allow-undefined diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt index 0738278c63a9c..bff3bac438d6b 100644 --- a/lldb/test/API/CMakeLists.txt +++ b/lldb/test/API/CMakeLists.txt @@ -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.") diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py index ac2301b361da2..e4a18c0ffeb56 100644 --- a/lldb/test/API/lit.cfg.py +++ b/lldb/test/API/lit.cfg.py @@ -346,6 +346,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(";")) diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in index b5b070bb8d60d..44c62414f8bdd 100644 --- a/lldb/test/API/lit.site.cfg.py.in +++ b/lldb/test/API/lit.site.cfg.py.in @@ -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@ config.lldb_use_lldb_server = @LLDB_TEST_USE_LLDB_SERVER@ _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
