diff options
| author | Jubilee <workingjubilee@gmail.com> | 2024-10-02 21:26:58 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-02 21:26:58 -0700 |
| commit | 44f6275e1453822b01d551cd5c93ca16b8753da6 (patch) | |
| tree | 7fac9a6e3b3adce40d4b2bb231abdc4883ab8107 /compiler/rustc_session/src | |
| parent | ad9c494835e746fb7c8a26eeed0ad90e4e834058 (diff) | |
| parent | 58c5ac43aea5c94d61e3a7a4e8646e714230574d (diff) | |
| download | rust-44f6275e1453822b01d551cd5c93ca16b8753da6.tar.gz rust-44f6275e1453822b01d551cd5c93ca16b8753da6.zip | |
Rollup merge of #126930 - Xaeroxe:file-checksum-hint, r=chenyukang
Add unstable support for outputting file checksums for use in cargo Adds an unstable option that appends file checksums and expected lengths to the end of the dep-info file such that `cargo` can read and use these values as an alternative to file mtimes. This PR powers the changes made in this cargo PR https://github.com/rust-lang/cargo/pull/14137 Here's the tracking issue for the cargo feature https://github.com/rust-lang/cargo/issues/14136.
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 19 |
2 files changed, 22 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 0d293415aa9..d2c03e588ff 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1242,6 +1242,10 @@ impl UnstableOptions { } }) } + + pub fn checksum_hash_algorithm(&self) -> Option<SourceFileHashAlgorithm> { + self.checksum_hash_algorithm + } } // The type of entry function, so users can have their own entry functions diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 1de09b8be4d..d63276db493 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -418,7 +418,9 @@ mod desc { "one of: `legacy`, `v0` (RFC 2603), or `hashed`"; pub(crate) const parse_opt_symbol_visibility: &str = "one of: `hidden`, `protected`, or `interposable`"; - pub(crate) const parse_src_file_hash: &str = "either `md5` or `sha1`"; + pub(crate) const parse_cargo_src_file_hash: &str = + "one of `blake3`, `md5`, `sha1`, or `sha256`"; + pub(crate) const parse_src_file_hash: &str = "one of `md5`, `sha1`, or `sha256`"; pub(crate) const parse_relocation_model: &str = "one of supported relocation models (`rustc --print relocation-models`)"; pub(crate) const parse_code_model: &str = @@ -1288,6 +1290,19 @@ mod parse { true } + pub(crate) fn parse_cargo_src_file_hash( + slot: &mut Option<SourceFileHashAlgorithm>, + v: Option<&str>, + ) -> bool { + match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) { + Some(hash_kind) => { + *slot = Some(hash_kind); + } + _ => return false, + } + true + } + pub(crate) fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool { match v { Some(s) => { @@ -1688,6 +1703,8 @@ options! { "instrument control-flow architecture protection"), check_cfg_all_expected: bool = (false, parse_bool, [UNTRACKED], "show all expected values in check-cfg diagnostics (default: no)"), + checksum_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_cargo_src_file_hash, [TRACKED], + "hash algorithm of source files used to check freshness in cargo (`blake3` or `sha256`)"), codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED], "the backend to use"), combine_cgu: bool = (false, parse_bool, [TRACKED], |
