Repository: rust
Issue: openssl-sys cross-compilation from MacOS to aarch64-unknown-linux-musl error
Labels: I-ICE,T-compiler,C-bug

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code

`No specific code. Just a project that depends on tokio-native-tls with vendored feature enabled.`

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

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`
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong></strong></summary>
<p>

```
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 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::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 - <rustc_codegen_llvm[cf8e79ba0618e858]::back::archive::LlvmArchiveBuilder as rustc_codegen_ssa[6e080b17af57daae]::back::archive::ArchiveBuilder>::build
  14:        0x10e43e29c - rustc_codegen_ssa[6e080b17af57daae]::back::link::link_binary
  15:        0x10b2b412c - <rustc_codegen_llvm[cf8e79ba0618e858]::LlvmCodegenBackend as rustc_codegen_ssa[6e080b17af57daae]::traits::backend::CodegenBackend>::link
  16:        0x10b11fe60 - <rustc_interface[5368bf6011624330]::queries::Linker>::link
  17:        0x10b08d008 - rustc_span[c5f28c4f2d409cdb]::with_source_map::<core[bacde730fb80eda9]::result::Result<(), rustc_errors[3041147eb80b6979]::ErrorGuaranteed>, rustc_interface[5368bf6011624330]::interface::run_compiler<core[bacde730fb80eda9]::result::Result<(), rustc_errors[3041147eb80b6979]::ErrorGuaranteed>, rustc_driver[7e9c70f5b960cc99]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  18:        0x10b042450 - std[bed70ebd0cf395b0]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[5368bf6011624330]::util::run_in_thread_pool_with_globals<rustc_interface[5368bf6011624330]::interface::run_compiler<core[bacde730fb80eda9]::result::Result<(), rustc_errors[3041147eb80b6979]::ErrorGuaranteed>, 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 - <<std[bed70ebd0cf395b0]::thread::Builder>::spawn_unchecked_<rustc_interface[5368bf6011624330]::util::run_in_thread_pool_with_globals<rustc_interface[5368bf6011624330]::interface::run_compiler<core[bacde730fb80eda9]::result::Result<(), rustc_errors[3041147eb80b6979]::ErrorGuaranteed>, 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`
```

</p>
</details>