buck2 icon indicating copy to clipboard operation
buck2 copied to clipboard

buck2 fails to build on m3 mac

Open 1024bees opened this issue 1 year ago • 2 comments

hey folks,

when trying to build from source

git clone [email protected]:facebook/buck2.git                                                                                                                                                    
cargo build

and with rust toolchain cargo 1.76.0-nightly (978722961 2023-12-06)

i see the following

error: failed to run custom build command for `buck2_data v0.1.0 (/Users/james/buck2/app/buck2_data)`

Caused by:
  process didn't exit successfully: `/Users/james/buck2/target/release/build/buck2_data-59ab57d73e33d3fd/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=OUT_DIR
  cargo:rerun-if-changed=data.proto
  cargo:rerun-if-changed=error.proto
  cargo:rerun-if-changed=data.proto
  cargo:rerun-if-changed=error.proto
  cargo:rerun-if-changed=.

  --- stderr
  INFO: Variable $PROTOC set to "/Users/james/.cargo/registry/src/index.crates.io-6f17d22bba15001f/protoc-bin-vendored-macos-x86_64-3.0.0/bin/protoc"
  INFO: Variable $PROTOC_INCLUDE set to "/Users/james/.cargo/registry/src/index.crates.io-6f17d22bba15001f/protoc-bin-vendored-macos-x86_64-3.0.0/include"
  Error: Custom { kind: Uncategorized, error: "failed to invoke protoc (hint: https://docs.rs/prost-build/#sourcing-protoc): (path: \"/Users/james/.cargo/registry/src/index.crates.io-6f17d22bba15001f/protoc-bin-v
endored-macos-x86_64-3.0.0/bin/protoc\"): Bad CPU type in executable (os error 86)" }
warning: build failed, waiting for other jobs to finish...
error: failed to compile `buck2 v0.1.0 (/Users/james/buck2/app/buck2)`, intermediate artifacts can be found at `/Users/james/buck2/target`.

this error is caused by the bundled protoc being compiled for x86 -- i'll find a work around and include a fix (installing protoc locally, pointing to it) -- longer term to make this just work, probably need to address https://github.com/stepancheg/rust-protoc-bin-vendored/issues/1

1024bees avatar Feb 29 '24 21:02 1024bees

Buck uses its own environment variables for protoc and protoc include. They are called BUCK2_BUILD_PROTOC and BUCK2_BUILD_PROTOC_INCLUDE. You may have to override those instead.

cormacrelf avatar Jun 01 '24 16:06 cormacrelf

Buck uses its own environment variables for protoc and protoc include. They are called BUCK2_BUILD_PROTOC and BUCK2_BUILD_PROTOC_INCLUDE. You may have to override those instead.

Can confirm that overriding these with the following fixed it for me

export BUCK2_BUILD_PROTOC=$(which protoc)
export BUCK2_BUILD_PROTOC_INCLUDE=$(brew --prefix protobuf)/include

svermeulen avatar Jul 18 '24 17:07 svermeulen