llvm-builder: do not build clang by default (#168)

We only need LLD for cross compilation. This significantly reduces the LLVM build times in a cross compilation scenario. Update the README as a drive-by.
This commit is contained in:
Cyrill Leutwiler
2025-01-17 16:03:04 +01:00
committed by GitHub
parent 06f43083c3
commit cec283986f
8 changed files with 38 additions and 36 deletions
+2 -2
View File
@@ -55,13 +55,13 @@ jobs:
- name: Build host LLVM - name: Build host LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true' if: steps.cache-llvm.outputs.cache-hit != 'true'
run: | run: |
revive-llvm build revive-llvm build --llvm-projects lld --llvm-projects clang
- name: Build target LLVM - name: Build target LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true' if: steps.cache-llvm.outputs.cache-hit != 'true'
run: | run: |
source emsdk/emsdk_env.sh source emsdk/emsdk_env.sh
revive-llvm --target-env emscripten build revive-llvm --target-env emscripten build --llvm-projects lld
- run: | - run: |
rustup show rustup show
Generated
+13 -13
View File
@@ -222,9 +222,9 @@ dependencies = [
[[package]] [[package]]
name = "alloy-rlp" name = "alloy-rlp"
version = "0.3.10" version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f542548a609dca89fcd72b3b9f355928cf844d4363c5eed9c5273a3dd225e097" checksum = "3d6c1d995bff8d011f7cd6c81820d51825e6e06d6db73914c1630ecf544d83d6"
dependencies = [ dependencies = [
"alloy-rlp-derive", "alloy-rlp-derive",
"arrayvec", "arrayvec",
@@ -233,9 +233,9 @@ dependencies = [
[[package]] [[package]]
name = "alloy-rlp-derive" name = "alloy-rlp-derive"
version = "0.3.10" version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a833d97bf8a5f0f878daf2c8451fff7de7f9de38baa5a45d936ec718d81255a" checksum = "a40e1ef334153322fd878d07e86af7a529bcb86b2439525920a88eba87bcf943"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -9805,7 +9805,7 @@ dependencies = [
[[package]] [[package]]
name = "sp-crypto-ec-utils" name = "sp-crypto-ec-utils"
version = "0.10.0" version = "0.10.0"
source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709"
dependencies = [ dependencies = [
"ark-bls12-377", "ark-bls12-377",
"ark-bls12-377-ext", "ark-bls12-377-ext",
@@ -9872,7 +9872,7 @@ dependencies = [
[[package]] [[package]]
name = "sp-debug-derive" name = "sp-debug-derive"
version = "14.0.0" version = "14.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -9892,7 +9892,7 @@ dependencies = [
[[package]] [[package]]
name = "sp-externalities" name = "sp-externalities"
version = "0.25.0" version = "0.25.0"
source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709"
dependencies = [ dependencies = [
"environmental", "environmental",
"parity-scale-codec", "parity-scale-codec",
@@ -10101,7 +10101,7 @@ dependencies = [
[[package]] [[package]]
name = "sp-runtime-interface" name = "sp-runtime-interface"
version = "24.0.0" version = "24.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709"
dependencies = [ dependencies = [
"bytes", "bytes",
"impl-trait-for-tuples", "impl-trait-for-tuples",
@@ -10133,7 +10133,7 @@ dependencies = [
[[package]] [[package]]
name = "sp-runtime-interface-proc-macro" name = "sp-runtime-interface-proc-macro"
version = "17.0.0" version = "17.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"expander", "expander",
@@ -10222,7 +10222,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?rev=cb0d8544dc8828c7b5e
[[package]] [[package]]
name = "sp-std" name = "sp-std"
version = "14.0.0" version = "14.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709"
[[package]] [[package]]
name = "sp-storage" name = "sp-storage"
@@ -10239,7 +10239,7 @@ dependencies = [
[[package]] [[package]]
name = "sp-storage" name = "sp-storage"
version = "19.0.0" version = "19.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709"
dependencies = [ dependencies = [
"impl-serde", "impl-serde",
"parity-scale-codec", "parity-scale-codec",
@@ -10274,7 +10274,7 @@ dependencies = [
[[package]] [[package]]
name = "sp-tracing" name = "sp-tracing"
version = "16.0.0" version = "16.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709"
dependencies = [ dependencies = [
"parity-scale-codec", "parity-scale-codec",
"tracing", "tracing",
@@ -10371,7 +10371,7 @@ dependencies = [
[[package]] [[package]]
name = "sp-wasm-interface" name = "sp-wasm-interface"
version = "20.0.0" version = "20.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#77c78e1561bbe5ee0ecf414312bae82396ae6d11" source = "git+https://github.com/paritytech/polkadot-sdk#f7baa84f48aa72b96e8c9a9ec8a1934431de6709"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"impl-trait-for-tuples", "impl-trait-for-tuples",
+1 -1
View File
@@ -9,7 +9,7 @@ COPY . .
RUN make install-llvm-builder RUN make install-llvm-builder
RUN revive-llvm --target-env musl clone 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 FROM messense/rust-musl-cross:x86_64-musl AS resolc-builder
WORKDIR /opt/revive WORKDIR /opt/revive
+1 -1
View File
@@ -36,7 +36,7 @@ install-llvm-builder:
install-llvm: install-llvm-builder install-llvm: install-llvm-builder
revive-llvm clone revive-llvm clone
revive-llvm build revive-llvm build --llvm-projects lld --llvm-projects clang
format: format:
cargo fmt --all --check cargo fmt --all --check
+18 -10
View File
@@ -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. `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 ### 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 ### 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: To install the `resolc` Solidity frontend executable:
```bash ```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 make install-bin
resolc --version 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 ```bash
# Build the host LLVM dependency with PolkaVM target support # 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 # Build the target LLVM dependency with PolkaVM target support
revive-llvm --target-env emscripten clone revive-llvm --target-env emscripten clone
source emsdk/emsdk_env.sh 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 export REVIVE_LLVM_TARGET_PREFIX=${PWD}/target-llvm/emscripten/target-final
# Build the resolc frontend executable # Build the resolc frontend executable
+1 -1
View File
@@ -19,7 +19,7 @@ path = "src/revive_llvm/main.rs"
doctest = false doctest = false
[dependencies] [dependencies]
clap = { workspace = true, features = ["std", "derive"] } clap = { workspace = true, features = ["help", "std", "derive"] }
anyhow = { workspace = true } anyhow = { workspace = true }
serde = { workspace = true, features = [ "derive" ] } serde = { workspace = true, features = [ "derive" ] }
toml = { workspace = true } toml = { workspace = true }
+1 -1
View File
@@ -83,7 +83,7 @@ Obtain a compatible build for your host platform from the release section of thi
```shell ```shell
revive-llvm clone 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. Build artifacts end up in the `./target-llvm/gnu/target-final/` directory by default.
@@ -36,13 +36,7 @@ pub enum Subcommand {
targets: Vec<String>, targets: Vec<String>,
/// LLVM projects to build LLVM with. /// LLVM projects to build LLVM with.
#[arg( #[arg(long)]
long,
default_values_t = vec![
revive_llvm_builder::llvm_project::LLVMProject::CLANG,
revive_llvm_builder::llvm_project::LLVMProject::LLD
]
)]
llvm_projects: Vec<revive_llvm_builder::llvm_project::LLVMProject>, llvm_projects: Vec<revive_llvm_builder::llvm_project::LLVMProject>,
/// Whether to build LLVM with run-time type information (RTTI) enabled. /// Whether to build LLVM with run-time type information (RTTI) enabled.