rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.58k stars 2.39k forks source link

error: linking with `rust-lld` failed: exit status: 1 #9989

Closed Hankappa closed 2 years ago

Hankappa commented 2 years ago

Problem

Hi I following the https://lowenware.com/blog/osdev/aarch64-bare-metal-program-in-rust/ try to test aarch64 bare-metal under QEMU. Seems meet error and I can't find how to solution. (I've try a lot way from google search....)

~/.cargo/bin/aarch64-bare-metal$ rustup target add aarch64-unknown-none info: component 'rust-std' for target 'aarch64-unknown-none' is up to date ~/.cargo/bin/aarch64-bare-metal$ cargo -v xbuild --target=aarch64-unknown-none.json error: failed to run rustc to learn about target-specific information

Caused by: process didn't exit successfully: rustc - --crate-name ___ --print=file-names -Cembed-bitcode=yes --target /home/hank/.cargo/bin/aarch64-bare-metal/aarch64-unknown-none.json --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg (exit status: 1) --- stderr error: Error loading target specification: may not set is_builtin for targets not built-in. Run rustc --print target-list for a list of built-in targets

error: "/home/hank/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo" "rustc" "-p" "alloc" "--release" "--manifest-path" "/tmp/cargo-xbuildsuBC5o/Cargo.toml" "--target" "aarch64-unknown-none.json" "--" "-Z" "force-unstable-if-unmarked" failed with exit code: Some(101)

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

~/.cargo/bin/aarch64-bare-metal$ cargo version --verbose
cargo 1.57.0-nightly (c7957a74b 2021-10-11)
release: 1.57.0
commit-hash: c7957a74bdcf3b11e7154c1a9401735f23ebd484
commit-date: 2021-10-11
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.79.1-DEV (sys:0.4.49+curl-7.79.1 vendored ssl:OpenSSL/1.1.1l)
os: Ubuntu 18.04 (bionic) [64-bit]
Eh2406 commented 2 years ago

What command did you run that gave you that error message? What did you do to set up the environment?

sorry I see it now.

ehuss commented 2 years ago

You need to remove the is_builtin field from the aarch64-unknown-none.json target spec file. That field is no longer allowed to be set (https://github.com/rust-lang/rust/pull/86062), so it needs to be removed if you are building the spec from --print target-spec-json.

Closing as this isn't related to cargo. If you have further issues with getting started with some bare metal development, I suggest trying one of the user forums or chat platforms like discord.

Hankappa commented 2 years ago

Okay~~Many thanks for your help.

quinn-dougherty commented 2 years ago

I encountered this when I tried to wasm_bindgen a struct. It comes with this note: note: rust-lld: error: unknown file type: exp.o