Skip to content

Commit 028401f

Browse files
authored
Unrolled build for rust-lang#125465
Rollup merge of rust-lang#125465 - weihanglo:opt-dist-vendor, r=Mark-Simulacrum bootstrap: vendor crates required by opt-dist to collect profiles These are the default package set required by opt-dist to correctly work, hence for people wanting to build a production grade of rustc in a sandboxed / air-gapped environment, these need to be vendored. The size of `rustc-src-nightly.tar.xz` before and after this change: * Before: 298M * After: 323M (+8%) Size change might or might not be a concern. See the previous discussion: rust-lang#125166 (comment) Previous efforts on making: * rust-lang#125125 * rust-lang#125166 --- Note that extra works still need to be done to make it fully vendored. * The current pinned rustc-perf uses `tempfile::Tempdir` as the working directory when collecting profiles from some of these packages. This "tmp" working directory usage make it impossible for Cargo to pick up the correct vendor sources setting in `.cargo/config.toml` bundled in the rustc-src tarball. [^1] * opt-dist verifies the final built rustc against a subset of rustc test suite. However it rolls out its own `config.toml` without setting `vendor = true`, and that results in `./vendor/` directory removed. [^2] [^1]: https://github.com/rust-lang/rustc-perf/blob/4f313add609f43e928e98132358e8426ed3969ae/collector/src/compile/benchmark/mod.rs#L164-L173 [^2]: https://github.com/rust-lang/rust/blob/606afbb617a2949a4e35c4b0258ff94c980b9451/src/tools/opt-dist/src/tests.rs#L62-L77
2 parents 65d1a73 + 3778703 commit 028401f

File tree

6 files changed

+83
-22
lines changed

6 files changed

+83
-22
lines changed

