Rename config.host_os to config.target_os.

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: https://github.com/llvm/llvm-project/pull/149015

GitOrigin-RevId: 3fa07ed5b38774656a2cff1bebc1785ce8e7feb8
diff --git a/lib/tysan/lit.cfg b/lib/tysan/lit.cfg
index e3ef6c9..c906c03 100644
--- a/lib/tysan/lit.cfg
+++ b/lib/tysan/lit.cfg
@@ -27,7 +27,7 @@
 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/test/asan/lit.cfg.py b/test/asan/lit.cfg.py
index 3da0733..96201e6 100644
--- a/test/asan/lit.cfg.py
+++ b/test/asan/lit.cfg.py
@@ -28,7 +28,7 @@
 # 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 @@
 # 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 @@
     ("%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 @@
     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 @@
 
 # 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 @@
 # 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 @@
     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/test/asan_abi/lit.cfg.py b/test/asan_abi/lit.cfg.py
index 5bc1881..dd99a53 100644
--- a/test/asan_abi/lit.cfg.py
+++ b/test/asan_abi/lit.cfg.py
@@ -68,7 +68,7 @@
 
 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/test/builtins/Unit/lit.cfg.py b/test/builtins/Unit/lit.cfg.py
index c030f89..59da054 100644
--- a/test/builtins/Unit/lit.cfg.py
+++ b/test/builtins/Unit/lit.cfg.py
@@ -80,10 +80,10 @@
         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 @@
     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/test/builtins/lit.cfg.py b/test/builtins/lit.cfg.py
index 9300488..6491f47 100644
--- a/test/builtins/lit.cfg.py
+++ b/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/test/ctx_profile/lit.cfg.py b/test/ctx_profile/lit.cfg.py
index 74d9bfd..75367d9 100644
--- a/test/ctx_profile/lit.cfg.py
+++ b/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/test/dfsan/lit.cfg.py b/test/dfsan/lit.cfg.py
index e947c51..b26ff3e 100644
--- a/test/dfsan/lit.cfg.py
+++ b/test/dfsan/lit.cfg.py
@@ -25,5 +25,5 @@
 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/test/fuzzer/lit.cfg.py b/test/fuzzer/lit.cfg.py
index 75d4cf2..1689f53 100644
--- a/test/fuzzer/lit.cfg.py
+++ b/test/fuzzer/lit.cfg.py
@@ -149,5 +149,5 @@
 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/test/gwp_asan/lit.cfg.py b/test/gwp_asan/lit.cfg.py
index 7f68682..1592cf4 100644
--- a/test/gwp_asan/lit.cfg.py
+++ b/test/gwp_asan/lit.cfg.py
@@ -67,5 +67,5 @@
 )
 
 # 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/test/hwasan/lit.cfg.py b/test/hwasan/lit.cfg.py
index bbf23e6..3a1c8e1 100644
--- a/test/hwasan/lit.cfg.py
+++ b/test/hwasan/lit.cfg.py
@@ -86,5 +86,5 @@
 # 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/test/lit.common.cfg.py b/test/lit.common.cfg.py
index 3c7323e..8328b40 100644
--- a/test/lit.common.cfg.py
+++ b/test/lit.common.cfg.py
@@ -66,7 +66,7 @@
     # 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 @@
 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 @@
     )
 )
 
-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 @@
         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 @@
     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 @@
     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 @@
     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 @@
     ("%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 @@
     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 @@
     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 @@
             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 @@
 # 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 @@
                 "-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 @@
             )
         )
         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 @@
             )
         )
         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 @@
     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 @@
 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 @@
 )
 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/test/lsan/lit.common.cfg.py b/test/lsan/lit.common.cfg.py
index 9426b7d..1e26794 100644
--- a/test/lsan/lit.common.cfg.py
+++ b/test/lsan/lit.common.cfg.py
@@ -34,7 +34,7 @@
     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 @@
     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 @@
 # 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 @@
 )
 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 @@
         "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/test/memprof/lit.cfg.py b/test/memprof/lit.cfg.py
