From 7856c7d1c2d2c8eeee68c7543c2d44e2164b5196 Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Fri, 31 Oct 2025 10:58:21 -0400 Subject: [PATCH 01/15] add LLVM 18.x as a git submodule This changeset is based on https://github.com/paritytech/revive/pull/346 --- .github/workflows/generate_versions.yml | 2 + .github/workflows/release-llvm.yml | 6 +- .github/workflows/release.yml | 4 + .github/workflows/test-llvm-builder.yml | 3 +- .github/workflows/test-wasm.yml | 4 + .github/workflows/test.yml | 2 + .gitignore | 4 +- .gitmodules | 4 + Cargo.lock | 42 ++-------- LLVM.lock | 3 - Makefile | 2 +- crates/llvm-builder/Cargo.toml | 2 - crates/llvm-builder/src/lib.rs | 84 ++----------------- .../llvm-builder/src/revive_llvm/arguments.rs | 14 ---- crates/llvm-builder/src/revive_llvm/main.rs | 21 ++--- crates/llvm-builder/tests/build.rs | 77 +++++------------ crates/llvm-builder/tests/checkout.rs | 48 ----------- crates/llvm-builder/tests/clone.rs | 36 -------- crates/llvm-builder/tests/common.rs | 47 ++++++----- llvm | 1 + 20 files changed, 90 insertions(+), 316 deletions(-) create mode 100644 .gitmodules delete mode 100644 LLVM.lock delete mode 100644 crates/llvm-builder/tests/checkout.rs delete mode 100644 crates/llvm-builder/tests/clone.rs create mode 160000 llvm diff --git a/.github/workflows/generate_versions.yml b/.github/workflows/generate_versions.yml index 4055a499..825b5142 100644 --- a/.github/workflows/generate_versions.yml +++ b/.github/workflows/generate_versions.yml @@ -16,12 +16,14 @@ jobs: uses: actions/checkout@v4 with: path: tmp + submodules: true - name: Checkout uses: actions/checkout@v4 with: repository: paritytech/resolc-bin path: resolc-bin + submodules: true - uses: actions/create-github-app-token@v1 id: app-token diff --git a/.github/workflows/release-llvm.yml b/.github/workflows/release-llvm.yml index 504dfb98..2bfe3e19 100644 --- a/.github/workflows/release-llvm.yml +++ b/.github/workflows/release-llvm.yml @@ -71,6 +71,8 @@ jobs: contents: write # for uploading assets to release steps: - uses: actions/checkout@v4 + with: + submodules: true - uses: actions-rust-lang/setup-rust-toolchain@v1 with: # without this it will override our rust flags @@ -96,10 +98,6 @@ jobs: run: | cargo install --locked --force --path crates/llvm-builder - - name: Clone LLVM - run: | - revive-llvm --target-env ${{ matrix.builder-arg }} clone - - name: Build LLVM if: ${{ matrix.target != 'wasm32-unknown-emscripten' }} run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a0d34e6e..9c92b367 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,6 +27,8 @@ jobs: RELEASE_NOTES: ${{ steps.versions.outputs.RELEASE_NOTES }} steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Check versions id: versions @@ -130,6 +132,8 @@ jobs: environment: tags steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Download Artifacts uses: actions/download-artifact@v4 diff --git a/.github/workflows/test-llvm-builder.yml b/.github/workflows/test-llvm-builder.yml index 66c9079b..b2f2a155 100644 --- a/.github/workflows/test-llvm-builder.yml +++ b/.github/workflows/test-llvm-builder.yml @@ -4,7 +4,6 @@ on: branches: ["main"] types: [opened, synchronize] paths: - - 'LLVM.lock' - 'crates/llvm-builder/**' - '.github/workflows/test-llvm-builder.yml' paths-ignore: @@ -25,6 +24,8 @@ jobs: runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 + with: + submodules: true - uses: actions-rust-lang/setup-rust-toolchain@v1 with: # without this it will override our rust flags diff --git a/.github/workflows/test-wasm.yml b/.github/workflows/test-wasm.yml index 2a1769f4..88aa8f35 100644 --- a/.github/workflows/test-wasm.yml +++ b/.github/workflows/test-wasm.yml @@ -26,6 +26,8 @@ jobs: shell: bash steps: - uses: actions/checkout@v4 + with: + submodules: true - uses: actions-rust-lang/setup-rust-toolchain@v1 with: target: wasm32-unknown-emscripten @@ -72,6 +74,8 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Create Target Directory run: mkdir -p ${{ env.REVIVE_WASM_INSTALL_DIR }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 48954b1b..4fb19c74 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,8 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 + with: + submodules: true - uses: actions-rust-lang/setup-rust-toolchain@v1 with: # without this it will override our rust flags diff --git a/.gitignore b/.gitignore index b856ff92..4f35c587 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,9 @@ target-llvm /*.yul /*.ll /*.s -/llvm* +/llvm-* +# Allow llvm submodule directory +!/llvm node_modules artifacts tmp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..8d51bb7f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "llvm"] + path = llvm + url = https://github.com/llvm/llvm-project.git + branch = release/18.x diff --git a/Cargo.lock b/Cargo.lock index 7e937c39..d4bf40b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2939,7 +2939,7 @@ dependencies = [ "regex", "syn 2.0.108", "termcolor", - "toml 0.8.23", + "toml", "walkdir", ] @@ -6809,7 +6809,7 @@ dependencies = [ "serde_json", "sp-core", "sp-io", - "toml 0.8.23", + "toml", ] [[package]] @@ -9084,9 +9084,7 @@ dependencies = [ "num_cpus", "path-slash", "regex", - "serde", "tar", - "toml 0.9.8", "which", ] @@ -10132,15 +10130,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_spanned" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" -dependencies = [ - "serde_core", -] - [[package]] name = "serde_stacker" version = "0.1.14" @@ -11758,26 +11747,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", - "serde_spanned 0.6.9", + "serde_spanned", "toml_datetime 0.6.11", "toml_edit 0.22.27", ] -[[package]] -name = "toml" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" -dependencies = [ - "indexmap 2.12.0", - "serde_core", - "serde_spanned 1.0.3", - "toml_datetime 0.7.3", - "toml_parser", - "toml_writer", - "winnow", -] - [[package]] name = "toml_datetime" version = "0.6.11" @@ -11804,7 +11778,7 @@ checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap 2.12.0", "serde", - "serde_spanned 0.6.9", + "serde_spanned", "toml_datetime 0.6.11", "toml_write", "winnow", @@ -11837,12 +11811,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" -[[package]] -name = "toml_writer" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" - [[package]] name = "tower" version = "0.5.2" @@ -12499,7 +12467,7 @@ dependencies = [ "serde", "serde_derive", "sha2 0.10.9", - "toml 0.8.23", + "toml", "windows-sys 0.59.0", "zstd 0.13.3", ] diff --git a/LLVM.lock b/LLVM.lock deleted file mode 100644 index 302ea0ab..00000000 --- a/LLVM.lock +++ /dev/null @@ -1,3 +0,0 @@ -url = "https://github.com/llvm/llvm-project.git" -branch = "release/18.x" -ref = "3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff" \ No newline at end of file diff --git a/Makefile b/Makefile index 3f1bf354..93370ee1 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ install-llvm-builder: cargo install --force --locked --path crates/llvm-builder install-llvm: install-llvm-builder - revive-llvm clone + git submodule update --init --recursive revive-llvm build --llvm-projects lld --llvm-projects clang install-revive-runner: diff --git a/crates/llvm-builder/Cargo.toml b/crates/llvm-builder/Cargo.toml index 4abb8e3f..ae684190 100644 --- a/crates/llvm-builder/Cargo.toml +++ b/crates/llvm-builder/Cargo.toml @@ -21,8 +21,6 @@ doctest = false [dependencies] clap = { workspace = true, features = ["help", "std", "derive"] } anyhow = { workspace = true } -serde = { workspace = true, features = [ "derive" ] } -toml = { workspace = true } num_cpus = { workspace = true } fs_extra = { workspace = true } path-slash = { workspace = true } diff --git a/crates/llvm-builder/src/lib.rs b/crates/llvm-builder/src/lib.rs index 94b19553..2aed8d42 100644 --- a/crates/llvm-builder/src/lib.rs +++ b/crates/llvm-builder/src/lib.rs @@ -5,7 +5,6 @@ pub mod builtins; pub mod ccache_variant; pub mod llvm_path; pub mod llvm_project; -pub mod lock; pub mod platforms; pub mod sanitizer; pub mod target_env; @@ -14,7 +13,6 @@ pub mod utils; pub use self::build_type::BuildType; pub use self::llvm_path::LLVMPath; -pub use self::lock::Lock; pub use self::platforms::Platform; use std::collections::HashSet; @@ -23,87 +21,21 @@ use std::process::Command; pub use target_env::TargetEnv; pub use target_triple::TargetTriple; -/// Executes the LLVM repository cloning. -pub fn clone(lock: Lock, deep: bool, target_env: TargetEnv) -> anyhow::Result<()> { +/// Initializes the LLVM submodule if not already done. +pub fn init_submodule() -> anyhow::Result<()> { utils::check_presence("git")?; - if target_env == TargetEnv::Emscripten { - utils::install_emsdk()?; - } - - let destination_path = PathBuf::from(LLVMPath::DIRECTORY_LLVM_SOURCE); - if destination_path.exists() { - log::warn!( - "LLVM repository directory {} already exists, falling back to checkout", - destination_path.display() - ); - return checkout(lock, false); - } - - let mut clone_args = vec!["clone", "--branch", lock.branch.as_str()]; - if !deep { - clone_args.push("--depth"); - clone_args.push("1"); - } - - utils::command( - Command::new("git") - .args(clone_args) - .arg(lock.url.as_str()) - .arg(destination_path.to_string_lossy().as_ref()), - "LLVM repository cloning", - )?; - - if let Some(r#ref) = lock.r#ref { - utils::command( - Command::new("git") - .args(["checkout", r#ref.as_str()]) - .current_dir(destination_path.to_string_lossy().as_ref()), - "LLVM repository commit checking out", - )?; - } - - Ok(()) -} - -/// Executes the checkout of the specified branch. -pub fn checkout(lock: Lock, force: bool) -> anyhow::Result<()> { let destination_path = PathBuf::from(LLVMPath::DIRECTORY_LLVM_SOURCE); - - utils::command( - Command::new("git") - .current_dir(destination_path.as_path()) - .args(["fetch", "--all", "--tags"]), - "LLVM repository data fetching", - )?; - - if force { - utils::command( - Command::new("git") - .current_dir(destination_path.as_path()) - .args(["clean", "-d", "-x", "--force"]), - "LLVM repository cleaning", - )?; + if destination_path.join(".git").exists() { + log::info!("LLVM submodule already initialized"); + return Ok(()); } utils::command( - Command::new("git") - .current_dir(destination_path.as_path()) - .args(["checkout", "--force", lock.branch.as_str()]), - "LLVM repository data pulling", + Command::new("git").args(["submodule", "update", "--init", "--recursive"]), + "LLVM submodule initialization", )?; - if let Some(r#ref) = lock.r#ref { - let mut checkout_command = Command::new("git"); - checkout_command.current_dir(destination_path.as_path()); - checkout_command.arg("checkout"); - if force { - checkout_command.arg("--force"); - } - checkout_command.arg(r#ref); - utils::command(&mut checkout_command, "LLVM repository checking out")?; - } - Ok(()) } @@ -332,8 +264,6 @@ pub fn clean() -> anyhow::Result<()> { .expect("target_env parent directory is target-llvm"), )?; remove_if_exists(&PathBuf::from(LLVMPath::DIRECTORY_EMSDK_SOURCE))?; - remove_if_exists(&PathBuf::from(LLVMPath::DIRECTORY_LLVM_SOURCE))?; - remove_if_exists(&PathBuf::from(LLVMPath::DIRECTORY_LLVM_HOST_SOURCE))?; Ok(()) } diff --git a/crates/llvm-builder/src/revive_llvm/arguments.rs b/crates/llvm-builder/src/revive_llvm/arguments.rs index 93a01226..e96236ba 100644 --- a/crates/llvm-builder/src/revive_llvm/arguments.rs +++ b/crates/llvm-builder/src/revive_llvm/arguments.rs @@ -18,13 +18,6 @@ pub struct Arguments { /// The revive LLVM builder arguments. #[derive(Debug, clap::Subcommand)] pub enum Subcommand { - /// Clone the branch specified in `LLVM.lock`. - Clone { - /// Clone with full commits history. - #[arg(long)] - deep: bool, - }, - /// Build the LLVM framework. Build { /// LLVM build type (`Debug`, `Release`, `RelWithDebInfo`, or `MinSizeRel`). @@ -77,13 +70,6 @@ pub enum Subcommand { enable_valgrind: bool, }, - /// Checkout the branch specified in `LLVM.lock`. - Checkout { - /// Remove all artifacts preventing the checkout (removes all local changes!). - #[arg(long)] - force: bool, - }, - /// Clean the build artifacts. Clean, diff --git a/crates/llvm-builder/src/revive_llvm/main.rs b/crates/llvm-builder/src/revive_llvm/main.rs index 25850d8b..9d3dd832 100644 --- a/crates/llvm-builder/src/revive_llvm/main.rs +++ b/crates/llvm-builder/src/revive_llvm/main.rs @@ -3,7 +3,6 @@ pub(crate) mod arguments; use std::collections::HashSet; -use std::path::PathBuf; use std::str::FromStr; use anyhow::Context; @@ -29,13 +28,6 @@ fn main_inner() -> anyhow::Result<()> { revive_llvm_builder::utils::directory_target_llvm(arguments.target_env); match arguments.subcommand { - Subcommand::Clone { deep } => { - let lock = revive_llvm_builder::Lock::try_from(&PathBuf::from( - revive_llvm_builder::lock::LLVM_LOCK_DEFAULT_PATH, - ))?; - revive_llvm_builder::clone(lock, deep, arguments.target_env)?; - } - Subcommand::Build { build_type, targets, @@ -50,6 +42,12 @@ fn main_inner() -> anyhow::Result<()> { sanitizer, enable_valgrind, } => { + if arguments.target_env == revive_llvm_builder::TargetEnv::Emscripten { + revive_llvm_builder::utils::install_emsdk()?; + } + + revive_llvm_builder::init_submodule()?; + let mut targets = targets .into_iter() .map(|target| revive_llvm_builder::Platform::from_str(target.as_str())) @@ -107,13 +105,6 @@ fn main_inner() -> anyhow::Result<()> { )?; } - Subcommand::Checkout { force } => { - let lock = revive_llvm_builder::Lock::try_from(&PathBuf::from( - revive_llvm_builder::lock::LLVM_LOCK_DEFAULT_PATH, - ))?; - revive_llvm_builder::checkout(lock, force)?; - } - Subcommand::Clean => { revive_llvm_builder::clean() .with_context(|| "Unable to remove target LLVM directory")?; diff --git a/crates/llvm-builder/tests/build.rs b/crates/llvm-builder/tests/build.rs index d5abc66a..2144ee7c 100644 --- a/crates/llvm-builder/tests/build.rs +++ b/crates/llvm-builder/tests/build.rs @@ -4,16 +4,10 @@ use std::process::Command; use assert_cmd::{cargo, prelude::*}; -/// This test verifies that the LLVM repository can be successfully cloned, built, and cleaned. +/// This test verifies that the LLVM repository can be successfully built and cleaned. #[test] -fn clone_build_and_clean() -> anyhow::Result<()> { - let test_dir = common::TestDir::with_lockfile(None)?; - - Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(test_dir.path()) - .arg("clone") - .assert() - .success(); +fn build_and_clean() -> anyhow::Result<()> { + let test_dir = common::TestDir::new()?; Command::new(cargo::cargo_bin!("revive-llvm")) .current_dir(test_dir.path()) @@ -40,18 +34,12 @@ fn clone_build_and_clean() -> anyhow::Result<()> { Ok(()) } -/// This test verifies that the LLVM repository can be successfully cloned, built, and cleaned +/// This test verifies that the LLVM repository can be successfully built and cleaned /// with 2-staged build using MUSL as sysroot. #[test] #[cfg(target_os = "linux")] -fn clone_build_and_clean_musl() -> anyhow::Result<()> { - let test_dir = common::TestDir::with_lockfile(None)?; - - Command::new(cargo::cargo_bin!("revive-llvm")) - .arg("clone") - .current_dir(test_dir.path()) - .assert() - .success(); +fn build_and_clean_musl() -> anyhow::Result<()> { + let test_dir = common::TestDir::new()?; Command::new(cargo::cargo_bin!("revive-llvm")) .current_dir(test_dir.path()) @@ -84,18 +72,12 @@ fn clone_build_and_clean_musl() -> anyhow::Result<()> { Ok(()) } -/// This test verifies that the LLVM repository can be successfully cloned and built in debug mode +/// This test verifies that the LLVM repository can be successfully built in debug mode /// with tests and coverage enabled. #[test] #[cfg(target_os = "linux")] fn debug_build_with_tests_coverage() -> anyhow::Result<()> { - let test_dir = common::TestDir::with_lockfile(None)?; - - Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(test_dir.path()) - .arg("clone") - .assert() - .success(); + let test_dir = common::TestDir::new()?; Command::new(cargo::cargo_bin!("revive-llvm")) .current_dir(test_dir.path()) @@ -118,13 +100,7 @@ fn debug_build_with_tests_coverage() -> anyhow::Result<()> { #[test] #[cfg(target_os = "linux")] fn build_with_sanitizers() -> anyhow::Result<()> { - let test_dir = common::TestDir::with_lockfile(None)?; - - Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(test_dir.path()) - .arg("clone") - .assert() - .success(); + let test_dir = common::TestDir::new()?; Command::new(cargo::cargo_bin!("revive-llvm")) .current_dir(test_dir.path()) @@ -141,19 +117,11 @@ fn build_with_sanitizers() -> anyhow::Result<()> { Ok(()) } -/// Tests the clone, build, and clean process of the LLVM repository for the emscripten target. +/// Tests the build and clean process of the LLVM repository for the emscripten target. #[test] #[cfg(target_os = "linux")] -fn clone_build_and_clean_emscripten() -> anyhow::Result<()> { - let test_dir = common::TestDir::with_lockfile(None)?; - let command = Command::new(cargo::cargo_bin!("revive-llvm")); - let program = command.get_program().to_string_lossy(); - - Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(test_dir.path()) - .arg("clone") - .assert() - .success(); +fn build_and_clean_emscripten() -> anyhow::Result<()> { + let test_dir = common::TestDir::new()?; Command::new(cargo::cargo_bin!("revive-llvm")) .current_dir(test_dir.path()) @@ -165,21 +133,14 @@ fn clone_build_and_clean_emscripten() -> anyhow::Result<()> { .assert() .success(); - // Two little shell-dependent things here: - // Doing `. ./emsdk_env.sh` instead of `source`, as `source` might be missing in some shells - // `cd {} && . ./emsdk_env.sh && cd ..` helps the script to locate `emsdk.py` - // @see https://github.com/emscripten-core/emsdk/blob/9dbdc4b3437750b85d16931c7c801bb71a782122/emsdk_env.sh#L61-L69 - let emsdk_wrapped_build_command = format!( - "{program} --target-env emscripten clone && \ - cd {} && . ./emsdk_env.sh && cd .. && \ - {program} --target-env emscripten build --llvm-projects lld", - revive_llvm_builder::LLVMPath::DIRECTORY_EMSDK_SOURCE, - ); - - Command::new("sh") - .arg("-c") - .arg(emsdk_wrapped_build_command) + // Build with emscripten target + Command::cargo_bin(common::REVIVE_LLVM)? .current_dir(test_dir.path()) + .arg("--target-env") + .arg("emscripten") + .arg("build") + .arg("--llvm-projects") + .arg("lld") .assert() .success(); diff --git a/crates/llvm-builder/tests/checkout.rs b/crates/llvm-builder/tests/checkout.rs deleted file mode 100644 index 1f4c923a..00000000 --- a/crates/llvm-builder/tests/checkout.rs +++ /dev/null @@ -1,48 +0,0 @@ -pub mod common; - -use std::process::Command; - -use assert_cmd::{cargo, prelude::*}; - -/// This test verifies that after cloning the LLVM repository, checking out a specific branch -/// or reference works as expected. -#[test] -fn checkout_after_clone() -> anyhow::Result<()> { - let test_dir = common::TestDir::with_lockfile(None)?; - - Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(test_dir.path()) - .arg("clone") - .assert() - .success(); - - Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(test_dir.path()) - .arg("checkout") - .assert() - .success(); - - Ok(()) -} - -/// This test verifies that after cloning the LLVM repository, checking out a specific branch -/// or reference with the `--force` option works as expected. -#[test] -fn force_checkout() -> anyhow::Result<()> { - let test_dir = common::TestDir::with_lockfile(None)?; - - Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(test_dir.path()) - .arg("clone") - .assert() - .success(); - - Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(test_dir.path()) - .arg("checkout") - .arg("--force") - .assert() - .success(); - - Ok(()) -} diff --git a/crates/llvm-builder/tests/clone.rs b/crates/llvm-builder/tests/clone.rs deleted file mode 100644 index 61d04f59..00000000 --- a/crates/llvm-builder/tests/clone.rs +++ /dev/null @@ -1,36 +0,0 @@ -pub mod common; - -use std::process::Command; - -use assert_cmd::{cargo, prelude::*}; - -/// This test verifies that the LLVM repository can be successfully cloned using a specific branch -/// and reference. -#[test] -fn clone() -> anyhow::Result<()> { - let test_dir = common::TestDir::with_lockfile(None)?; - - Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(test_dir.path()) - .arg("clone") - .assert() - .success(); - - Ok(()) -} - -/// This test verifies that the LLVM repository can be successfully cloned using a specific branch -/// and reference with --deep option. -#[test] -fn clone_deep() -> anyhow::Result<()> { - let test_dir = common::TestDir::with_lockfile(None)?; - - Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(test_dir.path()) - .arg("clone") - .arg("--deep") - .assert() - .success(); - - Ok(()) -} diff --git a/crates/llvm-builder/tests/common.rs b/crates/llvm-builder/tests/common.rs index 78465fc0..43cca5ac 100644 --- a/crates/llvm-builder/tests/common.rs +++ b/crates/llvm-builder/tests/common.rs @@ -1,32 +1,41 @@ -use assert_fs::fixture::FileWriteStr; +use assert_fs::TempDir; pub const REVIVE_LLVM: &str = "revive-llvm"; -pub const REVIVE_LLVM_REPO_URL: &str = "https://github.com/llvm/llvm-project"; -pub const REVIVE_LLVM_REPO_TEST_BRANCH: &str = "release/18.x"; pub struct TestDir { - _lockfile: assert_fs::NamedTempFile, + _tempdir: TempDir, path: std::path::PathBuf, } -/// Creates a temporary lock file for testing. +/// Creates a temporary directory for testing with submodule setup. impl TestDir { - pub fn with_lockfile(reference: Option) -> anyhow::Result { - let file = - assert_fs::NamedTempFile::new(revive_llvm_builder::lock::LLVM_LOCK_DEFAULT_PATH)?; - let lock = revive_llvm_builder::Lock { - url: REVIVE_LLVM_REPO_URL.to_string(), - branch: REVIVE_LLVM_REPO_TEST_BRANCH.to_string(), - r#ref: reference, - }; - file.write_str(toml::to_string(&lock)?.as_str())?; + pub fn new() -> anyhow::Result { + let tempdir = TempDir::new()?; + + // Initialize a git repo and add the LLVM submodule + std::process::Command::new("git") + .args(["init"]) + .current_dir(&tempdir) + .output()?; + + std::process::Command::new("git") + .args([ + "submodule", + "add", + "https://github.com/llvm/llvm-project.git", + "llvm", + ]) + .current_dir(&tempdir) + .output()?; + + std::process::Command::new("git") + .args(["submodule", "update", "--init", "--recursive"]) + .current_dir(&tempdir) + .output()?; Ok(Self { - path: file - .parent() - .expect("lockfile parent dir always exists") - .into(), - _lockfile: file, + path: tempdir.path().to_path_buf(), + _tempdir: tempdir, }) } diff --git a/llvm b/llvm new file mode 160000 index 00000000..3b5b5c1e --- /dev/null +++ b/llvm @@ -0,0 +1 @@ +Subproject commit 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff From 3ffc1f97157abd62ecae221fcc717c9ebb5d355f Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Fri, 31 Oct 2025 18:10:29 -0400 Subject: [PATCH 02/15] Fixed use of deprecated function --- crates/llvm-builder/tests/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/llvm-builder/tests/build.rs b/crates/llvm-builder/tests/build.rs index 2144ee7c..aecad694 100644 --- a/crates/llvm-builder/tests/build.rs +++ b/crates/llvm-builder/tests/build.rs @@ -134,7 +134,7 @@ fn build_and_clean_emscripten() -> anyhow::Result<()> { .success(); // Build with emscripten target - Command::cargo_bin(common::REVIVE_LLVM)? + Command::cargo_bin!(common::REVIVE_LLVM)? .current_dir(test_dir.path()) .arg("--target-env") .arg("emscripten") From a09049631858b99d64e19ef33e216b047b44557c Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Mon, 3 Nov 2025 08:42:09 -0500 Subject: [PATCH 03/15] Fixed bad code --- crates/llvm-builder/tests/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/llvm-builder/tests/build.rs b/crates/llvm-builder/tests/build.rs index aecad694..1a4198ba 100644 --- a/crates/llvm-builder/tests/build.rs +++ b/crates/llvm-builder/tests/build.rs @@ -134,7 +134,7 @@ fn build_and_clean_emscripten() -> anyhow::Result<()> { .success(); // Build with emscripten target - Command::cargo_bin!(common::REVIVE_LLVM)? + Command::new(common::REVIVE_LLVM)? .current_dir(test_dir.path()) .arg("--target-env") .arg("emscripten") From 3d310298645f48e57b4d0d44f47c6664f16514ec Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Mon, 3 Nov 2025 16:24:34 -0500 Subject: [PATCH 04/15] yet another fix --- crates/llvm-builder/tests/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/llvm-builder/tests/build.rs b/crates/llvm-builder/tests/build.rs index 1a4198ba..0153dfbe 100644 --- a/crates/llvm-builder/tests/build.rs +++ b/crates/llvm-builder/tests/build.rs @@ -134,7 +134,7 @@ fn build_and_clean_emscripten() -> anyhow::Result<()> { .success(); // Build with emscripten target - Command::new(common::REVIVE_LLVM)? + Command::new(common::REVIVE_LLVM) .current_dir(test_dir.path()) .arg("--target-env") .arg("emscripten") From 64ceedf99e8b794abc24f5f87ee65efaf633acdc Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Tue, 4 Nov 2025 12:04:48 -0500 Subject: [PATCH 05/15] Addressed comments --- .github/workflows/generate_versions.yml | 2 -- .github/workflows/release.yml | 4 ---- .github/workflows/test-llvm-builder.yml | 4 ---- .github/workflows/test-wasm.yml | 4 ---- .github/workflows/test.yml | 2 -- 5 files changed, 16 deletions(-) diff --git a/.github/workflows/generate_versions.yml b/.github/workflows/generate_versions.yml index 825b5142..4055a499 100644 --- a/.github/workflows/generate_versions.yml +++ b/.github/workflows/generate_versions.yml @@ -16,14 +16,12 @@ jobs: uses: actions/checkout@v4 with: path: tmp - submodules: true - name: Checkout uses: actions/checkout@v4 with: repository: paritytech/resolc-bin path: resolc-bin - submodules: true - uses: actions/create-github-app-token@v1 id: app-token diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c92b367..a0d34e6e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,8 +27,6 @@ jobs: RELEASE_NOTES: ${{ steps.versions.outputs.RELEASE_NOTES }} steps: - uses: actions/checkout@v4 - with: - submodules: true - name: Check versions id: versions @@ -132,8 +130,6 @@ jobs: environment: tags steps: - uses: actions/checkout@v4 - with: - submodules: true - name: Download Artifacts uses: actions/download-artifact@v4 diff --git a/.github/workflows/test-llvm-builder.yml b/.github/workflows/test-llvm-builder.yml index b2f2a155..ae5cacec 100644 --- a/.github/workflows/test-llvm-builder.yml +++ b/.github/workflows/test-llvm-builder.yml @@ -6,8 +6,6 @@ on: paths: - 'crates/llvm-builder/**' - '.github/workflows/test-llvm-builder.yml' - paths-ignore: - - "**.md" concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -24,8 +22,6 @@ jobs: runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 - with: - submodules: true - uses: actions-rust-lang/setup-rust-toolchain@v1 with: # without this it will override our rust flags diff --git a/.github/workflows/test-wasm.yml b/.github/workflows/test-wasm.yml index 88aa8f35..2a1769f4 100644 --- a/.github/workflows/test-wasm.yml +++ b/.github/workflows/test-wasm.yml @@ -26,8 +26,6 @@ jobs: shell: bash steps: - uses: actions/checkout@v4 - with: - submodules: true - uses: actions-rust-lang/setup-rust-toolchain@v1 with: target: wasm32-unknown-emscripten @@ -74,8 +72,6 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - with: - submodules: true - name: Create Target Directory run: mkdir -p ${{ env.REVIVE_WASM_INSTALL_DIR }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4fb19c74..48954b1b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,8 +22,6 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - with: - submodules: true - uses: actions-rust-lang/setup-rust-toolchain@v1 with: # without this it will override our rust flags From 9ccc0c64b26ffd2633c9e1af58756beaffb5563d Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Tue, 4 Nov 2025 15:18:08 -0500 Subject: [PATCH 06/15] Use submodule for `.github/workflows/test-llvm-builder.yml` --- .github/workflows/test-llvm-builder.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-llvm-builder.yml b/.github/workflows/test-llvm-builder.yml index ae5cacec..b25f7e4f 100644 --- a/.github/workflows/test-llvm-builder.yml +++ b/.github/workflows/test-llvm-builder.yml @@ -22,6 +22,8 @@ jobs: runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 + with: + submodules: true - uses: actions-rust-lang/setup-rust-toolchain@v1 with: # without this it will override our rust flags From ca131c026ed37007fcd4eb019a51bb8411314ab1 Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Wed, 5 Nov 2025 10:21:40 -0500 Subject: [PATCH 07/15] fix for llvm-builder and use --depth 1 for llvm submodule --- .github/workflows/release-llvm.yml | 2 -- Cargo.lock | 42 +++++++++++++++++++++++++---- crates/llvm-builder/src/builtins.rs | 3 ++- llvm | 1 - 4 files changed, 39 insertions(+), 9 deletions(-) delete mode 160000 llvm diff --git a/.github/workflows/release-llvm.yml b/.github/workflows/release-llvm.yml index 2bfe3e19..80e0b827 100644 --- a/.github/workflows/release-llvm.yml +++ b/.github/workflows/release-llvm.yml @@ -71,8 +71,6 @@ jobs: contents: write # for uploading assets to release steps: - uses: actions/checkout@v4 - with: - submodules: true - uses: actions-rust-lang/setup-rust-toolchain@v1 with: # without this it will override our rust flags diff --git a/Cargo.lock b/Cargo.lock index d4bf40b9..7e937c39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2939,7 +2939,7 @@ dependencies = [ "regex", "syn 2.0.108", "termcolor", - "toml", + "toml 0.8.23", "walkdir", ] @@ -6809,7 +6809,7 @@ dependencies = [ "serde_json", "sp-core", "sp-io", - "toml", + "toml 0.8.23", ] [[package]] @@ -9084,7 +9084,9 @@ dependencies = [ "num_cpus", "path-slash", "regex", + "serde", "tar", + "toml 0.9.8", "which", ] @@ -10130,6 +10132,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" +dependencies = [ + "serde_core", +] + [[package]] name = "serde_stacker" version = "0.1.14" @@ -11747,11 +11758,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", - "serde_spanned", + "serde_spanned 0.6.9", "toml_datetime 0.6.11", "toml_edit 0.22.27", ] +[[package]] +name = "toml" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" +dependencies = [ + "indexmap 2.12.0", + "serde_core", + "serde_spanned 1.0.3", + "toml_datetime 0.7.3", + "toml_parser", + "toml_writer", + "winnow", +] + [[package]] name = "toml_datetime" version = "0.6.11" @@ -11778,7 +11804,7 @@ checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap 2.12.0", "serde", - "serde_spanned", + "serde_spanned 0.6.9", "toml_datetime 0.6.11", "toml_write", "winnow", @@ -11811,6 +11837,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" +[[package]] +name = "toml_writer" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" + [[package]] name = "tower" version = "0.5.2" @@ -12467,7 +12499,7 @@ dependencies = [ "serde", "serde_derive", "sha2 0.10.9", - "toml", + "toml 0.8.23", "windows-sys 0.59.0", "zstd 0.13.3", ] diff --git a/crates/llvm-builder/src/builtins.rs b/crates/llvm-builder/src/builtins.rs index 8970f85c..b4b00207 100644 --- a/crates/llvm-builder/src/builtins.rs +++ b/crates/llvm-builder/src/builtins.rs @@ -4,13 +4,14 @@ use crate::utils::path_windows_to_unix as to_unix; use std::{env::consts::EXE_EXTENSION, process::Command}; /// Static CFLAGS variable passed to the compiler building the compiler-rt builtins. -const C_FLAGS: [&str; 6] = [ +const C_FLAGS: [&str; 7] = [ "--target=riscv64", "-march=rv64emac", "-mabi=lp64e", "-mcpu=generic-rv64", "-nostdlib", "-nodefaultlibs", + "-fuse-ld=lld", ]; /// Static CMAKE arguments for building the compiler-rt builtins. diff --git a/llvm b/llvm deleted file mode 160000 index 3b5b5c1e..00000000 --- a/llvm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff From 80213ba66c911a46ba44b119e29316e394d2ed82 Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Wed, 5 Nov 2025 20:35:17 -0500 Subject: [PATCH 08/15] Yet another set of fixes --- llvm | 1 + 1 file changed, 1 insertion(+) create mode 160000 llvm diff --git a/llvm b/llvm new file mode 160000 index 00000000..3b5b5c1e --- /dev/null +++ b/llvm @@ -0,0 +1 @@ +Subproject commit 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff From e9a1f22812baf85a0395cb01e12f1df043dc72dc Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Wed, 5 Nov 2025 20:58:31 -0500 Subject: [PATCH 09/15] Simplified submodule update --- Cargo.lock | 42 ++++------------------------- Makefile | 2 +- crates/llvm-builder/tests/build.rs | 2 +- crates/llvm-builder/tests/common.rs | 4 ++- 4 files changed, 10 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7e937c39..d4bf40b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2939,7 +2939,7 @@ dependencies = [ "regex", "syn 2.0.108", "termcolor", - "toml 0.8.23", + "toml", "walkdir", ] @@ -6809,7 +6809,7 @@ dependencies = [ "serde_json", "sp-core", "sp-io", - "toml 0.8.23", + "toml", ] [[package]] @@ -9084,9 +9084,7 @@ dependencies = [ "num_cpus", "path-slash", "regex", - "serde", "tar", - "toml 0.9.8", "which", ] @@ -10132,15 +10130,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_spanned" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" -dependencies = [ - "serde_core", -] - [[package]] name = "serde_stacker" version = "0.1.14" @@ -11758,26 +11747,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", - "serde_spanned 0.6.9", + "serde_spanned", "toml_datetime 0.6.11", "toml_edit 0.22.27", ] -[[package]] -name = "toml" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" -dependencies = [ - "indexmap 2.12.0", - "serde_core", - "serde_spanned 1.0.3", - "toml_datetime 0.7.3", - "toml_parser", - "toml_writer", - "winnow", -] - [[package]] name = "toml_datetime" version = "0.6.11" @@ -11804,7 +11778,7 @@ checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap 2.12.0", "serde", - "serde_spanned 0.6.9", + "serde_spanned", "toml_datetime 0.6.11", "toml_write", "winnow", @@ -11837,12 +11811,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" -[[package]] -name = "toml_writer" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" - [[package]] name = "tower" version = "0.5.2" @@ -12499,7 +12467,7 @@ dependencies = [ "serde", "serde_derive", "sha2 0.10.9", - "toml 0.8.23", + "toml", "windows-sys 0.59.0", "zstd 0.13.3", ] diff --git a/Makefile b/Makefile index 93370ee1..64223c6f 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ install-llvm-builder: cargo install --force --locked --path crates/llvm-builder install-llvm: install-llvm-builder - git submodule update --init --recursive + git submodule update --init --recursive --depth 1 revive-llvm build --llvm-projects lld --llvm-projects clang install-revive-runner: diff --git a/crates/llvm-builder/tests/build.rs b/crates/llvm-builder/tests/build.rs index 0153dfbe..1d66a540 100644 --- a/crates/llvm-builder/tests/build.rs +++ b/crates/llvm-builder/tests/build.rs @@ -10,7 +10,7 @@ fn build_and_clean() -> anyhow::Result<()> { let test_dir = common::TestDir::new()?; Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(test_dir.path()) + .current_dir(&test_dir.path()) .arg("build") .arg("--llvm-projects") .arg("clang") diff --git a/crates/llvm-builder/tests/common.rs b/crates/llvm-builder/tests/common.rs index 43cca5ac..dd980694 100644 --- a/crates/llvm-builder/tests/common.rs +++ b/crates/llvm-builder/tests/common.rs @@ -22,6 +22,8 @@ impl TestDir { .args([ "submodule", "add", + "-b", + "release/18.x", "https://github.com/llvm/llvm-project.git", "llvm", ]) @@ -29,7 +31,7 @@ impl TestDir { .output()?; std::process::Command::new("git") - .args(["submodule", "update", "--init", "--recursive"]) + .args(["submodule", "update", "--init", "--recursive", "--force", "--depth 1",]) .current_dir(&tempdir) .output()?; From bf27c6b53d226a6784af452544d24209cea01a32 Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Wed, 5 Nov 2025 21:05:55 -0500 Subject: [PATCH 10/15] fixed format --- crates/llvm-builder/tests/common.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/llvm-builder/tests/common.rs b/crates/llvm-builder/tests/common.rs index dd980694..21db5d30 100644 --- a/crates/llvm-builder/tests/common.rs +++ b/crates/llvm-builder/tests/common.rs @@ -31,7 +31,14 @@ impl TestDir { .output()?; std::process::Command::new("git") - .args(["submodule", "update", "--init", "--recursive", "--force", "--depth 1",]) + .args([ + "submodule", + "update", + "--init", + "--recursive", + "--force", + "--depth 1", + ]) .current_dir(&tempdir) .output()?; From 65c423f6758022bbfbf065fcd1184e71548b69f7 Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Wed, 5 Nov 2025 22:03:52 -0500 Subject: [PATCH 11/15] Remove accidentally added & --- crates/llvm-builder/tests/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/llvm-builder/tests/build.rs b/crates/llvm-builder/tests/build.rs index 1d66a540..0153dfbe 100644 --- a/crates/llvm-builder/tests/build.rs +++ b/crates/llvm-builder/tests/build.rs @@ -10,7 +10,7 @@ fn build_and_clean() -> anyhow::Result<()> { let test_dir = common::TestDir::new()?; Command::new(cargo::cargo_bin!("revive-llvm")) - .current_dir(&test_dir.path()) + .current_dir(test_dir.path()) .arg("build") .arg("--llvm-projects") .arg("clang") From 27d107ba03f33909a2645e6a80d3d5453e10e97a Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Thu, 6 Nov 2025 07:30:18 -0500 Subject: [PATCH 12/15] Fixed linux's llvm builder --- crates/llvm-builder/tests/build.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/llvm-builder/tests/build.rs b/crates/llvm-builder/tests/build.rs index 0153dfbe..47e9c2d4 100644 --- a/crates/llvm-builder/tests/build.rs +++ b/crates/llvm-builder/tests/build.rs @@ -127,14 +127,14 @@ fn build_and_clean_emscripten() -> anyhow::Result<()> { .current_dir(test_dir.path()) .arg("build") .arg("--llvm-projects") - .arg("lld") - .arg("--llvm-projects") .arg("clang") + .arg("--llvm-projects") + .arg("lld") .assert() .success(); // Build with emscripten target - Command::new(common::REVIVE_LLVM) + Command::new(cargo::cargo_bin!("revive-llvm")) .current_dir(test_dir.path()) .arg("--target-env") .arg("emscripten") From 09cc58cfc1c0a2535d8e462e46a88e3c7f65b234 Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Thu, 6 Nov 2025 17:58:49 -0500 Subject: [PATCH 13/15] Attempt to fix linux build --- crates/llvm-builder/tests/build.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/llvm-builder/tests/build.rs b/crates/llvm-builder/tests/build.rs index 47e9c2d4..679e7100 100644 --- a/crates/llvm-builder/tests/build.rs +++ b/crates/llvm-builder/tests/build.rs @@ -133,14 +133,21 @@ fn build_and_clean_emscripten() -> anyhow::Result<()> { .assert() .success(); - // Build with emscripten target - Command::new(cargo::cargo_bin!("revive-llvm")) + // Two little shell-dependent things here: + // Doing `. ./emsdk_env.sh` instead of `source`, as `source` might be missing in some shells + // `cd {} && . ./emsdk_env.sh && cd ..` helps the script to locate `emsdk.py` + // @see https://github.com/emscripten-core/emsdk/blob/9dbdc4b3437750b85d16931c7c801bb71a782122/emsdk_env.sh#L61-L69 + let emsdk_wrapped_build_command = format!( + "{program} --target-env emscripten clone && \ + cd {} && . ./emsdk_env.sh && cd .. && \ + {program} --target-env emscripten build --llvm-projects lld", + revive_llvm_builder::LLVMPath::DIRECTORY_EMSDK_SOURCE, + ); + + Command::new("sh") + .arg("-c") + .arg(emsdk_wrapped_build_command) .current_dir(test_dir.path()) - .arg("--target-env") - .arg("emscripten") - .arg("build") - .arg("--llvm-projects") - .arg("lld") .assert() .success(); From 15c6fd14a7d3e6b2274203c5079d69cedb9598d0 Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Thu, 6 Nov 2025 21:31:50 -0500 Subject: [PATCH 14/15] added missed code --- crates/llvm-builder/tests/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/llvm-builder/tests/build.rs b/crates/llvm-builder/tests/build.rs index 679e7100..9b2f7478 100644 --- a/crates/llvm-builder/tests/build.rs +++ b/crates/llvm-builder/tests/build.rs @@ -122,6 +122,8 @@ fn build_with_sanitizers() -> anyhow::Result<()> { #[cfg(target_os = "linux")] fn build_and_clean_emscripten() -> anyhow::Result<()> { let test_dir = common::TestDir::new()?; + let command = Command::new(cargo::cargo_bin!("revive-llvm")); + let program = command.get_program().to_string_lossy(); Command::new(cargo::cargo_bin!("revive-llvm")) .current_dir(test_dir.path()) From 025b6069278a195538c8040ad3d38dc6e79ac3d7 Mon Sep 17 00:00:00 2001 From: kvp <223931578+kvpanch@users.noreply.github.com> Date: Fri, 7 Nov 2025 07:31:44 -0500 Subject: [PATCH 15/15] remove clone command --- crates/llvm-builder/tests/build.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/llvm-builder/tests/build.rs b/crates/llvm-builder/tests/build.rs index 9b2f7478..f147e838 100644 --- a/crates/llvm-builder/tests/build.rs +++ b/crates/llvm-builder/tests/build.rs @@ -140,8 +140,7 @@ fn build_and_clean_emscripten() -> anyhow::Result<()> { // `cd {} && . ./emsdk_env.sh && cd ..` helps the script to locate `emsdk.py` // @see https://github.com/emscripten-core/emsdk/blob/9dbdc4b3437750b85d16931c7c801bb71a782122/emsdk_env.sh#L61-L69 let emsdk_wrapped_build_command = format!( - "{program} --target-env emscripten clone && \ - cd {} && . ./emsdk_env.sh && cd .. && \ + "cd {} && . ./emsdk_env.sh && cd .. && \ {program} --target-env emscripten build --llvm-projects lld", revive_llvm_builder::LLVMPath::DIRECTORY_EMSDK_SOURCE, );