Skip to content

Commit 556e4c9

Browse files
authored
Unrolled build for #142139
Rollup merge of #142139 - erickt:include-hashes, r=Mark-Simulacrum Include additional hashes in src/stage0 This patch changes `bump-stage0` to include: * The sha256 hash of the channel manifest used to create `src/stage0`. * The rust and rustfmt git commit in `src/stage0`. * Hashes of all the artifacts, like the source tarball, in `src/stage0`. Combined this will allow for: * Projects that bootstrap their own compiler, such as Fuchsia, or users of [bootstrap], to build their compilers offline without needing to communicate with static.rust-lang.org. * Auditors to detect if the channel manifest, and all the artifacts inside the manifest, were modified after it was used to generate `src/stage0`. Furthermore, if they did find modified artifacts, they could determine if the Rust Signing Key was compromised by checking if any modified file was signed properly. finally, it allows regeneration of `src/stage0` when specifying both the day of the build for rust, and the day of the build for rustfmt, which can allow a maintainer to regenerate `src/stage0` to verify nothing changed. [bootstrap]: https://github.com/dtolnay/bootstrap [mrustc]: https://github.com/thepowersgang/mrustc
2 parents 4ffeda1 + 76bb0d1 commit 556e4c9

File tree

6 files changed

+627
-512
lines changed

6 files changed

+627
-512
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,10 @@ dependencies = [
334334
"anyhow",
335335
"build_helper",
336336
"curl",
337+
"hex",
337338
"indexmap",
338339
"serde",
340+
"sha2",
339341
"toml 0.8.23",
340342
]
341343

src/bootstrap/src/core/download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ pub(crate) fn maybe_download_rustfmt<'a>(
506506
return Some(PathBuf::new());
507507
}
508508

509-
let VersionMetadata { date, version } = dwn_ctx.stage0_metadata.rustfmt.as_ref()?;
509+
let VersionMetadata { date, version, .. } = dwn_ctx.stage0_metadata.rustfmt.as_ref()?;
510510
let channel = format!("{version}-{date}");
511511

512512
let host = dwn_ctx.host_target;

src/build_helper/src/stage0_parser.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub struct Stage0 {
1010

1111
#[derive(Default, Clone)]
1212
pub struct VersionMetadata {
13+
pub channel_manifest_hash: String,
14+
pub git_commit_hash: String,
1315
pub date: String,
1416
pub version: String,
1517
}
@@ -50,9 +52,21 @@ pub fn parse_stage0_file() -> Stage0 {
5052
"git_merge_commit_email" => stage0.config.git_merge_commit_email = value.to_owned(),
5153
"nightly_branch" => stage0.config.nightly_branch = value.to_owned(),
5254

55+
"compiler_channel_manifest_hash" => {
56+
stage0.compiler.channel_manifest_hash = value.to_owned()
57+
}
58+
"compiler_git_commit_hash" => stage0.compiler.git_commit_hash = value.to_owned(),
5359
"compiler_date" => stage0.compiler.date = value.to_owned(),
5460
"compiler_version" => stage0.compiler.version = value.to_owned(),
5561

62+
"rustfmt_channel_manifest_hash" => {
63+
stage0.rustfmt.get_or_insert(VersionMetadata::default()).channel_manifest_hash =
64+
value.to_owned();
65+
}
66+
"rustfmt_git_commit_hash" => {
67+
stage0.rustfmt.get_or_insert(VersionMetadata::default()).git_commit_hash =
68+
value.to_owned();
69+
}
5670
"rustfmt_date" => {
5771
stage0.rustfmt.get_or_insert(VersionMetadata::default()).date = value.to_owned();
5872
}

0 commit comments

Comments
 (0)