index 4057da0..e28507b 100644
--- a/test/memprof/lit.cfg.py
+++ b/test/memprof/lit.cfg.py
@@ -106,7 +106,7 @@
 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/test/metadata/lit.cfg.py b/test/metadata/lit.cfg.py
index 73ba27a..9980e93 100644
--- a/test/metadata/lit.cfg.py
+++ b/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/test/msan/lit.cfg.py b/test/msan/lit.cfg.py
index 361be79..d9e83c6 100644
--- a/test/msan/lit.cfg.py
+++ b/test/msan/lit.cfg.py
@@ -20,7 +20,7 @@
     + config.debug_info_flags
 )
 # Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
-if config.host_os == "FreeBSD":
+if config.target_os == "FreeBSD":
     clang_msan_cflags += ["-lexecinfo", "-fPIC"]
 # On SystemZ we need -mbackchain to make the fast unwinder work.
 if config.target_arch == "s390x":
@@ -44,7 +44,7 @@
 # Default test suffixes.
 config.suffixes = [".c", ".cpp"]
 
-if config.host_os not in ["Linux", "NetBSD", "FreeBSD"]:
+if config.target_os not in ["Linux", "NetBSD", "FreeBSD"]:
     config.unsupported = True
 
 # For mips64, mips64el we have forced store_context_size to 1 because these
@@ -55,5 +55,5 @@
 else:
     config.substitutions.append(("CHECK-%short-stack", "CHECK-FULL-STACK"))
 
-if config.host_os == "NetBSD":
+if config.target_os == "NetBSD":
     config.substitutions.insert(0, ("%run", config.netbsd_noaslr_prefix))
diff --git a/test/nsan/lit.cfg.py b/test/nsan/lit.cfg.py
index 2d67911..8225c85 100644
--- a/test/nsan/lit.cfg.py
+++ b/test/nsan/lit.cfg.py
@@ -32,5 +32,5 @@
 )
 
 # NSan 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/test/orc/lit.cfg.py b/test/orc/lit.cfg.py
index 7a6eb4e..3c3badb 100644
--- a/test/orc/lit.cfg.py
+++ b/test/orc/lit.cfg.py
@@ -18,11 +18,11 @@
     config.available_features.add("host-arch-compatible")
 
 # If the target OS hasn't been set then assume host.
-if not config.target_os:
-    config.target_os = config.host_os
+if not config.orc_test_target_os:
+    config.orc_test_target_os = config.target_os
 
 config.test_target_is_host_executable = (
-    config.target_os == config.host_os and host_arch_compatible
+    config.orc_test_target_os == config.target_os and host_arch_compatible
 )
 
 # Assume that llvm-jitlink is in the config.llvm_tools_dir.
@@ -31,7 +31,7 @@
     config.compiler_rt_obj_root, "lib/orc/tests/tools/orc-rt-executor"
 )
 lli = os.path.join(config.llvm_tools_dir, "lli")
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     orc_rt_path = "%s/liborc_rt_osx.a" % config.compiler_rt_libdir
 else:
     orc_rt_path = "%s/liborc_rt%s.a" % (config.compiler_rt_libdir, config.target_suffix)
@@ -53,7 +53,7 @@
 config.substitutions.append(
     ("%clang_cl ", build_invocation(["--driver-mode=cl"] + [config.target_cflags]))
 )
