Skip to content

Commit 8f52169

Browse files
16bit-ykikoclaude
andcommitted
fix(build-llvm): pass --target to clang-cl for Windows cross-compile
On Windows, build-llvm.py uses clang-cl directly instead of the toolchain file, so CLICE_TARGET_TRIPLE wasn't setting the compiler target. Pass --target=<triple> via CMAKE_C/CXX_FLAGS and set LLVM_HOST_TRIPLE for correct cross-compilation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 65c36ce commit 8f52169

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/build-llvm.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,14 @@ def main():
111111
if sys.platform == "win32":
112112
# Use clang-cl (MSVC driver) on Windows so that LLVM's CMake
113113
# generates correct MSVC-style linker flags for LTO, etc.
114+
c_flags = "-w"
115+
if args.target_triple:
116+
c_flags += f" --target={args.target_triple}"
114117
cmake_args += [
115118
"-DCMAKE_C_COMPILER=clang-cl",
116119
"-DCMAKE_CXX_COMPILER=clang-cl",
117-
"-DCMAKE_C_FLAGS=-w",
118-
"-DCMAKE_CXX_FLAGS=-w",
120+
f"-DCMAKE_C_FLAGS={c_flags}",
121+
f"-DCMAKE_CXX_FLAGS={c_flags}",
119122
"-DLLVM_USE_LINKER=lld-link",
120123
]
121124
else:
@@ -205,6 +208,7 @@ def main():
205208

206209
if args.target_triple:
207210
cmake_args.append(f"-DCLICE_TARGET_TRIPLE={args.target_triple}")
211+
cmake_args.append(f"-DLLVM_HOST_TRIPLE={args.target_triple}")
208212

209213
build_dir.mkdir(exist_ok=True)
210214

0 commit comments

Comments
 (0)