alexcrichton / openssl-src-rs

Source code and logic to build OpenSSL from source
Apache License 2.0
69 stars 115 forks source link

Vendored build of rust-openssl fails on x86_64-apple-ios #41

Open edbaskerville opened 5 years ago

edbaskerville commented 5 years ago

(Filed here as requested by @sfackler – copied from https://github.com/sfackler/rust-openssl/issues/1172)

When building a crate using vendored OpenSSL for iOS using cargo lipo, the build succeeds on aarch64-apple-ios but fails on x86_64-apple-ios.

Rust 1.37.0 / Xcode 10.2.1 / macOS 10.14.5.

There is no actual code in the crate (empty lib.rs). Cargo.toml includes:

[dependencies]
openssl = { version = "0.10", features = ["vendored"] }

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

Stderr messages begin with:

ar: creating archive libssl.a
Undefined symbols for architecture x86_64:
  "_aesni_cbc_encrypt", referenced from:
      _aesni_init_key in libcrypto.a(e_aes.o)
      _aesni_cbc_cipher in libcrypto.a(e_aes.o)

and end with:

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [apps/openssl] Error 1
make: *** [all] Error 2
thread 'main' panicked at '

Error building OpenSSL:
    Command: "make"
    Exit status: exit code: 2

    ', /Users/ed/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.6.0+1.1.1d/src/lib.rs:363:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

[ERROR cargo_lipo] Failed to build "testcrate" for "x86_64-apple-ios": Executing "/Users/ed/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo" "--color" "auto" "build" "-p" "testcrate" "--target" "x86_64-apple-ios" "--lib" finished with error status: exit code: 101

I did modify openssl-src-rs/src/lib.rs a couple months back to get this to work, but because (1) I didn't understand what I was doing and (2) doing it correctly should be very straightforward for someone who does...I'm going to just link to the history rather than actually submitting a pull request:

https://github.com/edbaskerville/openssl-src-rs/commits/master/src/lib.rs