-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Description of the problem / feature request:
I have a project uses both cc_library and objc_library to compile for MacOS X platform.
The project could compile and run properly until I switched to Apple M1 based MacOS X.
I discovered that on M1 MacOS X, Bazel compiles objc_library with darwin_x86_64 platform and compiles
cc_library/cc_binary with darwin_arm64 platform. Therefore, the project no longer links these two libraries successfully.
The compilation fails at link-time with this error message:
ld: warning: ignoring file bazel-out/applebin_macos-darwin_x86_64-dbg-ST-cfb676c6944e/bin/test/libmacfile.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I have a minimal example project to reproduce this problem, please find the attached file.
unzip objc_apple_m1_linker.zip
cd objc_apple_m1_linker
bazel build -c dbg //test -s
ls -al bazel-out/
drwxr-xr-x 3 merck wheel 96 Feb 11 18:38 applebin_macos-darwin_x86_64-dbg-ST-cfb676c6944e
drwxr-xr-x 4 merck wheel 128 Feb 11 18:38 darwin_arm64-dbg
- objc_library was compiled into applebin_macos-darwin_x86_64-dbg-ST-cfb676c6944e
- cc_binary was compiled into darwin_arm64-dbg, they failed to link with each other.
What operating system are you running Bazel on?
Apple M1 (ARM64) MacOS X 12.2.1
bazel version is 6.0.0-pre.20220112.2 (Darwin ARM64 variant bazel-6.0.0-pre.20220112.2-darwin-arm64)
What's the output of bazel info release?
release 6.0.0-pre.20220112.2
Have you found anything relevant by searching the web?
I tried, but I didn't find anything similar.