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

Abseil bazel build fails on Apple M1 (ARM64) #954

Closed
devjgm opened this issue May 3, 2021 · 5 comments
Closed

Abseil bazel build fails on Apple M1 (ARM64) #954

devjgm opened this issue May 3, 2021 · 5 comments
Labels

Comments

@devjgm
Copy link

devjgm commented May 3, 2021

Describe the bug

I'm on a Mac mini M1 (ARM64), and when I bazel build Abseil I get an error:

$ git rev-parse HEAD
a9831f1cbf93fb18dd951453635f488037454ce9

$ bazel info release
release 4.0.0-homebrew

$ bazel build ...
INFO: Analyzed 381 targets (0 packages loaded, 0 targets configured).
INFO: Found 381 targets...
ERROR: /Users/jgm/github/devjgm/abseil-cpp/absl/synchronization/BUILD.bazel:68:11: Linking absl/synchronization/libsynchronization.so failed: (Exit 1): cc_wrapper.sh failed: error executing command external/local_config_cc/cc_wrapper.sh @bazel-out/darwin-fastbuild/bin/absl/synchronization/libsynchronization.so-2.params

Use --sandbox_debug to see verbose messages from the sandbox cc_wrapper.sh failed: error executing command external/local_config_cc/cc_wrapper.sh @bazel-out/darwin-fastbuild/bin/absl/synchronization/libsynchronization.so-2.params

Use --sandbox_debug to see verbose messages from the sandbox
ld: illegal thread local variable reference to regular symbol __ZN4absl13base_internal19thread_identity_ptrE for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
INFO: Elapsed time: 1.778s, Critical Path: 1.07s
INFO: 83 processes: 53 internal, 30 darwin-sandbox.
FAILED: Build did NOT complete successfully

Steps to reproduce the bug

Important You'll need a Mac with an M1 chip.

  1. Checkout Abseil head. For me that was a9831f1
  2. bazel build ...
  3. error

What version of Abseil are you using?

HEAD: a9831f1

What operating system and version are you using

ProductName:    macOS
ProductVersion: 11.3
BuildVersion:   20E232

On a Mac Mini M1

What compiler and version are you using?

Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: arm64-apple-darwin20.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

What build system are you using?

bazel 4.0.0-homebrew

Additional context

Add any other context about the problem here.

@devjgm devjgm added the bug label May 3, 2021
@devjgm devjgm changed the title Abseil build fails on Apple M1 (ARM64) Abseil bazel build fails on Apple M1 (ARM64) May 3, 2021
@phst
Copy link

phst commented May 23, 2021

Still happening with Bazel 4.1 for me.

@jesec
Copy link

jesec commented May 24, 2021

I can confirm this. bazel 4.1.0-homebrew

@derekmauro
Copy link
Member

Unfortunately I don't have the hardware to test this at the moment. Those of you who are experiencing the issue, can you try building with --copt=-DABSL_FORCE_THREAD_IDENTITY_MODE=N, replacing N with 0, 1, and 2, and let us know if the build succeeds in any of those configurations. That may give us a hint on how to fix the issue.

Another thing you could try is to tweak the conditional here and here to include this platform.

Thread-local storage has been a major pain on Apple platforms in general. Thanks to those who have reported this.

@phst
Copy link

phst commented May 24, 2021

For me this works with N = 0 and fails otherwise.

derekmauro added a commit to derekmauro/abseil-cpp that referenced this issue Jun 1, 2021
* Fixes build with glibc 2.34 (abseil#952)
* Fixes "illegal thread local variable" on some Apple platforms (abseil#954, abseil#965)

PiperOrigin-RevId: 371693908
derekmauro added a commit that referenced this issue Jun 1, 2021
* Fixes build with glibc 2.34 (#952)
* Fixes "illegal thread local variable" on some Apple platforms (#954, #965)
@derekmauro
Copy link
Member

This fix for this issue as been backported to the latest LTS release: https://github.com/abseil/abseil-cpp/releases/tag/20210324.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants
@phst @derekmauro @devjgm @jesec and others