Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile vendored version for iOS #1331

Closed
ivnsch opened this issue Aug 21, 2020 · 1 comment
Closed

Can't compile vendored version for iOS #1331

ivnsch opened this issue Aug 21, 2020 · 1 comment

Comments

@ivnsch
Copy link

ivnsch commented Aug 21, 2020

Trying to use rust-openssl on iOS:

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

Build script:

#!/bin/bash

# Ensure that `cargo` is in PATH, using the default location.
export PATH="$PATH:${HOME}/.cargo/bin"

# This obviously doesn't work for the app, only to build on desktop.
export OPENSSL_DIR="/usr/local/opt/openssl"

set -x

# Go to repo's root
cd "${SRCROOT}/../"

# Build binaries
RUSTFLAGS="-Z embed-bitcode" cargo +ios-arm64 build --target aarch64-apple-ios --release --lib
cargo build --target=x86_64-apple-ios --release

# Create fat binary
libtool -static -o ./ios_app/core/libcore ./target/aarch64-apple-ios/release/libcore.a ./target/x86_64-apple-ios/release/libcore.a

When the app is linking, it fails:

+ cd /Users/.../ios_app/../
+ RUSTFLAGS='-Z embed-bitcode'
+ cargo +ios-arm64 build --target aarch64-apple-ios --release --lib
   Compiling openssl v0.10.30
   Compiling openssl-sys v0.9.58
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib" "/Users/.../dev/match/apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4.build_script_build.2u6htd52-cgu.0.rcgu.o" "/Users/.../apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4.build_script_build.2u6htd52-cgu.1.rcgu.o" "/Users/.../apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4.build_script_build.2u6htd52-cgu.2.rcgu.o" "/Users/.../apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4.build_script_build.2u6htd52-cgu.3.rcgu.o" "/Users/.../apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4.build_script_build.2u6htd52-cgu.4.rcgu.o" "/Users/.../apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4.build_script_build.2u6htd52-cgu.5.rcgu.o" "/Users/.../apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4.build_script_build.2u6htd52-cgu.6.rcgu.o" "/Users/.../apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4.build_script_build.2u6htd52-cgu.7.rcgu.o" "/Users/.../apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4.build_script_build.2u6htd52-cgu.8.rcgu.o" "/Users/.../apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4.build_script_build.2u6htd52-cgu.9.rcgu.o" "-o" "/Users/.../apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4" "/Users/.../apps/target/release/build/openssl-c9dd36216d69fda4/build_script_build-c9dd36216d69fda4.2v08avjo20u7n477.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/.../apps/target/release/deps" "-L" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/libstd-fda0e7855b9402e8.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-8db4d246b93490a3.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-045cb03abe14acb0.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-08f40434a91057b9.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-85e9f4ed0eefd4eb.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-268fe4d097282e32.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-58ce83a0b48d29df.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/libunwind-93b6de48441f0c71.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-10b40de50aced175.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/liblibc-d2f2a948e54a1b51.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/liballoc-b63539fad2a53809.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-115f860040d4f0e8.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/libcore-2952e6310f3dc706.rlib" "/Users/.../.rust-ios-arm64/toolchain-1.43.0/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-d051efb0275a42f6.rlib" "-lSystem" "-lresolv" "-lc" "-lm"
  = note: ld: library not found for -lSystem
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: aborting due to previous error

error: could not compile `openssl`.

According to the docs, for vendored OpenSSL I need a C compiler, perl and make installed:

If the vendored Cargo feature is enabled, the openssl-src crate will be used to compile and statically link to a copy of OpenSSL. The build process requires a C compiler, perl, and make.

I checked: gcc, perl and make run in the terminal. The xcode tools also seem to be installed. I also ran brew update and brew upgrade gcc, just in case.

Someone suggested adding the path to libSystem.a to the linker flags. I couldn't find exactly libSystem.a in the SDK. I tried with libSystem.tbd and it didn't work.

I found a maybe related issue: alexcrichton/openssl-src-rs#41. My error is different and getting it both on the simulator and device.

Any ideas?

@sfackler
Copy link
Owner

I am not personally familiar with building things for iOS. The issue on openssl-src-rs would be the thing to refer to though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants