Auto merge of #97513 - jyn514:submodule-handling, r=Mark-Simulacrum

Fully remove submodule handling from bootstrap.py

These submodules were previously updated in python because Cargo gives a hard error if toml files
are missing from the workspace:

```
error: failed to load manifest for workspace member `/home/jnelson/rust-lang/rust/src/tools/rls`

Caused by:
  failed to read `/home/jnelson/rust-lang/rust/src/tools/rls/Cargo.toml`

Caused by:
  No such file or directory (os error 2)
failed to run: /home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /home/jnelson/rust-lang/rust/src/bootstrap/Cargo.toml
```

However, bootstrap doesn't actually need to be part of the workspace.
Remove it so we can move submodule handling fully to Rust, avoiding duplicate code between Rust and Python.

Note that this does break `cargo run`; it has to be `cd src/bootstrap && cargo run` now.
Given that we're planning to make the main entrypoint a shell script (or rust binary),
I think this is a good tradeoff for reduced complexity in bootstrap.py.

To get this working, I also had to remove support for vendoring when using the git sources, because `cargo vendor` requires all submodules to be checked out. I think this is ok; people who care about this are likely already using the pre-vendored `rustc-src` tarball.

Fixes https://github.com/rust-lang/rust/issues/90764. Helps with #94829
This commit is contained in:
bors 2022-06-25 21:01:10 +00:00
commit 20a6f3a8a8
9 changed files with 757 additions and 228 deletions

View file

@ -63,6 +63,10 @@ const EXCEPTIONS_CRANELIFT: &[(&str, &str)] = &[
("target-lexicon", "Apache-2.0 WITH LLVM-exception"),
];
const EXCEPTIONS_BOOTSTRAP: &[(&str, &str)] = &[
("ryu", "Apache-2.0 OR BSL-1.0"), // through serde
];
/// These are the root crates that are part of the runtime. The licenses for
/// these and all their dependencies *must not* be in the exception list.
const RUNTIME_CRATES: &[&str] = &["std", "core", "alloc", "test", "panic_abort", "panic_unwind"];
@ -96,7 +100,6 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
"chalk-ir",
"chalk-solve",
"chrono",
"cmake",
"compiler_builtins",
"cpufeatures",
"crc32fast",
@ -309,7 +312,13 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
let metadata = t!(cmd.exec());
let runtime_ids = compute_runtime_crates(&metadata);
check_exceptions(&metadata, EXCEPTIONS, runtime_ids, bad);
check_dependencies(&metadata, PERMITTED_DEPENDENCIES, RESTRICTED_DEPENDENCY_CRATES, bad);
check_dependencies(
&metadata,
"main workspace",
PERMITTED_DEPENDENCIES,
RESTRICTED_DEPENDENCY_CRATES,
bad,
);
check_crate_duplicate(&metadata, FORBIDDEN_TO_HAVE_DUPLICATES, bad);
check_rustfix(&metadata, bad);
@ -323,11 +332,20 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
check_exceptions(&metadata, EXCEPTIONS_CRANELIFT, runtime_ids, bad);
check_dependencies(
&metadata,
"cranelift",
PERMITTED_CRANELIFT_DEPENDENCIES,
&["rustc_codegen_cranelift"],
bad,
);
check_crate_duplicate(&metadata, &[], bad);
let mut cmd = cargo_metadata::MetadataCommand::new();
cmd.cargo_path(cargo)
.manifest_path(root.join("src/bootstrap/Cargo.toml"))
.features(cargo_metadata::CargoOpt::AllFeatures);
let metadata = t!(cmd.exec());
let runtime_ids = HashSet::new();
check_exceptions(&metadata, EXCEPTIONS_BOOTSTRAP, runtime_ids, bad);
}
/// Check that all licenses are in the valid list in `LICENSES`.
@ -409,6 +427,7 @@ fn check_exceptions(
/// Specifically, this checks that the dependencies are on the `PERMITTED_DEPENDENCIES`.
fn check_dependencies(
metadata: &Metadata,
descr: &str,
permitted_dependencies: &[&'static str],
restricted_dependency_crates: &[&'static str],
bad: &mut bool,
@ -438,7 +457,7 @@ fn check_dependencies(
}
if !unapproved.is_empty() {
tidy_error!(bad, "Dependencies not explicitly permitted:");
tidy_error!(bad, "Dependencies for {} not explicitly permitted:", descr);
for dep in unapproved {
println!("* {dep}");
}