Skip to content

Build stage 0 rust-std from rust-src with local rust (again) #148835

@weihanglo

Description

@weihanglo

Summary

(I know building stage 0 std is not officially supported)

This is kinda a reopen of #145859, because in 1.91.0 we shipped 5ce678a that errors out if codegen-backend is set to an empty list [].

We set rust.codegen-backends = [] is to avoid in in bootstrap sanity check that it determines CMake requirement by looking whether codegen-backend contains LLVM.

// We need cmake, but only if we're actually building LLVM or sanitizers.
let building_llvm = !build.config.llvm_from_ci
&& build.hosts.iter().any(|host| {
build.config.llvm_enabled(*host)
&& build
.config
.target_config
.get(host)
.map(|config| config.llvm_config.is_none())
.unwrap_or(true)
});
let need_cmake = building_llvm || build.config.any_sanitizers_to_build();
if need_cmake && cmd_finder.maybe_have("cmake").is_none() {
eprintln!(
"
Couldn't find required command: cmake
You should install cmake, or set `download-ci-llvm = true` in the
`[llvm]` section of `bootstrap.toml` to download LLVM rather
than building it.
"
);
crate::exit!(1);
}

pub fn llvm_enabled(&self, target: TargetSelection) -> bool {
self.enabled_codegen_backends(target).contains(&CodegenBackendKind::Llvm)
}

Since we build rust-std with the local rust toolchain, we should not need any llvm rebuild.


Below is pretty much the same as #145859 except commit sha.

We are actually building rust-std from rust-src with local rust built from the same rust-src.

For example,

  • I have a full toolchain installed locally and built from rust-stc in f8297e3
  • I'd like to build a dist tarball of rust-std with the toolchain I just built in the same f8297e3 commit.

Command used

A stripped down version of our configuration is roughly this:

./congfigure
	# we have this historically to avoid building LLVM
	--codegen-backends= 
	--enable-locked-deps
	--set rust.codegen-units-std=1
	--set rust.remap-debuginfo
	--debuginfo-level-std=1
	--dist-compression-formats=xz
	--release-channel=stable
	--enable-vendor
	--enable-local-rust
	--enable-local-rebuild
	--set "target.$TARGET_TRIPLE.linker=cc"
	--set "target.$TARGET_TRIPLE.ar=ar"
	--set "target.$TARGET_TRIPLE.ranlib=ranlib"
	--prefix "$INSTALL_DIR"
	--sysconfdir "etc"
	--build "$TARGET_TRIPLE"
	--target "$CROSS_TARGET"
	# other corss-target-specific flags…

python x.py dist --stage 0 rust-std

Expected behaviour

Before the bootstrap redesign, it worked without recompiling LLVM and stage1 compiler artifacts.
Now you need to rebuild them all, which is a bit undesired.

Proposed solution

Not sure. Maybe check whether build.local-rebuild is set to true in the bootstrap sanity check?

HEAD

1.91.0 or anything after 5ce678a

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions