Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/generate_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/release-llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
RELEASE_NOTES: ${{ steps.versions.outputs.RELEASE_NOTES }}
steps:
- uses: actions/checkout@v4
with:
submodules: true

# Check that tag and version in Cargo.toml match
- name: Check versions
Expand Down Expand Up @@ -91,6 +93,8 @@ jobs:
needs: [check-version-changed]
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
Expand Down Expand Up @@ -146,6 +150,8 @@ jobs:
RELEASE_RESOLC_WASM_URI: https://github.com/paritytech/revive/releases/download/${{ github.ref_name }}/resolc.wasm
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: wasm32-unknown-emscripten
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-llvm-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
branches: ["main"]
types: [opened, synchronize]
paths:
- 'LLVM.lock'
- 'crates/llvm-builder/**'
- '.github/workflows/test-llvm-builder.yml'

Expand All @@ -23,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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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
Expand Down Expand Up @@ -68,6 +70,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 }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ target-llvm
/*.yul
/*.ll
/*.s
/llvm*
/llvm-*
# Allow llvm submodule directory
!/llvm
node_modules
artifacts
tmp
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "llvm"]
path = llvm
url = https://github.com/llvm/llvm-project.git
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions LLVM.lock

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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:
Expand Down
2 changes: 0 additions & 2 deletions crates/llvm-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
84 changes: 7 additions & 77 deletions crates/llvm-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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(())
}

Expand Down Expand Up @@ -333,8 +265,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(())
}
37 changes: 0 additions & 37 deletions crates/llvm-builder/src/lock.rs

This file was deleted.

14 changes: 0 additions & 14 deletions crates/llvm-builder/src/revive_llvm/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
Expand Down Expand Up @@ -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,

Expand Down
21 changes: 6 additions & 15 deletions crates/llvm-builder/src/revive_llvm/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
pub(crate) mod arguments;

use std::collections::HashSet;
use std::path::PathBuf;
use std::str::FromStr;

use anyhow::Context;
Expand All @@ -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,
Expand All @@ -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()))
Expand Down Expand Up @@ -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")?;
Expand Down
Loading