Pin spec interpreter to a specific revision (#3868)

This commit updates the build script which clones the spec interpreter
for fuzzing to specifically pin at a hardcoded revision. This is
intended at improving reproducibility if we hit any issues while fuzzing
to ensure that the same wasmtime revision is always using the same spec
interpreter revision.
This commit is contained in:
Alex Crichton
2022-03-02 10:54:05 -06:00
committed by GitHub
parent e8ae3c0afd
commit f0fa01d552

View File

@@ -12,6 +12,7 @@ const OCAML_DIR: &'static str = "ocaml";
const SPEC_DIR: &'static str = "ocaml/spec"; const SPEC_DIR: &'static str = "ocaml/spec";
const SPEC_REPOSITORY: &'static str = "https://github.com/conrad-watt/spec"; const SPEC_REPOSITORY: &'static str = "https://github.com/conrad-watt/spec";
const SPEC_REPOSITORY_BRANCH: &'static str = "wasmtime_fuzzing"; const SPEC_REPOSITORY_BRANCH: &'static str = "wasmtime_fuzzing";
const SPEC_REPOSITORY_REV: &'static str = "7485eb0084b74871f96f261b9f916864596d8f1d";
fn main() { fn main() {
if cfg!(feature = "build-libinterpret") { if cfg!(feature = "build-libinterpret") {
@@ -33,7 +34,7 @@ fn build() {
} else { } else {
// Ensure the spec repository is present. // Ensure the spec repository is present.
if is_spec_repository_empty(SPEC_DIR) { if is_spec_repository_empty(SPEC_DIR) {
retrieve_spec_repository(SPEC_REPOSITORY, SPEC_REPOSITORY_BRANCH, SPEC_DIR) retrieve_spec_repository(SPEC_DIR)
} }
// Build the library to link to. // Build the library to link to.
@@ -72,17 +73,23 @@ fn is_spec_repository_empty(destination: &str) -> bool {
// Clone the spec repository into `destination`. This exists due to the large // Clone the spec repository into `destination`. This exists due to the large
// size of the dependencies (e.g. KaTeX) that are pulled if this were cloned // size of the dependencies (e.g. KaTeX) that are pulled if this were cloned
// recursively as a submodule. // recursively as a submodule.
fn retrieve_spec_repository(repository: &str, branch: &str, destination: &str) { fn retrieve_spec_repository(destination: &str) {
let status = Command::new("git") let status = Command::new("git")
.arg("clone") .arg("clone")
.arg("--depth") .arg(SPEC_REPOSITORY)
.arg("1")
.arg(repository)
.arg("-b") .arg("-b")
.arg(branch) .arg(SPEC_REPOSITORY_BRANCH)
.arg(destination) .arg(destination)
.status() .status()
.expect("Failed to execute 'git' command to clone spec repository."); .expect("Failed to execute 'git' command to clone spec repository.");
assert!(status.success(), "Failed to retrieve the spec repository.");
assert!(status.success(), "Failed to retrieve the spec repository.") let status = Command::new("git")
.arg("reset")
.arg("--hard")
.arg(SPEC_REPOSITORY_REV)
.current_dir(destination)
.status()
.expect("Failed to execute 'git' command to clone spec repository.");
assert!(status.success(), "Failed to reset to revision.");
} }