iOS fat binaries: should every arch include bitcode?
Asked Answered
L

1

6

When building a library that is to be used in bitcode-enabled apps, does each arch in the fat binary need to be built with -fembed-bitcode or only one of them?

One of them because the bitcode is architecture-independent and will just be duplicated?

All of them because pre-processor commands may alter the code based on architecture (e.g. NSInteger width)?

Excluding x86 slices otherwise duplicate symbol _llvm.cmdline happens? - rdar://21884601

Leoleod answered 22/7, 2015 at 14:59 Comment(3)
Bitcode is not architecture-independent, hence each slice in a fat binary should include bitcode.Outdo
@Outdo Have you got a reference for that?Leoleod
Posted an answer with links.Outdo
O
8

Bitcode is just another form of LLVM IR, which is architecture-dependent.

Which means that each slice in your fat binary should contain its own bitcode section.

Update: I wrote a blog-post about Bitcode, you may find there some useful details: Bitcode Demystified

Outdo answered 31/7, 2015 at 10:3 Comment(4)
Where does it say bitcode is architecture-dependent?Leoleod
Fair enough. Can't find it in documentation as well. But I can say for sure that's different for each slice. You can check it out manually by calling clang -S -emit-llvm -arch arch_name main.c using different 'arch_name' and discover LLVM IR.Outdo
I though the whole point of including bitcode was so Apple can compile it for different architectures in the future.Leoleod
In fact, if you do not include bitcode for each arch, you'll get failures at archive time.Thrift

© 2022 - 2024 — McMap. All rights reserved.