Build cargo with modified compiler and std from sources

Hello everyone,

I am modifying both rust compiler (new builtin target) and std (sys/pal) to be supported on a custom OS.
Building the compiler and std using ./x build --target builtin_target_triple, works, it does create a custom compiler inside build/host/stage1/bin that successfully cross-compiles for target_triple.
When trying to add cargo utility to the build, it does compile but both rustc and cargo ignore the existence of the new builtin target, how can I build rustc and cargo to work with the new builtin target and the changers added to the std ?
Thanks for your answers !

I'm not sure I understand, but when I modify rustc/cargo and I want to use them in my project without installing them first, so use them from the place where I've compiled them, I just set these:

dir="/var/tmp/portage/dev-lang/rust-1.76.0-r1/work/rustc-1.76.0-src"

export LD_LIBRARY_PATH="${dir}/build/x86_64-unknown-linux-gnu/stage1/lib:${dir}/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib"

export RUSTC="${dir}/build/x86_64-unknown-linux-gnu/stage1/bin/rustc"

export CARGO="/var/tmp/portage/dev-lang/rust-1.76.0-r1/work/rustc-1.76.0-src/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/cargo"

then use like:

"$CARGO" build 

which uses that compiled cargo which in turn uses the rustc executable pointed to by that RUSTC environment variable. RUSTC is also mentioned here. You may even want RUSTC_WRAPPER from there instead.

excerpts from the last link:

CARGO — If set, Cargo will forward this value instead of setting it to its own auto-detected path when it builds crates and when it executes build scripts and external subcommands. This value is not directly executed by Cargo, and should always point at a command that behaves exactly like cargo, as that’s what users of the variable will be expecting.

RUSTC — Instead of running rustc, Cargo will execute this specified compiler instead. See build.rustc to set via config.

RUSTC_WRAPPER — Instead of simply running rustc, Cargo will execute this specified wrapper, passing as its command-line arguments the rustc invocation, with the first argument being the path to the actual rustc. Useful to set up a build cache tool such as sccache. See build.rustc-wrapper to set via config. Setting this to the empty string overwrites the config

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.