Skip to content

Commit 24a340a

Browse files
dflemsWyverald
authored andcommitted
[apple] fix issues compiling C in objc_library for watchos/armv7k
Reproducible example here: https://github.com/dflems/bazel-repro-armv7k. This was tested against 5.0.0 rc2 and latest master and fails on both. The build succeeds after this fix is applied. Basically, if you have any non-objc files (like C sources) in `objc_library` rules, they'll get compiled for the wrong architecture when targeting watchOS/armv7k. The target triplet for the `watchos_armv7k` CPU was set to `armv7-apple-watchos` instead of `armv7k-apple-watchos` (which is what Xcode sets when compiling/linking for this architecture). It's been like this for a few years, but I think this has always been wrong. Before the recent starlark rewrite of the objc rules, it appears that all of the sources (objc or not) were compiled with the `-arch armv7k` arguments applied. After the rewrite, objc still gets compiled this way but C files in the same library get the target triplet from the crosstool, which is incorrect. Then when `libtool` creates the archive, the object files are filtered out because they don't match `-arch_only armv7k`. If approved, I think this should be cherry-picked into the 5.0 release. Closes bazelbuild#14367. PiperOrigin-RevId: 414693641
1 parent b46de75 commit 24a340a

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public static CcToolchainConfig.Builder watchos_armv7k() {
459459
.withCompiler("compiler")
460460
.withToolchainIdentifier("watchos_armv7k")
461461
.withHostSystemName("x86_64-apple-ios")
462-
.withTargetSystemName("armv7-apple-watchos")
462+
.withTargetSystemName("armv7k-apple-watchos")
463463
.withTargetLibc("watchos")
464464
.withAbiVersion("local")
465465
.withAbiLibcVersion("local")

src/test/java/com/google/devtools/build/lib/packages/util/mock/osx_cc_toolchain_config.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -6991,7 +6991,7 @@ def _impl(ctx):
69916991
actions = _ALL_LINK_ACTIONS,
69926992
flag_groups = [
69936993
flag_group(
6994-
flags = ["-lc++", "-target", "armv7-apple-watchos"],
6994+
flags = ["-lc++", "-target", "armv7k-apple-watchos"],
69956995
),
69966996
],
69976997
),

tools/osx/crosstool/cc_toolchain_config.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _impl(ctx):
6666
elif (ctx.attr.cpu == "ios_armv7"):
6767
target_system_name = "armv7-apple-ios"
6868
elif (ctx.attr.cpu == "watchos_armv7k"):
69-
target_system_name = "armv7-apple-watchos"
69+
target_system_name = "armv7k-apple-watchos"
7070
elif (ctx.attr.cpu == "ios_i386"):
7171
target_system_name = "i386-apple-ios"
7272
elif (ctx.attr.cpu == "watchos_i386"):

0 commit comments

Comments
 (0)