Repository navigation
Description
Description of the feature request:
Can it possible to specify the target CPU arch in the BUILD file for a objc_library? For example:
objc_library(
name = "myLib",
srcs = ["Interface.m"],
hdrs = ["Interface.h"],
ios_multi_cpus = ["armv7", "arm64"],
)Feature requests: what underlying problem are you trying to solve with this feature?
We want to make a universal (aka "fat") framework which includes device and simulator architectures (i386, x86_64, armv7, and arm64). Currently, we build it with the following command:
bazel build //mobile/ios:myFramework --ios_multi_cpus=i386,x86_64,armv7,arm64
We recently added NEON extensions which are specific to ARM processors, such as the ones found in physical iPhone devices. To do this, we add --define ptrit_platform=neon to the bazel command so that a certain macro is defined. However, when attempting to compile with the following command, we get errors because NEON extensions are not supported on i386 and x86_64 architectures:
bazel build //mobile/ios:myFramework --ios_multi_cpus=i386,x86_64,armv7,arm64 --define ptrit_platform=neon
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include/arm_neon.h:28:2: error: "NEON support not enabled"
#error "NEON support not enabled"
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include/arm_neon.h:48:24: error: 'neon_vector_type' attribute is not supported for this target
typedef __attribute__((neon_vector_type(8))) int8_t int8x8_t;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include/arm_neon.h:49:24: error: 'neon_vector_type' attribute is not supported for this target
typedef __attribute__((neon_vector_type(16))) int8_t int8x16_t;
...
While we could accomplish this by using individual commands (since the ios_multi_cpus argument can only be set on the command line) and then assembling the universal library using the lipo command, it would be ideal to use Bazel rules for this so everything can be stored in a BUILD file. As an example:
objc_library(
name = "myLib_iphoneos",
srcs = ["Interface.m"],
hdrs = ["Interface.h"],
defines = ["ptrit_platform=neon"],
ios_multi_cpus = ["armv7", "arm64"], # New option
)
objc_library(
name = "myLib_iphonesimulator",
srcs = ["Interface.m"],
hdrs = ["Interface.h"],
defines = ["ptrit_platform=64"],
ios_multi_cpus = ["i386", "x86_64"], # New option
)
ios_static_framework(
name = "myFramework",
hdrs = ["Interface.h"],
bundle_name = "MyFramework",
minimum_os_version = "9.0",
deps = [":myLib_iphoneos", ":myLib_iphonesimulator"],
)What operating system are you running Bazel on?
macOS Catalina 10.15.1 Beta
What's the output of bazel info release?
release 0.29.1-homebrew
Have you found anything relevant by searching the web?
Nope. I tried implementing this myself but I'm not entirely sure how/where to make the appropriate change (maybe src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java?)
Activity
[-]Specify CPU arch in arguments for objc_library[/-][+]Request: Specify CPU arch in arguments for objc_library[/+]rupertks commentedon Oct 24, 2019
Have you tried writing a custom Starlark rule/macro to do this? Just wondering if there is some reason that wouldn't work.
rupertks commentedon Oct 24, 2019
cc @DavidGoldman
rajivshah3 commentedon Oct 24, 2019
rupertks commentedon Oct 24, 2019
Thanks! If you were able to get a Starlark rule/macro working that might also be useful to others.
(Also this issue might actually belong at https://github.com/bazelbuild/rules_apple)
rajivshah3 commentedon Oct 24, 2019
Yep, if I make one I'll post it here
I almost opened an issue there but I felt that it should be opened here instead as
objc_libraryis a built-in rule and not part ofrules_applejmmv commentedon Oct 31, 2019
This really feels like an issue for the configurability team. At least to get guidance on what to do.
katre commentedon Nov 8, 2019
This is part of the configurability roadmap, tracked specifically as flagless multiplatform builds.
Short answer: we want to support this, but we're not ready yet.