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

Why can not Buck trigger Buildbarn's g++ using system_cxx_toolchain? #549

Closed
yaoddao opened this issue Jan 25, 2024 · 0 comments
Closed

Comments

@yaoddao
Copy link

yaoddao commented Jan 25, 2024

Buck can not trigger Buildbarn`s g++ using system_cxx_toolchain

Problem description

  • Prerequisite: Buck can already trigger the Buildbarn action: eg. various shell commands.
  • Buck cannot trigger Buildbarn worker to g++ build using configuration below in system_cxx_toolchain(), reporting errors.
    (PS. In Buildbarn worker's container, PATH is correct and includes /usr/bin/g++;/bin/g++)
system_cxx_toolchain(
     ¦ name = "cxx",
     ¦ visibility = ["PUBLIC"],
     ¦ compiler = "gcc",
     ¦ compiler_type = "gcc",
     ¦ cxx_compiler = "g++", **# Pay attention here!**
     ¦ linker = "g++",
   )

Error info:

user@***/codes (feature-buck2-base)>buck2 build -v 4 //buildbarn_helloworld/cpp/hello_world:
File changed: shim//4913
File changed: shim//BUCK
File changed: shim//BUCK
Running action: root//buildbarn_helloworld/cpp/hello_world:main (prelude//platforms:default#524f8da68ea2a374) (cxx_compile main.cpp (pic)) (build), re(OSFamily=linux,container-image=docke
r://ghcr.io/catthehacker/ubuntu:act-22.04@sha256:5f9c35c25db1d51a8ddaae5c0ba8d3c163c5e9a4a6cc97acd409ac7eae239448) executor: d1bab98dd5b618541d3f29e93f46f96aeeae064925e90eeade10cebc062f41
99:142
Running action: root//buildbarn_helloworld/cpp/hello_world:main (prelude//platforms:default#524f8da68ea2a374) (cxx_link libbuildbarn_helloworld_cpp_hello_world_main.so) (build), re(OSFami
ly=linux,container-image=docker://ghcr.io/catthehacker/ubuntu:act-22.04@sha256:5f9c35c25db1d51a8ddaae5c0ba8d3c163c5e9a4a6cc97acd409ac7eae239448) executor: febb48c18de54cceced33acb8397b679
7f204c81518aabb7c05b6713309b5ba2:142
Action failed: root//buildbarn_helloworld/cpp/hello_world:main (cxx_link libbuildbarn_helloworld_cpp_hello_world_main.so)
Internal error (stage: remote_call_error): Remote Execution Error (GRPC-SESSION-ID): RE: execution with digest febb48c18de54cceced33acb8397b6797f204c81518aabb7c05b6713309b5ba2:142: Error
was returned on the stream by RE: Failed to run command: **Cannot find executable "g++" in search paths ""**
stdout:
stderr:
Build ID: a884fe82-a227-4031-9252-e66e01a3dd29
Network: (GRPC-SESSION-ID)
Jobs completed: 11. Time elapsed: 0.4s.
Cache hits: 0%. Commands: 1 (cached: 0, remote: 1, local: 0)
BUILD FAILED

PS. Pay attention error above: Failed to run command: Cannot find executable "g++" in search paths "".
Buildbarn searches g++ in paths "", which is an empty directory, and it should not be done.
I have tested that Bazel does not have this issue.

  • But if you use configuration below, Buck can trigger the g++ build in Buildbarn and get main.o from Buildbarn.
  system_cxx_toolchain(
    ¦ name = "cxx",
    ¦ visibility = ["PUBLIC"],
    ¦ compiler = "gcc",
    ¦ compiler_type = "gcc",
    ¦ cxx_compiler = "/usr/bin/g++",  *Pay attention here!!*
    ¦ linker = "/usr/bin/g++",
  )

The result is as follows:

user@/codes (feature-buck2-base)>tree ./buck-out/
./buck-out/
└── v2
    ├── forkserver
    ├── gen
    │   └── root
    │       └── 524f8da68ea2a374
    │           └── buildbarn_helloworld
    │               └── cpp
    │                   └── hello_world
    │                       └── __main__
    │                           ├── __objects__
    │                           │   └── **main.cpp.pic.o  *** Here pay attention, and got main.o from Buildbarn*****
    │                           ├── buck-private-headers
    │                           │   └── buildbarn_helloworld
    │                           │       └── cpp
    │                           │           └── hello_world
    │                           │               └── main.hpp -> ../../../../../../../../../../../../../buildbarn_helloworld/cpp/hello_world/main.hpp
    │                           └── libbuildbarn_helloworld_cpp_hello_world_main.so.linker.argsfile
    └── log
        ├── 20240124-081657_build_a18af8ba-d8cd-4764-a565-3e31c74bba6e_events.pb.zst
  • I entered the Buildbarn worker's container and check PATH environment. PATH is correct and includes /usr/bin;/bin.
    /usr/bin/g++ and /bin/g++ can be found.
    So, the reason of this issue is not Buildbarn PATH environment.

Question

  • When I use system_cxx_toolchain(){cxx_compiler = "g++"}, why does Buildbarn searchs g++ in path "", which is empty directory?
    I think Buck2 somehow sent special information to buildbarn in gRPC calls when using system_cxx_toolchain(){cxx_compiler = "g++"}.

  • Does anyone have any insights on this issue?
    Thanks!

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

1 participant