rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.34k stars 12.72k forks source link

openssl-sys cross-compilation from MacOS to aarch64-unknown-linux-musl error #108969

Open Selyatin opened 1 year ago

Selyatin commented 1 year ago

Code

No specific code. Just a project that depends on tokio-native-tls with vendored feature enabled.

Meta

Exists on 1.70.0-nightly as well.

rustc --version --verbose:

rustc 1.68.0 (2c8cc3432 2023-03-06)
binary: rustc
commit-hash: 2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74
commit-date: 2023-03-06
host: aarch64-apple-darwin
release: 1.68.0
LLVM version: 15.0.6

and

rustc 1.70.0-nightly (39f2657d1 2023-03-09)
binary: rustc
commit-hash: 39f2657d1101b50f9b71ae460b762d330cc8426b
commit-date: 2023-03-09
host: aarch64-apple-darwin
release: 1.70.0-nightly
LLVM version: 15.0.7

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_codegen_llvm/src/back/archive.rs:367:67
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: <rustc_codegen_llvm::back::archive::LlvmArchiveBuilder as rustc_codegen_ssa::back::archive::ArchiveBuilder>::build
   4: rustc_codegen_ssa::back::link::link_binary
   5: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::link
   6: <rustc_interface::queries::Linker>::link
   7: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.68.0 (2c8cc3432 2023-03-06) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C opt-level=3 -C linker-plugin-lto -C linker=aarch64-unknown-linux-musl-gcc -C strip=symbols

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `openssl-sys`

``` RUST_BACKTRACE=full cargo build --release --target aarch64-unknown-linux-musl Compiling openssl-sys v0.9.80 Compiling openssl v0.10.45 thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_codegen_llvm/src/back/archive.rs:367:67 stack backtrace: 0: 0x102dbe978 - ::fmt::h1027694b54c428d0 1: 0x102e0ecf0 - core::fmt::write::hb60cc483d75d6594 2: 0x102db2374 - std::io::Write::write_fmt::h6c907fc10bdb865b 3: 0x102dbe78c - std::sys_common::backtrace::print::h1a62458f14dd2797 4: 0x102dc12e0 - std::panicking::default_hook::{{closure}}::h03c6918072c36210 5: 0x102dc1038 - std::panicking::default_hook::hd0f3cf66b6a0fb5e 6: 0x10b09c4fc - rustc_driver[7e9c70f5b960cc99]::DEFAULT_HOOK::{closure#0}::{closure#0} 7: 0x102dc19d8 - std::panicking::rust_panic_with_hook::h9ed2a7a45efbd034 8: 0x102dc1790 - std::panicking::begin_panic_handler::{{closure}}::h535244d6186e3534 9: 0x102dbede0 - std::sys_common::backtrace::__rust_end_short_backtrace::ha542aa49031c5cb5 10: 0x102dc152c - _rust_begin_unwind 11: 0x102e3a728 - core::panicking::panic_fmt::hc1e7b11add95109d 12: 0x102e3a798 - core::panicking::panic::h38074b3ed47cd9d2 13: 0x10b271198 - ::build 14: 0x10e43e29c - rustc_codegen_ssa[6e080b17af57daae]::back::link::link_binary 15: 0x10b2b412c - ::link 16: 0x10b11fe60 - ::link 17: 0x10b08d008 - rustc_span[c5f28c4f2d409cdb]::with_source_map::, rustc_interface[5368bf6011624330]::interface::run_compiler, rustc_driver[7e9c70f5b960cc99]::run_compiler::{closure#1}>::{closure#0}::{closure#0}> 18: 0x10b042450 - std[bed70ebd0cf395b0]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver[7e9c70f5b960cc99]::run_compiler::{closure#1}>::{closure#0}, core[bacde730fb80eda9]::result::Result<(), rustc_errors[3041147eb80b6979]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bacde730fb80eda9]::result::Result<(), rustc_errors[3041147eb80b6979]::ErrorGuaranteed>> 19: 0x10b024fe0 - <::spawn_unchecked_, rustc_driver[7e9c70f5b960cc99]::run_compiler::{closure#1}>::{closure#0}, core[bacde730fb80eda9]::result::Result<(), rustc_errors[3041147eb80b6979]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bacde730fb80eda9]::result::Result<(), rustc_errors[3041147eb80b6979]::ErrorGuaranteed>>::{closure#1} as core[bacde730fb80eda9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 20: 0x102dc9e18 - std::sys::unix::thread::Thread::new::thread_start::hd47d33498d4475f3 21: 0x1a722106c - __pthread_deallocate error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.68.0 (2c8cc3432 2023-03-06) running on aarch64-apple-darwin note: compiler flags: --crate-type lib -C opt-level=3 -C linker-plugin-lto -C linker=aarch64-unknown-linux-musl-gcc -C strip=symbols note: some of the compiler flags provided by cargo are hidden query stack during panic: end of query stack error: could not compile `openssl-sys` ```

Selyatin commented 1 year ago

Issue was fixed once I used the compiler & linker from the musl-cross-homebrew-formula, so not sure if it's still relevant or not.

Here's the old formula that I used.

franklinblanco commented 1 year ago

@Selyatin Hey, have you tried compiling for x86_64? I had to move like 18 microservices to use rustls-tls instead of openssl on all dependencies to avoid this issue.

Selyatin commented 1 year ago

@franklinblanco works fine on x86_64, now it works just fine on aarch64 as well after changing the formula. So I'm thinking of closing the issue.

Selyatin commented 1 year ago

Yeah well I'm getting the same issue now, no idea why.

jmg-duarte commented 11 months ago

I spent all day tracking this down. In my case, I had a aarch64 build failing inside a Docker container.

After checking every openssl related dependency on my project, I found we we're using cc 1.0.84 which was yanked, forcing 1.0.83 solved this issue.

I hope this helps some of you!