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

[Bug]: incompatible_sandbox_hermetic_tmp (on by default in bazel 7.0.0) breaks the gcc wrapper #161

Open
novas0x2a opened this issue Dec 12, 2023 · 1 comment
Labels
bug Something isn't working untriaged Requires traige

Comments

@novas0x2a
Copy link

novas0x2a commented Dec 12, 2023

What happened?

incompatible_sandbox_hermetic_tmp causes some relative paths to change, and results in this logic no longer pointing to the correct location (on my machine, it just ends up being /tmp)

This produces an error like:

external/gcc_toolchain_armv7/bin/gcc: line 45: /tmp/external/gcc_toolchain_armv7_files/bin/arm-linux-gcc: No such file or directory

Version

Development (host) and target OS/architectures: linux/amd64

Output of bazel --version: 7.0.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce

from aspect/gcc-toolchain:

echo 7.0.0 > .bazelversion
bazel build --noenable_bzlmod //...
ERROR: $ROOT/aspect/gcc-toolchain/examples/hello_world_cpp/BUILD.bazel:19:10: Compiling examples/hello_world_cpp/main.cpp failed: (Exit 127): gcc failed: error executing CppCompile command (from target //examples/hello_world_cpp:hello_world_cpp) external/gcc_toolchain_armv7/bin/gcc -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 32 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/gcc_toolchain_armv7/bin/gcc: line 45: /tmp/external/gcc_toolchain_armv7_files/bin/arm-linux-gcc: No such file or directory

Any other information?

What seems to work is to pass the previously calculated execroot into _render_tool_paths and then further into the wrapper via a new __EXECROOT__ substitution but i'm not sure if that's an approach that would backfire in some way.

@alexeagle
Copy link
Contributor

alexeagle commented Feb 15, 2024

I find that logic also fails under rules_rust which sets PATH to a single entry that doesn't include dirname or realpath:

PATH="bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/rust_toolchain/lib/rustlib/x86_64-unknown-linux-gnu/bin" ...

Perhaps this is a rules_rust bug?

I think this line needs to be rewritten but I'm not sure how to verify the change works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged Requires traige
Projects
None yet
Development

No branches or pull requests

2 participants