From 8d9104b221de41be23c5b2633af221d9407fe33a Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Sun, 19 Jan 2025 11:01:06 +0100 Subject: [PATCH 1/2] use threads instead of futures in build.rs There's no inherent reason why we should use future-based concurrency in build.rs. We don't spawn many futures and we don't make use of any of the nice patterns made possible by structured concurrency. The downside of using futures is that we have to pull in a bunch of dependencies. Switching to sync code and removing the dependencies resulted in a nice performance improvement (35s -> 30s). Also, it's just good practice to reduce the number of unneeded dependencies especially if some of them are unmaintained. --- Cargo.lock | 353 ----------------------------------------------------- Cargo.toml | 3 - build.rs | 101 ++++++++------- 3 files changed, 54 insertions(+), 403 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0cbe73c9..78bc7d77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,70 +14,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" -[[package]] -name = "async-channel" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-io" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" -dependencies = [ - "async-lock", - "autocfg", - "cfg-if", - "concurrent-queue", - "futures-lite", - "log", - "parking", - "polling", - "rustix", - "slab", - "socket2", - "waker-fn", -] - -[[package]] -name = "async-lock" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-process" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9d28b1d97e08915212e2e45310d47854eafa69600756fc735fb788f75199c9" -dependencies = [ - "async-io", - "async-lock", - "autocfg", - "blocking", - "cfg-if", - "event-listener", - "futures-lite", - "rustix", - "signal-hook", - "windows-sys", -] - -[[package]] -name = "async-task" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" - [[package]] name = "atomic-polyfill" version = "0.1.11" @@ -87,12 +23,6 @@ dependencies = [ "critical-section", ] -[[package]] -name = "atomic-waker" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" - [[package]] name = "autocfg" version = "1.1.0" @@ -138,32 +68,14 @@ dependencies = [ "wyz", ] -[[package]] -name = "blocking" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" -dependencies = [ - "async-channel", - "async-lock", - "async-task", - "atomic-waker", - "fastrand", - "futures-lite", - "log", -] - [[package]] name = "bootloader" version = "0.11.9" dependencies = [ "anyhow", - "async-process", "bootloader-boot-config", "bootloader_test_runner", "fatfs", - "futures", - "futures-concurrency", "gpt", "llvm-tools", "mbrman", @@ -293,15 +205,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "concurrent-queue" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "conquer-once" version = "0.3.2" @@ -338,15 +241,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" -[[package]] -name = "crossbeam-utils" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] - [[package]] name = "errno" version = "0.3.1" @@ -368,12 +262,6 @@ dependencies = [ "libc", ] -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - [[package]] name = "fastrand" version = "1.9.0" @@ -400,121 +288,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" -[[package]] -name = "futures" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-concurrency" -version = "7.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b726119e6cd29cf120724495b2085e1ed3d17821ea17b86de54576d1aa565f5e" -dependencies = [ - "bitvec", - "futures-core", - "pin-project", -] - -[[package]] -name = "futures-core" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" - -[[package]] -name = "futures-executor" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" - -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - -[[package]] -name = "futures-macro" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", -] - -[[package]] -name = "futures-sink" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" - -[[package]] -name = "futures-task" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" - -[[package]] -name = "futures-util" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - [[package]] name = "getrandom" version = "0.2.10" @@ -648,12 +421,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - [[package]] name = "noto-sans-mono-bitmap" version = "0.1.6" @@ -672,60 +439,6 @@ version = "0.1.0-alpha.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa50141d081512ab30fd9e7e7692476866df5098b028536ad6680212e717fa8d" -[[package]] -name = "parking" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" - -[[package]] -name = "pin-project" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "polling" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" -dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if", - "concurrent-queue", - "libc", - "log", - "pin-project-lite", - "windows-sys", -] - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -940,44 +653,6 @@ dependencies = [ "serde", ] -[[package]] -name = "signal-hook" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "732768f1176d21d09e076c23a93123d40bba92d50c4058da34d45c8de8e682b9" -dependencies = [ - "libc", - "signal-hook-registry", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - -[[package]] -name = "slab" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" -dependencies = [ - "autocfg", -] - -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "spin" version = "0.9.8" @@ -1261,40 +936,12 @@ dependencies = [ "quote", ] -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index c5fdc211..a854ef63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -129,9 +129,6 @@ opt-level = 2 [build-dependencies] llvm-tools = "0.1.1" -async-process = "1.6.0" -futures = "0.3.25" -futures-concurrency = "7.0.0" [package.metadata.docs.rs] rustc-args = ["--cfg", "docsrs_dummy_build"] diff --git a/build.rs b/build.rs index 3f543d3f..c83c6145 100644 --- a/build.rs +++ b/build.rs @@ -1,34 +1,40 @@ -use async_process::Command; -use futures::executor::block_on; -use futures_concurrency::future::Join; use std::path::{Path, PathBuf}; +use std::process::Command; const BOOTLOADER_VERSION: &str = env!("CARGO_PKG_VERSION"); fn main() { #[cfg(not(feature = "uefi"))] - async fn uefi_main() {} + fn uefi_main() {} #[cfg(not(feature = "bios"))] - async fn bios_main() {} + fn bios_main() {} - block_on((uefi_main(), bios_main()).join()); + // Spawn two threads to build the uefi and bios code concurrently. + let uefi_main_handle = std::thread::spawn(uefi_main); + let bios_main_handle = std::thread::spawn(bios_main); + + // Wait for the threads to finish. + uefi_main_handle.join().unwrap(); + bios_main_handle.join().unwrap(); } #[cfg(feature = "bios")] -async fn bios_main() { - let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); +fn bios_main() { // Run the bios build commands concurrently. // (Cargo already uses multiple threads for building dependencies, but these // BIOS crates don't have enough dependencies to utilize all cores on modern // CPUs. So by running the build commands in parallel, we increase the number // of utilized cores.) - let (bios_boot_sector_path, bios_stage_2_path, bios_stage_3_path, bios_stage_4_path) = ( - build_bios_boot_sector(&out_dir), - build_bios_stage_2(&out_dir), - build_bios_stage_3(&out_dir), - build_bios_stage_4(&out_dir), - ) - .join() - .await; + let bios_boot_sector_path_handle = std::thread::spawn(build_bios_boot_sector); + let bios_stage_2_path_handle = std::thread::spawn(build_bios_stage_2); + let bios_stage_3_path_handle = std::thread::spawn(build_bios_stage_3); + let bios_stage_4_path_handle = std::thread::spawn(build_bios_stage_4); + + // Wait for the commands to finish. + let bios_boot_sector_path = bios_boot_sector_path_handle.join().unwrap(); + let bios_stage_2_path = bios_stage_2_path_handle.join().unwrap(); + let bios_stage_3_path = bios_stage_3_path_handle.join().unwrap(); + let bios_stage_4_path = bios_stage_4_path_handle.join().unwrap(); + println!( "cargo:rustc-env=BIOS_BOOT_SECTOR_PATH={}", bios_boot_sector_path.display() @@ -48,11 +54,8 @@ async fn bios_main() { } #[cfg(feature = "uefi")] -async fn uefi_main() { - let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); - - let uefi_path = build_uefi_bootloader(&out_dir).await; - +fn uefi_main() { + let uefi_path = build_uefi_bootloader(); println!( "cargo:rustc-env=UEFI_BOOTLOADER_PATH={}", uefi_path.display() @@ -61,7 +64,8 @@ async fn uefi_main() { #[cfg(not(docsrs_dummy_build))] #[cfg(feature = "uefi")] -async fn build_uefi_bootloader(out_dir: &Path) -> PathBuf { +fn build_uefi_bootloader() -> PathBuf { + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into()); let mut cmd = Command::new(cargo); cmd.arg("install").arg("bootloader-x86_64-uefi"); @@ -77,12 +81,11 @@ async fn build_uefi_bootloader(out_dir: &Path) -> PathBuf { cmd.arg("--target").arg("x86_64-unknown-uefi"); cmd.arg("-Zbuild-std=core") .arg("-Zbuild-std-features=compiler-builtins-mem"); - cmd.arg("--root").arg(out_dir); + cmd.arg("--root").arg(&out_dir); cmd.env_remove("RUSTFLAGS"); cmd.env_remove("CARGO_ENCODED_RUSTFLAGS"); let status = cmd .status() - .await .expect("failed to run cargo install for uefi bootloader"); if status.success() { let path = out_dir.join("bin").join("bootloader-x86_64-uefi.efi"); @@ -100,9 +103,10 @@ async fn build_uefi_bootloader(out_dir: &Path) -> PathBuf { // This will put an empty file in out_dir and return its path. #[cfg(docsrs_dummy_build)] #[cfg(feature = "uefi")] -async fn build_uefi_bootloader(out_dir: &Path) -> PathBuf { +fn build_uefi_bootloader() -> PathBuf { use std::fs::File; + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); let path = out_dir.join("bootloader-dummy-bootloader-uefi"); if File::create(&path).is_err() { @@ -118,7 +122,8 @@ async fn build_uefi_bootloader(out_dir: &Path) -> PathBuf { #[cfg(not(docsrs_dummy_build))] #[cfg(feature = "bios")] -async fn build_bios_boot_sector(out_dir: &Path) -> PathBuf { +fn build_bios_boot_sector() -> PathBuf { + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into()); let mut cmd = Command::new(cargo); cmd.arg("install").arg("bootloader-x86_64-bios-boot-sector"); @@ -137,13 +142,12 @@ async fn build_bios_boot_sector(out_dir: &Path) -> PathBuf { cmd.arg("--profile").arg("stage-1"); cmd.arg("-Zbuild-std=core") .arg("-Zbuild-std-features=compiler-builtins-mem"); - cmd.arg("--root").arg(out_dir); + cmd.arg("--root").arg(&out_dir); cmd.env_remove("RUSTFLAGS"); cmd.env_remove("CARGO_ENCODED_RUSTFLAGS"); cmd.env_remove("RUSTC_WORKSPACE_WRAPPER"); // used by clippy let status = cmd .status() - .await .expect("failed to run cargo install for bios bootsector"); let elf_path = if status.success() { let path = out_dir @@ -157,16 +161,17 @@ async fn build_bios_boot_sector(out_dir: &Path) -> PathBuf { } else { panic!("failed to build bios boot sector"); }; - convert_elf_to_bin(elf_path).await + convert_elf_to_bin(elf_path) } // dummy implementation because docsrs builds have no network access. // This will put an empty file in out_dir and return its path. #[cfg(docsrs_dummy_build)] #[cfg(feature = "bios")] -async fn build_bios_boot_sector(out_dir: &Path) -> PathBuf { +fn build_bios_boot_sector() -> PathBuf { use std::fs::File; + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); let path = out_dir.join("bootloader-dummy-bios-boot-sector"); if File::create(&path).is_err() { @@ -182,7 +187,8 @@ async fn build_bios_boot_sector(out_dir: &Path) -> PathBuf { #[cfg(not(docsrs_dummy_build))] #[cfg(feature = "bios")] -async fn build_bios_stage_2(out_dir: &Path) -> PathBuf { +fn build_bios_stage_2() -> PathBuf { + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into()); let mut cmd = Command::new(cargo); cmd.arg("install").arg("bootloader-x86_64-bios-stage-2"); @@ -205,13 +211,12 @@ async fn build_bios_stage_2(out_dir: &Path) -> PathBuf { cmd.arg("--profile").arg("stage-2"); cmd.arg("-Zbuild-std=core") .arg("-Zbuild-std-features=compiler-builtins-mem"); - cmd.arg("--root").arg(out_dir); + cmd.arg("--root").arg(&out_dir); cmd.env_remove("RUSTFLAGS"); cmd.env_remove("CARGO_ENCODED_RUSTFLAGS"); cmd.env_remove("RUSTC_WORKSPACE_WRAPPER"); // used by clippy let status = cmd .status() - .await .expect("failed to run cargo install for bios second stage"); let elf_path = if status.success() { let path = out_dir.join("bin").join("bootloader-x86_64-bios-stage-2"); @@ -223,16 +228,17 @@ async fn build_bios_stage_2(out_dir: &Path) -> PathBuf { } else { panic!("failed to build bios second stage"); }; - convert_elf_to_bin(elf_path).await + convert_elf_to_bin(elf_path) } // dummy implementation because docsrs builds have no network access. // This will put an empty file in out_dir and return its path. #[cfg(docsrs_dummy_build)] #[cfg(feature = "bios")] -async fn build_bios_stage_2(out_dir: &Path) -> PathBuf { +fn build_bios_stage_2() -> PathBuf { use std::fs::File; + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); let path = out_dir.join("bootloader-dummy-bios-stage-2"); if File::create(&path).is_err() { @@ -248,7 +254,8 @@ async fn build_bios_stage_2(out_dir: &Path) -> PathBuf { #[cfg(not(docsrs_dummy_build))] #[cfg(feature = "bios")] -async fn build_bios_stage_3(out_dir: &Path) -> PathBuf { +fn build_bios_stage_3() -> PathBuf { + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into()); let mut cmd = Command::new(cargo); cmd.arg("install").arg("bootloader-x86_64-bios-stage-3"); @@ -267,13 +274,12 @@ async fn build_bios_stage_3(out_dir: &Path) -> PathBuf { cmd.arg("--profile").arg("stage-3"); cmd.arg("-Zbuild-std=core") .arg("-Zbuild-std-features=compiler-builtins-mem"); - cmd.arg("--root").arg(out_dir); + cmd.arg("--root").arg(&out_dir); cmd.env_remove("RUSTFLAGS"); cmd.env_remove("CARGO_ENCODED_RUSTFLAGS"); cmd.env_remove("RUSTC_WORKSPACE_WRAPPER"); // used by clippy let status = cmd .status() - .await .expect("failed to run cargo install for bios stage-3"); let elf_path = if status.success() { let path = out_dir.join("bin").join("bootloader-x86_64-bios-stage-3"); @@ -285,16 +291,17 @@ async fn build_bios_stage_3(out_dir: &Path) -> PathBuf { } else { panic!("failed to build bios stage-3"); }; - convert_elf_to_bin(elf_path).await + convert_elf_to_bin(elf_path) } // dummy implementation because docsrs builds have no network access. // This will put an empty file in out_dir and return its path. #[cfg(docsrs_dummy_build)] #[cfg(feature = "bios")] -async fn build_bios_stage_3(out_dir: &Path) -> PathBuf { +fn build_bios_stage_3() -> PathBuf { use std::fs::File; + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); let path = out_dir.join("bootloader-dummy-bios-stage-3"); if File::create(&path).is_err() { @@ -310,7 +317,8 @@ async fn build_bios_stage_3(out_dir: &Path) -> PathBuf { #[cfg(not(docsrs_dummy_build))] #[cfg(feature = "bios")] -async fn build_bios_stage_4(out_dir: &Path) -> PathBuf { +fn build_bios_stage_4() -> PathBuf { + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into()); let mut cmd = Command::new(cargo); cmd.arg("install").arg("bootloader-x86_64-bios-stage-4"); @@ -329,13 +337,12 @@ async fn build_bios_stage_4(out_dir: &Path) -> PathBuf { cmd.arg("--profile").arg("stage-4"); cmd.arg("-Zbuild-std=core") .arg("-Zbuild-std-features=compiler-builtins-mem"); - cmd.arg("--root").arg(out_dir); + cmd.arg("--root").arg(&out_dir); cmd.env_remove("RUSTFLAGS"); cmd.env_remove("CARGO_ENCODED_RUSTFLAGS"); cmd.env_remove("RUSTC_WORKSPACE_WRAPPER"); // used by clippy let status = cmd .status() - .await .expect("failed to run cargo install for bios stage-4"); let elf_path = if status.success() { let path = out_dir.join("bin").join("bootloader-x86_64-bios-stage-4"); @@ -348,16 +355,17 @@ async fn build_bios_stage_4(out_dir: &Path) -> PathBuf { panic!("failed to build bios stage-4"); }; - convert_elf_to_bin(elf_path).await + convert_elf_to_bin(elf_path) } // dummy implementation because docsrs builds have no network access. // This will put an empty file in out_dir and return its path. #[cfg(docsrs_dummy_build)] #[cfg(feature = "bios")] -async fn build_bios_stage_4(out_dir: &Path) -> PathBuf { +fn build_bios_stage_4() -> PathBuf { use std::fs::File; + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); let path = out_dir.join("bootloader-dummy-bios-stage-4"); if File::create(&path).is_err() { @@ -373,7 +381,7 @@ async fn build_bios_stage_4(out_dir: &Path) -> PathBuf { #[cfg(not(docsrs_dummy_build))] #[cfg(feature = "bios")] -async fn convert_elf_to_bin(elf_path: PathBuf) -> PathBuf { +fn convert_elf_to_bin(elf_path: PathBuf) -> PathBuf { let flat_binary_path = elf_path.with_extension("bin"); let llvm_tools = llvm_tools::LlvmTools::new().expect("failed to get llvm tools"); @@ -390,7 +398,6 @@ async fn convert_elf_to_bin(elf_path: PathBuf) -> PathBuf { cmd.arg(&flat_binary_path); let output = cmd .output() - .await .expect("failed to execute llvm-objcopy command"); if !output.status.success() { panic!( From 51576e30553315710f934e5dfa67a0caeaf97553 Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Sun, 19 Jan 2025 11:09:08 +0100 Subject: [PATCH 2/2] remove macos-12 from CI test matrix macos-12 has been removed from GitHub actions. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2d9e796..981deef6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-12, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} timeout-minutes: 30