cargo-lipo icon indicating copy to clipboard operation
cargo-lipo copied to clipboard

bitcode support

Open extrawurst opened this issue 6 years ago • 7 comments

I thought rust supports bitcode generation. How can I make cargo lipo build such libraries?

extrawurst avatar Jan 02 '19 00:01 extrawurst

Please see the upstream issue https://github.com/rust-lang/rust/issues/35968: Support is apparently experimental and can be enabled using RUSTFLAGS="-Z embed-bitcode" cargo lipo --release, but may not work on all architectures.

TimNN avatar Jan 02 '19 10:01 TimNN

Right now I'm having trouble with the i386 architecture.

When you build with xcode you'll notice this warning:

ld: warning: ignoring file /Users/maxalex/ditto/ditto-crdt-lib/target/universal/release/libditto.a, missing required architecture i386 in file /Users/maxalex/ditto/ditto-crdt-lib/target/universal/release/libditto.a (2 slices)

What I'm noticing is that when I run:

RUSTFLAGS="-Z embed-bitcode" cargo lipo --release;

It builds for all of them except for i386-apple-ios, armv7-apple-ios, armv7s-apple-ios

  • aarch64-apple-ios
  • armv7-apple-ios (this one never makes it)
  • armv7s-apple-ios (this one never makes it)
  • x86_64-apple-ios
  • i386-apple-ios . (this one never makes it)

I've run

rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios;

And still cargo lipo seems to skip it..

Update:

If you're using Xcode 10, i386 has been removed!

mbalex99 avatar Jan 21 '19 20:01 mbalex99

^^^ i'm seeing the same thing , it wont build 32bit targets.. i have an old iPad2 i'd like to be able to test on. 32bit keeps devices out of landfill.. and devices can keep getting smaller,cheaper (watches, IoT things) .. i'm surprised people want to consider 32bit "obsolete"

~/Desktop/rustios/greetings/cargo$ rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios
info: component 'rust-std' for target 'aarch64-apple-ios' is up to date
info: component 'rust-std' for target 'armv7-apple-ios' is up to date
info: component 'rust-std' for target 'armv7s-apple-ios' is up to date
info: component 'rust-std' for target 'x86_64-apple-ios' is up to date
info: component 'rust-std' for target 'i386-apple-ios' is up to date
~/Desktop/rustios/greetings/cargo$ more Cargo.toml 
[package]
name = "greetings"
version = "0.1.1"
edition = "2018"
publish = false

[lib]
name = "greetings"
crate-type = ["staticlib"]

[dependencies]
~/Desktop/rustios/greetings/cargo$ cargo lipo --release
[INFO  cargo_lipo::meta] Will build universal library for ["greetings"]
[INFO  cargo_lipo::lipo] Building "greetings" for "aarch64-apple-ios"
   Compiling greetings v0.1.1 (/Users/walter/Desktop/rustios/greetings/cargo)
    Finished release [optimized] target(s) in 2.04s
[INFO  cargo_lipo::lipo] Building "greetings" for "x86_64-apple-ios"
   Compiling greetings v0.1.1 (/Users/walter/Desktop/rustios/greetings/cargo)
    Finished release [optimized] target(s) in 1.39s
[INFO  cargo_lipo::lipo] Creating universal library for greetings
~/Desktop/rustios/greetings/cargo$ 

dobkeratops avatar Feb 17 '19 21:02 dobkeratops

@dobkeratops: I'm not quite sure what your issue is, but I don't think it's related to the previous comments.

In any case, since ~recently cargo-lipo only builds for 64 bit targets by default (aarch64-apple-ios and x86_64-apple-ios). You can use the --targets flag to specify all four targets if necessary.

TimNN avatar Feb 17 '19 21:02 TimNN

ah i see now you can re-enable 32bit builds as you say (cargo lipo --targets=aarch64-apple-ios,x86_64-apple-ios,armv7-apple-ios,armv7s-apple-ios)
#22 , I see it was disabled by default (to reduce build times..)

I was about to open an issue but I see the person above had bumped into the same thing (not getting all the targets he assumed would be done)

dobkeratops avatar Feb 17 '19 22:02 dobkeratops

@TimNN there should be indications in readme that 32 bits are not built by default and an example command for building these should be documented as well in my opinion. It is odd to have to go in the issues to learn this.

ndusart avatar Jun 19 '19 09:06 ndusart

It would be nice to have a mention about the default targets in the README. I was about to post a new issue about the missing targets, but fortunately found the reason here.

JoyceBabu avatar Jul 15 '19 13:07 JoyceBabu