-if config.host_os == "Windows":
+if config.target_os == "Windows":
     config.substitutions.append(
         (
             "%llvm_jitlink",
@@ -86,7 +86,7 @@
 # Exclude Inputs directories.
 config.excludes = ["Inputs"]
 
-if config.host_os not in ["Darwin", "FreeBSD", "Linux", "Windows"]:
+if config.target_os not in ["Darwin", "FreeBSD", "Linux", "Windows"]:
     config.unsupported = True
 
 # Ask llvm-config about assertion mode.
diff --git a/test/orc/lit.site.cfg.py.in b/test/orc/lit.site.cfg.py.in
index a33ef3d..d0625f6 100644
--- a/test/orc/lit.site.cfg.py.in
+++ b/test/orc/lit.site.cfg.py.in
@@ -5,7 +5,8 @@
 config.orc_lit_source_dir = "@ORC_LIT_SOURCE_DIR@"
 config.target_cflags = "@ORC_TEST_TARGET_CFLAGS@"
 config.target_arch = "@ORC_TEST_TARGET_ARCH@"
-config.target_os = "@ORC_TEST_TARGET_OS@"
+# FIXME: Remove this variable, the target OS is available in config.target_os.
+config.orc_test_target_os = "@ORC_TEST_TARGET_OS@"
 config.built_with_llvm = ("@COMPILER_RT_STANDALONE_BUILD@" != "TRUE")
 config.libunwind_shared = "@LIBUNWIND_ENABLE_SHARED@"
 config.libunwind_install_dir = "@LLVM_BINARY_DIR@/@LIBUNWIND_INSTALL_LIBRARY_DIR@"
diff --git a/test/profile/lit.cfg.py b/test/profile/lit.cfg.py
index c9a716a..df7f11e 100644
--- a/test/profile/lit.cfg.py
+++ b/test/profile/lit.cfg.py
@@ -30,7 +30,7 @@
 
 target_is_msvc = bool(re.match(r".*-windows-msvc$", config.target_triple))
 
-if config.host_os in ["Linux"]:
+if config.target_os in ["Linux"]:
     extra_link_flags = ["-ldl"]
 elif target_is_msvc:
     # InstrProf is incompatible with incremental linking. Disable it as a
@@ -154,7 +154,7 @@
     )
 )
 
-if config.host_os not in [
+if config.target_os not in [
     "Windows",
     "Darwin",
     "FreeBSD",
@@ -167,10 +167,10 @@
     config.unsupported = True
 
 config.substitutions.append(
-    ("%shared_lib_flag", "-dynamiclib" if (config.host_os == "Darwin") else "-shared")
+    ("%shared_lib_flag", "-dynamiclib" if (config.target_os == "Darwin") else "-shared")
 )
 
-if config.host_os in ["AIX"]:
+if config.target_os in ["AIX"]:
     config.available_features.add("system-aix")
     exclude_unsupported_files_for_aix(config.test_source_root)
     exclude_unsupported_files_for_aix(config.test_source_root + "/Posix")
@@ -184,5 +184,5 @@
 if config.have_curl:
     config.available_features.add("curl")
 
-if config.host_os in ("AIX", "Darwin", "Linux"):
+if config.target_os in ("AIX", "Darwin", "Linux"):
     config.available_features.add("continuous-mode")
diff --git a/test/rtsan/Unit/lit.site.cfg.py.in b/test/rtsan/Unit/lit.site.cfg.py.in
index 59e1e10..41fcb32 100644
--- a/test/rtsan/Unit/lit.site.cfg.py.in
+++ b/test/rtsan/Unit/lit.site.cfg.py.in
@@ -15,7 +15,7 @@
 if not config.parallelism_group:
   config.parallelism_group = 'shadow-memory'
 
-if config.host_os == 'Darwin':
+if config.target_os == 'Darwin':
   # On Darwin, we default to ignore_noninstrumented_modules=1, which also
   # suppresses some races the tests are supposed to find.  See rtsan/lit.cfg.py.
   if 'RTSAN_OPTIONS' in config.environment:
diff --git a/test/rtsan/lit.cfg.py b/test/rtsan/lit.cfg.py
index 7c75515..6d880c1 100644
--- a/test/rtsan/lit.cfg.py
+++ b/test/rtsan/lit.cfg.py
@@ -6,7 +6,7 @@
 
 default_rtsan_opts = "atexit_sleep_ms=0"
 
-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'.
     default_rtsan_opts += ":abort_on_error=0"
@@ -36,7 +36,7 @@
 llvm_rtsan = os.path.join(config.llvm_tools_dir, "llvm-rtsan")
 
 # Setup substitutions.
-if config.host_os == "Linux":
+if config.target_os == "Linux":
     libdl_flag = "-ldl"
 else:
     libdl_flag = ""
@@ -52,7 +52,7 @@
 # Default test suffixes.
 config.suffixes = [".c", ".cpp"]
 
-if config.host_os not in ["Darwin", "FreeBSD", "Linux", "NetBSD", "OpenBSD"]:
+if config.target_os not in ["Darwin", "FreeBSD", "Linux", "NetBSD", "OpenBSD"]:
     config.unsupported = True
 elif "64" not in config.host_arch:
     if "arm" in config.host_arch:
@@ -61,5 +61,5 @@
     else:
         config.unsupported = True
 
-if config.host_os == "NetBSD":
+if config.target_os == "NetBSD":
     config.substitutions.insert(0, ("%run", config.netbsd_nomprotect_prefix))
diff --git a/test/safestack/lit.cfg.py b/test/safestack/lit.cfg.py
index 4ab9c1c..3f5565c 100644
--- a/test/safestack/lit.cfg.py
+++ b/test/safestack/lit.cfg.py
@@ -33,5 +33,5 @@
         )
     )
 
-if config.host_os not in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
+if config.target_os not in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
     config.unsupported = True
diff --git a/test/sanitizer_common/lit.common.cfg.py b/test/sanitizer_common/lit.common.cfg.py
index 88d3ea9..5614229 100644
--- a/test/sanitizer_common/lit.common.cfg.py
+++ b/test/sanitizer_common/lit.common.cfg.py
@@ -40,7 +40,7 @@
 config.available_features.add(config.tool_name)
 
 if (
-    config.host_os == "Linux"
+    config.target_os == "Linux"
     and config.tool_name == "lsan"
     and config.target_arch == "i386"
 ):
@@ -49,7 +49,7 @@
 if config.arm_thumb:
     config.available_features.add("thumb")
 
-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'.
     default_tool_options += ["abort_on_error=0"]
@@ -68,7 +68,7 @@
 
 extra_link_flags = []
 
-if config.host_os in ["Linux"]:
+if config.target_os in ["Linux"]:
     extra_link_flags += ["-ldl"]
 
 clang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags]
@@ -92,13 +92,13 @@
 
 config.suffixes = [".c", ".cpp"]
 
-if config.host_os not in ["Linux", "Darwin", "NetBSD", "FreeBSD", "SunOS"]:
+if config.target_os not in ["Linux", "Darwin", "NetBSD", "FreeBSD", "SunOS"]:
     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))
 
 if os.path.exists("/etc/services"):
diff --git a/test/scudo/lit.cfg.py b/test/scudo/lit.cfg.py
index 5d45bd9..b09c996 100644
--- a/test/scudo/lit.cfg.py
+++ b/test/scudo/lit.cfg.py
@@ -70,5 +70,5 @@
 )
 
 # Hardened Allocator 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/test/shadowcallstack/lit.cfg.py b/test/shadowcallstack/lit.cfg.py
index 70a6b16..5b95deb 100644
--- a/test/shadowcallstack/lit.cfg.py
+++ b/test/shadowcallstack/lit.cfg.py
@@ -32,5 +32,5 @@
     )
 )
 
-if config.host_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
diff --git a/test/tsan/Unit/lit.site.cfg.py.in b/test/tsan/Unit/lit.site.cfg.py.in
index a9c6261..b90af4f 100644
--- a/test/tsan/Unit/lit.site.cfg.py.in
+++ b/test/tsan/Unit/lit.site.cfg.py.in
@@ -15,7 +15,7 @@
 if not config.parallelism_group:
   config.parallelism_group = 'shadow-memory'
 
-if config.host_os == 'Darwin':
+if config.target_os == 'Darwin':
   # On Darwin, we default to ignore_noninstrumented_modules=1, which also
   # suppresses some races the tests are supposed to find.  See tsan/lit.cfg.py.
   if 'TSAN_OPTIONS' in config.environment:
diff --git a/test/tsan/libdispatch/lit.local.cfg.py b/test/tsan/libdispatch/lit.local.cfg.py
index a7653f4..27edf61 100644
--- a/test/tsan/libdispatch/lit.local.cfg.py
+++ b/test/tsan/libdispatch/lit.local.cfg.py
@@ -14,5 +14,5 @@
 else:
     config.unsupported = True
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     config.environment["TSAN_OPTIONS"] += ":ignore_noninstrumented_modules=1"
diff --git a/test/tsan/lit.cfg.py b/test/tsan/lit.cfg.py
index a93333e..8803a7b 100644
--- a/test/tsan/lit.cfg.py
+++ b/test/tsan/lit.cfg.py
@@ -23,7 +23,7 @@
 # Setup environment variables for running ThreadSanitizer.
 default_tsan_opts = "atexit_sleep_ms=0"
 
-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'.
     default_tsan_opts += ":abort_on_error=0"
@@ -61,7 +61,7 @@
 )
 # Add additional flags if we're using instrumented libc++.
 # Instrumented libcxx currently not supported on Darwin.
-if config.has_libcxx and config.host_os != "Darwin":
+if config.has_libcxx and config.target_os != "Darwin":
     # FIXME: Dehardcode this path somehow.
     libcxx_path = os.path.join(
         config.compiler_rt_obj_root,
@@ -86,7 +86,7 @@
 config.substitutions.append(("%clangxx_tsan ", build_invocation(clang_tsan_cxxflags)))
 
 # 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)))
 
 config.substitutions.append(
     (
@@ -101,7 +101,7 @@
 # Default test suffixes.
 config.suffixes = [".c", ".cpp", ".m", ".mm"]
 
-if config.host_os not in ["FreeBSD", "Linux", "Darwin", "NetBSD"]:
+if config.target_os not in ["FreeBSD", "Linux", "Darwin", "NetBSD"]:
     config.unsupported = True
 
 if config.android:
@@ -110,5 +110,5 @@
 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/test/tysan/lit.cfg.py b/test/tysan/lit.cfg.py
index f38e021..2684601 100644
--- a/test/tysan/lit.cfg.py
+++ b/test/tysan/lit.cfg.py
@@ -71,7 +71,7 @@
 # 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 = ""
@@ -127,10 +127,10 @@
 # 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", ""))
@@ -140,7 +140,7 @@
     config.substitutions.append(("%pie", "-pie"))
 
 # Only run the tests on supported OSs.
-if config.host_os not in [
+if config.target_os not in [
     "Linux",
     "Darwin",
 ]:
diff --git a/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py b/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py
index e69d15f..4342649 100644
--- a/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py
+++ b/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py
@@ -1,4 +1,4 @@
-if config.host_os not in ["Darwin", "FreeBSD", "Linux", "NetBSD"]:
+if config.target_os not in ["Darwin", "FreeBSD", "Linux", "NetBSD"]:
     config.unsupported = True
 # Work around "Cannot represent a difference across sections"
 if config.target_arch == "powerpc64":
diff --git a/test/ubsan/lit.common.cfg.py b/test/ubsan/lit.common.cfg.py
index 04d6f24..25e5279 100644
--- a/test/ubsan/lit.common.cfg.py
+++ b/test/ubsan/lit.common.cfg.py
@@ -74,7 +74,7 @@
 config.suffixes = [".c", ".cpp", ".m"]
 
 # Check that the host supports UndefinedBehaviorSanitizer tests
-if config.host_os not in [
+if config.target_os not in [
     "Linux",
     "Darwin",
     "FreeBSD",
@@ -90,5 +90,5 @@
 if ubsan_lit_test_mode in ["AddressSanitizer", "MemorySanitizer", "ThreadSanitizer"]:
     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/test/ubsan_minimal/lit.common.cfg.py b/test/ubsan_minimal/lit.common.cfg.py
index 714241a..bcc0e46 100644
--- a/test/ubsan_minimal/lit.common.cfg.py
+++ b/test/ubsan_minimal/lit.common.cfg.py
@@ -35,7 +35,7 @@
 config.suffixes = [".c", ".cpp"]
 
 # Check that the host supports UndefinedBehaviorSanitizerMinimal tests
-if config.host_os not in [
+if config.target_os not in [
     "Linux",
     "FreeBSD",
     "NetBSD",
diff --git a/test/xray/lit.cfg.py b/test/xray/lit.cfg.py
index f73ae3a..e56ed85 100644
--- a/test/xray/lit.cfg.py
+++ b/test/xray/lit.cfg.py
@@ -14,7 +14,7 @@
 # If libc++ was used to build XRAY libraries, libc++ is needed. Fix applied
 # to Linux only since -rpath may not be portable. This can be extended to
 # other platforms.
-if config.libcxx_used == "1" and config.host_os == "Linux":
+if config.libcxx_used == "1" and config.target_os == "Linux":
     clang_xray_cflags = clang_xray_cflags + (
         ["-L%s -lc++ -Wl,-rpath=%s" % (config.llvm_shlib_dir, config.llvm_shlib_dir)]
     )
@@ -30,7 +30,7 @@
 llvm_xray = os.path.join(config.llvm_tools_dir, "llvm-xray")
 
 # Setup substitutions.
-if config.host_os == "Linux":
+if config.target_os == "Linux":
     libdl_flag = "-ldl"
 else:
     libdl_flag = ""
@@ -56,7 +56,7 @@
 # Default test suffixes.
 config.suffixes = [".c", ".cpp"]
 
-if config.host_os not in ["FreeBSD", "Linux", "NetBSD", "OpenBSD"]:
+if config.target_os not in ["FreeBSD", "Linux", "NetBSD", "OpenBSD"]:
     config.unsupported = True
 elif "64" not in config.host_arch:
     if "arm" in config.host_arch:
@@ -65,5 +65,5 @@
     else:
         config.unsupported = True
 
-if config.host_os == "NetBSD":
+if config.target_os == "NetBSD":
     config.substitutions.insert(0, ("%run", config.netbsd_nomprotect_prefix))
diff --git a/unittests/lit.common.unit.cfg.py b/unittests/lit.common.unit.cfg.py
index 557a428..93f417c 100644
--- a/unittests/lit.common.unit.cfg.py
+++ b/unittests/lit.common.unit.cfg.py
@@ -42,7 +42,7 @@
 if "TEMP" in os.environ:
     config.environment["TEMP"] = os.environ["TEMP"]
 
-if config.host_os == "Darwin":
+if config.target_os == "Darwin":
     # Only run up to 3 processes that require shadow memory simultaneously on
     # 64-bit Darwin. Using more scales badly and hogs the system due to
     # inefficient handling of large mmap'd regions (terabytes) by the kernel.
diff --git a/unittests/lit.common.unit.configured.in b/unittests/lit.common.unit.configured.in
index 3e42e83..30ccf45 100644
--- a/unittests/lit.common.unit.configured.in
+++ b/unittests/lit.common.unit.configured.in
@@ -10,7 +10,7 @@
 config.enable_per_target_runtime_dir = @LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_PYBOOL@
 config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@")
 config.host_arch = "@HOST_ARCH@"
-config.host_os = "@HOST_OS@"
+config.target_os = "@HOST_OS@"
 config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
 config.gwp_asan = @COMPILER_RT_HAS_GWP_ASAN_PYBOOL@
 config.emulator = "@COMPILER_RT_EMULATOR@"