Repository: rust
Issue: error: internal compiler error: unexpected panic while compiling openssl-sys
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

I'm on M1 Mac, and am trying to compile openssl vendored for linux arm and linux aarch using the following:
```
cargo b --release --target aarch64-unknown-linux-gnu
cargo b --release --target x86_64-unknown-linux-gnu
```


### 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.
-->

`rustc --version --verbose`:
```
$ rustc --version --verbose
rustc 1.67.1 (d5a82bbd2 2023-02-07)
binary: rustc
commit-hash: d5a82bbd26e1ad8b7401f6a718a9c57c96905483
commit-date: 2023-02-07
host: aarch64-apple-darwin
release: 1.67.1
LLVM version: 15.0.6
```

### Error output

```
<output>
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
```
$ cargo b --release --target aarch64-unknown-linux-gnu
   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:33
stack backtrace:
   0:        0x102a265c0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb33e6e8152f78c95
   1:        0x102a77954 - core::fmt::write::hd33da007f7a27e39
   2:        0x102a19c78 - std::io::Write::write_fmt::h7edc10723862001e
   3:        0x102a263d4 - std::sys_common::backtrace::print::h895ee35b3f17b334
   4:        0x102a28e84 - std::panicking::default_hook::{{closure}}::h3b7ee083edc2ea3e
   5:        0x102a28bdc - std::panicking::default_hook::h4e7c2c28eba716f5
   6:        0x10ac34460 - rustc_driver[a234c6c3a001744e]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x102a2957c - std::panicking::rust_panic_with_hook::h1672176227032c45
   8:        0x102a29334 - std::panicking::begin_panic_handler::{{closure}}::h0b2d072f9624d32e
   9:        0x102a26a28 - std::sys_common::backtrace::__rust_end_short_backtrace::he9abda779115b93c
  10:        0x102a290d0 - _rust_begin_unwind
  11:        0x102aa3488 - core::panicking::panic_fmt::h23ae44661fec0889
  12:        0x102aa351c - core::panicking::panic::hce667fe29ffebbcd
  13:        0x10ade7324 - <rustc_codegen_llvm[4f55889b98689b27]::back::archive::LlvmArchiveBuilder as rustc_codegen_ssa[ea58c8650e29c10d]::back::archive::ArchiveBuilder>::build
  14:        0x10dfe3a8c - rustc_codegen_ssa[ea58c8650e29c10d]::back::link::link_binary
  15:        0x10ae3694c - <rustc_codegen_llvm[4f55889b98689b27]::LlvmCodegenBackend as rustc_codegen_ssa[ea58c8650e29c10d]::traits::backend::CodegenBackend>::link
  16:        0x10ad143b4 - <rustc_interface[5e186cb074b70a2d]::queries::Linker>::link
  17:        0x10ac10a3c - rustc_span[d521b58236fcfe34]::with_source_map::<core[c3092a4e7301e8c6]::result::Result<(), rustc_errors[4dbd0da469f7da4d]::ErrorGuaranteed>, rustc_interface[5e186cb074b70a2d]::interface::run_compiler<core[c3092a4e7301e8c6]::result::Result<(), rustc_errors[4dbd0da469f7da4d]::ErrorGuaranteed>, rustc_driver[a234c6c3a001744e]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  18:        0x10ac0475c - <scoped_tls[61f650bcd9c15f2b]::ScopedKey<rustc_span[d521b58236fcfe34]::SessionGlobals>>::set::<rustc_interface[5e186cb074b70a2d]::interface::run_compiler<core[c3092a4e7301e8c6]::result::Result<(), rustc_errors[4dbd0da469f7da4d]::ErrorGuaranteed>, rustc_driver[a234c6c3a001744e]::run_compiler::{closure#1}>::{closure#0}, core[c3092a4e7301e8c6]::result::Result<(), rustc_errors[4dbd0da469f7da4d]::ErrorGuaranteed>>
  19:        0x10abd9404 - std[1a4ed070555b2e10]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[5e186cb074b70a2d]::util::run_in_thread_pool_with_globals<rustc_interface[5e186cb074b70a2d]::interface::run_compiler<core[c3092a4e7301e8c6]::result::Result<(), rustc_errors[4dbd0da469f7da4d]::ErrorGuaranteed>, rustc_driver[a234c6c3a001744e]::run_compiler::{closure#1}>::{closure#0}, core[c3092a4e7301e8c6]::result::Result<(), rustc_errors[4dbd0da469f7da4d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c3092a4e7301e8c6]::result::Result<(), rustc_errors[4dbd0da469f7da4d]::ErrorGuaranteed>>
  20:        0x10abbf7b4 - <<std[1a4ed070555b2e10]::thread::Builder>::spawn_unchecked_<rustc_interface[5e186cb074b70a2d]::util::run_in_thread_pool_with_globals<rustc_interface[5e186cb074b70a2d]::interface::run_compiler<core[c3092a4e7301e8c6]::result::Result<(), rustc_errors[4dbd0da469f7da4d]::ErrorGuaranteed>, rustc_driver[a234c6c3a001744e]::run_compiler::{closure#1}>::{closure#0}, core[c3092a4e7301e8c6]::result::Result<(), rustc_errors[4dbd0da469f7da4d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c3092a4e7301e8c6]::result::Result<(), rustc_errors[4dbd0da469f7da4d]::ErrorGuaranteed>>::{closure#1} as core[c3092a4e7301e8c6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  21:        0x102a31974 - std::sys::unix::thread::Thread::new::thread_start::h92ee0ad602ca1aab
  22:        0x1860a206c - __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.67.1 (d5a82bbd2 2023-02-07) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C opt-level=3 -C linker-plugin-lto -C codegen-units=1 -C linker=aarch64-unknown-linux-gnu-gcc

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`
warning: build failed, waiting for other jobs to finish...
```

```
$ RUST_BACKTRACE=1 cargo b --release --target aarch64-unknown-linux-gnu
   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:33
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}>
   8: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
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.67.1 (d5a82bbd2 2023-02-07) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C opt-level=3 -C linker-plugin-lto -C codegen-units=1 -C linker=aarch64-unknown-linux-gnu-gcc

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`
warning: build failed, waiting for other jobs to finish...
```

</p>
</details>