Bitcode and Assembly?

I work for a third party library vendor and we are pretty sure our customers will ask us for a Bitcode version of our library.


We are very performance sensitive though, and we've optimized critical sections of our library in NEON assembly. When we compile to LLVM bitcode, we are assuming that NEON assembly will be encapsulated. Is that correct?


We're also worried about writing code in assembly though. Bitcode seems to leave open the possibility that our application could end up running on a platform who's capabilities we did not optimize for in advance. It seems like it might be a good idea to make sure our software paths are working well. Would it also be a good idea to attempt to drop out of NEON directly and use the LLVM SIMD intrinsics? I believe Accelerate was also tried and found to be too high level for our stuff. We're also multiplatform.

Accepted Reply

One small correction: The option name to include bitcode is "-fembed-bitcode".


As far as the question about whether Neon intrinsics are preferable to writing assembly code, I will say "yes", at least in most cases. If you use intrinsics, the compiler can optimize the code to run well on different processors, and it is generally easier to maintain C code than assembly. But, if you need to hand-optimize the assembly to get the performance you want, you can certainly do that and it should "just work" for iOS even when you have bitcode for the other parts of your code.

Replies

One aside:


> 2. When using Xcode, bitcode is only produced during archive build, not debug or release build.


The build setting that causes Xcode to pass `-fembed-bitcode` to the compiler in an archive build, but not in a release, or debug build, is `DEPLOYMENT_POSTPROCESSING`. Setting this to `YES` for your release configuration in combination with `ENABLE_BITCODE = YES` will cause Xcode to generate bitcode in regular release builds, as well.

You wrote: "For iOS, this should *just work*."


What about tvOS? Or Apple Watch?


Many thanks!

It seems there are several ways to include bitcode in normal build and not just archive:

* setting the flag to '-fembed-bitcode'

* setting user-defined setting 'BITCODE_GENERATION_MODE=bitcode'

* setting option DEPLOYMENT_POSTPROCESSING to YES


What is the correct way that will stick in future versions of Xcode?

Thanks for this validation of what I was finding as well. Sure took a while to narrow down why a local release build (not archive) for a device (not simulator) was still generating bitcode when I was expecting it to for only an build+archive action.