src/bootstrap/src/core/build_steps/dist.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,21 @@ impl Step for PlainSourceTarball {
10411041
.env("RUSTC_BOOTSTRAP", "1")
10421042
.current_dir(plain_dst_src);
10431043

1044+
// Vendor packages that are required by opt-dist to collect PGO profiles.
1045+
let pkgs_for_pgo_training = build_helper::LLVM_PGO_CRATES
1046+
.iter()
1047+
.chain(build_helper::RUSTC_PGO_CRATES)
1048+
.map(|pkg| {
1049+
let mut manifest_path =
1050+
builder.src.join("./src/tools/rustc-perf/collector/compile-benchmarks");
1051+
manifest_path.push(pkg);
1052+
manifest_path.push("Cargo.toml");
1053+
manifest_path
1054+
});
1055+
for manifest_path in pkgs_for_pgo_training {
1056+
cmd.arg("--sync").arg(manifest_path);
1057+
}
1058+
10441059
let config = if !builder.config.dry_run() {
10451060
t!(String::from_utf8(t!(cmd.output()).stdout))
10461061
} else {

src/tools/build_helper/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Types and functions shared across tools in this workspace.

src/tools/build_helper/src/lib.rs

+25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
1+
//! Types and functions shared across tools in this workspace.
2+
13
pub mod ci;
24
pub mod git;
35
pub mod metrics;
46
pub mod stage0_parser;
57
pub mod util;
8+
9+
/// The default set of crates for opt-dist to collect LLVM profiles.
10+
pub const LLVM_PGO_CRATES: &[&str] = &[
11+
"syn-1.0.89",
12+
"cargo-0.60.0",
13+
"serde-1.0.136",
14+
"ripgrep-13.0.0",
15+
"regex-1.5.5",
16+
"clap-3.1.6",
17+
"hyper-0.14.18",
18+
];
19+
20+
/// The default set of crates for opt-dist to collect rustc profiles.
21+
pub const RUSTC_PGO_CRATES: &[&str] = &[
22+
"externs",
23+
"ctfe-stress-5",
24+
"cargo-0.60.0",
25+
"token-stream-stress",
26+
"match-stress",
27+
"tuple-stress",
28+
"diesel-1.4.8",
29+
"bitmaps-3.1.0",
30+
];

src/tools/opt-dist/src/training.rs

+1-21
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,10 @@ use crate::exec::{cmd, CmdBuilder};
33
use crate::utils::io::{count_files, delete_directory};
44
use crate::utils::with_log_group;
55
use anyhow::Context;
6+
use build_helper::{LLVM_PGO_CRATES, RUSTC_PGO_CRATES};
67
use camino::{Utf8Path, Utf8PathBuf};
78
use humansize::BINARY;
89

9-
const LLVM_PGO_CRATES: &[&str] = &[
10-
"syn-1.0.89",
11-
"cargo-0.60.0",
12-
"serde-1.0.136",
13-
"ripgrep-13.0.0",
14-
"regex-1.5.5",
15-
"clap-3.1.6",
16-
"hyper-0.14.18",
17-
];
18-
19-
const RUSTC_PGO_CRATES: &[&str] = &[
20-
"externs",
21-
"ctfe-stress-5",
22-
"cargo-0.60.0",
23-
"token-stream-stress",
24-
"match-stress",
25-
"tuple-stress",
26-
"diesel-1.4.8",
27-
"bitmaps-3.1.0",
28-
];
29-
3010
fn init_compiler_benchmarks(
3111
env: &Environment,
3212
profiles: &[&str],

src/tools/tidy/src/deps.rs

+36
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub(crate) const WORKSPACES: &[(&str, ExceptionList, Option<(&[&str], &[&str])>)
6767
//("src/tools/miri/test-cargo-miri", &[], None), // FIXME uncomment once all deps are vendored
6868
//("src/tools/miri/test_dependencies", &[], None), // FIXME uncomment once all deps are vendored
6969
("src/tools/rust-analyzer", EXCEPTIONS_RUST_ANALYZER, None),
70+
("src/tools/rustc-perf", EXCEPTIONS_RUSTC_PERF, None),
7071
("src/tools/x", &[], None),
7172
// tidy-alphabetical-end
7273
];
@@ -142,6 +143,22 @@ const EXCEPTIONS_RUST_ANALYZER: ExceptionList = &[
142143
// tidy-alphabetical-end
143144
];
144145

146+
const EXCEPTIONS_RUSTC_PERF: ExceptionList = &[
147+
// tidy-alphabetical-start
148+
("alloc-no-stdlib", "BSD-3-Clause"),
149+
("alloc-stdlib", "BSD-3-Clause"),
150+
("brotli", "BSD-3-Clause/MIT"),
151+
("brotli-decompressor", "BSD-3-Clause/MIT"),
152+
("encoding_rs", "(Apache-2.0 OR MIT) AND BSD-3-Clause"),
153+
("inferno", "CDDL-1.0"),
154+
("instant", "BSD-3-Clause"),
155+
("ring", NON_STANDARD_LICENSE), // see EXCEPTIONS_NON_STANDARD_LICENSE_DEPS for more.
156+
("ryu", "Apache-2.0 OR BSL-1.0"),
157+
("snap", "BSD-3-Clause"),
158+
("subtle", "BSD-3-Clause"),
159+
// tidy-alphabetical-end
160+
];
161+
145162
const EXCEPTIONS_CRANELIFT: ExceptionList = &[
146163
// tidy-alphabetical-start
147164
("cranelift-bforest", "Apache-2.0 WITH LLVM-exception"),
@@ -178,6 +195,20 @@ const EXCEPTIONS_UEFI_QEMU_TEST: ExceptionList = &[
178195
("r-efi", "MIT OR Apache-2.0 OR LGPL-2.1-or-later"), // LGPL is not acceptible, but we use it under MIT OR Apache-2.0
179196
];
180197

198+
/// Placeholder for non-standard license file.
199+
const NON_STANDARD_LICENSE: &str = "NON_STANDARD_LICENSE";
200+
201+
/// These dependencies have non-standard licenses but are genenrally permitted.
202+
const EXCEPTIONS_NON_STANDARD_LICENSE_DEPS: &[&str] = &[
203+
// `ring` is included because it is an optional dependency of `hyper`,
204+
// which is a training data in rustc-perf for optimized build.
205+
// The license of it is generally `ISC AND MIT AND OpenSSL`,
206+
// though the `package.license` field is not set.
207+
//
208+
// See https://github.com/briansmith/ring/issues/902
209+
"ring",
210+
];
211+
181212
/// These are the root crates that are part of the runtime. The licenses for
182213
/// these and all their dependencies *must not* be in the exception list.
183214
const RUNTIME_CRATES: &[&str] = &["std", "core", "alloc", "test", "panic_abort", "panic_unwind"];
@@ -610,6 +641,11 @@ fn check_license_exceptions(metadata: &Metadata, exceptions: &[(&str, &str)], ba
610641
for pkg in metadata.packages.iter().filter(|p| p.name == *name) {
611642
match &pkg.license {
612643
None => {
644+
if *license == NON_STANDARD_LICENSE
645+
&& EXCEPTIONS_NON_STANDARD_LICENSE_DEPS.contains(&pkg.name.as_str())
646+
{
647+
continue;
648+
}
613649
tidy_error!(
614650
bad,
615651
"dependency exception `{}` does not declare a license expression",

src/tools/tidy/src/extdeps.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ use std::fs;
44
use std::path::Path;
55

66
/// List of allowed sources for packages.
7-
const ALLOWED_SOURCES: &[&str] = &["\"registry+https://github.com/rust-lang/crates.io-index\""];
7+
const ALLOWED_SOURCES: &[&str] = &[
8+
r#""registry+https://github.com/rust-lang/crates.io-index""#,
9+
// This is `rust_team_data` used by `site` in src/tools/rustc-perf,
10+
r#""git+https://github.com/rust-lang/team#a5260e76d3aa894c64c56e6ddc8545b9a98043ec""#,
11+
];
812

913
/// Checks for external package sources. `root` is the path to the directory that contains the
1014
/// workspace `Cargo.toml`.

0 commit comments

Comments
 (0)