sfackler / rust-openssl

OpenSSL bindings for Rust
1.4k stars 749 forks source link

Vendored crate build fails in OSX Cross environment: archive has no symbols #1873

Open xrl opened 1 year ago

xrl commented 1 year ago

Posted on https://github.com/cross-rs/cross/issues/1243 but I wanted to bring it over here in case someone had seen this before.

I am building redistributable binaries for Darwin (x86_64 for now), using custom-made cross-rs Dockerimages. The current failures are with the Apple SDK 12.0.

The public reproduction: https://github.com/xrl/broken-ssl-example . The project only has one dependency, openssl:

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

The error:

  --- stderr
  x86_64-apple-darwin21.1-ar: creating archive apps/libapps.a
  x86_64-apple-darwin21.1-ar: creating archive libcrypto.a
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(async_null.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(async_win.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(cms_cd.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(dso_dl.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(dso_dlfcn.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(dso_vms.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(dso_win32.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(ebcdic.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(ecp_nistp224.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(ecp_nistp256.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(ecp_nistp521.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(ecp_nistputil.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(e_camellia.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(e_idea.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(e_rc5.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(e_seed.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(m_md2.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(rand_egd.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(rand_vms.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(rand_win.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(threads_none.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libcrypto.a(threads_win.o) has no symbols
  x86_64-apple-darwin21.1-ar: creating archive libssl.a
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libssl.a(ssl_utst.o) has no symbols
  /opt/osxcross/bin/x86_64-apple-darwin21.1-ranlib: file: libssl.a(t1_trce.o) has no symbols
  ranlib: /target/x86_64-apple-darwin/release/build/openssl-sys-aa87580c099679b3/out/openssl-build/install/lib/libcrypto.a.new: malformed archive
  make: *** [Makefile:326: install_dev] Error 1
  thread 'main' panicked at '

  Error installing OpenSSL:
      Command: cd "/target/x86_64-apple-darwin/release/build/openssl-sys-aa87580c099679b3/out/openssl-build/build/src" && "make" "install_dev"
      Exit status: exit status: 2

      ', /cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.25.2+1.1.1t/src/lib.rs:505:13
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Command exited with non-zero status 101
26.78user 1.17system 2:08.36elapsed 21%CPU (0avgtext+0avgdata 161096maxresident)k
0inputs+326048outputs (0major+216276minor)pagefaults 0swaps

The full cross build log: https://gist.github.com/xrl/eeb05f044281a30ddf7b2dbdfcd7d4b5

sfackler commented 1 year ago

This seems like a problem with your toolchain. IIRC the binutils that osxcross builds creates a ranlib that doesn't actually understand osx archives.