4 ms·
Can someone ELIF what's a toolchain for iOS bitcode?
by tbojanin 7y ago
Can someone ELIF what's a toolchain for iOS bitcode?
- taneq 7y agoIf I'm reading it right, it lets you build Rust libraries so you can use them in iOS programs.
- rapsey 7y agoYou can already build for iOS, just not apple tv or watch without bitcode. For building for iphone this is not needed.
- MuffinFlavored 7y agoLibraries only, or can you write native iOS apps 100% in Rust, no Swift?
- quells 7y agoYou would need at least a bridging layer (of Objective-C) to so that your app code could use the system frameworks and respond to events (user input, network, sensors, etc).
- Diggsey 7y agoObjective-C shares calling conventions and struct layout with C, so theoretically you could directly call the system frameworks from Rust via extern "C" functions.
- MuffinFlavored 7y agoIt'd be super cool to see a 100% Rust (with extern "C" calls) Hello, world! iOS compatible app.
- holy_city 7y agoNot even theoretically, the bindings for the runtime are out there [1] with some nifty helper macros. [1] https://github.com/SSheldon/rust-objc https://github.com/SSheldon/rust-objc
- bluejekyll 7y agoApple requires bitcode submissions for tvOS and watchOS, this has effectively meant that you needed Apple’s toolchain to build and distribute binaries for those platforms. Bitcode is an intermediate format produced by LLVM, which allows for optimization passes to be applied to it across different languages. For example, C, C++, Swift, ObjC, and Rust can all benefit from some of the same bitcode optimization passes. In theory Apple wanted this so they could improve the performance of applications when distributed on some of their platforms, though the benefits and potential of this has been a bit dubious. It did mean that Rust (until this) couldn’t easily target those Apple products.
- anonova 7y agoI was under the impression that it wasn't for performance but for distribution, i.e., to optimize for app size. Instead of having a fat binary crosscompiled for different architectures, Apple uses the bitcode to compile and distribute per architecture. It's part of the "app thinning" process.
- bluejekyll 7y agoI think you’re right that that is the primary reason today. In their marketing material I think they always use the term “reoptimize”, of course, that can mean for size. Thanks for the correction.
- MaxGabriel 7y agoTo expand on this, it also lets them target new CPU architectures without having developers recompile code for that architecture. This lets them make incremental improvements (eg armv7), but would also let them use their own CPU architecture should they move away from Intel/ARM. As an example here’s Chris Lattner tweeting about that use case: https://twitter.com/clattner_llvm/status/1091186386634326017?s=21 https://twitter.com/clattner_llvm/status/1091186386634326017...
- saagarjha 7y ago> but would also let them use their own CPU architecture should they move away from Intel/ARM Only if their new architecture looked a lot like Intel/ARM. Bitcode can’t paper over all architectural differences.