Previously, I had always built rustc with the follow command: ./x build library --stage 2
Looking at the build logs everything seems correct, however, when I try to build (tag=v.1.85.0) I get an error saying it doesn't have the stdlib. Also, suspiciously, the rustc bin is half the size of my old builds.
rror[E0463]: can't find crate for `std`
|
= note: the `aarch64-apple-darwin` target may not be installed
= help: consider adding the standard library to the sysroot with `x build library --target aarch64-apple-darwin`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
For more information about this error, try `rustc --explain E0463`.
error[E0463]: can't find crate for `core`
|
= note: the `aarch64-apple-darwin` target may not be installed
= help: consider adding the standard library to the sysroot with `x build library --target aarch64-apple-darwin`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
error: could not compile `version_check` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `serde` (build script) due to 1 previous error
error: could not compile `proc-macro2` (build script) due to 1 previous error
error: could not compile `syn` (build script) due to 1 previous error
error: could not compile `base64` (lib) due to 1 previous error
error: could not compile `unicode-ident` (lib) due to 1 previous error
error: could not compile `typenum` (build script) due to 1 previous error
error: could not compile `autocfg` (lib) due to 1 previous error
error: could not compile `unicode-width` (lib) due to 1 previous error
In the target key you need to also include the triple of the host platform. Otherwise the resulting compiler can't build proc macros and build scripts for the host.
When doing ./x.py build --stage 2 compiler/rustc library implicitly causes a standard library to be built for the host as that is necessary for building the stage 2 compiler for the host.
Even when cross-compiling you often have dependencies with build scripts and proc macros that need to be compiled for the host.
When doing ./x.py build --stage 2 compiler/rustc library implicitly causes a standard library to be built for the host as that is necessary for building the stage 2 compiler for the host.
Oh so even without my "host" target listed in the config.toml it still creates some things for my host, but not everything I may need? And this is the reason I was seeing the errors, even though I was compiling to the custom target?
Yes, if one of your dependencies has a build script or proc macro it will get compiled for the host. Most projects have at least one build script or proc macro somewhere in their dependency graph. In your case for example serde, base64, typenum and one or more dependencies that use autocfg.