-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Support cross-compile install #42320
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
Comments
How about using the dist tarballs? You already ran |
That also works for the time being, but it's not clear to me whether if the layout or build-location of the tarballs will change in the future. (For example, the install command has already changed from On Debian a native-build works by running If I get firm instructions from rust here to "yes, ignore install and just extract the tarballs" then of course I'll do this, but it's not clear at the moment what is the preferred way to do a cross-built staged install. For the time being I'm using the patch below, which I wrote before I saw your reply: diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs
--- a/src/bootstrap/step.rs
+++ b/src/bootstrap/step.rs
@@ -899,11 +899,15 @@ pub struct Rules<'a> {
impl<'a> Rules<'a> {
fn new(build: &'a Build) -> Rules<'a> {
+ let target = ::std::env::var("DEB_HOST_RUST_TYPE").unwrap();
+ // rust forces us to do this dance because of lifetimes :/
+ let hosts = &build.config.host;
+ let tidx = hosts.iter().position(|x| x == target.as_str()).unwrap();
Rules {
build: build,
sbuild: Step {
stage: build.flags.stage.unwrap_or(2),
- target: &build.config.build,
+ target: hosts[tidx].as_str(),
host: &build.config.build,
name: "",
}, There might be a tidier way of doing this, I couldn't figure out how to make the envvar have the correct lifetime so I pulled the equivalent object off |
I suppose this is similar in spirit to rust-lang/cargo#3810. |
When cross-compiling, also build target-arch tarballs for libstd. (Closes: #42320) Half of the logic is actually in there already in install.rs:install_std but it fails with an error like: sh: 0: Can't open /<<BUILDDIR>>/rustc-1.21.0+dfsg1/build/tmp/dist/rust-std-1.21.0-powerpc64le-unknown-linux-gnu/install.sh because the target-arch dist tarball wasn't built as well. This commit fixes that so the overall install works. There is one minor bug in the existing code which this commit doesn't fix - the install.log from multiple runs of the installer gets clobbered, which seems like it might interfere with the uninstall process (I didn't look very deeply into this, because it doesn't affect what I need to do.) The actual installed files under DESTDIR seem fine though - either they are installed under an arch-specific path, or the multiple runs will clobber the same path with the same arch-independent file.
I can't get a cross-compiled install to work, it keeps installing the build (native) architecture's binaries and libraries instead of the host (foreign) architecture binaries and libraries. Even if I do
./x.py dist --install --host $HOST --target $TARGET
these extra flags just get ignored.As an example, cross-compiling from a build machine x86_64 to a foreign host aarch64:
It looks like this is hardcoded into step.rs:
It would be good if a cross-compile install were possible. Otherwise I'd have to manually hack up some custom install scripts to install the files directly from
build/aarch64-unknown-linux-gnu/stage2/
.The text was updated successfully, but these errors were encountered: