-
Notifications
You must be signed in to change notification settings - Fork 52
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
upon cross-compiling with emerge-cross-wrappers #394
Comments
The build.log itself isn't very usefull, as it hides the actuall compile commands from the user. Therefore, the first thing to do in an attempt to debug this is, to reenable cargo build -v in the cargo.eclass in the local portage tree:
which gives a more verbose build.log to read through: cbindgen-0.6.7-cross.log.zip |
next step would be to find out, wether a build outside of portage would work: I copied the folder here is the build log of that approach: cbindgen-0.6.7-cross-non-portage.log.zip which gives a valid arm binary: file cbindgen which can be striped with cross-strip: file cbindgen |
one smoking gun I found is, that upon linking during cross-compile cargo has to be told about where the cross-gcc is to be found via ~/.cargo/config
otherwise the non-portage build would flake out with and it seems to me that portage sets its own cargo home config during each install, which makes sense as emerge is run via the the user/group portage:portage, and it doesn't have a folder in /home/ but, to be honest, I think the first problem here is that portage doesn't invoke rustc with the correct --target option at all, but simply issues the native rustc command. How may I change this behavior, for to emerge the package with cross-portage? |
ok, we're getting closer as I switched on --target option via the cargo.eclass
This is of course very unsophisticated, needs more general approach if ever going to the overlay or the tree even. But it makes emerge run into the linker errors, as it should when picking native gcc to link a foreign binary, which shows that cross-compile has happened at some point:
|
Ok, so let's set up the linker as well:
this solves the linking error, but still emerge installs the native binary in src_install.
|
portage acutally ends up with two binaries now, one native and one cross-compiled one, in seperate folders: user@tuxbox /usr/armv7a-unknown-linux-gnueabihf/tmp/portage/dev-util/cbindgen-0.6.7/work/cbindgen-0.6.7/target/release $ file cbindgen user@tuxbox /usr/armv7a-unknown-linux-gnueabihf/tmp/portage/dev-util/cbindgen-0.6.7/work/cbindgen-0.6.7/target/armv7-unknown-linux-gnueabihf/release $ file cbindgen |
Ok, finally got there: rust-lang/cargo#5614 added an option to enable cargo install --target
|
lousy ebuild I hacked for rust-std-bin: https://github.com/stefson/gentoo-extras/blob/master/dev-lang/rust-std/rust-std-1.30.1.ebuild |
Do you plan producing thumb targets for rust-std? Also why haven't you pushed it into ::rust? |
how can you not see the thumb code in the ebuild? https://github.com/gentoo/gentoo-rust/blob/master/dev-lang/rust/rust-1.41.0-r666.ebuild#L102 |
The ebuild requires you to be on an arm arch or otherwise have |
You're welcome to use my overlay if you want to, the thumb target is in an extra package named rust-std-neon since I couldn't find a way to make my rust-std ebuild installing both armv7 and thumbv7neon on an amd64 host. You'll need both of them for cross compiling firefox. Actually I don't think you'll need arm-none-eabi-gcc for compiling the thumbv7neon target. Where did you get that information from? |
On Thu, Feb 27, 2020 at 01:03:08PM -0800, stefson wrote:
You're welcome to use my overlay if you want to, the thumb target is in an extra package named rust-std-neon since I couldn't find a way to make my rust-std ebuild installing both armv7 and thumbv7neon on an amd64 host. You'll need both of them for cross compiling firefox.
My question was why isn't it in ::rust.
Actually I don't think you'll need arm-none-eabi-gcc for compiling the thumbv7neon target. Where did you get that information from?
From trying to build it (in fact thumbv6m-none-eabi, as i need it): `couldn't find required command: "arm-none-eabi-gcc"`
…--
() ascii ribbon campaign - against html mail
/\ http://arc.pasp.de/ - against proprietary attachments
|
bootstrapping additional rust-std from source requires you to have a suitable gcc cross compiler at hand for linking, and yes some of the crates are so stupid to only look for gcc name paterns matching those of debian based distros. You have no choice but to symlink your own cross compiler to the debian name scheme. That said, please take the ebuild and modify it for your own case. You're not presenting any usefull information to me for helping you with that. Thanks. |
recently I did some research into how to to use rust and cargo to cross-compile, especially for armhf.
I found out, it's rather easy to set up rust for that: if rust-bin is your rust-provider, download rust-std-${PN}-${ARCH-TRIPLE}.tar.xz and install it with:
./install.sh --disable-verify --prefix=/opt/${P}/ --mandir="/usr/share/${P}/man" --disable-ldconfig
which gives you a rust-bin with the ability to cross-compile. (since rustc is more or less a frontend to llvm, you should have it emerged with llvm_target_arm?)
also emerge a full cross toolchain with crossdev, since rustc needs the cross-gcc as a linker.
now, it is common practice to cross-compile with emerge-wrappers, so an
emerge-armv7a-unknown-linux-gnueabihf -auvND world
should bootstrap a base cross system to work with, inheriting @System, and from there on it should be possible to compile individual packages and copy the tbz2 files from the cross environement over to the memory restrained arm device and emerge with the-k
option to grab a binary if possible. Done that withsys-devel/gcc
,sys-devel/llvm
,dev-libs/boost
, etc. pp.Now, with a host where rustc has the foreign rust-std installed it should just work to emerge, for instance,
dev-util/cbindgen
this way. It does, however, with a bit of a show stopper:the binary is in fact not a cross-compiled one, but for the hosts arch, thus cross-strip can't do anything about it.
The text was updated successfully, but these errors were encountered: