From cd5b26e3cee3ceab7aef734800d89159d06731d5 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Wed, 12 Jun 2024 20:47:37 +0200 Subject: [PATCH] Initial commit --- .gitignore | 3 + Cargo.lock | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 7 ++ src/main.rs | 151 ++++++++++++++++++++++++++++++++++ 4 files changed, 388 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4d8df6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +/targets +/results diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..4c38efd --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,227 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "backtrace" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "cc" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "color-eyre" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + +[[package]] +name = "does-it-build" +version = "0.1.0" +dependencies = [ + "color-eyre", +] + +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "miniz_oxide" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +dependencies = [ + "adler", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-error" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "sharded-slab", + "thread_local", + "tracing-core", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..5019015 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "does-it-build" +version = "0.1.0" +edition = "2021" + +[dependencies] +color-eyre = "0.6.3" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..9d07316 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,151 @@ +use std::{collections::BTreeMap, num::NonZeroUsize, path::Path, process::Command, sync::Mutex}; + +use color_eyre::{ + eyre::{bail, WrapErr}, + Result, +}; + +fn main() -> Result<()> { + let targets = String::from_utf8( + Command::new("rustc") + .arg("--print") + .arg("target-list") + .output()? + .stdout, + )?; + + let year = 2024; + let current_month = 6_u32; + let current_day = 12_u32; + + let dates = (current_month.saturating_sub(5)..=current_month).flat_map(|month| { + if month == current_month && current_day <= 16 { + vec![format!("{year}-{month:0>2}-01")] + } else { + vec![ + format!("{year}-{month:0>2}-01"), + format!("{year}-{month:0>2}-15"), + ] + } + }); + + for date in dates { + println!("Doing date {date}"); + + let toolchain = format!("nightly-{date}"); + let result = Command::new("rustup") + .arg("toolchain") + .arg("install") + .arg(&toolchain) + .arg("--profile") + .arg("minimal") + .spawn()? + .wait()?; + if !result.success() { + bail!("rustup failed"); + } + let result = Command::new("rustup") + .arg("component") + .arg("add") + .arg("rust-src") + .arg("--toolchain") + .arg(&toolchain) + .spawn()? + .wait()?; + if !result.success() { + bail!("rustup failed"); + } + + let queue = targets.lines().collect::>(); + let queue = &Mutex::new(queue); + + std::fs::create_dir_all("targets")?; + + let failures = Mutex::new(BTreeMap::new()); + + let targets = Path::new("targets").join(&toolchain); + + std::thread::scope(|s| -> Result<()> { + let mut handles = vec![]; + + for _ in 0..std::thread::available_parallelism() + .unwrap_or(NonZeroUsize::new(1).unwrap()) + .get() + { + let handle = s.spawn(|| -> Result<()> { + loop { + let target = { + let mut queue = queue.lock().unwrap(); + let Some(next) = queue.pop() else { + return Ok(()); + }; + println!("remaining: {:>3 } - {next}", queue.len()); + next + }; + (|| -> Result<()> { + let target_dir = targets.join(target); + std::fs::create_dir_all(&target_dir) + .wrap_err("creating target src dir")?; + + if !target_dir.join("Cargo.toml").exists() { + let init = Command::new("cargo") + .args(["init", "--lib", "--name", "target-test"]) + .current_dir(&target_dir) + .output() + .wrap_err("spawning cargo init")?; + if !init.status.success() { + bail!("init failed: {}", String::from_utf8(init.stderr)?); + } + } + let librs = target_dir.join("src").join("lib.rs"); + std::fs::write(&librs, "#![no_std]\n") + .wrap_err_with(|| format!("writing to {}", librs.display()))?; + + let output = Command::new("cargo") + .arg(format!("+{toolchain}")) + .args(["build", "-Zbuild-std=core", "--target"]) + .arg(target) + .current_dir(&target_dir) + .output() + .wrap_err("spawning cargo build")?; + if !output.status.success() { + println!("failure: {target}"); + let stderr = String::from_utf8(output.stderr) + .wrap_err("cargo stderr utf8")?; + failures.lock().unwrap().insert(target.to_owned(), stderr); + } + Ok(()) + })() + .wrap_err_with(|| format!("while checking {target}"))?; + } + }); + handles.push(handle); + } + + for handle in handles { + handle.join().unwrap()?; + } + + Ok(()) + })?; + + std::fs::create_dir_all("results").wrap_err("creating results directory")?; + std::fs::write( + Path::new("results").join(date), + failures + .lock() + .unwrap() + .keys() + .cloned() + .collect::>() + .join(","), + ) + .wrap_err("writing results file")?; + + for (target, stderr) in failures.into_inner().unwrap() { + println!("-----------------\nBROKEN TARGET: {target}\n{stderr}\n\n"); + } + } + + Ok(()) +}