diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:01 +0000 |
commit | c29d7c1ba10d6debd11f9d8aad5d069a6491e60e (patch) | |
tree | a2ad46eb513b315f0efd8170af5eb08870165757 /debian/patches/upstream/u-fix-get-toml-when-test.patch | |
parent | Merging upstream version 1.76.0+dfsg1. (diff) | |
download | rustc-c29d7c1ba10d6debd11f9d8aad5d069a6491e60e.tar.xz rustc-c29d7c1ba10d6debd11f9d8aad5d069a6491e60e.zip |
Adding debian version 1.76.0+dfsg1-1.debian/1.76.0+dfsg1-1debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/patches/upstream/u-fix-get-toml-when-test.patch')
-rw-r--r-- | debian/patches/upstream/u-fix-get-toml-when-test.patch | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/debian/patches/upstream/u-fix-get-toml-when-test.patch b/debian/patches/upstream/u-fix-get-toml-when-test.patch new file mode 100644 index 000000000..cbe054b73 --- /dev/null +++ b/debian/patches/upstream/u-fix-get-toml-when-test.patch @@ -0,0 +1,54 @@ +From: Debian Rust Maintainers <pkg-rust-maintainers@alioth-lists.debian.net> +Date: Thu, 13 Jun 2024 11:16:38 +0200 +Subject: Fix get_toml() when cfg(test) + +Bug: https://github.com/rust-lang/rust/issues/105766 +Last-Update: 2023-03-29 + +When cfg(test), Config::parse doesn't parse a config.toml but uses default +values, failing when the initial rustc is needed. This is a workaround before +upstream issue gets solved. +Last-Update: 2023-03-29 +--- + src/bootstrap/src/core/config/config.rs | 28 ++++++++++++++++++++++++++-- + 1 file changed, 26 insertions(+), 2 deletions(-) + +diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs +index f1e1b89..738d2e1 100644 +--- a/src/bootstrap/src/core/config/config.rs ++++ b/src/bootstrap/src/core/config/config.rs +@@ -1180,8 +1180,32 @@ impl Config { + + pub fn parse(args: &[String]) -> Config { + #[cfg(test)] +- fn get_toml(_: &Path) -> TomlConfig { +- TomlConfig::default() ++ fn get_toml(file: &Path) -> TomlConfig { ++ // Debian: We use previous version as a custom rustc, which ++ // unfortunately won't be picked up because config.toml isn't ++ // read when cfg!(test). Making tests use the entirety of our ++ // config.toml isn't feasible either as it panicks on ++ // GitRepo::Llvm (d-bootstrap-custom-debuginfo-path.patch), so ++ // only give paths of initial rustc and cargo. ++ let contents = ++ t!(fs::read_to_string(file), format!("config file {} not found", file.display())); ++ // Deserialize to Value and then TomlConfig to prevent the Deserialize impl of ++ // TomlConfig and sub types to be monomorphized 5x by toml. ++ toml::from_str(&contents) ++ .and_then(|table: toml::Value| TomlConfig::deserialize(table)) ++ .map(|table| { ++ let mut config = TomlConfig::default(); ++ let mut build = Build::default(); ++ let cbuild = table.build.unwrap(); ++ build.rustc = cbuild.rustc; ++ build.cargo = cbuild.cargo; ++ config.build = Some(build); ++ config ++ }) ++ .unwrap_or_else(|err| { ++ eprintln!("failed to parse TOML configuration '{}': {err}", file.display()); ++ crate::detail_exit(2); ++ }) + } + + #[cfg(not(test))] |