Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error: Could not find specification for target "x86_64-unknown-none-gnu" #28

Open
frol opened this issue Aug 1, 2018 · 3 comments

Comments

@frol
Copy link

frol commented Aug 1, 2018

$ rustup run nightly make KERNEL_BUILD_PATH=/lib/modules/4.17.11-arch1/build/ CARGO=/home/frol/.cargo/bin/xargo
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --sysroot /home/frol/.xargo -Z force-unstable-if-unmarked --target x86_64-unknown-none-gnu --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro` (exit code: 1)
--- stderr
error: Error loading target specification: Field target-c-int-width in target specification is required
  |
  = help: Use `--print target-list` for a list of built-in targets

I have updated the x86_64-unknown-none-gnu.json file with the version from rust-barebones-kernel, but still cannot get through error:

$ rustup run nightly make KERNEL_BUILD_PATH=/lib/modules/4.17.11-arch1/build/ CARGO=/home/frol/.cargo/bin/xargo
   Compiling core v0.1.0 (https://github.com/phil-opp/nightly-libcore.git#54571deb)
   Compiling kernel32-sys v0.2.2
   Compiling log v0.4.3
   Compiling clang-sys v0.5.4
error: Error loading target specification: Could not find specification for target "x86_64-unknown-none-gnu"
  |
  = help: Use `--print target-list` for a list of built-in targets

error: Could not compile `core`.
warning: build failed, waiting for other jobs to finish...
error: build failed
make[2]: *** [/mnt/storage/projects/linux-kernel-basecamp/rust.ko/build/Makefile:46: /mnt/storage/projects/linux-kernel-basecamp/rust.ko/build/libhello.a] Error 101
make[1]: *** [Makefile:1571: _module_/mnt/storage/projects/linux-kernel-basecamp/rust.ko/build] Error 2
make: *** [Makefile:36: all] Error 2

Can anyone help me?

@wfraser
Copy link
Contributor

wfraser commented Jan 15, 2019

I got past this error by adding RUST_TARGET_PATH='${BASE_DIR}' as an additional environment variable to the cargo command in kbuild.mk on line 46. It appears there's a bug in Cargo where when it changes directory to build other crates, it loses where to find the target specification, so you have to set that variable to make it remember. See rust-lang/cargo#4905

But after fixing that, I get a ton of errors from the nightly-libcore crate, which it seems has not been kept up to date.

@wfraser
Copy link
Contributor

wfraser commented Jan 17, 2019

Ah, it seems the proper way going forward is to use Xargo instead of Cargo and this nightly-libcore hack. Xargo takes care of building libcore for the proper target for you. I've done a bit of work on my fork (https://github.com/wfraser/rust.ko) that involves this, and also updating the bindgen version used, among other things, that gets it building on the current nightly rustc.

@Skarlett
Copy link

Skarlett commented Mar 2, 2019

Is this fixed yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants