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

cpp-tutorial/stage1 bazel build looks for compiler in wrong /tmp path #394

Open
WaiTsun-Yeung opened this issue Jan 4, 2024 · 1 comment

Comments

@WaiTsun-Yeung
Copy link

WaiTsun-Yeung commented Jan 4, 2024

Hello!

I was trying to build cpp-tutorial/stage1 on Ubuntu 22.04 with a bazel binary installed from the Bazel's apt repository, and it returned the following error:

(base) user@computer:/media/user/drive/repositories/bazel_examples/cpp-tutorial/stage1$ bazel build //main:hello-world --verbose_failures
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Analyzed target //main:hello-world (69 packages loaded, 6451 targets configured).
ERROR: /media/user/drive/repositories/bazel_examples/cpp-tutorial/stage1/main/BUILD:3:10: Compiling main/hello-world.cc failed: (Exit 127): gcc failed: error executing CppCompile command (from target //main:hello-world) 
  (cd /home/user/.cache/bazel/_bazel_user/57a42fc2a5495574ce64c6e247ef67dd/sandbox/linux-sandbox/1/execroot/_main && \
  exec env - \
    BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 \
    PATH=/bin:/usr/bin:/usr/local/bin \
    PWD=/proc/self/cwd \
  external/gcc_toolchain_x86_64/bin/gcc -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF bazel-out/k8-fastbuild/bin/main/_objs/hello-world/hello-world.pic.d '-frandom-seed=bazel-out/k8-fastbuild/bin/main/_objs/hello-world/hello-world.pic.o' -fPIC -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/bazel_tools -iquote bazel-out/k8-fastbuild/bin/external/bazel_tools --sysroot external/sysroot_x86_64/ -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' '-fdiagnostics-color=always' -nostdinc -nostdinc++ -Bexternal/gcc_toolchain_x86_64/bin -isystemexternal/sysroot_x86_64//include/c++/10.3.0 -isystemexternal/sysroot_x86_64//include/c++/10.3.0/x86_64-linux -isystemexternal/sysroot_x86_64//lib/gcc/x86_64-linux/10.3.0/include-fixed -isystemexternal/sysroot_x86_64//lib/gcc/x86_64-linux/10.3.0/include -isystemexternal/sysroot_x86_64//usr/include -c main/hello-world.cc -o bazel-out/k8-fastbuild/bin/main/_objs/hello-world/hello-world.pic.o)
# Configuration: 957e8b61236b28eb7e242f1293c1f3119632cdff86140ed1fb6bf77ff4547bca
# Execution platform: @@local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
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
Target //main:hello-world failed to build
INFO: Elapsed time: 127.229s, Critical Path: 0.18s
INFO: 5 processes: 5 internal.
ERROR: Build did NOT complete successfully

I checked the bazel cache folder and found both

  • /home/user/.cache/bazel/_bazel_user/57a42fc2a5495574ce64c6e247ef67dd/external/gcc_toolchain_x86_64/bin/gcc
  • /home/user/.cache/bazel/_bazel_user/57a42fc2a5495574ce64c6e247ef67dd/external/gcc_toolchain_x86_64_files/bin/x86_64-linux-gcc

but I had trouble figuring out how to direct the build to reach the latter path.

Any help will be very much appreciated!

@prasad-shirodkar
Copy link

Relates to bazelbuild/bazel#20533

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

No branches or pull requests

2 participants