diff --git a/.github/workflows/build-revive-wasm.yml b/.github/workflows/build-revive-wasm.yml index 5ad06fa..b5d6888 100644 --- a/.github/workflows/build-revive-wasm.yml +++ b/.github/workflows/build-revive-wasm.yml @@ -55,13 +55,13 @@ jobs: - name: Build host LLVM if: steps.cache-llvm.outputs.cache-hit != 'true' run: | - revive-llvm build + revive-llvm build --llvm-projects lld --llvm-projects clang - name: Build target LLVM if: steps.cache-llvm.outputs.cache-hit != 'true' run: | source emsdk/emsdk_env.sh - revive-llvm --target-env emscripten build + revive-llvm --target-env emscripten build --llvm-projects lld - run: | rustup show diff --git a/Cargo.lock b/Cargo.lock index 55ba8f1..2dbc519 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -222,9 +222,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f542548a609dca89fcd72b3b9f355928cf844d4363c5eed9c5273a3dd225e097" +checksum = "3d6c1d995bff8d011f7cd6c81820d51825e6e06d6db73914c1630ecf544d83d6" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -233,9 +233,9 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a833d97bf8a5f0f878daf2c8451fff7de7f9de38baa5a45d936ec718d81255a" +checksum = "a40e1ef334153322fd878d07e86af7a529bcb86b2439525920a88eba87bcf943" dependencies = [ "proc-macro2", "quote", @@ -9805,7 +9805,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" +source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -9872,7 +9872,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" +source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709" dependencies = [ "proc-macro2", "quote", @@ -9892,7 +9892,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" +source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709" dependencies = [ "environmental", "parity-scale-codec", @@ -10101,7 +10101,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" +source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -10133,7 +10133,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" +source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709" dependencies = [ "Inflector", "expander", @@ -10222,7 +10222,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?rev=cb0d8544dc8828c7b5e [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" +source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709" [[package]] name = "sp-storage" @@ -10239,7 +10239,7 @@ dependencies = [ [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" +source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10274,7 +10274,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" +source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709" dependencies = [ "parity-scale-codec", "tracing", @@ -10371,7 +10371,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" +source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709" dependencies = [ "anyhow", "impl-trait-for-tuples", diff --git a/Dockerfile b/Dockerfile index 23d1c9b..d607abd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ COPY . . RUN make install-llvm-builder RUN revive-llvm --target-env musl clone -RUN revive-llvm --target-env musl build +RUN revive-llvm --target-env musl build --llvm-projects lld --llvm-projects clang FROM messense/rust-musl-cross:x86_64-musl AS resolc-builder WORKDIR /opt/revive diff --git a/Makefile b/Makefile index 4275250..e8ecabd 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ install-llvm-builder: install-llvm: install-llvm-builder revive-llvm clone - revive-llvm build + revive-llvm build --llvm-projects lld --llvm-projects clang format: cargo fmt --all --check diff --git a/README.md b/README.md index 940538b..4a4afae 100644 --- a/README.md +++ b/README.md @@ -17,29 +17,37 @@ Discussion around the development is hosted on the [Polkadot Forum](https://foru `resolc` depends on the [solc](https://github.com/ethereum/solidity) binary installed on your system. -Building from source requires a compatible LLVM build. +Download and install the `resolc` frontend executable for your platform from our [releases](https://github.com/paritytech/revive/releases). + +## Building from source + +Building revive requires a [stable Rust installation](https://rustup.rs/) and a C++ toolchain for building [LLVM](https://github.com/llvm/llvm-project) on your system. ### LLVM -`revive` requires a build of LLVM v18.1.8 with the RISC-V _embedded_ target, including `compiler-rt`. Use the provided [revive-llvm](crates/llvm-builder/README.md) utility to compile a compatible LLVM build locally and point `$LLVM_SYS_181_PREFIX` to the installation directory afterwards. +`revive` depends on a custom build of LLVM `v18.1.8` with the RISC-V _embedded_ target, including the `compiler-rt` builtins. Use the provided [revive-llvm](crates/llvm-builder/README.md) utility to compile a compatible LLVM build locally and point `$LLVM_SYS_181_PREFIX` to the installation afterwards. + +The `Makefile` provides a shortcut target to obtain a compatible LLVM build: + +```bash +make install-llvm +export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final +``` ### The `resolc` Solidity frontend +To build the `resolc` Solidity frontend executable, make sure you have obtained a compatible LLVM build using [revive-llvm](crates/llvm-builder/README.md) and did export the `LLVM_SYS_181_PREFIX` environment variable pointing to it (see [above](#LLVM)). + To install the `resolc` Solidity frontend executable: ```bash -# Build the host LLVM dependency with PolkaVM target support -make install-llvm -export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final - -# Build the resolc frontend executable make install-bin resolc --version ``` -### Cross-compilation to WASM +### Cross-compilation to Wasm -Cross-compile resolc.js frontend executable to Wasm for running it in a Node.js or browser environment. The `REVIVE_LLVM_TARGET_PREFIX` environment variable is used to control the target environment LLVM dependency. +Cross-compile the `resolc.js` frontend executable to Wasm for running it in a Node.js or browser environment. The `REVIVE_LLVM_TARGET_PREFIX` environment variable is used to control the target environment LLVM dependency. ```bash # Build the host LLVM dependency with PolkaVM target support @@ -49,7 +57,7 @@ export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final # Build the target LLVM dependency with PolkaVM target support revive-llvm --target-env emscripten clone source emsdk/emsdk_env.sh -revive-llvm --target-env emscripten build +revive-llvm --target-env emscripten build --llvm-projects lld export REVIVE_LLVM_TARGET_PREFIX=${PWD}/target-llvm/emscripten/target-final # Build the resolc frontend executable diff --git a/crates/llvm-builder/Cargo.toml b/crates/llvm-builder/Cargo.toml index a12ec6f..75380ff 100644 --- a/crates/llvm-builder/Cargo.toml +++ b/crates/llvm-builder/Cargo.toml @@ -19,7 +19,7 @@ path = "src/revive_llvm/main.rs" doctest = false [dependencies] -clap = { workspace = true, features = ["std", "derive"] } +clap = { workspace = true, features = ["help", "std", "derive"] } anyhow = { workspace = true } serde = { workspace = true, features = [ "derive" ] } toml = { workspace = true } diff --git a/crates/llvm-builder/README.md b/crates/llvm-builder/README.md index 40be01c..a159879 100644 --- a/crates/llvm-builder/README.md +++ b/crates/llvm-builder/README.md @@ -83,7 +83,7 @@ Obtain a compatible build for your host platform from the release section of thi ```shell revive-llvm clone - revive-llvm build + revive-llvm build --llvm-projects lld --llvm-projects clang ``` Build artifacts end up in the `./target-llvm/gnu/target-final/` directory by default. diff --git a/crates/llvm-builder/src/revive_llvm/arguments.rs b/crates/llvm-builder/src/revive_llvm/arguments.rs index 0c58590..93a0122 100644 --- a/crates/llvm-builder/src/revive_llvm/arguments.rs +++ b/crates/llvm-builder/src/revive_llvm/arguments.rs @@ -36,13 +36,7 @@ pub enum Subcommand { targets: Vec, /// LLVM projects to build LLVM with. - #[arg( - long, - default_values_t = vec![ - revive_llvm_builder::llvm_project::LLVMProject::CLANG, - revive_llvm_builder::llvm_project::LLVMProject::LLD - ] - )] + #[arg(long)] llvm_projects: Vec, /// Whether to build LLVM with run-time type information (RTTI) enabled.