rust-osdev / cargo-xbuild

Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc.
Apache License 2.0
258 stars 25 forks source link

Cargo xbuild fails to build with older rustc nightly #74

Closed ghost closed 4 years ago

ghost commented 4 years ago

I'm using nightly-2020-02-24, but cargo xbuild tries to build core crate with lastest rust-src, which failed. cargo xbuild need a way to specify which rust-src to use when building core crate.

phil-opp commented 4 years ago

Cargo-xbuild uses the rust-src component provided by rustup, so it should always be in sync with with your nightly version. What error message are you seeing exactly?

ghost commented 4 years ago
error[E0635]: unknown feature `llvm_asm`
 --> /home/william/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.28/src/lib.rs:3:12
  |
3 | #![feature(llvm_asm)]
  |   
ghost commented 4 years ago

llvm_asm just included in recent version of rust, and I have no problems compile core crate in the past (about 2 months ago). So I think cargo xbuild must pull new version of rust-src

ghost commented 4 years ago

looking at compiler builtins version, i'm sure that it tries to compile latest rust-src

ghost commented 4 years ago

By the way, the very reason i'm trying to use old nightly is that nightly-2020-05-12 don't let me link my kernel to higher haft address, it's just throw alots of R_x86_64_32 relocations errors.

phil-opp commented 4 years ago

The problem is that the alloc library itself has a dependency on the compiler_builtins crate from crates.io: https://github.com/rust-lang/rust/blob/750db09fa800dceebba57d609d42969172118c92/src/liballoc/Cargo.toml#L15

This library just received an update that switches to llvm_asm: https://github.com/rust-lang/compiler-builtins/pull/351. Given that it was released as a normal patch release, cargo automatically tries to use the latest version if there is no lockfile.

To fix this issue, we need to update cargo-xbuild to respect the lockfile (i.e. the Cargo.lock) of the rust-src component. I opened https://github.com/rust-osdev/cargo-xbuild/pull/75 to fix this. Could you try whether this new version works for you? You can install it through:

cargo install cargo-xbuild --git https://github.com/rust-osdev/cargo-xbuild.git --branch respect-lockfile  --debug --force
ghost commented 4 years ago

That worked! But I still have problems linking code to higher address when using cargo xbuild, guess I will open new issue for this. Thanks!

phil-opp commented 4 years ago

Great, I will merge the PR then!