Add Hermetic C++ Toolchains for Linux x86_64 builds.
Hermetic toolchains provide builds that are isolated from the host system, cutting down on unexpected dependencies and side effects.
By default, JAX now builds for Linux x86_64 architectures (both CPU and CUDA-enabled GPU) using hermetic C++ toolchains. For non-hermetic builds, add the flag --config=clang_local. For remote builds with a non-hermetic toolchain, simply append _clang_local to the existing RBE flag. For example, if hermetic RBE build runs with --config=rbe_linux_cpu, the non-hermetic version would be --config=rbe_linux_cpu_clang_local.
Example 1: Run CPU tests for Linux x86_64
For hermetic tests run the command for Linux x86_64 build without env variables CC, CXX, etc.:
bazel test //tests:cpu_tests \
--config=avx_posix \
--config=clang \
--linkopt=-lrt \
--host_linkopt=-lrt \
--repo_env=HERMETIC_PYTHON_VERSION="3.13" \
--test_tag_filters=-multiaccelerator
For non-hermetic tests use commands with the flag "--config=clang_local" and env variables CC, CXX, etc.:
bazel test //tests:cpu_tests \
--config=clang_local \
--config=avx_posix \
--config=clang \
--linkopt=-lrt \
--host_linkopt=-lrt \
--repo_env=HERMETIC_PYTHON_VERSION="3.13" \
--test_tag_filters=-multiaccelerator \
--action_env=CLANG_COMPILER_PATH=/usr/lib/llvm-18/bin/clang \
--repo_env=CC=/usr/lib/llvm-18/bin/clang \
--repo_env=CXX=/usr/lib/llvm-18/bin/clang++ \
--repo_env=BAZEL_COMPILER=/usr/lib/llvm-18/bin/clang \
--action_env=CCC_OVERRIDE_OPTIONS="^--gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/13"
Example 2: Run CUDA GPU tests for Linux x86_64
For hermetic tests, run the command without env variables CC, CXX, etc.:
bazel test //tests:gpu_tests \
--config=cuda \
--config=clang \
--config=build_cuda_with_nvcc \
--config=avx_posix \
--linkopt=-lrt \
--host_linkopt=-lrt \
--test_tag_filters=-multiaccelerator \
--repo_env=HERMETIC_PYTHON_VERSION=3.13
For non-hermetic tests use commands with the flag "--config=clang_local" and env variables CC, CXX, etc.:
bazel test //tests:gpu_tests \
--config=clang_local \
--config=avx_posix \
--config=build_cuda_with_nvcc \
--config=clang \
--config=cuda \
--linkopt=-lrt \
--host_linkopt=-lrt \
--action_env=CCC_OVERRIDE_OPTIONS="^--gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/9" \
--test_tag_filters=-multiaccelerator \
--action_env=CLANG_COMPILER_PATH=/usr/lib/llvm-18/bin/clang \
--repo_env=CC=/usr/lib/llvm-18/bin/clang \
--repo_env=CXX=/usr/lib/llvm-18/bin/clang++ \
--repo_env=BAZEL_COMPILER=/usr/lib/llvm-18/bin/clang \
--repo_env=HERMETIC_PYTHON_VERSION=3.13
Example 3: Run RBE build for Linux x86_64
For hermetic build, run the same command as before modification:
bazel build \
--config=ci_linux_x86_64 \
--repo_env=HERMETIC_PYTHON_VERSION=3.13 \
//jaxlib/tools:jaxlib_wheel
For non-hermetic builds, add "_clang_local" suffix to RBE configuration:
bazel build \
--config=ci_linux_x86_64_clang_local \
--repo_env=HERMETIC_PYTHON_VERSION=3.13 \
//jaxlib/tools:jaxlib_wheel
We don't support other "rbe_*_clang_local" configuration flags, and you could construct your own combinations.
PiperOrigin-RevId: 786346447