Skip to content

Commit f2b3ae8

Browse files
build: Try Zig CC for x86_64 Linux
1 parent c1cd383 commit f2b3ae8

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@ build:dev --copt="-Og" # For testing against large projects locally
5959

6060
build:release --copt="-O2"
6161
build:release --config=stacktraces
62+
# Zig uses UBSan by default
63+
build:release --copt="-fno-sanitize=undefined"

WORKSPACE

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ load("//:fetch_deps.bzl", "fetch_direct_dependencies")
44

55
fetch_direct_dependencies()
66

7+
load("@bazel-zig-cc//toolchain:defs.bzl", zig_toolchains = "toolchains")
8+
9+
zig_toolchains()
10+
11+
# Register the Zig toolchain before the grailbio one
12+
# so that the Zig one is preferred on Linux.
13+
register_toolchains(
14+
"@zig_sdk//toolchain:linux_amd64_gnu.2.19",
15+
"@zig_sdk//toolchain:linux_arm64_gnu.2.28",
16+
)
17+
718
# Setup the toolchain before setting up other dependencies
819
load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies")
920

@@ -14,10 +25,11 @@ load("//:setup_llvm.bzl", "setup_llvm_toolchain")
1425
setup_llvm_toolchain(name = "llvm_toolchain")
1526

1627
load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
17-
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
1828

1929
llvm_register_toolchains()
2030

31+
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
32+
2133
python_register_toolchains(
2234
name = "python_3_10",
2335
# Remove this once agents stop running tests as root

fetch_deps.bzl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ _SCIP_COMMIT = "aa0e511dcfefbacc3b96dcc2fe2abd9894416b1e"
1616
# in the types for which we implement hashing and comparison in
1717
# indexer/ScipExtras.{h,cc}
1818

19+
_BAZEL_ZIG_CC_VERSION = "v1.0.1"
1920
_DOCTEST_VERSION = "2.4.9"
2021
_DTL_VERSION = "1.20"
2122
_RULES_PYTHON_VERSION = "0.18.1"
@@ -46,6 +47,18 @@ def fetch_direct_dependencies():
4647
],
4748
)
4849

50+
http_archive(
51+
# The repo hard-codes this name in internal functions,
52+
# so use kebab-case instead of camel case.
53+
name = "bazel-zig-cc",
54+
sha256 = "e9f82bfb74b3df5ca0e67f4d4989e7f1f7ce3386c295fd7fda881ab91f83e509",
55+
strip_prefix = "bazel-zig-cc-{}".format(_BAZEL_ZIG_CC_VERSION),
56+
urls = [
57+
"https://mirror.bazel.build/github.com/uber/bazel-zig-cc/releases/download/{0}/{0}.tar.gz".format(_BAZEL_ZIG_CC_VERSION),
58+
"https://github.com/uber/bazel-zig-cc/releases/download/{0}/{0}.tar.gz".format(_BAZEL_ZIG_CC_VERSION),
59+
],
60+
)
61+
4962
http_archive(
5063
name = "com_github_nelhage_rules_boost",
5164
sha256 = "dc9140b868de82ae46dd44da73a7d9749b680b1e7d63b0912288c2de2cabcb1d",

setup_llvm.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ def setup_llvm_toolchain(name):
44
# NOTE: The ASan build uses paths which involve the version.
55
# Keep the version list in sync with settings.bzl
66
mapping = {
7+
# Even though we're using zig cc on Linux, keep these
8+
# in to keep clang-format working in CI until we figure
9+
# out a more lightweight solution.
710
"linux-aarch64": {"version": "15.0.6", "triple": "aarch64-linux-gnu", "sha256": "8ca4d68cf103da8331ca3f35fe23d940c1b78fb7f0d4763c1c059e352f5d1bec"},
811
"linux-x86_64": {"version": "15.0.6", "triple": "x86_64-linux-gnu-ubuntu-18.04", "sha256": "38bc7f5563642e73e69ac5626724e206d6d539fbef653541b34cae0ba9c3f036"},
912
"darwin-arm64": {"version": "15.0.6", "triple": "arm64-apple-darwin21.0", "sha256": "32bc7b8eee3d98f72dd4e5651e6da990274ee2d28c5c19a7d8237eb817ce8d91"},

0 commit comments

Comments
 (0)