<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62360>62360</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Bazel] LLVM-16 build failed on Ubuntu 22.04
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
CanftIn
</td>
</tr>
</table>
<pre>
When I tried to compile `LLVM-16.0.2` using `Bazel` according to the instructions under `utils/bazel/README.md`, I encountered the following error:
# Compile Command:
```sh
⚡ /llvm-project-llvmorg-16.0.2> cd utils/bazel
⚡ /llvm-project-llvmorg-16.0.2/utils/bazel> bazel build --config=generic_clang @llvm-project//...
```
# Output:
```sh
Starting local Bazel server and connecting to it...
DEBUG: Rule 'rules_foreign_cc' indicated that a canonical reproducible form can be obtained by modifying arguments commit = "8d540605805fb69e24c6bf5dc885b0403d74746a", shallow_since = "1659470209 +0000" and dropping ["tag"]
DEBUG: Repository rules_foreign_cc instantiated at:
/root/workspace/llvm-project-llvmorg-16.0.2/utils/bazel/WORKSPACE:82:15: in <toplevel>
Repository rule git_repository defined at:
/root/.cache/bazel/_bazel_root/400f5c477571028fbb03c345a0d70f4a/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
DEBUG: Rule 'pfm' indicated that a canonical reproducible form can be obtained by modifying arguments commit = "56f6a05d46b7592ddf81d77f4714dfc9b4c975e5", shallow_since = "1663660302 -0700" and dropping ["tag"]
DEBUG: Repository pfm instantiated at:
/root/workspace/llvm-project-llvmorg-16.0.2/utils/bazel/WORKSPACE:117:6: in <toplevel>
/root/.cache/bazel/_bazel_root/400f5c477571028fbb03c345a0d70f4a/external/bazel_tools/tools/build_defs/repo/utils.bzl:233:18: in maybe
Repository rule new_git_repository defined at:
/root/.cache/bazel/_bazel_root/400f5c477571028fbb03c345a0d70f4a/external/bazel_tools/tools/build_defs/repo/git.bzl:186:37: in <toplevel>
INFO: Analyzed 3824 targets (104 packages loaded, 22321 targets configured).
INFO: Found 3824 targets...
ERROR: /root/.cache/bazel/_bazel_root/400f5c477571028fbb03c345a0d70f4a/external/llvm-project/llvm/BUILD.bazel:184:11: Compiling llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S failed: (Exit 1): clang-16 failed: error executing command /usr/local/bin/clang-16 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 ... (remaining 75 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox
canftin begin
canftin begin
external/llvm-project/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S:3:10: fatal error: 'llvm_blake3_prefix.h' file not found
#include "llvm_blake3_prefix.h"
^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
INFO: Elapsed time: 56.762s, Critical Path: 0.99s
INFO: 1342 processes: 1336 internal, 6 processwrapper-sandbox.
FAILED: Build did NOT complete successfully
```
# Solution:
However, after applying the patch I modified, the compilation passed successfully, which is:
```diff
diff --git a/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel
index 78df6d1f9eaa..d63124df8c33 100644
--- a/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel
@@ -253,6 +253,7 @@ cc_test(
deps = [
"//clang:ast",
"//clang:basic",
+ "//clang:frontend",
"//clang:lex",
"//clang:parse",
"//clang:sema",
diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index b01f0474862d..65916effe9ed 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -201,6 +201,7 @@ cc_library(
]),
}) + [
"lib/Support/BLAKE3/blake3_impl.h",
+ "lib/Support/BLAKE3/llvm_blake3_prefix.h",
"lib/Support/BLAKE3/blake3.c",
"lib/Support/BLAKE3/blake3_dispatch.c",
"lib/Support/BLAKE3/blake3_portable.c",
@@ -3120,6 +3121,7 @@ cc_binary(
stamp = 0,
deps = [
":Coverage",
+ ":Debuginfod",
":Instrumentation",
":Object",
":ProfileData",
@@ -4106,6 +4108,7 @@ cc_binary(
":RcTableGen",
":Support",
":WindresTableGen",
+ ":config",
":llvm-rc-defs-lib",
],
)
```
In addition, This situation not happened on LLVM-17.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWNty2zjSfhr6BkUWCJ6kC1_IOszvmsx4yol_116pQKAhYUMBLAD0YS722bcalBzJsZxMZnZq16VKSKDR6MOH7o_g3uuNAbhMqqukWlzwIWytu5xzo8K1uWitfL6834Ih1yQ4DZIES4Td9boDktT0w4f__yXN64xmLKkpGbw2Gxy_4r9DhyNcCOskjgZLwhaINj64QQRtjSeDkeBQfgi68wlbtXEdW90uZ4tfltlOJjVN2JxcEzDCDiaAQxu2QJTtOvuIisE565JiRhK6SOhs_y8ryHxv59zudtzIpDjM1XT8-e04QJIlS6azZJaThK267mGX9s7-E0RI8cW6zcHHYkmEJCfWkj-qg61OvS2WZFTUDrqTJE2FNUpvkmKxAQNOi7XoOIa1pMdqE7ZK2CrLsldOvY7CzRD6IZx3_mPgLmAcOyt4R2LmiAf3AI5wI4mwxoAI-xTq8LLjYnl19xPG_XZAMLDGDR34tbIO9MashUhYQ7SRWvAQk8YD4URwY43GnRz0zspB6LbDdLodzpEWiG0D1wYkaZ_JzkqtnnFz7jbDDkzwiL-dDiQpFiRhbCKrkta0mtBKtfUUWCnqVlVSTCZVS0tayKZsyponjCGS_JYjcNZeGwEHHXldTcuGMjolCbuilNKEsei9dLbvI6irq4SxwDeop1q8DgH01utg3TN5HYWIeG6CjlHgXzJBECjOWszko3Wffc8F_EHssNX9ze3P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