Skip to content

Commit

Permalink
toolchain-bootstrap: force target triple when building on Apple
Browse files Browse the repository at this point in the history
This used to "just work." But for reasons unknown to me, GitHub Actions
Apple ARM runners result in `config.guess` thinking it is a x86-64
machine and this causes LLVM's CMake to build x86-64 binaries which
target x86-64 by default!

Our Python code has working target sniffing. So we use that to feed
an appropriate triple into LLVM's CMake.
  • Loading branch information
indygreg committed Feb 23, 2024
1 parent cae96dc commit 2251ffa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions toolchain-bootstrap/scripts/clang-macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ def build_llvm(
env["NUM_JOBS_AGGRESSIVE"] = "%d" % max(cpu_count + 2, cpu_count * 2)
env["MACOSX_DEPLOYMENT_TARGET"] = "11.0"

if ARCH == "aarch64":
env["HOST_TRIPLE"] = "arm64-apple-darwin23.2.0"
else:
env["HOST_TRIPLE"] = "x86_64-apple-darwin23.2.0"

subprocess.run(
[str(temp_dir / script)],
cwd=temp_dir,
Expand Down
2 changes: 2 additions & 0 deletions toolchain-bootstrap/scripts/clang-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ cmake \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_ASM_COMPILER=/usr/bin/clang \
-DLLVM_APPEND_VC_REV=OFF \
-DLLVM_DEFAULT_TARGET_TRIPLE="${HOST_TRIPLE}" \
-DLLVM_ENABLE_PROJECTS="bolt;clang;lld" \
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi" \
-DLLVM_ENABLE_LIBCXX=ON \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_HOST_TRIPLE="${HOST_TRIPLE}" \
-DLLVM_OPTIMIZED_TABLEGEN=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_TARGETS_TO_BUILD="AArch64;X86" \
Expand Down

0 comments on commit 2251ffa

Please sign in to comment.