Repository: rust
Issue: Build to AArch64 errors with "error: fixup value out of range"
Labels: A-linkage,A-LLVM,I-ICE,T-compiler,C-bug,D-terse,O-AArch64

### Code

Something to do with using these structures which would have a size of.. roughly 2^36.
Obviously, this shouldn't work in practice, but this error is very cryptic; and it compiles on x86.
It's not triggered on just this; it needs to be with other code. I'm not sure the exact specifics.

https://github.com/midnightveil/microkit-rustc-bug This repo is a much of a minification I could do in a few hours. Much of the code near the end of build_system() that touches the results of PGD/PUD etc once removed seems to make it work again. The relevant struct definitions are at the bottom of the file.


```Rust
#[derive(Copy, Clone)]
struct PGD {
    puds: [Option<PUD>; 512],
}

impl PGD {
    fn new() -> Self {
        PGD { puds: [None; 512] }
    }
}

#[derive(Copy, Clone)]
struct PUD {
    dirs: [Option<DIR>; 512],
}

impl PUD {
    fn new() -> Self {
        PUD { dirs: [None; 512] }
    }
}

#[derive(Copy, Clone)]
struct DIR {
    pts: [Option<PT>; 512],
}

impl DIR {
    fn new() -> Self {
        DIR { pts: [None; 512] }
    }
}

#[derive(Copy, Clone)]
struct PT {
    pages: [u64; 512],
}

impl PT {
    fn new() -> Self {
        PT {
            pages: [u64::MAX; 512],
        }
    }
}

```


### 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.
-->

Using either a macOS host, or with `cargo +nightly rustc --target aarch64-unknown-linux-gnu` on Linux; it works fine on x86-64 builds (the compiler doesn't crash at least). It's specific to AArch64 targets.

`rustc --version --verbose`:
```
rustc 1.82.0-nightly (636d7ff91 2024-08-19)
binary: rustc
commit-hash: 636d7ff91b9847d6d43c7bbe023568828f6e3246
commit-date: 2024-08-19
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0
```

### Error output

```
error: fixup value out of range
```

With `-Z treat-err-as-bug=1`:

```
thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs:1803:17:
aborting due to `-Z treat-err-as-bug=1`
stack backtrace:
   0:     0x7f427c0aa7a5 - std::backtrace::Backtrace::create::hd44cf642eac7dd13
   1:     0x7f427a5aa8d5 - std::backtrace::Backtrace::force_capture::h1c6a5336f4788f1c
   2:     0x7f427974448e - std[f4f7433038ca58d7]::panicking::update_hook::<alloc[5afee40ebe45352b]::boxed::Box<rustc_driver_impl[bf262a983b89031b]::install_ice_hook::{closure#0}>>::{closure#0}
   3:     0x7f427a5c2747 - std::panicking::rust_panic_with_hook::h2812277631d65a18
   4:     0x7f427a5c23d3 - std::panicking::begin_panic_handler::{{closure}}::h1cbf6e1a8ab08919
   5:     0x7f427a5bfc09 - std::sys::backtrace::__rust_end_short_backtrace::he514a61806a4f1e2
   6:     0x7f427a5c20d4 - rust_begin_unwind
   7:     0x7f42774a80f3 - core::panicking::panic_fmt::hc4e73aa92e327778
   8:     0x7f427c933996 - <rustc_errors[522b8b3df7a583e8]::DiagCtxtInner>::panic_if_treat_err_as_bug.cold
   9:     0x7f427bfce210 - <rustc_errors[522b8b3df7a583e8]::DiagCtxtInner>::emit_diagnostic::{closure#3}
  10:     0x7f427bfd16bf - rustc_interface[632640cbf95a869f]::callbacks::track_diagnostic::<core[688a17d15409e27]::option::Option<rustc_span[7b3448155f652e2d]::ErrorGuaranteed>>
  11:     0x7f427bfcfabe - <rustc_errors[522b8b3df7a583e8]::DiagCtxtInner>::emit_diagnostic
  12:     0x7f427bfcf95d - <rustc_errors[522b8b3df7a583e8]::DiagCtxtHandle>::emit_diagnostic
  13:     0x7f4278f6b2bb - <() as rustc_errors[522b8b3df7a583e8]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  14:     0x7f427bd62d64 - <rustc_codegen_ssa[65d2e4fac7b81301]::back::write::SharedEmitterMain>::check
  15:     0x7f427bd5ef44 - <rustc_codegen_llvm[d285dc14666e2f1]::LlvmCodegenBackend as rustc_codegen_ssa[65d2e4fac7b81301]::traits::backend::CodegenBackend>::join_codegen
  16:     0x7f427bd5c006 - <rustc_interface[632640cbf95a869f]::queries::Linker>::link
  17:     0x7f427bbe1de3 - rustc_interface[632640cbf95a869f]::interface::run_compiler::<core[688a17d15409e27]::result::Result<(), rustc_span[7b3448155f652e2d]::ErrorGuaranteed>, rustc_driver_impl[bf262a983b89031b]::run_compiler::{closure#0}>::{closure#1}
  18:     0x7f427bbc7290 - std[f4f7433038ca58d7]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[632640cbf95a869f]::util::run_in_thread_with_globals<rustc_interface[632640cbf95a869f]::util::run_in_thread_pool_with_globals<rustc_interface[632640cbf95a869f]::interface::run_compiler<core[688a17d15409e27]::result::Result<(), rustc_span[7b3448155f652e2d]::ErrorGuaranteed>, rustc_driver_impl[bf262a983b89031b]::run_compiler::{closure#0}>::{closure#1}, core[688a17d15409e27]::result::Result<(), rustc_span[7b3448155f652e2d]::ErrorGuaranteed>>::{closure#0}, core[688a17d15409e27]::result::Result<(), rustc_span[7b3448155f652e2d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[688a17d15409e27]::result::Result<(), rustc_span[7b3448155f652e2d]::ErrorGuaranteed>>
  19:     0x7f427bbc78fa - <<std[f4f7433038ca58d7]::thread::Builder>::spawn_unchecked_<rustc_interface[632640cbf95a869f]::util::run_in_thread_with_globals<rustc_interface[632640cbf95a869f]::util::run_in_thread_pool_with_globals<rustc_interface[632640cbf95a869f]::interface::run_compiler<core[688a17d15409e27]::result::Result<(), rustc_span[7b3448155f652e2d]::ErrorGuaranteed>, rustc_driver_impl[bf262a983b89031b]::run_compiler::{closure#0}>::{closure#1}, core[688a17d15409e27]::result::Result<(), rustc_span[7b3448155f652e2d]::ErrorGuaranteed>>::{closure#0}, core[688a17d15409e27]::result::Result<(), rustc_span[7b3448155f652e2d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[688a17d15409e27]::result::Result<(), rustc_span[7b3448155f652e2d]::ErrorGuaranteed>>::{closure#1} as core[688a17d15409e27]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  20:     0x7f427bbc7c6b - std::sys::pal::unix::thread::Thread::new::thread_start::hcb43f834109dfd4d
  21:     0x7f427d64a272 - start_thread
  22:     0x7f427d6c5dec - clone3
  23:                0x0 - <unknown>
```

</p>
</details>