Repository: rust
Issue: Error: `cargo build -Zbuild-std=core --target=bpfel-unknown-none` on aarch64-unknown-linux-gnu
Labels: A-linkage,I-ICE,T-compiler,O-eBPF

<!--
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

```Rust
// src/main.rs
#![no_std]
#![feature(start)]

#[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
    0
}

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
    unsafe { core::hint::unreachable_unchecked() }
}
---
// build.rs
use std::env;
use std::path::PathBuf;

use bindgen;

fn main() {
    println!("cargo:rustc-link-lib=bz2");

    println!("cargo:rerun-if-changed=wrapper.h");

    let bindings = bindgen::Builder::default()
        .header("wrapper.h")
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        .clang_arg("-I/usr/include/aarch64-linux-gnu")
        .generate()
        .expect("Unable to generate bindings");

    // Write the bindings to the $OUT_DIR/bindings.rs file.
    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
    bindings
        .write_to_file(out_path.join("bindings.rs"))
        .expect("Couldn't write bindings!");
}
```


### 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 1.75.0-nightly (e0d7ed1f4 2023-10-01)
binary: rustc
commit-hash: e0d7ed1f453fb54578cc96dfea859b0e7be15016
commit-date: 2023-10-01
host: aarch64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.2
```

### Error output

```
thread 'rustc' panicked at compiler/rustc_codegen_ssa/src/back/linker.rs:1884:9:
external dylibs not supported
stack backtrace:
   0:     0xfffface8231c - std::backtrace_rs::backtrace::libunwind::trace::h15fd799bb4c6e0df
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0xfffface8231c - std::backtrace_rs::backtrace::trace_unsynchronized::h3a85c751e6883cb9
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0xfffface8231c - std::backtrace::Backtrace::create::h6ce5e9c8fd81b495
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/backtrace.rs:331:13
   3:     0xffffadaa1258 - std[ecead54e5ef6b68e]::panicking::update_hook::<alloc[a784b4add7c892ba]::boxed::Box<rustc_driver_impl[50c65c1143d3c3b2]::install_ice_hook::{closure#0}>>::{closure#0}
   4:     0xfffface9c964 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h5a08fcd16fe3bf9c
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/alloc/src/boxed.rs:2021:9
   5:     0xfffface9c964 - std::panicking::rust_panic_with_hook::hb7c396703f16fb7a
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/panicking.rs:735:13
   6:     0xfffface9c6ac - std::panicking::begin_panic_handler::{{closure}}::h751851c23f82412a
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/panicking.rs:601:13
   7:     0xfffface99ce4 - std::sys_common::backtrace::__rust_end_short_backtrace::hc3198b325a94a5a5
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/sys_common/backtrace.rs:170:18
   8:     0xfffface9c448 - rust_begin_unwind
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/panicking.rs:597:5
   9:     0xfffface649d4 - core::panicking::panic_fmt::h674221e51070cfff
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/core/src/panicking.rs:72:14
  10:     0xffffb1a66470 - <rustc_codegen_ssa[aadcf4f7e81c667d]::back::linker::BpfLinker as rustc_codegen_ssa[aadcf4f7e81c667d]::back::linker::Linker>::link_dylib
  11:     0xffffb1a46840 - rustc_codegen_ssa[aadcf4f7e81c667d]::back::link::add_native_libs_from_crate
  12:     0xffffb1a41ef4 - rustc_codegen_ssa[aadcf4f7e81c667d]::back::link::linker_with_args
  13:     0xffffb1a3ae40 - rustc_codegen_ssa[aadcf4f7e81c667d]::back::link::link_natively
  14:     0xffffb1a376bc - rustc_codegen_ssa[aadcf4f7e81c667d]::back::link::link_binary
  15:     0xffffadd98df4 - <rustc_codegen_llvm[32efad79566345ff]::LlvmCodegenBackend as rustc_codegen_ssa[aadcf4f7e81c667d]::traits::backend::CodegenBackend>::link
  16:     0xffffadbf1254 - <rustc_interface[ea3203495a139f33]::queries::Linker>::link
  17:     0xffffadab0410 - rustc_span[44fb1fb82b8eb99e]::set_source_map::<core[bd555b9c7313bef9]::result::Result<(), rustc_span[44fb1fb82b8eb99e]::ErrorGuaranteed>, rustc_interface[ea3203495a139f33]::interface::run_compiler<core[bd555b9c7313bef9]::result::Result<(), rustc_span[44fb1fb82b8eb99e]::ErrorGuaranteed>, rustc_driver_impl[50c65c1143d3c3b2]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  18:     0xffffadaa0378 - std[ecead54e5ef6b68e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ea3203495a139f33]::util::run_in_thread_with_globals<rustc_interface[ea3203495a139f33]::interface::run_compiler<core[bd555b9c7313bef9]::result::Result<(), rustc_span[44fb1fb82b8eb99e]::ErrorGuaranteed>, rustc_driver_impl[50c65c1143d3c3b2]::run_compiler::{closure#1}>::{closure#0}, core[bd555b9c7313bef9]::result::Result<(), rustc_span[44fb1fb82b8eb99e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bd555b9c7313bef9]::result::Result<(), rustc_span[44fb1fb82b8eb99e]::ErrorGuaranteed>>
  19:     0xffffadaa1548 - <<std[ecead54e5ef6b68e]::thread::Builder>::spawn_unchecked_<rustc_interface[ea3203495a139f33]::util::run_in_thread_with_globals<rustc_interface[ea3203495a139f33]::interface::run_compiler<core[bd555b9c7313bef9]::result::Result<(), rustc_span[44fb1fb82b8eb99e]::ErrorGuaranteed>, rustc_driver_impl[50c65c1143d3c3b2]::run_compiler::{closure#1}>::{closure#0}, core[bd555b9c7313bef9]::result::Result<(), rustc_span[44fb1fb82b8eb99e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bd555b9c7313bef9]::result::Result<(), rustc_span[44fb1fb82b8eb99e]::ErrorGuaranteed>>::{closure#1} as core[bd555b9c7313bef9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  20:     0xffffacea67ac - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbce7c765369d32e9
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/alloc/src/boxed.rs:2007:9
  21:     0xffffacea67ac - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbf6d2b857b638f99
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/alloc/src/boxed.rs:2007:9
  22:     0xffffacea67ac - std::sys::unix::thread::Thread::new::thread_start::h40f91f03400d1139
                               at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/sys/unix/thread.rs:108:17
  23:     0xffffaccbd5c8 - <unknown>
  24:     0xffffacd25d1c - <unknown>
  25:                0x0 - <unknown>


rustc version: 1.75.0-nightly (e0d7ed1f4 2023-10-01)
platform: aarch64-unknown-linux-gnu
```

<!--
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>Backtrace</strong></summary>
<p>

```
thread 'rustc' panicked at compiler/rustc_codegen_ssa/src/back/linker.rs:1884:9:
external dylibs not supported
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/e0d7ed1f453fb54578cc96dfea859b0e7be15016/library/core/src/panicking.rs:72:14
   2: <rustc_codegen_ssa::back::linker::BpfLinker as rustc_codegen_ssa::back::linker::Linker>::link_dylib
   3: rustc_codegen_ssa::back::link::add_native_libs_from_crate
   4: rustc_codegen_ssa::back::link::linker_with_args
   5: rustc_codegen_ssa::back::link::link_natively
   6: rustc_codegen_ssa::back::link::link_binary
   7: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::link
   8: <rustc_interface::queries::Linker>::link
   9: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```

</p>
</details>