FS#49169 - [rust] enable cross-compilation

Attached to Project: Community Packages
Opened by Yanus Poluektovich (ypoluektovich) - Sunday, 01 May 2016, 19:54 GMT
Last edited by Alexander F. Rødseth (xyproto) - Wednesday, 10 August 2016, 18:21 GMT
Task Type Feature Request
Category Packages
Status Closed
Assigned To Alexander F. Rødseth (xyproto)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

The archlinux wiki page suggests using nightly builds of rust from unofficial repositories if you want to cross-compile stuff (e.g. for windows). If, however, you want to use stable releases of the compiler, you're out of luck, because nobody provides rust standard library packages for stable versions, and the libraries from the official distribution site are currently incompatible with rustc from [community], because they were compiled with a different version of rustc.

To fix it, ArchLinux maintainers could either provide standard libraries (for all triples supported by rust) built from scratch with the compiler that's being distributed in [community] now (built from sources), or package the compiler from the official Rust distribution site. The latter is probably better.
This task depends upon

Closed by  Alexander F. Rødseth (xyproto)
Wednesday, 10 August 2016, 18:21 GMT
Reason for closing:  None
Additional comments about closing:  Now has a plan for a future package that can enable cross compilation, one way or the other (either as the complete cross-compiler, or as a complimentary package for the rust compiler).
Comment by Yanus Poluektovich (ypoluektovich) - Sunday, 01 May 2016, 20:00 GMT
In fact, I've already made some PKGBUILDs that package the official releases of rustc and rust-std. Since that's a lot of similar packages, I've made a PKGBUILD generator that may be of interest.

https://github.com/ypoluektovich/rust-pkgbuilds

To build packages for "your" system, run:

./configure && make

That'll build rust-bin-1.8.0-1 for $CARCH (this package contains only rustc without any standard libraries), and two rust-std packages for x86_64 linux and windows gnu-based triples. That's what I needed for myself.

Supporting new triples is as easy as adding lines to defines.m4 file, then rerunning configure and make. (You might need to run `make clean` between rebuilds, as I haven't ironed out all kinks from the generated Makefile.) The lines contain the triple id and two SHA256 sums — for the distribution file and for the file with its GPG signature.

I'll be happy to provide additional info and answer questions, if you require it :)
Comment by Doug Newgard (Scimmia) - Sunday, 01 May 2016, 21:24 GMT
Upstream binaries are never better than building from source.
Comment by Alexander F. Rødseth (xyproto) - Monday, 02 May 2016, 15:57 GMT
Arch packages are built from source, not from binary releases, whenever possible.

For other variations on packaging rust, it is possible to submit PKGBUILDs to the AUR. If they grow in popularity (and a TU/dev wish to maintain them), they may become official packages.

The official rust package for Arch Linux tries to adhere to the default build + install procedure for Rust.

Is this bug report about the default build + install procedure, as provided by the upstream Rust developers?
Comment by Yanus Poluektovich (ypoluektovich) - Monday, 02 May 2016, 16:29 GMT
This bug report is about "I want to cross-compile a Rust program, but I don't want to use the nightly compiler; what should I do?".

The reason I can't use the rust compiler from [community] is because there are no accompanying standard library packages. (More specifically, there is the library packaged with the compiler, but it's only for linux on my architecture.) The problem is that the standard libraries for the target triple have to be built by the same version of rustc that is used to build the whole program.

AUR currently has only nightly packages, which I don't want to use because of stability concerns.

As I see it, there can be two solutions:

1) You agree to build and maintain the packages for at least the most popular of the triples supported by Rust. (Triples, if you don't know, specify target platforms; examples are "x86_64-unknown-linux-gnu", "i686-pc-windows-gnu", "x86_64-apple-darwin", etc. You can get the full list by running `rustc --print target-list`.)

2) You don't agree to do that, for whatever reason. In that case, I'll just publish my packages in AUR. That will have to include a replacement compiler package, as the one in [community] is incompatible with the officially distributed rust-std binaries.

Maybe it's possible to use the compiler from [community] to build rust-std for other platforms, but I don't know how.
Comment by Alexander F. Rødseth (xyproto) - Tuesday, 09 August 2016, 11:09 GMT
These are the arguments against enabling cross-compilation (same applies to the "go" package):
* Enabling cross-compilation may make the package increase significantly in size. Some people might want to keep it small. ("go" increases with 100s of MBs).
* Cross-compilation is not enabled by default, by the Rust developers. We normally follow the default installation procedures.

It is possible to add a second rust package for cross-compilation in [community]. For instance, Erlang has "erlang" and "erlang-nox" for the official and the headless version. Something like "rust-cross" and "go-cross" might be a good idea.

If a rust package for cross-compilation achieves a minimum of popularity on AUR (around 10 votes), I will happily add it to [community] (keeping both rust and the new package). The AUR package should build rust from a source release (not the latest commit from git and not from a pre-built binary) and enable cross compilation as the only modification.

Sounds like a possible future solution to the issue?
Comment by Yanus Poluektovich (ypoluektovich) - Tuesday, 09 August 2016, 22:31 GMT
Yep, sounds good.

What exactly causes the increase of the size of the package? If the majority of it is the compiled standard libraries, then it might be better to extract them to separate packages (so that one could select which libraries to install depending on their targets), and then the bare rustc-with-cross-compilation package may (or may not) replace the current one.
Comment by Alexander F. Rødseth (xyproto) - Wednesday, 10 August 2016, 18:19 GMT
I agree that having a main package with the possibility of installing a package that enables cross compilation would be best, if possible.

For now, I think getting a good "rust" and "rust-cross" package up is a nice intermediate goal.

Cheers!

Loading...