Open Earlz opened 4 years ago
I think this is a bug of rust itself. Have you tried building this with cargo's built-in -Zbuild-std=core,alloc
flag instead of cargo-xbuild
? You probably need to add a dependency on rlibc
and an extern crate rlibc
statement when trying this to resolve memset
etc.
If the problem still occurs with -Zbuild-std
, we know that it's not a problem in cargo-xbuild
. In that case, we should report it in the rust-lang/rust repository directly.
It seems to slightly be a bug in cargo-xbuild. Specifically, the .cargo/config Rust flags aren't used for building the core etc crate. The target file is however used, so the solution I found is to add "relocation-model": "static"
to the target file
Ah yeah, we deliberately set a RUSTFLAGS
environment variable to override any rustflags
keys in .cargo/config
files: https://github.com/rust-osdev/cargo-xbuild/blob/a779803ab1062ce3e3f864f242b6c45aa02a0332/src/sysroot.rs#L93
Apart from passing -Cembed-bitcode=yes
, the reason for this is that most of the time you don't want to apply your rustflags to the sysroot build. For example, you probably don't want that the sysroot crates are built with "-C", "link-arg=-Tlink.x"
in your case.
So setting it in the target file is currently the only option I think. I would also recommend trying the -Zbuild-std
flag, which builds the sysroot crates as normal dependencies and thus shouldn't have this problem.
I'm getting this error " = note: rust-lld: error: no memory region specified for section '.got'" which is unexpected because my target does not support the .got section at all. It is allowed in the linker script just to trigger a compiler error. This was working as of the .29 release, but is now broken with .33. With .29 I had the error with LTO code when using release mode, but with .33 that error went away. This .got error only occurs with debug builds.
The target file I'm using:
The linker script:
And the .cargo/config file:
I'm building it using
cargo xbuild --target i486-neutron.json --verbose
I have a few other targeted crates that I'm using, as well as some common ones like serde, alloc, etc