Fails to link with `rust-lld` with an out of range error in latest Rust Nightly
w-henderson opened this issue · comments
I'm trying to build a project using bootimage and it successfully builds when I run cargo build
(not using bootimage to make it bootable), but fails to compile when I run cargo run
on the final step of compiling bootloader with bootimage. I wasn't sure whether to make this issue here or on bootloader, but my project compiles bootloader fine so I figured it was probably an issue with bootimage (or my environment!).
I get the following errors:
rust-lld: error: bootloader.30ac1y0p-cgu.0:(.boot-first-stage+0x81): relocation R_X86_64_16 out of range: 88576 is not in [-32768, 65535]; references _rest_of_bootloader_end_addr
rust-lld: error: bootloader.30ac1y0p-cgu.0:(.boot+0x6A): relocation R_X86_64_16 out of range: 88576 is not in [-32768, 65535]; references _kernel_start_addr
>>> defined in C:\Rust\Pogostick\target\bootimage\bootloader\x86_64-bootloader\release\deps\libbootloader-0325a9ea9e448093.rlib(kernel_bin-pogostick.o)
rust-lld: error: bootloader.30ac1y0p-cgu.0:(.boot+0x85): relocation R_X86_64_16 out of range: 880472 is not in [-32768, 65535]; references _kernel_size
>>> defined in C:\Rust\Pogostick\target\bootimage\bootloader\x86_64-bootloader\release\deps\libbootloader-0325a9ea9e448093.rlib(kernel_bin-pogostick.o)
My target JSON file looks like this:
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"arch": "x86_64",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"os": "none",
"executables": true,
"linker-flavor": "ld.lld",
"linker": "rust-lld",
"panic-strategy": "abort",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float"
}
As a side note, it tells me I can run with --verbose
to get additional info, but when I do, it only applies to the original build and not to bootloader's runner. I've already tried rebooting and running cargo clean
.
Any advice would be much appreciated!
Update: downgrading to Rust Nightly from 1st March (nightly-2021-03-01) fixed this for me
Thanks a lot for reporting! This is a bug in the bootloader
crate which was presumably triggered by the recent update to LLVM 12 on Rust nightly. I'm already looking into it.
I just published bootloader version 0.9.15. You should be able to fix your errors by running cargo update -p bootloader
. Please let me know if there are still problems!