Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build the toy language example with bazel #71514

Open
tisonkun opened this issue Nov 7, 2023 · 1 comment
Open

Cannot build the toy language example with bazel #71514

tisonkun opened this issue Nov 7, 2023 · 1 comment
Labels
bazel "Peripheral" support tier build system: utils/bazel build-problem

Comments

@tisonkun
Copy link

tisonkun commented Nov 7, 2023

Reproduce

The reproduce is simple, with file structure:

toy/
toy/BUILD
toy/MODULE.bazel
toy/WORKSPACE
toy/toy.cpp

where

  1. toy.cpp contains the example code
  2. WORKSPACE is empty.
  3. BUILD contains:
cc_binary(
  name = "toy",
  srcs = ["toy.cpp"],
  deps = [
    "@org_llvm_project//llvm:Core",
    "@org_llvm_project//llvm:Support",
  ]
)
  1. MODULE.bazel contains:
module(name = "toy", version = "0.1.0")
bazel_dep(name = "llvm-project", version = "17.0.3", repo_name = "org_llvm_project")

when build with:

$ bazel build --enable_bzlmod --action_env=BAZEL_CXXOPTS="-std=c++17" --sandbox_debug --verbose_failures //:toy

it fails with:

INFO: Analyzed target //:toy (58 packages loaded, 1490 targets configured).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_tison/c244744f015d9943cebd9b4c9b18d7b0/external/llvm-project~17.0.3/llvm/BUILD.bazel:600:10: Linking external/llvm-project~17.0.3/llvm/llvm-min-tblgen [for tool] failed: (Exit 254): sandbox-exec failed: error executing command 
  (cd /private/var/tmp/_bazel_tison/c244744f015d9943cebd9b4c9b18d7b0/sandbox/darwin-sandbox/338/execroot/_main && \
  exec env - \
    PATH='...' \
    PWD=/proc/self/cwd \
    TMPDIR=/var/folders/ts/160w4k_j5mv5bjk9rnjkzjpm0000gn/T/ \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_tison/c244744f015d9943cebd9b4c9b18d7b0/sandbox/darwin-sandbox/338/sandbox.sb /var/tmp/_bazel_tison/install/ba45a1a358416fb2acebb17d65c986f3/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_tison/c244744f015d9943cebd9b4c9b18d7b0/sandbox/darwin-sandbox/338/stats.out' external/bazel_tools~cc_configure_extension~local_config_cc/cc_wrapper.sh @bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/llvm-project~17.0.3/llvm/llvm-min-tblgen-2.params)
clang: error: unable to execute command: Segmentation fault: 11
clang: error: linker command failed due to signal (use -v to see invocation)
Target //:toy failed to build
INFO: Elapsed time: 40.140s, Critical Path: 2.66s
INFO: 381 processes: 44 internal, 337 darwin-sandbox.

while if built with:

$ clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy

It succeeds with preinstalled LLVM@17.

Environment

$ uname -a
Darwin xxx Darwin Kernel Version 22.5.0: Mon Apr 24 20:53:19 PDT 2023; root:xnu-xxx/RELEASE_ARM64_T6020 arm64

$ clang -v
Homebrew clang version 17.0.4
Target: arm64-apple-darwin22.5.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin

Reference

@tisonkun
Copy link
Author

tisonkun commented Nov 7, 2023

It seems a script returns value other than 0. I tried to debug and get:

$ /private/var/tmp/_bazel_tison/c244744f015d9943cebd9b4c9b18d7b0/sandbox/darwin-sandbox/338/execroot/_main/external/bazel_tools~cc_configure_extension~local_config_cc/cc_wrapper.sh bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/llvm-project\~17.0.3/llvm/llvm-min-tblgen-2.params 
ld: warning: ignoring file bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/llvm-project~17.0.3/llvm/llvm-min-tblgen-2.params, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x2D 0x6F 0x0A 0x62 0x61 0x7A 0x65 0x6C 0x2D 0x6F 0x75 0x74 0x2F 0x64 0x61 0x72 )
Undefined symbols for architecture arm64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@dtcxzyw dtcxzyw added build-problem bazel "Peripheral" support tier build system: utils/bazel and removed new issue labels Nov 7, 2023
michaelmaitland added a commit to michaelmaitland/llvm-project that referenced this issue Nov 14, 2023
This is a precommit for llvm#71514 to use TypeSize instead of unsigned to
avoid crashes when scalable vectors are used.
michaelmaitland added a commit that referenced this issue Nov 15, 2023
This is a precommit for #71514 to use TypeSize instead of unsigned to
avoid crashes when scalable vectors are used.
zahiraam pushed a commit to zahiraam/llvm-project that referenced this issue Nov 20, 2023
This is a precommit for llvm#71514 to use TypeSize instead of unsigned to
avoid crashes when scalable vectors are used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel build-problem
Projects
None yet
Development

No branches or pull requests

2 participants