From 6a4716f0f403e69241bb49e869caca45740b947c Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Tue, 16 Nov 2021 14:56:30 -0800 Subject: [PATCH] Two CI fixes: Windows line-endings in manifest file, and "meta deterministic check". - The Windows line-ending canonicalization was incomplete: we need to canonicalize the manifest text itself too! - The "meta deterministic check" runs the cranelift-codegen build script N times outside of the source tree, examining what it produces to ensure the output is always the same (is detministic). This works fine when everything comes from the internal DSL, but when reading ISLE, this breaks because we no longer have the ISLE source paths. The initial ISLE integration did not hit this because without the `rebuild-isle` feature, it simply did nothing in the build script; now, with the manifest check, we hit the issue. The fix for now is just to turn off all ISLE-specific behavior in the build script by setting a special-purpose Cargo feature in the specific CI job. Eventually IMHO we should remove or find a better way to do this check. --- .github/workflows/main.yml | 2 +- cranelift/codegen/Cargo.toml | 4 ++++ cranelift/codegen/build.rs | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b880bfafb3..530f8941fa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -400,7 +400,7 @@ jobs: submodules: true - name: Install Rust run: rustup update stable && rustup default stable - - run: cd cranelift/codegen && cargo build --features all-arch + - run: cd cranelift/codegen && cargo build --features "all-arch completely-skip-isle-for-ci-deterministic-check" - run: ci/ensure_deterministic_build.sh # Perform release builds of `wasmtime` and `libwasmtime.so`. Builds on diff --git a/cranelift/codegen/Cargo.toml b/cranelift/codegen/Cargo.toml index ae8066ac16..ba7e7488b6 100644 --- a/cranelift/codegen/Cargo.toml +++ b/cranelift/codegen/Cargo.toml @@ -104,6 +104,10 @@ souper-harvest = ["souper-ir", "souper-ir/stringify"] # Recompile ISLE DSL source files into their generated Rust code. rebuild-isle = ["isle", "cranelift-codegen-meta/rebuild-isle"] +# A hack to skip the ISLE-rebuild logic when testing for determinism +# with the "Meta deterministic check" CI job. +completely-skip-isle-for-ci-deterministic-check = [] + [badges] maintenance = { status = "experimental" } diff --git a/cranelift/codegen/build.rs b/cranelift/codegen/build.rs index a3f31c7db9..adb99386c5 100644 --- a/cranelift/codegen/build.rs +++ b/cranelift/codegen/build.rs @@ -78,7 +78,17 @@ fn main() { .unwrap() } - maybe_rebuild_isle(crate_dir).expect("Unhandled failure in ISLE rebuild"); + // The "Meta deterministic check" CI job runs this build script N + // times to ensure it produces the same output + // consistently. However, it runs the script in a fresh directory, + // without any of the source tree present; this breaks our + // manifest check (we need the ISLE source to be present). To keep + // things simple, we just disable all ISLE-related logic for this + // specific CI job. + #[cfg(not(feature = "completely-skip-isle-for-ci-deterministic-check"))] + { + maybe_rebuild_isle(crate_dir).expect("Unhandled failure in ISLE rebuild"); + } let pkg_version = env::var("CARGO_PKG_VERSION").unwrap(); let mut cmd = std::process::Command::new("git"); @@ -259,6 +269,9 @@ fn maybe_rebuild_isle( } let manifest = std::fs::read_to_string(compilation.manifest_filename())?; + // Canonicalize Windows line-endings into Unix line-endings in + // the manifest text itself. + let manifest = manifest.replace("\r\n", "\n"); let expected_manifest = compilation.compute_manifest()?; if manifest != expected_manifest { rebuild_compilations.push((compilation, expected_manifest));