add LLVM 18.x as a git submodule (#399)

This changeset is based on https://github.com/paritytech/revive/pull/346
This commit is contained in:
kvpanch
2025-11-18 16:10:15 -05:00
committed by GitHub
parent a1090cfa5a
commit e78f3cc419
18 changed files with 89 additions and 310 deletions
+24 -49
View File
@@ -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,27 +117,28 @@ 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)?;
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();
let path = test_dir.path();
Command::new(cargo::cargo_bin!("revive-llvm"))
.current_dir(test_dir.path())
.arg("clone")
.current_dir(path)
.arg("build")
.arg("--llvm-projects")
.arg("clang")
.arg("--llvm-projects")
.arg("lld")
.assert()
.success();
Command::new(cargo::cargo_bin!("revive-llvm"))
.current_dir(test_dir.path())
.arg("build")
.arg("--llvm-projects")
.arg("lld")
.arg("--llvm-projects")
.arg("clang")
.current_dir(path)
.arg("emsdk")
.assert()
.success();
@@ -170,22 +147,20 @@ fn clone_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,
);
Command::new("sh")
.arg("-c")
.arg(emsdk_wrapped_build_command)
.current_dir(test_dir.path())
.current_dir(path)
.assert()
.success();
Command::new(cargo::cargo_bin!("revive-llvm"))
.arg("clean")
.current_dir(test_dir.path())
.current_dir(path)
.assert()
.success();