Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any indication as to which Apple platforms allow inline assembly?

I've been trying to decypher for a while now what the status is of inline assembly on the various platforms since Apple announced bitcode.

As of right now (Xcode 7.1.1) this is what I observe:

  • OSX - allowed (I expect will always)
  • iOS - allowed, even with bitcode (inline assembly is put into the bitcode) with probable confirmation
  • watchOS - not allowed (won't compile, gives inline assembly is disabled error)
  • tvOS - allowed

However, these are dubious conclusions since I don't have apps on every market to verify this.

I've seen some posts from open source libraries and apps that iOS apps will be rejected when containing inline assembly and bitcode. I've seen some posts that tvOS is similar to watchOS and won't let you use inline assembly (maybe fixed in latest Xcode?)

Is there some solid reference from Apple or.. ANYWHERE as to what platforms I can use inline assembly on?

like image 884
Earlz Avatar asked Nov 12 '15 20:11

Earlz


1 Answers

On any ARM platform (iOS, watchOS, tvOS), if you provide a mixed bitcode/asm archive, it can ONLY (see details below) be compiled for the same architecture as the embedded asm. This means that you might just as well submit a full binary application targeted at that architecture - there is absolutely no advantage to submitting bitcode (and therefore no reason for Apple to allow it).

As per Apple docs bitcode is required for watchOS and tvOS - and therefore inline assembly is disabled.

Note: For iOS apps, bitcode is the default, but optional. For watchOS and tvOS apps, bitcode is required. If you provide bitcode, all apps and frameworks in the app bundle (all targets in the project) need to include bitcode. After you distribute your app using iTunes Connect, you can download the dSYMs file for the build, described in Viewing and Importing Crashes in the Devices Window.

On X86, an archive containing a mixture of bitcode and X86 ASM can be compiled into a 64-bit application. It's not obvious that this is a sensible thing to do, because presumably the hand-crafted assembler is the performance critical section - but it can work.

The same is not true on ARM. The X86 case works because the X86 instruction set is a pure subset of X86_64 meaning that any X86 assembler is valid X86_64 assembler. On ARM a 64-bit processor needs to run in 32-bit state to execute 32-bit code. You cannot mix 32 and 64-bit assembly in the same application, as per the ARM docs (see Changing Execution State)

...Practically speaking, this means that you cannot have a mixed 32-bit and 64-bit application, because there is no direct way of calling between them.

This means that if you provide a mixture of bitcode plus inline asm targeting ARM architecture ARCH, practically the only thing that the AppStore can do (at least at present) is compile your bitcode for ARCH, which gives you (say) a fully 32 bit application running on a 64-bit processor. What's the point? It would be much simpler to upload a normal 32-bit executable with no bitcode in the first place.

like image 140
Airsource Ltd Avatar answered Oct 15 '22 23:10

Airsource Ltd