[Solved] Cross-compiling rustc from bootstrap broken in current master (1.47.0)

I don't know whether this is the right place to post this, but the current master (nightly 1.47.0) breaks my current configuration for cross-compiling rustc from x86_64-unknown-linux-gnu to i686-unknown-haiku. For various reasons Rust needs to be bootstrapped from another platform to work on Haiku.

On the beta branch (1.46.0), I accomplish this by putting the following in the config.toml file:

...
[build]
host = ["i686-unknown-haiku"]
target = ["i686-unknown-haiku"]
...

This used to cross-compile rustc and all dependencies using a cross-compiler that was running on Linux. The host option is necessary to create a cross-compiled rustc for i686-unknown-haiku, otherwise it would only just generate the std artifacts.

However, with this change that no longer works, as suddenly some steps are introduced where the rustc for Haiku is used to compile libstd. Obviously this fails on linux because the binary does not work. The output is:

> Std { target: "x86_64-unknown-linux-gnu", compiler: Compiler { stage: 1, host: "i686-unknown-haiku" } }
  > StartupObjects { compiler: Compiler { stage: 1, host: "i686-unknown-haiku" }, target: "x86_64-unknown-linux-gnu" }
  < StartupObjects { compiler: Compiler { stage: 1, host: "i686-unknown-haiku" }, target: "x86_64-unknown-linux-gnu" }
  c Assemble { target_compiler: Compiler { stage: 1, host: "i686-unknown-haiku" } }
  > Libdir { compiler: Compiler { stage: 1, host: "i686-unknown-haiku" }, target: "x86_64-unknown-linux-gnu" }
    c Sysroot { compiler: Compiler { stage: 1, host: "i686-unknown-haiku" } }
  < Libdir { compiler: Compiler { stage: 1, host: "i686-unknown-haiku" }, target: "x86_64-unknown-linux-gnu" }
  c Sysroot { compiler: Compiler { stage: 1, host: "i686-unknown-haiku" } }
  c Sysroot { compiler: Compiler { stage: 1, host: "i686-unknown-haiku" } }
  c Sysroot { compiler: Compiler { stage: 1, host: "i686-unknown-haiku" } }
  c Sysroot { compiler: Compiler { stage: 1, host: "i686-unknown-haiku" } }

Now I don't know whether I was relying on undefined or undocumented behaviour (config.toml.example is slightly ambiguous in describing the relation of the host platform to the build platform), I am still hoping that there is a way to get the desired output without ending in errors.

Unfortunately the history on the src/bootstrap directory does not directly show a culprit.

Any ideas? Have I been doing it all wrong?

You might need to use ./x.py --stage 2, which used to be the default.

2 Likes

That's it. Just tried it and now it builds. It looks like this commit changed the default stage for the build command to stage 1, which broke my assumptions.

1 Like