Skip to content

Commit a7c3e85

Browse files
Add support for building PyTorch/XLA using clang. (#9059)
Co-authored-by: Zhanyong Wan <[email protected]>
1 parent d16766f commit a7c3e85

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

.bazelrc

+27
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,33 @@ build --spawn_strategy=standalone
3131

3232
###########################################################################
3333

34+
build:clang --action_env=CC=/usr/bin/clang-17
35+
build:clang --action_env=CXX=/usr/bin/clang++-17
36+
37+
# clang requires the sandbox mode. Without this, `bazel build` generates an
38+
# error like:
39+
#
40+
# ERROR: .../external/llvm-project/llvm/BUILD.bazel:2006:11: Compiling
41+
# llvm/lib/CodeGenTypes/LowLevelType.cpp failed: undeclared inclusion(s) in
42+
# rule '@llvm-project//llvm:CodeGenTypes':
43+
# this rule is missing dependency declarations for the following files
44+
# included by 'llvm/lib/CodeGenTypes/LowLevelType.cpp':
45+
# 'bazel-out/k8-opt/bin/external/llvm-project/llvm/config.cppmap'
46+
# 'bazel-out/k8-opt/bin/external/llvm-project/llvm/Demangle.cppmap'
47+
#
48+
# The sandbox mode requires all source files to be readable by others, as
49+
# inside the docker we build PyTorch/XLA as root, not the original user who
50+
# created the files. You can ensure this by either:
51+
# 1. `umask 022` before running the `git clone` commands, or
52+
# 2. after running the `git clone` commands, go to the workspace directory
53+
# and run `chmod -R o+rX .`. The X (capital X) is important: it gives
54+
# execute permission to directories, and to files only if they already have
55+
# execute permission for the owner (or group or others). This is generally
56+
# safer than o+rx.
57+
build:clang --spawn_strategy=sandboxed
58+
59+
###########################################################################
60+
3461
build:posix --copt=-Wno-sign-compare
3562
build:posix --cxxopt=-std=c++17
3663
build:posix --host_cxxopt=-std=c++17

0 commit comments

Comments
 (0)