bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Fail to build cpp-tutorial stage1 with Bazel 7.0.0

Open sjwo opened this issue 2 years ago • 8 comments

Description of the bug:

Bazel 7.0.0 fails to build the stage1 portion of the bazelbuild/examples/cpp-tutorial. It appears to fail to resolve a path it constructs.

Reverting to Bazel 6.4.0, or passing the --noincompatible_sandbox_hermetic_tmp build option, are both successful workarounds.

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Ubuntu 20.04.
  2. Download bazelisk-linux-amd64 from https://github.com/bazelbuild/bazelisk/releases/tag/v1.19.0, add it to your PATH, and make it executable.
  3. Clone https://github.com/bazelbuild/examples, and change into the examples/cpp-tutorial/stage1 directory.
  4. Execute bazelisk-linux-amd64 build //main:hello-world.
  5. As part of the build failure output, receive the following error message:
external/gcc_toolchain_x86_64/bin/gcc: line 45: /tmp/external/gcc_toolchain_x86_64_files/bin/x86_64-linux-gcc: No such file or directory

Which operating system are you running Bazel on?

Ubuntu 20.04

What is the output of bazel info release?

release 7.0.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

https://github.com/bazelbuild/examples
master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
9c4e6c5de1a053efa956c0a7a8f54d302d24e0b1

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

Possibly.

Have you found anything relevant by searching the web?

  • My post to the Bazel getstarted Slack includes responses from other users suggesting the workarounds mentioned above: https://bazelbuild.slack.com/archives/CD42R4HJL/p1702485704389129
  • This issue over at the examples repo appears to be having a similar and possibly the same issue: https://github.com/bazelbuild/examples/issues/383

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

Here is the output of git rev-parse main:

9c4e6c5de1a053efa956c0a7a8f54d302d24e0b1

sjwo avatar Dec 13 '23 19:12 sjwo

I verified that this issue is still present with https://github.com/bazelbuild/bazel/pull/20603.

I dug further and think that this logic just doesn't work with the kind of relocation performed by --incompatible_sandbox_hermetic_tmp: https://github.com/aspect-build/gcc-toolchain/blob/e2a34698bd20c7a2f771586ddfcf504330b77a97/toolchain/wrapper.sh.tpl#L20-L25

I don't think that this is a bug in Bazel, it's only an incompatible change to some aspects of the path layout. CC @f0rmiga

fmeum avatar Dec 19 '23 12:12 fmeum

Thanks @fmeum. I'll take a look at that.

f0rmiga avatar Dec 19 '23 17:12 f0rmiga

This bug still exist Ubuntu: 22.4 Bazel: 7.0.2 GCC: 11.4.0

dubrovin-sudo avatar Feb 16 '24 13:02 dubrovin-sudo

FYI looks like the --sandbox_add_mount_pair=/tmp build option is also a workaround.

From: https://github.com/bazelbuild/bazel/issues/19915

jeangud avatar Feb 22 '24 15:02 jeangud

Ubuntu 22.4 Bazel: 7.1.0

The workaround as suggested by @jeangud works for me --sandbox_add_mount_pair=/tmp

Still open. Why is this closed? @fmeum

pawsaw avatar Mar 14 '24 11:03 pawsaw

@pawsaw I closed it as not planned since it's more of a bug in the gcc toolchain that isn't part of Bazel. But it's still referenced by Bazel examples, so I now agree that it's better to reopen the bug.

@iancha1992 Could you reopen this issue? I don't have permission to do so.

fmeum avatar Mar 14 '24 12:03 fmeum

cc @lberki for incompatible_sandbox_hermetic_tmp

comius avatar May 03 '24 13:05 comius

I have the bandwidth to look into it today on my end. As for Bazel itself, I don't know if there's an action to take.

f0rmiga avatar May 03 '24 20:05 f0rmiga