Skip to content

Commit 684e35d

Browse files
committed
chore: use toolchains_llvm with clang 19.1.0
Fixes macos build Signed-off-by: Matt Leon <mattleon@google.com>
1 parent ead5989 commit 684e35d

File tree

5 files changed

+82
-26
lines changed

5 files changed

+82
-26
lines changed

.bazelrc

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,33 @@ build:gcc --action_env=BAZEL_COMPILER=gcc
6767
build:gcc --action_env=CC=gcc
6868
build:gcc --action_env=CXX=g++
6969

70-
# Use Zig C/C++ compiler.
71-
build:zig-cc --incompatible_enable_cc_toolchain_resolution
72-
build:zig-cc --extra_toolchains @zig_sdk//:aarch64-linux-gnu.2.28_toolchain
73-
build:zig-cc --extra_toolchains @zig_sdk//:x86_64-linux-gnu.2.28_toolchain
74-
build:zig-cc --host_copt=-fno-sanitize=undefined
75-
76-
# Use Zig C/C++ compiler (cross-compile to Linux/aarch64).
77-
build:zig-cc-linux-aarch64 --config=zig-cc
78-
build:zig-cc-linux-aarch64 --platforms @zig_sdk//:linux_aarch64_platform
79-
build:zig-cc-linux-aarch64 --run_under=qemu-aarch64-static
80-
build:zig-cc-linux-aarch64 --test_env=QEMU_LD_PREFIX=/usr/aarch64-linux-gnu/
70+
build:hermetic --incompatible_enable_cc_toolchain_resolution
71+
build:hermetic --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
72+
build:hermetic --extra_toolchains @emsdk//emscripten_toolchain:cc-toolchain-wasm
73+
74+
# Use vendored LLVM C/C++ compiler.
75+
build:hermetic-llvm --config=hermetic
76+
build:hermetic-llvm --extra_toolchains @llvm_toolchain//:cc-toolchain-x86_64-linux
77+
78+
build:hermetic-llvm-macos-x86_64 --config=hermetic
79+
build:hermetic-llvm-macos-x86_64 --extra_toolchains @llvm_toolchain//:cc-toolchain-x86_64-darwin
80+
# Below flags mitigate https://github.com/bazel-contrib/toolchains_llvm/pull/229.
81+
build:hermetic-llvm-macos-x86_64 --features=-libtool
82+
83+
build:hermetic-llvm --incompatible_enable_cc_toolchain_resolution
84+
build:hermetic-llvm --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
85+
build:hermetic-llvm --extra_toolchains @llvm_toolchain//:cc-toolchain-x86_64-linux
86+
build:hermetic-llvm --extra_toolchains @llvm_aarch64//:cc-toolchain-aarch64-linux
87+
build:hermetic-llvm --extra_toolchains @emsdk//emscripten_toolchain:cc-toolchain-wasm
88+
89+
# Use vendored LLVM C/C++ compiler (cross-compile to Linux/aarch64).
90+
build:linux-aarch64-cross --config=hermetic-llvm
91+
build:linux-aarch64-cross --extra_toolchains @llvm_aarch64//:cc-toolchain-aarch64-linux
92+
build:linux-aarch64-cross --platforms @toolchains_llvm//platforms:linux-aarch64
93+
build:linux-aarch64-cross --cxxopt --gcc-install-dir=external/sysroot_linux_arm64/usr/lib/gcc/aarch64-linux-gnu/13/
94+
# Below 2 flags allow tests to be run after cross-compiling.
95+
build:linux-aarch64-cross --test_env=QEMU_LD_PREFIX=/usr/aarch64-linux-gnu/
96+
build:linux-aarch64-cross --run_under=qemu-aarch64-static
8197

8298
build --enable_platform_specific_config
8399

@@ -86,6 +102,7 @@ build:linux --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
86102
build:macos --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
87103
build:windows --cxxopt="/std:c++20" --host_cxxopt="/std:c++20"
88104

105+
89106
# Enable symlinks and runfiles on Windows (enabled by default on other platforms).
90107
startup --windows_enable_symlinks
91108
build:windows --enable_runfiles

.github/workflows/test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172
arch: aarch64
173173
action: test
174174
targets: -//test/fuzz/...
175-
flags: --config=zig-cc-linux-aarch64 --@v8//bazel/config:v8_target_cpu=arm64
175+
flags: --config=linux-aarch64-cross --@v8//bazel/config:v8_target_cpu=arm64
176176
deps: qemu-user-static libc6-arm64-cross
177177
cache: true
178178
- name: 'V8 on macOS/x86_64'
@@ -181,6 +181,7 @@ jobs:
181181
os: macos-13
182182
arch: x86_64
183183
action: test
184+
flags: --config=hermetic-llvm-macos-x86_64
184185
cache: true
185186
- name: 'WAMR interp on Linux/x86_64'
186187
engine: 'wamr-interp'
@@ -244,7 +245,7 @@ jobs:
244245
os: ubuntu-24.04
245246
arch: aarch64
246247
action: build
247-
flags: --config=zig-cc-linux-aarch64
248+
flags: --config=linux-aarch64-cross
248249
deps: qemu-user-static libc6-arm64-cross
249250
- name: 'Wasmtime on Linux/s390x'
250251
engine: 'wasmtime'

bazel/dependencies.bzl

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("@bazel-zig-cc//toolchain:defs.bzl", zig_register_toolchains = "register_toolchains")
1615
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
16+
load("@envoy_toolshed//sysroot:sysroot.bzl", "setup_sysroots")
1717
load("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:crates.bzl", wasmsign_crate_repositories = "crate_repositories")
1818
load("@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:crates.bzl", wasmtime_crate_repositories = "crate_repositories")
1919
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
2020
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
2121
load("@rules_rust//rust:repositories.bzl", "rust_repositories", "rust_repository_set")
22+
load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies")
23+
load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain")
2224

2325
def proxy_wasm_cpp_host_dependencies():
2426
# Bazel extensions.
@@ -52,14 +54,39 @@ def proxy_wasm_cpp_host_dependencies():
5254
)
5355
crate_universe_dependencies(bootstrap = True)
5456

55-
zig_register_toolchains(
56-
version = "0.9.1",
57-
url_format = "https://ziglang.org/download/{version}/zig-{host_platform}-{version}.tar.xz",
58-
host_platform_sha256 = {
59-
"linux-aarch64": "5d99a39cded1870a3fa95d4de4ce68ac2610cca440336cfd252ffdddc2b90e66",
60-
"linux-x86_64": "be8da632c1d3273f766b69244d80669fe4f5e27798654681d77c992f17c237d7",
61-
"macos-aarch64": "8c473082b4f0f819f1da05de2dbd0c1e891dff7d85d2c12b6ee876887d438287",
62-
"macos-x86_64": "2d94984972d67292b55c1eb1c00de46580e9916575d083003546e9a01166754c",
57+
setup_sysroots()
58+
bazel_toolchain_dependencies()
59+
llvm_toolchain(
60+
name = "llvm_toolchain",
61+
llvm_version = "19.1.0",
62+
sha256 = {
63+
"linux-x86_64": "cee77d641690466a193d9b88c89705de1c02bbad46bde6a3b126793c0a0f2923",
64+
"linux-aarch64": "7bb54afd330fe1a1c2d4c593fa1e2dbe2abd9bf34fb3597994ff41e443cf144b",
65+
"darwin-aarch64": "9da86f64a99f5ce9b679caf54e938736ca269c5e069d0c94ad08b995c5f25c16",
66+
"darwin-x86_64": "264f2f1e8b67f066749349ae8b4943d346cd44e099464164ef21b42a57663540",
67+
},
68+
strip_prefix = {
69+
"linux-x86_64": "LLVM-19.1.0-Linux-X64",
70+
"linux-aarch64": "clang+llvm-19.1.0-aarch64-linux-gnu",
71+
"darwin-aarch64": "LLVM-19.1.0-macOS-ARM64",
72+
"darwin-x86_64": "LLVM-19.1.0-macOS-X64",
73+
},
74+
urls = {
75+
"linux-x86_64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/LLVM-19.1.0-Linux-X64.tar.xz"],
76+
"linux-aarch64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/clang+llvm-19.1.0-aarch64-linux-gnu.tar.xz"],
77+
"darwin-aarch64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/LLVM-19.1.0-macOS-ARM64.tar.xz"],
78+
"darwin-x86_64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/LLVM-19.1.0-macOS-X64.tar.xz"],
79+
},
80+
)
81+
82+
llvm_toolchain(
83+
name = "llvm_aarch64",
84+
llvm_version = "19.1.0",
85+
toolchain_roots = {
86+
"": "@llvm_toolchain_llvm//",
87+
},
88+
sysroot = {
89+
"linux-aarch64": "@sysroot_linux_arm64//:sysroot",
6390
},
6491
)
6592

bazel/dependencies_import.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
# limitations under the License.
1414

1515
load("@fuzzing_py_deps//:requirements.bzl", pip_fuzzing_dependencies = "install_deps")
16+
load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
1617
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
1718
load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
1819
load("@v8_python_deps//:requirements.bzl", pip_v8_dependencies = "install_deps")
1920

2021
def proxy_wasm_cpp_host_dependencies_import():
22+
llvm_register_toolchains()
23+
2124
rules_foreign_cc_dependencies()
2225
rules_fuzzing_dependencies()
2326

bazel/repositories.bzl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,18 @@ def proxy_wasm_cpp_host_repositories():
6060

6161
maybe(
6262
http_archive,
63-
name = "bazel-zig-cc",
64-
sha256 = "ff89e0220c72cdc774e451a35e5c3b9f1593d0df71341844b2108c181ac0eef9",
65-
strip_prefix = "hermetic_cc_toolchain-0.4.4",
66-
url = "https://github.com/uber/hermetic_cc_toolchain/archive/refs/tags/v0.4.4.tar.gz",
63+
name = "envoy_toolshed",
64+
sha256 = "e2252e46e64417d5cedd9f1eb34a622bce5e13b43837e5fe051c83066b0a400b",
65+
strip_prefix = "toolshed-bazel-bins-v0.1.13/bazel",
66+
url = "https://github.com/envoyproxy/toolshed/archive/refs/tags/bazel-bins-v0.1.13.tar.gz",
67+
)
68+
maybe(
69+
http_archive,
70+
name = "toolchains_llvm",
71+
sha256 = "b7cd301ef7b0ece28d20d3e778697a5e3b81828393150bed04838c0c52963a01",
72+
strip_prefix = "toolchains_llvm-0.10.3",
73+
canonical_id = "v0.10.3",
74+
url = "https://github.com/grailbio/bazel-toolchain/releases/download/0.10.3/toolchains_llvm-0.10.3.tar.gz",
6775
)
6876

6977
maybe(

0 commit comments

Comments
 (0)