Skip to content

Conversation

pcc
Copy link
Contributor

@pcc pcc commented Jul 16, 2025

config.host_os is derived from CMAKE_SYSTEM_NAME
which specifies the target. See:
https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html

To reduce confusion, rename it to config.target_os.

The variable name config.target_os was already being used by the Orc
tests. Rename it to config.orc_test_target_os with a FIXME to remove.

Created using spr 1.3.6-beta.1
@pcc pcc requested a review from JDevlieghere as a code owner July 16, 2025 04:03
@llvmbot llvmbot added compiler-rt lldb compiler-rt:asan Address sanitizer compiler-rt:builtins compiler-rt:fuzzer compiler-rt:tsan Thread sanitizer compiler-rt:ubsan Undefined behavior sanitizer compiler-rt:scudo Scudo Hardened Allocator xray compiler-rt:hwasan Hardware-assisted address sanitizer PGO Profile Guided Optimizations compiler-rt:msan Memory sanitizer compiler-rt:lsan Leak sanitizer compiler-rt:sanitizer labels Jul 16, 2025
@pcc pcc requested a review from MaskRay July 16, 2025 04:03
@llvmbot
Copy link
Member

llvmbot commented Jul 16, 2025

@llvm/pr-subscribers-pgo

@llvm/pr-subscribers-xray

Author: Peter Collingbourne (pcc)

Changes

config.host_os is derived from CMAKE_SYSTEM_NAME
which specifies the target. See:
https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html

To reduce confusion, rename it to config.target_os.

The variable name config.target_os was already being used by the Orc
tests. Rename it to config.orc_test_target_os with a FIXME to remove.


Patch is 42.06 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/149015.diff

39 Files Affected:

  • (modified) compiler-rt/lib/tysan/lit.cfg (+1-1)
  • (modified) compiler-rt/test/asan/lit.cfg.py (+13-13)
  • (modified) compiler-rt/test/asan_abi/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/builtins/Unit/lit.cfg.py (+3-3)
  • (modified) compiler-rt/test/builtins/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/ctx_profile/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/dfsan/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/fuzzer/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/gwp_asan/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/hwasan/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/lit.common.cfg.py (+19-19)
  • (modified) compiler-rt/test/lsan/lit.common.cfg.py (+6-6)
  • (modified) compiler-rt/test/memprof/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/metadata/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/msan/lit.cfg.py (+3-3)
  • (modified) compiler-rt/test/nsan/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/orc/lit.cfg.py (+6-6)
  • (modified) compiler-rt/test/orc/lit.site.cfg.py.in (+2-1)
  • (modified) compiler-rt/test/profile/lit.cfg.py (+5-5)
  • (modified) compiler-rt/test/rtsan/Unit/lit.site.cfg.py.in (+1-1)
  • (modified) compiler-rt/test/rtsan/lit.cfg.py (+4-4)
  • (modified) compiler-rt/test/safestack/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/sanitizer_common/lit.common.cfg.py (+5-5)
  • (modified) compiler-rt/test/scudo/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/shadowcallstack/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/tsan/Unit/lit.site.cfg.py.in (+1-1)
  • (modified) compiler-rt/test/tsan/libdispatch/lit.local.cfg.py (+1-1)
  • (modified) compiler-rt/test/tsan/lit.cfg.py (+5-5)
  • (modified) compiler-rt/test/tysan/lit.cfg.py (+4-4)
  • (modified) compiler-rt/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py (+1-1)
  • (modified) compiler-rt/test/ubsan/lit.common.cfg.py (+2-2)
  • (modified) compiler-rt/test/ubsan_minimal/lit.common.cfg.py (+1-1)
  • (modified) compiler-rt/test/xray/lit.cfg.py (+4-4)
  • (modified) compiler-rt/unittests/lit.common.unit.cfg.py (+1-1)
  • (modified) compiler-rt/unittests/lit.common.unit.configured.in (+1-1)
  • (modified) lldb/test/API/lit.cfg.py (+2-2)
  • (modified) lldb/test/API/lit.site.cfg.py.in (+1-1)
  • (modified) llvm/test/lit.cfg.py (+1-1)
  • (modified) llvm/test/lit.site.cfg.py.in (+1-1)
