Skip to content

Instantly share code, notes, and snippets.

@yopito
Created October 11, 2018 05:02
Show Gist options
  • Save yopito/e7b86aca2ffa4c833fd420d651bcf2e8 to your computer and use it in GitHub Desktop.
Save yopito/e7b86aca2ffa4c833fd420d651bcf2e8 to your computer and use it in GitHub Desktop.
rust crossbuild fails
Working within an xbps-src chroot:
$ xbps-query -p pkgver rust
rust-1.28.0_2
$ xbps-query -p pkgver -s cross
cross-aarch64-linux-gnu-0.28_1: cross-aarch64-linux-gnu-0.28_1
cross-aarch64-linux-gnu-libc-0.28_1: cross-aarch64-linux-gnu-libc-0.28_1
following https://github.com/japaric/rust-cross#cross-compiling-with-rustc:
$ cat hello.rs
fn main() {
println!("Hello, world!");
}
native build is fine:
$ rustc hello.rs && ./hello
Hello, world!
rustc available cross-build targets for aarch64:
$ rustc --print target-list | grep aarch64
aarch64-linux-android
aarch64-unknown-cloudabi
aarch64-unknown-freebsd
aarch64-unknown-fuchsia
aarch64-unknown-linux-gnu
aarch64-unknown-linux-musl
aarch64-unknown-openbsd
1s crossbuild try:
$ rustc --target=aarch64-unknown-linux-gnu hello.rs
error[E0463]: can't find crate for `std`
|
= note: the `aarch64-unknown-linux-gnu` target may not be installed
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
2nd build try:
$ rustc --target=aarch64-unknown-linux-gnu -C linker=aarch64-linux-gnu-gcc hello.rs
error[E0463]: can't find crate for `std`
|
= note: the `aarch64-unknown-linux-gnu` target may not be installed
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
@yopito
Copy link
Author

yopito commented Oct 11, 2018

Have to provides the necessary paths that are provided since install rust for crossbuilding too:

$ rustc -L /usr/aarch64-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/lib \
		--target=aarch64-unknown-linux-gnu \
		 -C linker=aarch64-linux-gnu-gcc \
		hello.rs

check it's fine:

$ file hello
hello: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=e32b29801cce80896e3444beb47310f0235dc6ae, not stripped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment