carbon-language / carbon-lang

Carbon Language's main repository: documents, design, implementation, and related tools. (NOTE: Carbon Language is experimental; see README)
http://docs.carbon-lang.dev/
Other
32.32k stars 1.48k forks source link

bazel build fails Ubuntu 23.10 #3990

Closed panjea closed 5 months ago

panjea commented 5 months ago

Description of the bug:

sudo apt install bazel-bootstrap

git clone --depth 1 https://github.com/carbon-language/carbon-lang

cd carbon-lang

~/carbon-lang$ bazel run //explorer -- ./explorer/testdata/print/format_only.carbon
Starting local Bazel server and connecting to it...
INFO: Reading rc options for 'run' from /home/rap/carbon-lang/.bazelrc:
  Inherited 'build' options: --disk_cache=~/.cache/carbon-lang-build-cache --experimental_guard_against_concurrent_changes --per_file_copt=external/.*.(c|cc|cpp|cxx)$@-w --host_per_file_copt=external/.*.(c|cc|cpp|cxx)$@-w --dynamic_mode=off --force_pic --strip=never --define=absl=1 --test_env=ASAN_SYMBOLIZER_PATH --action_env=LANG=en_US.UTF-8
ERROR: --host_per_file_copt=external/.*.(c|cc|cpp|cxx)$@-w :: Unrecognized option: --host_per_file_copt=external/.*.(c|cc|cpp|cxx)$@-w
INFO: Invocation ID: e74a8406-7060-4d62-9d83-81e15e11279c

What did you do, or what's a simple way to reproduce the bug?

No response

What did you expect to happen?

No response

What actually happened?

No response

Any other information, logs, or outputs that you want to share?

No response

chandlerc commented 5 months ago

What version of Bazel do you have? (bazel --version or bazel info should show)

My guess is that it is a (quite) old system installed Bazel. I suspect you'll want to use Bazelisk: https://bazel.build/install/bazelisk

We should probably update our docs to make this more clear...

dasshiva commented 5 months ago

The same occurred for me on ubuntu 22.04 LTS. I had to download bazel 7.1.2 to get it to work because ubuntu ships with bazel 3.5.X

panjea commented 5 months ago

i installed bazelisk, but now get this error:

~/carbon-lang$ /usr/local/bin/bazelisk-linux-amd64 run //explorer -- ./explorer/testdata/print/format_only.carbon
2024/05/26 12:43:59 Downloading https://releases.bazel.build/7.1.2/release/bazel-7.1.2-linux-x86_64...
Downloading: 66 MB out of 66 MB (100%) 
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 0f57a49d-69c2-48b9-8d67-1247ec5dcd9d
INFO: Analyzed target //explorer:explorer (109 packages loaded, 2115 targets configured).
ERROR: /home/rap/.cache/bazel/_bazel_rap/6a55a3082644891e2316d6f8c5b0782d/external/_main~llvm_project~llvm-project/llvm/BUILD.bazel:188:11: Compiling llvm/lib/Demangle/DLangDemangle.cpp failed: (Exit 1): clang++ failed: error executing CppCompile command (from target @@_main~llvm_project~llvm-project//llvm:Demangle) /usr/lib/llvm-16/bin/clang++ -no-canonical-prefixes -fcolor-diagnostics -Werror -Wall -Wextra -Wthread-safety -Wself-assign -Wimplicit-fallthrough -Wctad-maybe-unsupported -Wdelete-non-virtual-dtor ... (remaining 69 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/_main~llvm_project~llvm-project/llvm/lib/Demangle/DLangDemangle.cpp:16:
external/_main~llvm_project~llvm-project/llvm/include/llvm/Demangle/Demangle.h:12:10: fatal error: 'cstddef' file not found
#include <cstddef>
         ^~~~~~~~~
1 error generated.
Target //explorer:explorer failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 72.347s, Critical Path: 0.71s
INFO: 209 processes: 154 internal, 55 linux-sandbox.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
panjea commented 5 months ago

sudo apt install libstdc++-12-dev fixes the previous error

next error is:

/usr/local/bin/bazelisk-linux-amd64 run //explorer -- ./explorer/testdata/print/format_only.carbon
INFO: Invocation ID: c47d5d74-d837-4f78-93ab-7b0c1eb44af4
INFO: Analyzed target //explorer:explorer (0 packages loaded, 0 targets configured).
ERROR: /home/rap/.cache/bazel/_bazel_rap/6a55a3082644891e2316d6f8c5b0782d/external/_main~llvm_project~llvm-project/llvm/BUILD.bazel:215:11: Compiling llvm/lib/Support/Hashing.cpp failed: (Exit 1): clang++ failed: error executing CppCompile command (from target @@_main~llvm_project~llvm-project//llvm:Support) /usr/lib/llvm-16/bin/clang++ -no-canonical-prefixes -fcolor-diagnostics -Werror -Wall -Wextra -Wthread-safety -Wself-assign -Wimplicit-fallthrough -Wctad-maybe-unsupported -Wdelete-non-virtual-dtor ... (remaining 86 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/_main~llvm_project~llvm-project/llvm/lib/Support/Hashing.cpp:15:
In file included from external/_main~llvm_project~llvm-project/llvm/include/llvm/ADT/Hashing.h:49:
In file included from external/_main~llvm_project~llvm-project/llvm/include/llvm/Support/SwapByteOrder.h:17:
external/_main~llvm_project~llvm-project/llvm/include/llvm/ADT/STLForwardCompat.h:20:10: fatal error: 'optional' file not found
#include <optional>
         ^~~~~~~~~~
1 error generated.
Target //explorer:explorer failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.881s, Critical Path: 0.43s
INFO: 34 processes: 34 internal.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
chandlerc commented 5 months ago

All of these seem likely to be missing packages in the setup suggested here: https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/contribution_tools.md#debian-or-ubuntu

Can you confirm you've done all of those steps?

panjea commented 5 months ago

I can confirm build works using bazelisk and this apt-get:

sudo apt-get install libc++abi-dev clang gh lld pipx libc++-dev

It sure would make life easier for those of us using Ubuntu if Google had better support for bazel on Debian or Ubuntu, downloading bazelisk and installing it felt like a hack.

chandlerc commented 5 months ago

Glad that got you working!

FWIW, we're discussing whether we can do something to avoid the difficulty of installing bazelisk. =/