diff --git a/compiler-rt/lib/tysan/lit.cfg b/compiler-rt/lib/tysan/lit.cfg
index e3ef6c9c97147..c906c03cc3fb2 100644
--- a/compiler-rt/lib/tysan/lit.cfg
+++ b/compiler-rt/lib/tysan/lit.cfg
@@ -27,7 +27,7 @@ config.substitutions.append( ("%clangxx_tysan ", build_invocation(clang_tysan_cx
 config.suffixes = ['.c', '.cc', '.cpp']
 
 # TypeSanitizer tests are currently supported on Linux only.
-if config.host_os not in ['Linux']:
+if config.target_os not in ['Linux']:
   config.unsupported = True
 
 if config.target_arch != 'aarch64':
diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py
index 3da073332c458..96201e679b0a3 100644
--- a/compiler-rt/test/asan/lit.cfg.py
+++ b/compiler-rt/test/asan/lit.cfg.py
@@ -28,7 +28,7 @@ def get_required_attr(config, attr_name):
 # tests to prevent regressions.
 # Currently, detect_leaks for asan tests only work on Intel MacOS.
 if (
-    config.host_os == "Darwin"
+    config.target_os == "Darwin"
     and config.apple_platform == "osx"
     and config.target_arch == "x86_64"
 ):
@@ -45,7 +45,7 @@ def get_required_attr(config, attr_name):
 # Setup source root.
 config.test_source_root = os.path.dirname(__file__)
 
-if config.host_os not in ["FreeBSD", "NetBSD"]:
+if config.target_os not in ["FreeBSD", "NetBSD"]:
     libdl_flag = "-ldl"
 else:
     libdl_flag = ""
@@ -125,17 +125,17 @@ def build_invocation(compile_flags, with_lto=False):
     ("%clangxx_asan_lto ", build_invocation(clang_asan_cxxflags, True))
 )
 if config.asan_dynamic:
-    if config.host_os in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
+    if config.target_os in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
         shared_libasan_path = os.path.join(
             config.compiler_rt_libdir,
             "libclang_rt.asan{}.so".format(config.target_suffix),
         )
-    elif config.host_os == "Darwin":
+    elif config.target_os == "Darwin":
         shared_libasan_path = os.path.join(
             config.compiler_rt_libdir,
             "libclang_rt.asan_{}_dynamic.dylib".format(config.apple_platform),
         )
-    elif config.host_os == "Windows":
+    elif config.target_os == "Windows":
         shared_libasan_path = os.path.join(
             config.compiler_rt_libdir,
             "clang_rt.asan_dynamic-{}.lib".format(config.target_suffix),
@@ -274,16 +274,16 @@ def build_invocation(compile_flags, with_lto=False):
     and (config.target_arch in ["x86_64", "i386", "i686", "aarch64"])
 )
 leak_detection_linux = (
-    (config.host_os == "Linux")
+    (config.target_os == "Linux")
     and (not config.android)
     and (config.target_arch in ["x86_64", "i386", "riscv64", "loongarch64"])
 )
 leak_detection_mac = (
-    (config.host_os == "Darwin")
+    (config.target_os == "Darwin")
     and (config.apple_platform == "osx")
     and (config.target_arch == "x86_64")
 )
-leak_detection_netbsd = (config.host_os == "NetBSD") and (
+leak_detection_netbsd = (config.target_os == "NetBSD") and (
     config.target_arch in ["x86_64", "i386"]
 )
 if (
@@ -296,7 +296,7 @@ def build_invocation(compile_flags, with_lto=False):
 
 # Add the RT libdir to PATH directly so that we can successfully run the gtest
 # binary to list its tests.
-if config.host_os == "Windows":
+if config.target_os == "Windows":
     os.environ["PATH"] = os.path.pathsep.join(
         [config.compiler_rt_libdir, os.environ.get("PATH", "")]
     )
@@ -310,10 +310,10 @@ def build_invocation(compile_flags, with_lto=False):
 # Default test suffixes.
 config.suffixes = [".c", ".cpp"]
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     config.suffixes.append(".mm")
 
-if config.host_os == "Windows":
+if config.target_os == "Windows":
     config.substitutions.append(("%fPIC", ""))
     config.substitutions.append(("%fPIE", ""))
     config.substitutions.append(("%pie", ""))
@@ -323,11 +323,11 @@ def build_invocation(compile_flags, with_lto=False):
     config.substitutions.append(("%pie", "-pie"))
 
 # Only run the tests on supported OSs.
-if config.host_os not in ["Linux", "Darwin", "FreeBSD", "SunOS", "Windows", "NetBSD"]:
+if config.target_os not in ["Linux", "Darwin", "FreeBSD", "SunOS", "Windows", "NetBSD"]:
     config.unsupported = True
 
 if not config.parallelism_group:
     config.parallelism_group = "shadow-memory"
 
-if config.host_os == "NetBSD":
+if config.target_os == "NetBSD":
     config.substitutions.insert(0, ("%run", config.netbsd_noaslr_prefix))
diff --git a/compiler-rt/test/asan_abi/lit.cfg.py b/compiler-rt/test/asan_abi/lit.cfg.py
index 5bc1881ed9c32..dd99a5373e7b6 100644
--- a/compiler-rt/test/asan_abi/lit.cfg.py
+++ b/compiler-rt/test/asan_abi/lit.cfg.py
@@ -68,7 +68,7 @@ def build_invocation(compile_flags):
 
 config.suffixes = ['.c', '.cpp']
 
-if config.host_os == 'Darwin':
+if config.target_os == 'Darwin':
   config.suffixes.append('.mm')
 else:
   config.unsupported = True
diff --git a/compiler-rt/test/builtins/Unit/lit.cfg.py b/compiler-rt/test/builtins/Unit/lit.cfg.py
index c030f89c66e42..59da054848f3c 100644
--- a/compiler-rt/test/builtins/Unit/lit.cfg.py
+++ b/compiler-rt/test/builtins/Unit/lit.cfg.py
@@ -80,10 +80,10 @@ def get_libgcc_file_name():
         config.compiler_rt_libdir, "clang_rt.builtins%s.lib " % config.target_suffix
     )
     config.substitutions.append(("%librt ", base_lib))
-elif config.host_os == "Darwin":
+elif config.target_os == "Darwin":
     base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.osx.a ")
     config.substitutions.append(("%librt ", base_lib + " -lSystem "))
-elif config.host_os == "Windows":
+elif config.target_os == "Windows":
     base_lib = os.path.join(
         config.compiler_rt_libdir, "libclang_rt.builtins%s.a" % config.target_suffix
     )
@@ -104,7 +104,7 @@ def get_libgcc_file_name():
     if sys.platform in ["win32"] and execute_external:
         # Don't pass dosish path separator to msys bash.exe.
         base_lib = base_lib.replace("\\", "/")
-    if config.host_os == "Haiku":
+    if config.target_os == "Haiku":
         config.substitutions.append(("%librt ", base_lib + " -lroot "))
     else:
         config.substitutions.append(("%librt ", base_lib + " -lc -lm "))
diff --git a/compiler-rt/test/builtins/lit.cfg.py b/compiler-rt/test/builtins/lit.cfg.py
index 9300488c8428d..6491f4735b9e6 100644
--- a/compiler-rt/test/builtins/lit.cfg.py
+++ b/compiler-rt/test/builtins/lit.cfg.py
@@ -21,7 +21,7 @@
     ("%clang ", " " + config.clang + " " + " ".join(extra_flags) + " ")
 )
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     config.substitutions.append(
         ("%macos_version_major", str(config.darwin_osx_version[0]))
     )
diff --git a/compiler-rt/test/ctx_profile/lit.cfg.py b/compiler-rt/test/ctx_profile/lit.cfg.py
index 74d9bfd11ae28..75367d95a47bd 100644
--- a/compiler-rt/test/ctx_profile/lit.cfg.py
+++ b/compiler-rt/test/ctx_profile/lit.cfg.py
@@ -7,7 +7,7 @@
 import lit.formats
 
 # Only run the tests on supported OSs.
-if config.host_os not in ["Linux"]:
+if config.target_os not in ["Linux"]:
     config.unsupported = True
 
 
diff --git a/compiler-rt/test/dfsan/lit.cfg.py b/compiler-rt/test/dfsan/lit.cfg.py
index e947c51f99a5b..b26ff3e367942 100644
--- a/compiler-rt/test/dfsan/lit.cfg.py
+++ b/compiler-rt/test/dfsan/lit.cfg.py
@@ -25,5 +25,5 @@ def build_invocation(compile_flags):
 config.suffixes = [".c", ".cpp"]
 
 # DataFlowSanitizer tests are currently supported on Linux only.
-if not (config.host_os in ["Linux"] and config.target_arch in ["aarch64", "x86_64", "loongarch64"]):
+if not (config.target_os in ["Linux"] and config.target_arch in ["aarch64", "x86_64", "loongarch64"]):
     config.unsupported = True
diff --git a/compiler-rt/test/fuzzer/lit.cfg.py b/compiler-rt/test/fuzzer/lit.cfg.py
index 75d4cf2e4c529..1689f53d0b021 100644
--- a/compiler-rt/test/fuzzer/lit.cfg.py
+++ b/compiler-rt/test/fuzzer/lit.cfg.py
@@ -149,5 +149,5 @@ def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True, msan_enabled=False):
 if not config.parallelism_group:
     config.parallelism_group = "shadow-memory"
 
-if config.host_os == "NetBSD":
+if config.target_os == "NetBSD":
     config.substitutions.insert(0, ("%run", config.netbsd_noaslr_prefix))
diff --git a/compiler-rt/test/gwp_asan/lit.cfg.py b/compiler-rt/test/gwp_asan/lit.cfg.py
index 7f68682162e3f..1592cf400023e 100644
--- a/compiler-rt/test/gwp_asan/lit.cfg.py
+++ b/compiler-rt/test/gwp_asan/lit.cfg.py
@@ -67,5 +67,5 @@ def build_invocation(compile_flags):
 )
 
 # GWP-ASan tests are currently supported on Linux only.
-if config.host_os not in ["Linux"]:
+if config.target_os not in ["Linux"]:
     config.unsupported = True
diff --git a/compiler-rt/test/hwasan/lit.cfg.py b/compiler-rt/test/hwasan/lit.cfg.py
index bbf23e683240a..3a1c8e1466aea 100644
--- a/compiler-rt/test/hwasan/lit.cfg.py
+++ b/compiler-rt/test/hwasan/lit.cfg.py
@@ -86,5 +86,5 @@ def build_invocation(compile_flags):
 # Default test suffixes.
 config.suffixes = [".c", ".cpp"]
 
-if config.host_os not in ["Linux", "Android"] or not config.has_lld:
+if config.target_os not in ["Linux", "Android"] or not config.has_lld:
     config.unsupported = True
diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index f5576ce0e013d..16edfe6213c4a 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -66,7 +66,7 @@ def find_compiler_libdir():
     # Fall back for older AppleClang that doesn't support `-print-runtime-dir`
     # Note `-print-file-name=<path to compiler-rt lib>` was broken for Apple
     # platforms so we can't use that approach here (see https://reviews.llvm.org/D101682).
-    if config.host_os == "Darwin":
+    if config.target_os == "Darwin":
         lib_dir, _ = get_path_from_clang(["-print-file-name=lib"], allow_failure=False)
         runtime_dir = os.path.join(lib_dir, "darwin")
         if not os.path.exists(runtime_dir):
@@ -312,7 +312,7 @@ def push_dynamic_library_lookup_path(config, new_path):
 if platform.system() == "Windows" and target_is_msvc:
     config.environment["LIB"] = os.environ["LIB"]
 
-config.available_features.add(config.host_os.lower())
+config.available_features.add(config.target_os.lower())
 
 if config.target_triple.startswith("ppc") or config.target_triple.startswith("powerpc"):
     config.available_features.add("ppc")
@@ -344,7 +344,7 @@ def push_dynamic_library_lookup_path(config, new_path):
     )
 )
 
-if config.host_os == "NetBSD":
+if config.target_os == "NetBSD":
     nb_commands_dir = os.path.join(
         config.compiler_rt_src_root, "test", "sanitizer_common", "netbsd_commands"
     )
@@ -395,7 +395,7 @@ def get_ios_commands_dir():
         if sanitizer not in config.environment:
             config.environment[sanitizer] = symbolizer_path
 
