rules_foreign_cc icon indicating copy to clipboard operation
rules_foreign_cc copied to clipboard

Disable cc toolchain resolution in examples on Mac

Open comius opened this issue 2 years ago • 2 comments

The examples/cmake_android picks up local instead of Android Cc toolchains.

comius avatar Sep 20 '22 13:09 comius

I'm not familiar with the android toolchains at all so can you clarify to me here is there an issue with the build files in rules_foreign_cc examples that needs fixing to flip this flag or is it a bazel core issue?

jsharpe avatar Sep 20 '22 13:09 jsharpe

I'm not familiar with the android toolchains at all so can you clarify to me here is there an issue with the build files in rules_foreign_cc examples that needs fixing to flip this flag or is it a bazel core issue?

It seems the problem is in rules_foreign_cc. For reproduction run cd examples; bazel build --incompatible_enable_cc_toolchain_resolution -- //cmake_android:all on Mac.

Example error:

ERROR: /Users/ilist/src/rules_foreign_cc/examples/cmake_android/BUILD.bazel:5:6: Foreign Cc - CMake: Building libhello failed: (Exit 64): bash failed: error executing command /bin/bash -c bazel-out/android-armeabi-v7a-fastbuild/bin/cmake_android/libhello_foreign_cc/wrapper_build_script.sh

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
rules_foreign_cc: Build failed!
rules_foreign_cc: Keeping temp build directory and dependencies directory for debug.
rules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify --sandbox_debug Bazel command line flag.
rules_foreign_cc: Printing build logs:
_____ BEGIN BUILD LOGS _____

Bazel external C/C++ Rules. Building library libhello

xcrun: error: no utility name specified
Usage: xcrun [options] <tool name> ... arguments ...

Link to logs: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/2641#01835443-c1d8-4c64-b27a-4d7c3f6da962

I further inspected and compared the generated cmake_android/libhello_foreign_cc/build_script.sh scripts.

Good ones point to /androidndk/ndk/toolchains/llvm/prebuilt/darwin-x86_64/, bad ones point to local_config_cc.

I'm assuming those scripts are generated by rules_foreign_cc and somewhere they depend on crosstool_top instead on cc toolchain.

comius avatar Sep 21 '22 15:09 comius