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

Bazel 3.7.0 can't be compiled on Alpine linux #12460

Closed
kigero opened this issue Nov 11, 2020 · 3 comments
Closed

Bazel 3.7.0 can't be compiled on Alpine linux #12460

kigero opened this issue Nov 11, 2020 · 3 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug

Comments

@kigero
Copy link

kigero commented Nov 11, 2020

Description of the problem / feature request:

Bazel 3.7.0 can't be compiled on Alpine linux; I get the following error:

$ wget https://github.com/bazelbuild/bazel/releases/download/3.7.0/bazel-3.7.0-dist.zip && unzip bazel-3.7.0-dist.zip
$ env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh
Building Bazel from scratch......
Building Bazel with Bazel.
<snip>
    Compiling src/main/tools/linux-sandbox.cc; 0s local
src/main/tools/linux-sandbox-pid1.cc: In function 'int WaitForChild()':
src/main/tools/linux-sandbox-pid1.cc:402:23: error: 'TEMP_FAILURE_RETRY' was not declared in this scope
  402 |     const pid_t pid = TEMP_FAILURE_RETRY(wait(&status));
      |                       ^~~~~~~~~~~~~~~~~~

It seems that TEMP_FAILURE_RETRY is only available on GNU libc, where Alpine uses musl libc. The last Bazel version I tried on Alpine was 3.5.0 and that was compiling/running fine.

What operating system are you running Bazel on?

Alpine linux, 3.13.0_alpha20200917. Running within docker using the alpine:edge tag.

Have you found anything relevant by searching the web?

  1. The line that errors was added in commit 1517af1.
  2. I found a definition for TEMP_FAILURE_RETRY on StackOverflow that does seem to work (meaning, compilation succeeds) when added to the linux-sandbox-pid1.cc file, but this is not my area of expertise so I can't tell if it's actually doing what it's supposed to do, or if it just looks like it is.
@oquenchil oquenchil added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: support / not a bug (process) untriaged labels Nov 16, 2020
@philwo philwo added P2 We'll consider working on this in future. (Assignee optional) type: bug and removed type: support / not a bug (process) untriaged labels Nov 25, 2020
@philwo
Copy link
Member

philwo commented Nov 25, 2020

@kigero Sorry for that. I'll see that we revert this part or fix it in a way that works with non-glibcs.

@philwo philwo self-assigned this Nov 25, 2020
@foopub
Copy link

foopub commented May 13, 2021

Same problem with bazel 4.0 and musl. This fix seems fairly straightforward, other projects seem to be implementing too:

https://git.sailfishos.org/mer-core/profiled/merge_requests/5/diffs

I've successfully built Bazel by adding the snippet from the above push to linux-sandbox-pid1.cc as suggested by kigero.

I don't know much about Java, but if there are any tests you'd like me to run on my musl system to verify that it works correctly, please let me know - it's a real shame that such a small thing is preventing musl support.

@philwo
Copy link
Member

philwo commented May 17, 2021

@foopub Do you want to send us a PR that fixes this (the diff that you linked seems fine to be)? Please ping me in the PR and I can import it asap.

@jesec jesec mentioned this issue Jun 26, 2021
9 tasks
katre pushed a commit that referenced this issue Jul 12, 2021
This allows us to build Bazel on Linux systems which use a C standard library that does not include this macro, like Alpine Linux (which uses musl).

Fixes #12460.

PiperOrigin-RevId: 374873483
ZacxDev pushed a commit to ZacxDev/bazel that referenced this issue Jul 16, 2021
This allows us to build Bazel on Linux systems which use a C standard library that does not include this macro, like Alpine Linux (which uses musl).

Fixes bazelbuild#12460.

PiperOrigin-RevId: 374873483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug
Projects
None yet
Development

No branches or pull requests

4 participants