Cross compile OSX > FreeBSD rustc version mismatch


#1

Hi

I’m trying to cross compile from OSX to FreeBSD according to this but I get the error message

src/main.rs:1:1: 1:1 error: the crate `std` has been compiled with rustc 1.7.0, which is incompatible with this version of rustc [E0514]

even though all versions used should be 1.7.0 stable.

Since there is no official build for FreeBSD multirust can not download them for me so I copied the prebuilt package from FreeBSD’s ports.

Looking at the rustc -vV output I can see that the rustc on FreeBSD has unknown commit-hash and date, could be the reason for the error message?

If so, how can I build the libraries on FreeBSD in a way that makes it compatible with cross compiling?


#2

Since there is no official build for FreeBSD multirust can not download them for me so I copied the prebuilt package from FreeBSD’s ports.

For cross compilation to work the cross compiled std crates and the native rustc must have been built at the same commit hash and for the same channel. That doesn’t seem to be the case here, because the FreeBSD rustc reports an “unknown” commit hash/date.

On a related note, we have been working on official rustc/libstd releases for freebsd and netbsd. Soon, you’ll be able to install rustc on those *BSD using either rustup or multirust. Actually, the binaries should have came up today but due to a bug the final upload process failed :disappointed:. I expect they’ll be available in the next few days! And I expect that once those are ready multirust add-target nightly $freebsd_target will work for cross compilation.


#3

That’s great news :smile:
Thank you for your efforts. Please let me know when its up and working.


#4

The cross compiled std crates are already available (on nightly >= 2016-03-20) you can install them with:

$ multirust add-target nightly x86_64-unknown-freebsd

Then you should be able to cross compile to freebsd using:

$ cargo build --target x86_64-unknown-freebsd

Assuming that (a) you have a C cross compiler (osx -> freebsd) and (b) have configured the cross linker in .cargo/config.

The freebsd rustc is also available in this directory, look for rustc-nightly-x86_64-unknown-freebsd.tar.gz. But you would have to install it manually (there’s an install.sh script inside the tarball) because multirust default/update nightly is not yet working for these new hosts.


#5

Great! Thank you very much :slight_smile:

Got it working and instructions and a set of binaries is available here: