[compiler-rt] Fix: windows i386 builtins tests (PR #179062)

via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 1 03:46:52 PST 2026


https://github.com/thulasiramk-2310 updated https://github.com/llvm/llvm-project/pull/179062

>From 1e6c35e3639f24f154b3d086e8eca1be28305599 Mon Sep 17 00:00:00 2001
From: thulasiramk-2310 <thulasiramk.git at gmail.com>
Date: Sat, 31 Jan 2026 22:12:07 +0530
Subject: [PATCH] [compiler-rt] Fix builtins i386 Windows tests using wrong
 target

---
 compiler-rt/test/builtins/Unit/lit.cfg.py | 10 ++++++++++
 compiler-rt/test/builtins/lit.cfg.py      |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/compiler-rt/test/builtins/Unit/lit.cfg.py b/compiler-rt/test/builtins/Unit/lit.cfg.py
index 59da054848f3c..d945b8c549cc9 100644
--- a/compiler-rt/test/builtins/Unit/lit.cfg.py
+++ b/compiler-rt/test/builtins/Unit/lit.cfg.py
@@ -147,6 +147,16 @@ def get_libgcc_file_name():
 extra_link_flags = ["-nodefaultlibs"]
 
 target_cflags = [get_required_attr(config, "target_cflags")]
+
+# On Windows, when testing i386 architecture, explicitly pass the target triple
+# to ensure clang compiles for i386 instead of defaulting to x64.
+# This is necessary because the test runner links against clang_rt.builtins-i386.lib
+# which requires i386 object files.
+target_arch = get_required_attr(config, "target_arch")
+if config.target_os == "Windows" and target_arch == "i386":
+    # Use explicit target triple for i386 on Windows
+    target_cflags += ["--target=i386-pc-windows-msvc"]
+
 target_cflags += ["-fno-builtin", "-I", builtins_source_dir]
 target_cflags += extra_link_flags
 target_cxxflags = config.cxx_mode_flags + target_cflags
diff --git a/compiler-rt/test/builtins/lit.cfg.py b/compiler-rt/test/builtins/lit.cfg.py
index 44c36212ee3fd..497dfe3d0942c 100644
--- a/compiler-rt/test/builtins/lit.cfg.py
+++ b/compiler-rt/test/builtins/lit.cfg.py
@@ -15,6 +15,11 @@
     # detect incorrect declarations of libgcc functions
     extra_flags.append("-Werror=builtin-declaration-mismatch")
 
+# On Windows, when testing i386 architecture, explicitly pass the target triple
+# to ensure clang compiles for i386 instead of defaulting to x64.
+if config.target_os == "Windows" and config.target_arch == "i386":
+    extra_flags.append("--target=i386-pc-windows-msvc")
+
 
 # Define %clang and %clangxx substitutions to use in test RUN lines.
 config.substitutions.append(



More information about the llvm-commits mailing list