-env_utility = "/opt/freeware/bin/env" if config.host_os == "AIX" else "env"
+env_utility = "/opt/freeware/bin/env" if config.target_os == "AIX" else "env"
 env_unset_command = " ".join(f"-u {var}" for var in tool_symbolizer_path_list)
 config.substitutions.append(
     ("%env_unset_tool_symbolizer_path", f"{env_utility} {env_unset_command}")
@@ -410,7 +410,7 @@ def get_ios_commands_dir():
     lit_config.warning("%device_rm is not implemented")
     config.substitutions.append(("%device_rm", "echo "))
     config.compile_wrapper = ""
-elif config.host_os == "Darwin" and config.apple_platform != "osx":
+elif config.target_os == "Darwin" and config.apple_platform != "osx":
     # Darwin tests can be targetting macOS, a device or a simulator. All devices
     # are declared as "ios", even for iOS derivatives (tvOS, watchOS). Similarly,
     # all simulators are "iossim". See the table below.
@@ -498,7 +498,7 @@ def get_ios_commands_dir():
     config.compile_wrapper = ""
 
 # Define CHECK-%os to check for OS-dependent output.
-config.substitutions.append(("CHECK-%os", ("CHECK-" + config.host_os)))
+config.substitutions.append(("CHECK-%os", ("CHECK-" + config.target_os)))
 
 # Define %arch to check for architecture-dependent output.
 config.substitutions.append(("%arch", (config.host_arch)))
@@ -519,7 +519,7 @@ def get_ios_commands_dir():
     config.available_features.add(target_arch + "-target-arch")
     if target_arch in ["x86_64", "i386"]:
         config.available_features.add("x86-target-arch")
-    config.available_features.add(target_arch + "-" + config.host_os.lower())
+    config.available_features.add(target_arch + "-" + config.target_os.lower())
 
 compiler_rt_debug = getattr(config, "compiler_rt_debug", False)
 if not compiler_rt_debug:
@@ -565,7 +565,7 @@ def get_ios_commands_dir():
     ("%darwin_min_target_with_tls_support", "%min_macos_deployment_target=10.12")
 )
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     osx_version = (10, 0, 0)
     try:
         osx_version = subprocess.check_output(
@@ -708,7 +708,7 @@ def get_macos_aligned_version(macos_vers):
     config.substitutions.append(("%push_to_device", "echo "))
     config.substitutions.append(("%adb_shell", "echo "))
 
-if config.host_os == "Linux":
+if config.target_os == "Linux":
     def add_glibc_versions(ver_string):
         if config.android:
             return
@@ -806,10 +806,10 @@ def is_windows_lto_supported():
     return os.path.exists(os.path.join(config.llvm_tools_dir, "lld-link.exe"))
 
 
-if config.host_os == "Darwin" and is_darwin_lto_supported():
+if config.target_os == "Darwin" and is_darwin_lto_supported():
     config.lto_supported = True
     config.lto_flags = ["-Wl,-lto_library," + liblto_path()]
-elif config.host_os in ["Linux", "FreeBSD", "NetBSD"]:
+elif config.target_os in ["Linux", "FreeBSD", "NetBSD"]:
     config.lto_supported = False
     if config.use_lld and is_lld_lto_supported():
         config.lto_supported = True
@@ -822,7 +822,7 @@ def is_windows_lto_supported():
             config.lto_flags = ["-fuse-ld=lld"]
         else:
             config.lto_flags = ["-fuse-ld=gold"]
-elif config.host_os == "Windows" and is_windows_lto_supported():
+elif config.target_os == "Windows" and is_windows_lto_supported():
     config.lto_supported = True
     config.lto_flags = ["-fuse-ld=lld"]
 else:
@@ -871,7 +871,7 @@ def is_windows_lto_supported():
 # Note that substitutions with numbers have to be defined first to avoid
 # being subsumed by substitutions with smaller postfix.
 for postfix in ["2", "1", ""]:
-    if config.host_os == "Darwin":
+    if config.target_os == "Darwin":
         config.substitutions.append(
             (
                 "%ld_flags_rpath_exe" + postfix,
@@ -884,7 +884,7 @@ def is_windows_lto_supported():
                 "-install_name @rpath/`basename %dynamiclib{}`".format(postfix),
             )
         )
-    elif config.host_os in ("FreeBSD", "NetBSD", "OpenBSD"):
+    elif config.target_os in ("FreeBSD", "NetBSD", "OpenBSD"):
         config.substitutions.append(
             (
                 "%ld_flags_rpath_exe" + postfix,
@@ -893,7 +893,7 @@ def is_windows_lto_supported():
             )
         )
         config.substitutions.append(("%ld_flags_rpath_so" + postfix, ""))
-    elif config.host_os == "Linux":
+    elif config.target_os == "Linux":
         config.substitutions.append(
             (
                 "%ld_flags_rpath_exe" + postfix,
@@ -901,7 +901,7 @@ def is_windows_lto_supported():
             )
         )
         config.substitutions.append(("%ld_flags_rpath_so" + postfix, ""))
-    elif config.host_os == "SunOS":
+    elif config.target_os == "SunOS":
         config.substitutions.append(
             (
                 "%ld_flags_rpath_exe" + postfix,
@@ -923,7 +923,7 @@ def is_windows_lto_supported():
     config.substitutions.append(("%xdynamiclib_namespec", "%basename_t.dynamic"))
 
 config.default_sanitizer_opts = []
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     # On Darwin, we default to `abort_on_error=1`, which would make tests run
     # much slower. Let's override this and run lit tests with 'abort_on_error=0'.
     config.default_sanitizer_opts += ["abort_on_error=0"]
@@ -983,7 +983,7 @@ def is_windows_lto_supported():
 elif config.use_lld and (not config.has_lld):
     config.unsupported = True
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     if getattr(config, "darwin_linker_version", None):
         extra_cflags += ["-mlinker-version=" + config.darwin_linker_version]
 
@@ -998,7 +998,7 @@ def is_windows_lto_supported():
 )
 config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " "
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     config.substitutions.append(
         (
             "%get_pid_from_output",
diff --git a/compiler-rt/test/lsan/lit.common.cfg.py b/compiler-rt/test/lsan/lit.common.cfg.py
index 9426b7d108bbf..1e2679438b114 100644
--- a/compiler-rt/test/lsan/lit.common.cfg.py
+++ b/compiler-rt/test/lsan/lit.common.cfg.py
@@ -34,7 +34,7 @@ def get_required_attr(config, attr_name):
     config.name = "LeakSanitizer-AddressSanitizer"
     lsan_cflags = ["-fsanitize=address"]
     config.available_features.add("asan")
-    if config.host_os == "NetBSD":
+    if config.target_os == "NetBSD":
         config.substitutions.insert(0, ("%run", config.netbsd_noaslr_prefix))
 elif lsan_lit_test_mode == "HWAddressSanitizer":
     config.name = "LeakSanitizer-HWAddressSanitizer"
@@ -42,7 +42,7 @@ def get_required_attr(config, attr_name):
     if target_arch == "x86_64":
         lsan_cflags = lsan_cflags + ["-fsanitize-hwaddress-experimental-aliasing"]
     config.available_features.add("hwasan")
-    if config.host_os == "NetBSD":
+    if config.target_os == "NetBSD":
         config.substitutions.insert(0, ("%run", config.netbsd_noaslr_prefix))
 else:
     lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode)
@@ -51,7 +51,7 @@ def get_required_attr(config, attr_name):
 # Platform-specific default LSAN_OPTIONS for lit tests.
 default_common_opts_str = ":".join(list(config.default_sanitizer_opts))
 default_lsan_opts = default_common_opts_str + ":detect_leaks=1"
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     # On Darwin, we default to `abort_on_error=1`, which would make tests run
     # much slower. Let's override this and run lit tests with 'abort_on_error=0'.
     # Also, make sure we do not overwhelm the syslog while testing.
@@ -101,7 +101,7 @@ def build_invocation(compile_flags):
 )
 supported_linux = (
     (not config.android)
-    and config.host_os == "Linux"
+    and config.target_os == "Linux"
     and config.host_arch
     in [
         "aarch64",
@@ -117,8 +117,8 @@ def build_invocation(compile_flags):
         "loongarch64",
     ]
 )
-supported_darwin = config.host_os == "Darwin" and config.target_arch in ["x86_64"]
-supported_netbsd = config.host_os == "NetBSD" and config.target_arch in [
+supported_darwin = config.target_os == "Darwin" and config.target_arch in ["x86_64"]
+supported_netbsd = config.target_os == "NetBSD" and config.target_arch in [
     "x86_64",
     "i386",
 ]
diff --git a/compiler-rt/test/memprof/lit.cfg.py b/compiler-rt/test/memprof/lit.cfg.py
index 4057da0c65b51..e28507be4dc9e 100644
--- a/compiler-rt/test/memprof/lit.cfg.py
+++ b/compiler-rt/test/memprof/lit.cfg.py
@@ -106,7 +106,7 @@ def build_invocation(compile_flags):
 config.substitutions.append(("%pie", "-pie"))
 
 # Only run the tests on supported OSs.
-if config.host_os not in ["Linux"]:
+if config.target_os not in ["Linux"]:
     config.unsupported = True
 
 if not config.parallelism_group:
diff --git a/compiler-rt/test/metadata/lit.cfg.py b/compiler-rt/test/metadata/lit.cfg.py
index 73ba27ad3a4e2..9980e93b3a6ec 100644
--- a/compiler-rt/test/metadata/lit.cfg.py
+++ b/compiler-rt/test/metadata/lit.cfg.py
@@ -5,5 +5,5 @@
 config.suffixes = [".cpp"]
 # Binary metadata is currently emitted only for ELF binaries
 # and sizes of stack arguments depend on the arch.
-if config.host_os not in ["Linux"] or config.target_arch not in ["x86_64"]:
+if config.target_os not in ["Linux"] or config.target_arch not in ["x86_64"]:
     config.unsupported = True
diff --git a/compiler-rt/test/msan/lit.cfg.py b/compiler-rt/test/msan/lit.cfg.py
index 361be79e2557e..d9e83c67b84c8 100644
--- a/compiler-rt/test/msan/lit.cfg.py
+++ b/compiler-rt/test/msan/lit.cfg.py
@@ -20,7 +20,7 @@
     + config.debug_info_flags
 )
 # Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
-if...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Jul 16, 2025

@llvm/pr-subscribers-lldb

Author: Peter Collingbourne (pcc)

Changes

config.host_os is derived from CMAKE_SYSTEM_NAME
which specifies the target. See:
https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html

To reduce confusion, rename it to config.target_os.

The variable name config.target_os was already being used by the Orc
tests. Rename it to config.orc_test_target_os with a FIXME to remove.


Patch is 42.06 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/149015.diff

39 Files Affected:

  • (modified) compiler-rt/lib/tysan/lit.cfg (+1-1)
  • (modified) compiler-rt/test/asan/lit.cfg.py (+13-13)
  • (modified) compiler-rt/test/asan_abi/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/builtins/Unit/lit.cfg.py (+3-3)
  • (modified) compiler-rt/test/builtins/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/ctx_profile/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/dfsan/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/fuzzer/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/gwp_asan/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/hwasan/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/lit.common.cfg.py (+19-19)
  • (modified) compiler-rt/test/lsan/lit.common.cfg.py (+6-6)
  • (modified) compiler-rt/test/memprof/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/metadata/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/msan/lit.cfg.py (+3-3)
  • (modified) compiler-rt/test/nsan/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/orc/lit.cfg.py (+6-6)
  • (modified) compiler-rt/test/orc/lit.site.cfg.py.in (+2-1)
  • (modified) compiler-rt/test/profile/lit.cfg.py (+5-5)
  • (modified) compiler-rt/test/rtsan/Unit/lit.site.cfg.py.in (+1-1)
  • (modified) compiler-rt/test/rtsan/lit.cfg.py (+4-4)
  • (modified) compiler-rt/test/safestack/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/sanitizer_common/lit.common.cfg.py (+5-5)
  • (modified) compiler-rt/test/scudo/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/shadowcallstack/lit.cfg.py (+1-1)
  • (modified) compiler-rt/test/tsan/Unit/lit.site.cfg.py.in (+1-1)
  • (modified) compiler-rt/test/tsan/libdispatch/lit.local.cfg.py (+1-1)
  • (modified) compiler-rt/test/tsan/lit.cfg.py (+5-5)
  • (modified) compiler-rt/test/tysan/lit.cfg.py (+4-4)
  • (modified) compiler-rt/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py (+1-1)
  • (modified) compiler-rt/test/ubsan/lit.common.cfg.py (+2-2)
  • (modified) compiler-rt/test/ubsan_minimal/lit.common.cfg.py (+1-1)
  • (modified) compiler-rt/test/xray/lit.cfg.py (+4-4)
  • (modified) compiler-rt/unittests/lit.common.unit.cfg.py (+1-1)
  • (modified) compiler-rt/unittests/lit.common.unit.configured.in (+1-1)
  • (modified) lldb/test/API/lit.cfg.py (+2-2)
  • (modified) lldb/test/API/lit.site.cfg.py.in (+1-1)
  • (modified) llvm/test/lit.cfg.py (+1-1)
  • (modified) llvm/test/lit.site.cfg.py.in (+1-1)
diff --git a/compiler-rt/lib/tysan/lit.cfg b/compiler-rt/lib/tysan/lit.cfg
index e3ef6c9c97147..c906c03cc3fb2 100644
--- a/compiler-rt/lib/tysan/lit.cfg
+++ b/compiler-rt/lib/tysan/lit.cfg
@@ -27,7 +27,7 @@ config.substitutions.append( ("%clangxx_tysan ", build_invocation(clang_tysan_cx
 config.suffixes = ['.c', '.cc', '.cpp']
 
 # TypeSanitizer tests are currently supported on Linux only.
-if config.host_os not in ['Linux']:
+if config.target_os not in ['Linux']:
   config.unsupported = True
 
 if config.target_arch != 'aarch64':
diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py
index 3da073332c458..96201e679b0a3 100644
--- a/compiler-rt/test/asan/lit.cfg.py
+++ b/compiler-rt/test/asan/lit.cfg.py
@@ -28,7 +28,7 @@ def get_required_attr(config, attr_name):
 # tests to prevent regressions.
 # Currently, detect_leaks for asan tests only work on Intel MacOS.
 if (
-    config.host_os == "Darwin"
+    config.target_os == "Darwin"
     and config.apple_platform == "osx"
     and config.target_arch == "x86_64"
 ):
@@ -45,7 +45,7 @@ def get_required_attr(config, attr_name):
 # Setup source root.
 config.test_source_root = os.path.dirname(__file__)
 
-if config.host_os not in ["FreeBSD", "NetBSD"]:
+if config.target_os not in ["FreeBSD", "NetBSD"]:
     libdl_flag = "-ldl"
 else:
     libdl_flag = ""
@@ -125,17 +125,17 @@ def build_invocation(compile_flags, with_lto=False):
     ("%clangxx_asan_lto ", build_invocation(clang_asan_cxxflags, True))
 )
 if config.asan_dynamic:
-    if config.host_os in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
+    if config.target_os in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
         shared_libasan_path = os.path.join(
             config.compiler_rt_libdir,
             "libclang_rt.asan{}.so".format(config.target_suffix),
         )
-    elif config.host_os == "Darwin":
+    elif config.target_os == "Darwin":
         shared_libasan_path = os.path.join(
             config.compiler_rt_libdir,
             "libclang_rt.asan_{}_dynamic.dylib".format(config.apple_platform),
         )
-    elif config.host_os == "Windows":
+    elif config.target_os == "Windows":
         shared_libasan_path = os.path.join(
             config.compiler_rt_libdir,
             "clang_rt.asan_dynamic-{}.lib".format(config.target_suffix),
@@ -274,16 +274,16 @@ def build_invocation(compile_flags, with_lto=False):
     and (config.target_arch in ["x86_64", "i386", "i686", "aarch64"])
 )
 leak_detection_linux = (
-    (config.host_os == "Linux")
+    (config.target_os == "Linux")
     and (not config.android)
     and (config.target_arch in ["x86_64", "i386", "riscv64", "loongarch64"])
 )
 leak_detection_mac = (
-    (config.host_os == "Darwin")
+    (config.target_os == "Darwin")
     and (config.apple_platform == "osx")
     and (config.target_arch == "x86_64")
 )
-leak_detection_netbsd = (config.host_os == "NetBSD") and (
+leak_detection_netbsd = (config.target_os == "NetBSD") and (
     config.target_arch in ["x86_64", "i386"]
 )
 if (
@@ -296,7 +296,7 @@ def build_invocation(compile_flags, with_lto=False):
 
 # Add the RT libdir to PATH directly so that we can successfully run the gtest
 # binary to list its tests.
-if config.host_os == "Windows":
+if config.target_os == "Windows":
     os.environ["PATH"] = os.path.pathsep.join(
         [config.compiler_rt_libdir, os.environ.get("PATH", "")]
     )
@@ -310,10 +310,10 @@ def build_invocation(compile_flags, with_lto=False):
 # Default test suffixes.
 config.suffixes = [".c", ".cpp"]
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     config.suffixes.append(".mm")
 
-if config.host_os == "Windows":
+if config.target_os == "Windows":
     config.substitutions.append(("%fPIC", ""))
     config.substitutions.append(("%fPIE", ""))
     config.substitutions.append(("%pie", ""))
@@ -323,11 +323,11 @@ def build_invocation(compile_flags, with_lto=False):
     config.substitutions.append(("%pie", "-pie"))
 
 # Only run the tests on supported OSs.
-if config.host_os not in ["Linux", "Darwin", "FreeBSD", "SunOS", "Windows", "NetBSD"]:
+if config.target_os not in ["Linux", "Darwin", "FreeBSD", "SunOS", "Windows", "NetBSD"]:
     config.unsupported = True
 
 if not config.parallelism_group:
     config.parallelism_group = "shadow-memory"
 
-if config.host_os == "NetBSD":
+if config.target_os == "NetBSD":
     config.substitutions.insert(0, ("%run", config.netbsd_noaslr_prefix))
diff --git a/compiler-rt/test/asan_abi/lit.cfg.py b/compiler-rt/test/asan_abi/lit.cfg.py
index 5bc1881ed9c32..dd99a5373e7b6 100644
--- a/compiler-rt/test/asan_abi/lit.cfg.py
+++ b/compiler-rt/test/asan_abi/lit.cfg.py
@@ -68,7 +68,7 @@ def build_invocation(compile_flags):
 
 config.suffixes = ['.c', '.cpp']
 
-if config.host_os == 'Darwin':
+if config.target_os == 'Darwin':
   config.suffixes.append('.mm')
 else:
   config.unsupported = True
diff --git a/compiler-rt/test/builtins/Unit/lit.cfg.py b/compiler-rt/test/builtins/Unit/lit.cfg.py
index c030f89c66e42..59da054848f3c 100644
--- a/compiler-rt/test/builtins/Unit/lit.cfg.py
+++ b/compiler-rt/test/builtins/Unit/lit.cfg.py
@@ -80,10 +80,10 @@ def get_libgcc_file_name():
         config.compiler_rt_libdir, "clang_rt.builtins%s.lib " % config.target_suffix
     )
     config.substitutions.append(("%librt ", base_lib))
-elif config.host_os == "Darwin":
+elif config.target_os == "Darwin":
     base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.osx.a ")
     config.substitutions.append(("%librt ", base_lib + " -lSystem "))
-elif config.host_os == "Windows":
+elif config.target_os == "Windows":
     base_lib = os.path.join(
         config.compiler_rt_libdir, "libclang_rt.builtins%s.a" % config.target_suffix
     )
@@ -104,7 +104,7 @@ def get_libgcc_file_name():
     if sys.platform in ["win32"] and execute_external:
         # Don't pass dosish path separator to msys bash.exe.
         base_lib = base_lib.replace("\\", "/")
-    if config.host_os == "Haiku":
+    if config.target_os == "Haiku":
         config.substitutions.append(("%librt ", base_lib + " -lroot "))
     else:
         config.substitutions.append(("%librt ", base_lib + " -lc -lm "))
diff --git a/compiler-rt/test/builtins/lit.cfg.py b/compiler-rt/test/builtins/lit.cfg.py
index 9300488c8428d..6491f4735b9e6 100644
--- a/compiler-rt/test/builtins/lit.cfg.py
+++ b/compiler-rt/test/builtins/lit.cfg.py
@@ -21,7 +21,7 @@
     ("%clang ", " " + config.clang + " " + " ".join(extra_flags) + " ")
 )
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     config.substitutions.append(
         ("%macos_version_major", str(config.darwin_osx_version[0]))
     )
diff --git a/compiler-rt/test/ctx_profile/lit.cfg.py b/compiler-rt/test/ctx_profile/lit.cfg.py
index 74d9bfd11ae28..75367d95a47bd 100644
--- a/compiler-rt/test/ctx_profile/lit.cfg.py
+++ b/compiler-rt/test/ctx_profile/lit.cfg.py
@@ -7,7 +7,7 @@
 import lit.formats
 
 # Only run the tests on supported OSs.
-if config.host_os not in ["Linux"]:
+if config.target_os not in ["Linux"]:
     config.unsupported = True
 
 
diff --git a/compiler-rt/test/dfsan/lit.cfg.py b/compiler-rt/test/dfsan/lit.cfg.py
index e947c51f99a5b..b26ff3e367942 100644
--- a/compiler-rt/test/dfsan/lit.cfg.py
+++ b/compiler-rt/test/dfsan/lit.cfg.py
@@ -25,5 +25,5 @@ def build_invocation(compile_flags):
 config.suffixes = [".c", ".cpp"]
 
 # DataFlowSanitizer tests are currently supported on Linux only.
-if not (config.host_os in ["Linux"] and config.target_arch in ["aarch64", "x86_64", "loongarch64"]):
+if not (config.target_os in ["Linux"] and config.target_arch in ["aarch64", "x86_64", "loongarch64"]):
     config.unsupported = True
diff --git a/compiler-rt/test/fuzzer/lit.cfg.py b/compiler-rt/test/fuzzer/lit.cfg.py
index 75d4cf2e4c529..1689f53d0b021 100644
--- a/compiler-rt/test/fuzzer/lit.cfg.py
+++ b/compiler-rt/test/fuzzer/lit.cfg.py
@@ -149,5 +149,5 @@ def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True, msan_enabled=False):
 if not config.parallelism_group:
     config.parallelism_group = "shadow-memory"
 
-if config.host_os == "NetBSD":
+if config.target_os == "NetBSD":
     config.substitutions.insert(0, ("%run", config.netbsd_noaslr_prefix))
diff --git a/compiler-rt/test/gwp_asan/lit.cfg.py b/compiler-rt/test/gwp_asan/lit.cfg.py
index 7f68682162e3f..1592cf400023e 100644
--- a/compiler-rt/test/gwp_asan/lit.cfg.py
+++ b/compiler-rt/test/gwp_asan/lit.cfg.py
@@ -67,5 +67,5 @@ def build_invocation(compile_flags):
 )
 
 # GWP-ASan tests are currently supported on Linux only.
-if config.host_os not in ["Linux"]:
+if config.target_os not in ["Linux"]:
     config.unsupported = True
diff --git a/compiler-rt/test/hwasan/lit.cfg.py b/compiler-rt/test/hwasan/lit.cfg.py
index bbf23e683240a..3a1c8e1466aea 100644
--- a/compiler-rt/test/hwasan/lit.cfg.py
+++ b/compiler-rt/test/hwasan/lit.cfg.py
@@ -86,5 +86,5 @@ def build_invocation(compile_flags):
 # Default test suffixes.
 config.suffixes = [".c", ".cpp"]
 
-if config.host_os not in ["Linux", "Android"] or not config.has_lld:
+if config.target_os not in ["Linux", "Android"] or not config.has_lld:
     config.unsupported = True
diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index f5576ce0e013d..16edfe6213c4a 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -66,7 +66,7 @@ def find_compiler_libdir():
     # Fall back for older AppleClang that doesn't support `-print-runtime-dir`
     # Note `-print-file-name=<path to compiler-rt lib>` was broken for Apple
     # platforms so we can't use that approach here (see https://reviews.llvm.org/D101682).
-    if config.host_os == "Darwin":
+    if config.target_os == "Darwin":
         lib_dir, _ = get_path_from_clang(["-print-file-name=lib"], allow_failure=False)
         runtime_dir = os.path.join(lib_dir, "darwin")
         if not os.path.exists(runtime_dir):
@@ -312,7 +312,7 @@ def push_dynamic_library_lookup_path(config, new_path):
 if platform.system() == "Windows" and target_is_msvc:
     config.environment["LIB"] = os.environ["LIB"]
 
-config.available_features.add(config.host_os.lower())
+config.available_features.add(config.target_os.lower())
 
 if config.target_triple.startswith("ppc") or config.target_triple.startswith("powerpc"):
     config.available_features.add("ppc")
@@ -344,7 +344,7 @@ def push_dynamic_library_lookup_path(config, new_path):
     )
 )
 
