From 10bb2c447c3240b3a8b06e31ded9662eeed2b1fd Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 5 Feb 2020 17:04:49 -0800 Subject: [PATCH] Ignore the host in rustc.verbose_version for metadata Cross-compiling the same target from different hosts should still produce the same output from rustc, but cargo effects a difference by hashing the full `rustc.verbose_version`, including `host: `. We can filter that particular line to allow different hosts to produce the same target metadata after all. --- src/cargo/core/compiler/context/compilation_files.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/compiler/context/compilation_files.rs b/src/cargo/core/compiler/context/compilation_files.rs index 1f8286d06ce..4b9c1d915e5 100644 --- a/src/cargo/core/compiler/context/compilation_files.rs +++ b/src/cargo/core/compiler/context/compilation_files.rs @@ -572,7 +572,13 @@ fn compute_metadata<'a, 'cfg>( unit.target.name().hash(&mut hasher); unit.target.kind().hash(&mut hasher); - bcx.rustc.verbose_version.hash(&mut hasher); + // Throw in the verbose rustc version output. Cross-compiling the same target from different + // hosts should still produce the same output, so filter out the host triple. + for line in bcx.rustc.verbose_version.lines() { + if !line.starts_with("host:") { + line.hash(&mut hasher); + } + } if cx.is_primary_package(unit) { // This is primarily here for clippy. This ensures that the clippy