Open bwesen opened 3 years ago
You might not necessarily need to specify the sysroot. (It depends on how the compiler was configured/built.)
For Ubuntu Focal something like this should work I think:
apt install g++-arm-linux-gnueabihf libc6-dev-armhf-cross
rustup target add armv7-unknown-linux-gnueabihf
.cargo/.config
:[target.armv7-unknown-linux-gnueabihf]
linker = "/usr/bin/arm-linux-gnueabihf-gcc"
cargo build --release --target=armv7-unknown-linux-gnueabihf
.Thanks, yeah I eventually managed to compile it but I had to spend many hours scourging stack overflow confused posts from a lot of other people who also had problems cross-compiling with Rust :) (not compiling not-perf in particular)
The main issue is that when you install the Ubuntu 20.04 rust packages you don't get rustup and they don't provide the necessary pre-built std/core crates for armv7 either, so you get confused and nothing works and the various tutorials on the net are confusing if you try to use the Debian packages; there are multiple ways to set this up it seems. And you just get weird error messages from rust about the std/core crates missing and if you don't know anything about Rust this just adds to the confusion :)
I ended up having to remove all of the Ubuntu rust-related packages, and instead use the rust shell script to set it up, do the rustup target add and added the cross compiler to the .config like you wrote and then it compiled.
However, while it compiled properly, I never got any binaries. In the release dir there are only a couple of libs it seems, any suggestions?
~/tmp/not-perf/target/armv7-unknown-linux-gnueabihf/release$ ls -l
total 7904
drwxrwxr-x 28 bjorn bjorn 4096 Jul 7 18:05 build
drwxrwxr-x 2 bjorn bjorn 16384 Jul 7 18:06 deps
drwxrwxr-x 2 bjorn bjorn 4096 Jul 7 17:11 examples
drwxrwxr-x 2 bjorn bjorn 4096 Jul 7 17:11 incremental
-rw-rw-r-- 1 bjorn bjorn 2290 Jul 7 18:06 libnperf_core.d
-rw-rw-r-- 2 bjorn bjorn 8058580 Jul 7 18:06 libnperf_core.rlib
Try cargo build --release --target=armv7-unknown-linux-gnueabihf --workspace
. The root dir defines the nperf_core
crate it seems. The cli is found in a different crate in a subdirectory. --workspace
causes the whole workspace to be built instead of just the root nperf_core
.
Ah, right, I forgot to update README after that change! Yes, the bin crate is no longer in the root; if you go into the cli
directory and build from there it will build properly.
Thanks both, going into cli/ and running the build with the appropriate --target produced the nperf binary (in the top-level target/ structure). And it seems to execute on my target.
Now for finding out how to use the tool :)
Hi! There are some suggestions in the README that this perf-version was designed with cross compilation in mind etc and there are some very brief instructions on how to cross compile it. Could you please expand this into a working example?
For example, on Ubuntu 20.04 you can install gcc-9-arm-linux-gnueabihf and in it you can find a gcc (the "linker" for Rust .config) but where do you find the "sys-root"?