-if config.host_os == "NetBSD":
+if config.target_os == "NetBSD":
     nb_commands_dir = os.path.join(
         config.compiler_rt_src_root, "test", "sanitizer_common", "netbsd_commands"
     )
@@ -395,7 +395,7 @@ def get_ios_commands_dir():
         if sanitizer not in config.environment:
             config.environment[sanitizer] = symbolizer_path
 
-env_utility = "/opt/freeware/bin/env" if config.host_os == "AIX" else "env"
+env_utility = "/opt/freeware/bin/env" if config.target_os == "AIX" else "env"
 env_unset_command = " ".join(f"-u {var}" for var in tool_symbolizer_path_list)
 config.substitutions.append(
     ("%env_unset_tool_symbolizer_path", f"{env_utility} {env_unset_command}")
@@ -410,7 +410,7 @@ def get_ios_commands_dir():
     lit_config.warning("%device_rm is not implemented")
     config.substitutions.append(("%device_rm", "echo "))
     config.compile_wrapper = ""
-elif config.host_os == "Darwin" and config.apple_platform != "osx":
+elif config.target_os == "Darwin" and config.apple_platform != "osx":
     # Darwin tests can be targetting macOS, a device or a simulator. All devices
     # are declared as "ios", even for iOS derivatives (tvOS, watchOS). Similarly,
     # all simulators are "iossim". See the table below.
@@ -498,7 +498,7 @@ def get_ios_commands_dir():
     config.compile_wrapper = ""
 
 # Define CHECK-%os to check for OS-dependent output.
-config.substitutions.append(("CHECK-%os", ("CHECK-" + config.host_os)))
+config.substitutions.append(("CHECK-%os", ("CHECK-" + config.target_os)))
 
 # Define %arch to check for architecture-dependent output.
 config.substitutions.append(("%arch", (config.host_arch)))
@@ -519,7 +519,7 @@ def get_ios_commands_dir():
     config.available_features.add(target_arch + "-target-arch")
     if target_arch in ["x86_64", "i386"]:
         config.available_features.add("x86-target-arch")
-    config.available_features.add(target_arch + "-" + config.host_os.lower())
+    config.available_features.add(target_arch + "-" + config.target_os.lower())
 
 compiler_rt_debug = getattr(config, "compiler_rt_debug", False)
 if not compiler_rt_debug:
@@ -565,7 +565,7 @@ def get_ios_commands_dir():
     ("%darwin_min_target_with_tls_support", "%min_macos_deployment_target=10.12")
 )
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     osx_version = (10, 0, 0)
     try:
         osx_version = subprocess.check_output(
@@ -708,7 +708,7 @@ def get_macos_aligned_version(macos_vers):
     config.substitutions.append(("%push_to_device", "echo "))
     config.substitutions.append(("%adb_shell", "echo "))
 
-if config.host_os == "Linux":
+if config.target_os == "Linux":
     def add_glibc_versions(ver_string):
         if config.android:
             return
@@ -806,10 +806,10 @@ def is_windows_lto_supported():
     return os.path.exists(os.path.join(config.llvm_tools_dir, "lld-link.exe"))
 
 
-if config.host_os == "Darwin" and is_darwin_lto_supported():
+if config.target_os == "Darwin" and is_darwin_lto_supported():
     config.lto_supported = True
     config.lto_flags = ["-Wl,-lto_library," + liblto_path()]
-elif config.host_os in ["Linux", "FreeBSD", "NetBSD"]:
+elif config.target_os in ["Linux", "FreeBSD", "NetBSD"]:
     config.lto_supported = False
     if config.use_lld and is_lld_lto_supported():
         config.lto_supported = True
@@ -822,7 +822,7 @@ def is_windows_lto_supported():
             config.lto_flags = ["-fuse-ld=lld"]
         else:
             config.lto_flags = ["-fuse-ld=gold"]
-elif config.host_os == "Windows" and is_windows_lto_supported():
+elif config.target_os == "Windows" and is_windows_lto_supported():
     config.lto_supported = True
     config.lto_flags = ["-fuse-ld=lld"]
 else:
@@ -871,7 +871,7 @@ def is_windows_lto_supported():
 # Note that substitutions with numbers have to be defined first to avoid
 # being subsumed by substitutions with smaller postfix.
 for postfix in ["2", "1", ""]:
-    if config.host_os == "Darwin":
+    if config.target_os == "Darwin":
         config.substitutions.append(
             (
                 "%ld_flags_rpath_exe" + postfix,
@@ -884,7 +884,7 @@ def is_windows_lto_supported():
                 "-install_name @rpath/`basename %dynamiclib{}`".format(postfix),
             )
         )
-    elif config.host_os in ("FreeBSD", "NetBSD", "OpenBSD"):
+    elif config.target_os in ("FreeBSD", "NetBSD", "OpenBSD"):
         config.substitutions.append(
             (
                 "%ld_flags_rpath_exe" + postfix,
@@ -893,7 +893,7 @@ def is_windows_lto_supported():
             )
         )
         config.substitutions.append(("%ld_flags_rpath_so" + postfix, ""))
-    elif config.host_os == "Linux":
+    elif config.target_os == "Linux":
         config.substitutions.append(
             (
                 "%ld_flags_rpath_exe" + postfix,
@@ -901,7 +901,7 @@ def is_windows_lto_supported():
             )
         )
         config.substitutions.append(("%ld_flags_rpath_so" + postfix, ""))
-    elif config.host_os == "SunOS":
+    elif config.target_os == "SunOS":
         config.substitutions.append(
             (
                 "%ld_flags_rpath_exe" + postfix,
@@ -923,7 +923,7 @@ def is_windows_lto_supported():
     config.substitutions.append(("%xdynamiclib_namespec", "%basename_t.dynamic"))
 
 config.default_sanitizer_opts = []
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     # On Darwin, we default to `abort_on_error=1`, which would make tests run
     # much slower. Let's override this and run lit tests with 'abort_on_error=0'.
     config.default_sanitizer_opts += ["abort_on_error=0"]
@@ -983,7 +983,7 @@ def is_windows_lto_supported():
 elif config.use_lld and (not config.has_lld):
     config.unsupported = True
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     if getattr(config, "darwin_linker_version", None):
         extra_cflags += ["-mlinker-version=" + config.darwin_linker_version]
 
@@ -998,7 +998,7 @@ def is_windows_lto_supported():
 )
 config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " "
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     config.substitutions.append(
         (
             "%get_pid_from_output",
diff --git a/compiler-rt/test/lsan/lit.common.cfg.py b/compiler-rt/test/lsan/lit.common.cfg.py
index 9426b7d108bbf..1e2679438b114 100644
--- a/compiler-rt/test/lsan/lit.common.cfg.py
+++ b/compiler-rt/test/lsan/lit.common.cfg.py
@@ -34,7 +34,7 @@ def get_required_attr(config, attr_name):
     config.name = "LeakSanitizer-AddressSanitizer"
     lsan_cflags = ["-fsanitize=address"]
     config.available_features.add("asan")
-    if config.host_os == "NetBSD":
+    if config.target_os == "NetBSD":
         config.substitutions.insert(0, ("%run", config.netbsd_noaslr_prefix))
 elif lsan_lit_test_mode == "HWAddressSanitizer":
     config.name = "LeakSanitizer-HWAddressSanitizer"
@@ -42,7 +42,7 @@ def get_required_attr(config, attr_name):
     if target_arch == "x86_64":
         lsan_cflags = lsan_cflags + ["-fsanitize-hwaddress-experimental-aliasing"]
     config.available_features.add("hwasan")
-    if config.host_os == "NetBSD":
+    if config.target_os == "NetBSD":
         config.substitutions.insert(0, ("%run", config.netbsd_noaslr_prefix))
 else:
     lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode)
@@ -51,7 +51,7 @@ def get_required_attr(config, attr_name):
 # Platform-specific default LSAN_OPTIONS for lit tests.
 default_common_opts_str = ":".join(list(config.default_sanitizer_opts))
 default_lsan_opts = default_common_opts_str + ":detect_leaks=1"
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     # On Darwin, we default to `abort_on_error=1`, which would make tests run
     # much slower. Let's override this and run lit tests with 'abort_on_error=0'.
     # Also, make sure we do not overwhelm the syslog while testing.
@@ -101,7 +101,7 @@ def build_invocation(compile_flags):
 )
 supported_linux = (
     (not config.android)
-    and config.host_os == "Linux"
+    and config.target_os == "Linux"
     and config.host_arch
     in [
         "aarch64",
@@ -117,8 +117,8 @@ def build_invocation(compile_flags):
         "loongarch64",
     ]
 )
-supported_darwin = config.host_os == "Darwin" and config.target_arch in ["x86_64"]
-supported_netbsd = config.host_os == "NetBSD" and config.target_arch in [
+supported_darwin = config.target_os == "Darwin" and config.target_arch in ["x86_64"]
+supported_netbsd = config.target_os == "NetBSD" and config.target_arch in [
     "x86_64",
     "i386",
 ]
diff --git a/compiler-rt/test/memprof/lit.cfg.py b/compiler-rt/test/memprof/lit.cfg.py
index 4057da0c65b51..e28507be4dc9e 100644
--- a/compiler-rt/test/memprof/lit.cfg.py
+++ b/compiler-rt/test/memprof/lit.cfg.py
@@ -106,7 +106,7 @@ def build_invocation(compile_flags):
 config.substitutions.append(("%pie", "-pie"))
 
 # Only run the tests on supported OSs.
-if config.host_os not in ["Linux"]:
+if config.target_os not in ["Linux"]:
     config.unsupported = True
 
 if not config.parallelism_group:
diff --git a/compiler-rt/test/metadata/lit.cfg.py b/compiler-rt/test/metadata/lit.cfg.py
index 73ba27ad3a4e2..9980e93b3a6ec 100644
--- a/compiler-rt/test/metadata/lit.cfg.py
+++ b/compiler-rt/test/metadata/lit.cfg.py
@@ -5,5 +5,5 @@
 config.suffixes = [".cpp"]
 # Binary metadata is currently emitted only for ELF binaries
 # and sizes of stack arguments depend on the arch.
-if config.host_os not in ["Linux"] or config.target_arch not in ["x86_64"]:
+if config.target_os not in ["Linux"] or config.target_arch not in ["x86_64"]:
     config.unsupported = True
diff --git a/compiler-rt/test/msan/lit.cfg.py b/compiler-rt/test/msan/lit.cfg.py
index 361be79e2557e..d9e83c67b84c8 100644
--- a/compiler-rt/test/msan/lit.cfg.py
+++ b/compiler-rt/test/msan/lit.cfg.py
@@ -20,7 +20,7 @@
     + config.debug_info_flags
 )
 # Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
-if...
[truncated]

Copy link

⚠️ Python code formatter, darker found issues in your code. ⚠️

You can test this locally with the following command:
darker --check --diff -r HEAD~1...HEAD compiler-rt/test/asan/lit.cfg.py compiler-rt/test/asan_abi/lit.cfg.py compiler-rt/test/builtins/Unit/lit.cfg.py compiler-rt/test/builtins/lit.cfg.py compiler-rt/test/ctx_profile/lit.cfg.py compiler-rt/test/dfsan/lit.cfg.py compiler-rt/test/fuzzer/lit.cfg.py compiler-rt/test/gwp_asan/lit.cfg.py compiler-rt/test/hwasan/lit.cfg.py compiler-rt/test/lit.common.cfg.py compiler-rt/test/lsan/lit.common.cfg.py compiler-rt/test/memprof/lit.cfg.py compiler-rt/test/metadata/lit.cfg.py compiler-rt/test/msan/lit.cfg.py compiler-rt/test/nsan/lit.cfg.py compiler-rt/test/orc/lit.cfg.py compiler-rt/test/profile/lit.cfg.py compiler-rt/test/rtsan/lit.cfg.py compiler-rt/test/safestack/lit.cfg.py compiler-rt/test/sanitizer_common/lit.common.cfg.py compiler-rt/test/scudo/lit.cfg.py compiler-rt/test/shadowcallstack/lit.cfg.py compiler-rt/test/tsan/libdispatch/lit.local.cfg.py compiler-rt/test/tsan/lit.cfg.py compiler-rt/test/tysan/lit.cfg.py compiler-rt/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py compiler-rt/test/ubsan/lit.common.cfg.py compiler-rt/test/ubsan_minimal/lit.common.cfg.py compiler-rt/test/xray/lit.cfg.py compiler-rt/unittests/lit.common.unit.cfg.py lldb/test/API/lit.cfg.py llvm/test/lit.cfg.py
View the diff from darker here.
--- compiler-rt/test/asan_abi/lit.cfg.py	2025-07-16 04:03:11.000000 +0000
+++ compiler-rt/test/asan_abi/lit.cfg.py	2025-07-16 04:05:27.311666 +0000
@@ -66,9 +66,9 @@
   config.substitutions.append( ('%clang_asan_abi_static ', build_invocation(clang_asan_abi_static_cflags)) )
   config.substitutions.append( ('%clangxx_asan_abi_static ', build_invocation(clang_asan_abi_static_cxxflags)) )
 
 config.suffixes = ['.c', '.cpp']
 
-if config.target_os == 'Darwin':
-  config.suffixes.append('.mm')
+if config.target_os == "Darwin":
+    config.suffixes.append(".mm")
 else:
   config.unsupported = True
--- compiler-rt/test/dfsan/lit.cfg.py	2025-07-16 04:03:11.000000 +0000
+++ compiler-rt/test/dfsan/lit.cfg.py	2025-07-16 04:05:27.407630 +0000
@@ -23,7 +23,10 @@
 
 # Default test suffixes.
 config.suffixes = [".c", ".cpp"]
 
 # DataFlowSanitizer tests are currently supported on Linux only.
-if not (config.target_os in ["Linux"] and config.target_arch in ["aarch64", "x86_64", "loongarch64"]):
+if not (
+    config.target_os in ["Linux"]
+    and config.target_arch in ["aarch64", "x86_64", "loongarch64"]
+):
     config.unsupported = True
--- compiler-rt/test/shadowcallstack/lit.cfg.py	2025-07-16 04:03:11.000000 +0000
+++ compiler-rt/test/shadowcallstack/lit.cfg.py	2025-07-16 04:05:28.042088 +0000
@@ -30,7 +30,10 @@
         "%clang_scs ",
         config.clang + " -O0 -fsanitize=shadow-call-stack " + scs_arch_cflags + " ",
     )
 )
 
-if config.target_os not in ["Linux"] or config.target_arch not in ["aarch64", "riscv64"]:
+if config.target_os not in ["Linux"] or config.target_arch not in [
+    "aarch64",
+    "riscv64",
+]:
     config.unsupported = True

@pcc pcc merged commit 3fa07ed into main Jul 17, 2025
23 of 24 checks passed
@pcc pcc deleted the users/pcc/spr/rename-confighost_os-to-configtarget_os branch July 17, 2025 18:12
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jul 17, 2025
config.host_os is derived from CMAKE_SYSTEM_NAME
which specifies the target. See:
https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html

To reduce confusion, rename it to config.target_os.

The variable name config.target_os was already being used by the Orc
tests. Rename it to config.orc_test_target_os with a FIXME to remove.

Reviewers: JDevlieghere, MaskRay

Reviewed By: MaskRay

Pull Request: llvm/llvm-project#149015
@teresajohnson
Copy link
Contributor

I'm getting an error in my testing that I'm guessing is from this change (paths shortened for simplicity):

llvm-lit: llvm/utils/lit/lit/TestingConfig.py:157: fatal: unable to parse config file 'compiler-rt/test/lit.common.cfg.py', traceback: Traceback (most recent call last):
  File "llvm/utils/lit/lit/TestingConfig.py", line 145, in load_from_path
    exec(compile(data, path, "exec"), cfg_globals, None)
  File "compiler-rt/test/lit.common.cfg.py", line 315, in <module>
    config.available_features.add(config.target_os.lower())
                                  ^^^^^^^^^^^^^^^^
AttributeError: 'TestingConfig' object has no attribute 'target_os'

@teresajohnson
Copy link
Contributor

I'm getting an error in my testing that I'm guessing is from this change (paths shortened for simplicity):

llvm-lit: llvm/utils/lit/lit/TestingConfig.py:157: fatal: unable to parse config file 'compiler-rt/test/lit.common.cfg.py', traceback: Traceback (most recent call last):
  File "llvm/utils/lit/lit/TestingConfig.py", line 145, in load_from_path
    exec(compile(data, path, "exec"), cfg_globals, None)
  File "compiler-rt/test/lit.common.cfg.py", line 315, in <module>
    config.available_features.add(config.target_os.lower())
                                  ^^^^^^^^^^^^^^^^
AttributeError: 'TestingConfig' object has no attribute 'target_os'

I re-ran cmake and am still getting this error

pcc added a commit that referenced this pull request Jul 17, 2025
@pcc
Copy link
Contributor Author

pcc commented Jul 17, 2025

Should now be fixed: e68efed

Verified that check-asan runs.

@teresajohnson
Copy link
Contributor

thanks that fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-rt:asan Address sanitizer compiler-rt:builtins compiler-rt:fuzzer compiler-rt:hwasan Hardware-assisted address sanitizer compiler-rt:lsan Leak sanitizer compiler-rt:msan Memory sanitizer compiler-rt:sanitizer compiler-rt:scudo Scudo Hardened Allocator compiler-rt:tsan Thread sanitizer compiler-rt:ubsan Undefined behavior sanitizer compiler-rt lldb PGO Profile Guided Optimizations xray
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants