Skip to content
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

rust: cross build (&template cleanup) #3233

Merged
merged 2 commits into from
Oct 8, 2018
Merged

Conversation

Cogitri
Copy link
Contributor

@Cogitri Cogitri commented Sep 30, 2018

Continuation of #3101. @Gottox currently seems to be very busy,
so I offered to get this working in #xbps earlier. Currently
building x86_64 -> aarch64, which doesn't work as of now, but early progresses somewhat further than before. However,
there's still stuff to be done:

@Cogitri Cogitri changed the title rust: cross build WIP: rust: cross build Sep 30, 2018
@maxice8
Copy link
Contributor

maxice8 commented Sep 30, 2018

needs to add [ci skip]

@Cogitri
Copy link
Contributor Author

Cogitri commented Sep 30, 2018

Currently tries to link against the host's LLVM: https://gist.github.com/0d9460d77cd0ce964b53f9526c6f47fe

@jnbr
Copy link
Contributor

jnbr commented Oct 1, 2018

Here is a workaround for linking against host llvm:

--- rustc-1.28.0-src/src/librustc_llvm/build.rs.orig    2018-10-01 04:00:15.481334857 +0200
+++ rustc-1.28.0-src/src/librustc_llvm/build.rs 2018-10-01 04:01:15.145790417 +0200
@@ -227,8 +227,8 @@
             println!("cargo:rustc-link-search=native={}", &lib[9..]);
         } else if is_crossed {
             if lib.starts_with("-L") {
-                println!("cargo:rustc-link-search=native={}",
-                         lib[2..].replace(&host, &target));
+                println!("cargo:rustc-link-search=native={}{}",
+                         env::var("XBPS_CROSS_BASE").unwrap(), &lib[2..]);
             }
         } else if lib.starts_with("-l") {
             println!("cargo:rustc-link-lib={}", &lib[2..]);

The original replace() doesn't work because the vlaue of host doesn't appear in the output of llvm-config --link-shared --ldflags.

@Cogitri
Copy link
Contributor Author

Cogitri commented Oct 1, 2018

Thanks, that worked. Now it tries to run the just cross compiled stage0 compiler though (which obviously doesn't work due to it being compiled for a different arch). Will look into it.

@Gottox
Copy link
Member

Gottox commented Oct 1, 2018

I had the approach to unset the cross build environment variables through stage0 and let the build system figure out which vars to set. An alternative approach that would safe build time is to skip stage0 and stage1 and directly build the final compiler. The bootstrapping is already done in the native build.

@Cogitri
Copy link
Contributor Author

Cogitri commented Oct 1, 2018

An alternative approach that would safe build time is to skip stage0 and stage1 and directly build the final compiler.

Sounds good, as we can't run any stage1 binaries during cross compilation anyway

@Gottox
Copy link
Member

Gottox commented Oct 1, 2018

But I have no idea how to convince the build system to start with stage2.

@Cogitri
Copy link
Contributor Author

Cogitri commented Oct 1, 2018

I suppose we can do so by directly using x.py

@Cogitri
Copy link
Contributor Author

Cogitri commented Oct 1, 2018

Seems like we've mixed up build and host though, if I understand it correctly build is the machine running the build (and the arch for which the stage0 compiler is compiled for) while host and target are the triplets we want to compile for.

@Cogitri Cogitri force-pushed the rust-cross branch 9 times, most recently from c8a2e54 to c2d89bd Compare October 1, 2018 20:47
@Cogitri Cogitri changed the title WIP: rust: cross build rust: cross build (&template cleanup) Oct 1, 2018
@Cogitri
Copy link
Contributor Author

Cogitri commented Oct 1, 2018

Alright, cross building to aarch64 works now, testing the other arches. Does someone have aarch64 hardware to test the package? Otherwise I'll setup void on my RPI 3.

@Cogitri
Copy link
Contributor Author

Cogitri commented Oct 1, 2018

Do note that bootstrapping rust on the host platform (not cross compiling) doesn't work right now, but the issue that causes it to fail is fixed in 1.28->1.29 anyway, so I don't really feel like wasting time on fixing that, I just need the 1.28 rust musl dist tarball to be uploaded my someone.

@Cogitri
Copy link
Contributor Author

Cogitri commented Oct 1, 2018

Okay, in theory we could also build the rust standard library for every target, but that seems rather cumbersome and unnecessary. For our use cases it works just fine if we only compile the standard library for the target we're building for and just using --sysroot to use the correct standard library for the target. People who want to use rust for developing and want to cross compile should most likely use rustup anyway.

@Cogitri
Copy link
Contributor Author

Cogitri commented Oct 1, 2018

Alright, rust builds for all platforms. Just adjusted the cargo build style and testing cross build for all of those packages.

@Gottox
Copy link
Member

Gottox commented Oct 2, 2018

bootstrap musl rustc is currently compiling 👍

srcpkgs/rust/template Outdated Show resolved Hide resolved
@Cogitri Cogitri force-pushed the rust-cross branch 5 times, most recently from 43b9e5c to 9374f43 Compare October 2, 2018 18:21
@Cogitri
Copy link
Contributor Author

Cogitri commented Oct 2, 2018

I will update rust to 1.29.1 after this, AFAIK firefox doesn't build with it and it makes sense to not merge all of this at once so that it's easier to see why stuff is breaking (in case it does).

Rasmus Thomsen added 2 commits October 7, 2018 20:42
also cleanup the template

[ci skip]
- enable cross compilation

[ci skip]
@Gottox Gottox merged commit 02992b4 into void-linux:master Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants