I am trying to build or to cross-compile a project for Apple M1. I
can build the project on linux-x86_64 without a problem (with gcc11 as
the compiler). But when I try to build the same project on Apple M1, I
get this error:
ERROR: ./BUILD.bazel:38:10: Target
'//:tandem-tap' depends on toolchain
'@local_config_cc//:cc-compiler-darwin_arm64', which cannot be found: no
such target '@local_config_cc//:cc-compiler-darwin_arm64': target
'cc-compiler-darwin_arm64' not declared in package '' defined by
/private/var/tmp/_bazel_meisam/eed07f1d1238ba70d8dab89b67f79478/external/local_config_cc/BUILD'
ERROR: Analysis of target '//:tandem-tap' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.058s
INFO: 0 processes.FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
I have gcc11 for arm installed on the apple M1 system
$ which gcc-11
/opt/homebrew/bin/gcc-11
$ file /opt/homebrew/bin/gcc-11
/opt/homebrew/bin/gcc-11: Mach-O 64-bit executable arm64
Apple Clang is also installed on the system:
$ which clang
/usr/bin/clang
$ file /usr/bin/clang
/usr/bin/clang:
Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit
executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/clang (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/clang (for architecture arm64e): Mach-O 64-bit executable arm64e
I
looked around to see how I can define a toolchain for Bazel, but I
cannot find a coherent document that shows all the steps in one place.
The bazel documentation jumps around so many times that it is
practically impossible to follow, It also appears that, at various
spots, the documentation is mixing concepts in bazel 4.x and older
versions.
Can someone point me to an example? I'd be happy to help update the
documentation or even add an example project to
https://github.com/bazelbuild/examples once I figure out how to fix the issues I am facing.
Thanks,
Meisam