Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: run macos in CI #6

Merged
merged 43 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
bd786db
ci: run macos in CI
DaniPopes Apr 25, 2024
b5b9de6
ci
DaniPopes Apr 25, 2024
e884b68
v2
DaniPopes Apr 25, 2024
7b66a58
string
DaniPopes Apr 25, 2024
46360a8
no macos13
DaniPopes Apr 25, 2024
7f095fb
try
DaniPopes Apr 25, 2024
662dc95
megapin
DaniPopes Apr 25, 2024
c8010c0
arching
DaniPopes Apr 25, 2024
03aa9f2
unarm
DaniPopes Apr 25, 2024
62d282d
unverbose
DaniPopes Apr 25, 2024
932158c
zlib
DaniPopes Apr 25, 2024
bae0ead
fuck
DaniPopes Apr 25, 2024
0357011
fuck off
DaniPopes Apr 25, 2024
6513f6b
a
DaniPopes Apr 25, 2024
677327b
b
DaniPopes Apr 25, 2024
7bfc31b
z
DaniPopes Apr 25, 2024
d18b8b4
zz
DaniPopes Apr 25, 2024
719e81e
zstd
DaniPopes Apr 25, 2024
30f6598
v
DaniPopes Apr 25, 2024
c0bdd60
:D
onbjerg Apr 25, 2024
066a05a
:)
onbjerg Apr 25, 2024
7820543
oopsie
onbjerg Apr 25, 2024
d06b7fa
https://media.tenor.com/-vS4uZTepRcAAAAe/cat-despair.png
onbjerg Apr 25, 2024
d5e771d
srs?
onbjerg Apr 25, 2024
31794af
i!i!i!i!i!i!i!i!i!i!i!i
onbjerg Apr 25, 2024
cfac4db
now it works
onbjerg Apr 25, 2024
285d3a3
now it woks
onbjerg Apr 25, 2024
4648736
a
onbjerg Apr 25, 2024
f97620a
coldd vishunss
onbjerg Apr 25, 2024
d9cebfd
foijgrnkfosdafejiwoksd
onbjerg Apr 25, 2024
4b5cea0
grrr...
onbjerg Apr 25, 2024
0280ff6
inshallah1
onbjerg Apr 25, 2024
26f673f
fix other stuff
onbjerg Apr 25, 2024
9ad9115
done frfr
onbjerg Apr 25, 2024
872918a
driveby
onbjerg Apr 25, 2024
cfe776d
linkings
DaniPopes Apr 25, 2024
a919768
fuse lld
DaniPopes Apr 26, 2024
be010b7
clang
DaniPopes Apr 26, 2024
a5b4601
path
DaniPopes Apr 26, 2024
4516914
wtf
DaniPopes Apr 26, 2024
19b4414
mashallah. cleanup
DaniPopes Apr 26, 2024
619fdbd
apple linker args
DaniPopes Apr 26, 2024
7ee315f
do not display command output
DaniPopes Apr 26, 2024
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
31 changes: 23 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,42 @@ on:

env:
CARGO_TERM_COLOR: always
LLVM_VERSION: "17.0"
LLVM_VERSION: "17"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
name: test +${{ matrix.toolchain }} ${{ matrix.profile }}
runs-on: ubuntu-latest
name: test +${{ matrix.runner }}-${{ matrix.arch }}-${{ matrix.toolchain }} ${{ matrix.profile }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
runner: ["ubuntu-latest", "macos-14"]
arch: ["x64", "arm64"]
toolchain: ["stable", "nightly"]
profile: ["dev", "release"]
exclude:
- runner: "ubuntu-latest"
arch: "arm64"
- runner: "macos-14"
arch: "x64"
steps:
- uses: actions/checkout@v4
- uses: KyleMayes/install-llvm-action@v1
- uses: KyleMayes/[email protected]
if: ${{ !contains(matrix.runner, 'macos') }}
with:
version: ${{ env.LLVM_VERSION }}
- name: Install LLVM
if: ${{ contains(matrix.runner, 'macos') }}
run: |
v=${{ env.LLVM_VERSION }}
brew install "llvm@${v}"
echo "LLVM_SYS_${v}0_PREFIX=$(brew --prefix llvm@${v})" >> $GITHUB_ENV
echo "/opt/homebrew/opt/llvm@${v}/bin" >> $GITHUB_PATH
- name: llvm-config
run: llvm-config --version --bindir --libdir
- uses: dtolnay/rust-toolchain@master
Expand All @@ -37,14 +52,14 @@ jobs:
with:
cache-on-failure: true
- name: test
run: cargo test --all-features --workspace --verbose --profile ${{ matrix.profile }}
run: cargo test --all-features --workspace --profile ${{ matrix.profile }}

feature-checks:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: KyleMayes/install-llvm-action@v1
- uses: KyleMayes/install-llvm-action@v2.0.2
with:
version: ${{ env.LLVM_VERSION }}
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -61,7 +76,7 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: KyleMayes/install-llvm-action@v1
- uses: KyleMayes/install-llvm-action@v2.0.2
with:
version: ${{ env.LLVM_VERSION }}
- uses: dtolnay/rust-toolchain@clippy
Expand All @@ -77,7 +92,7 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: KyleMayes/install-llvm-action@v1
- uses: KyleMayes/install-llvm-action@v2.0.2
with:
version: ${{ env.LLVM_VERSION }}
- uses: dtolnay/rust-toolchain@nightly
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ Experimental [JIT] and [AOT] compiler for the [Ethereum Virtual Machine][EVM].
The compiler implementation is abstracted over an intermediate representation backend.

This repository hosts two backend implementations:

- [LLVM] ([`revm-jit-llvm`]): main backend with full test coverage;
- [Cranelift] ([`revm-jit-cranelift`]); currently not functional due to missing `i256` support in Cranelift. This will likely require a custom fork of Cranelift.

Compiling the crate requires LLVM 17.

[JIT]: https://en.wikipedia.org/wiki/Just-in-time_compilation
[AOT]: https://en.wikipedia.org/wiki/Ahead-of-time_compilation
[EVM]: https://ethereum.org/en/developers/docs/evm/
Expand Down
53 changes: 43 additions & 10 deletions crates/revm-jit/src/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::path::{Path, PathBuf};
#[derive(Debug)]
pub struct Linker {
cc: Option<PathBuf>,
linker: Option<PathBuf>,
cflags: Vec<String>,
}

Expand All @@ -16,14 +17,19 @@ impl Default for Linker {
impl Linker {
/// Creates a new linker.
pub fn new() -> Self {
Self { cc: None, cflags: vec![] }
Self { cc: None, linker: None, cflags: vec![] }
}

/// Sets the C compiler to use for linking.
/// Sets the C compiler to use for linking. Default: "cc".
pub fn cc(&mut self, cc: Option<PathBuf>) {
self.cc = cc;
}

/// Sets the linker to use for linking. Default: `lld`.
pub fn linker(&mut self, linker: Option<PathBuf>) {
self.linker = linker;
}

/// Sets the C compiler flags to use for linking.
pub fn cflags(&mut self, cflags: impl IntoIterator<Item = impl Into<String>>) {
self.cflags.extend(cflags.into_iter().map(Into::into));
Expand Down Expand Up @@ -62,11 +68,16 @@ impl Linker {
cmd.arg("-o").arg(out);
cmd.arg("-shared");
cmd.arg("-O3");
if !cfg!(debug_assertions) {
cmd.arg("-Wl,--gc-sections");
cmd.arg("-Wl,--strip-all");
if let Some(linker) = &self.linker {
cmd.arg(format!("-fuse-ld={}", linker.display()));
} else {
cmd.arg("-fuse-ld=lld");
}
if cfg!(target_vendor = "apple") {
cmd.arg("-Wl,-dead_strip,-undefined,dynamic_lookup");
} else {
cmd.arg("-Wl,--gc-sections,--strip-all,--undefined");
}
cmd.arg("-Wl,-undefined");
cmd.args(&self.cflags);
cmd.args(objects);
debug!(cmd=?cmd.get_program(), "linking");
Expand Down Expand Up @@ -112,10 +123,32 @@ mod tests {
assert!(obj.exists());

// Link object to shared library.
let linker = Linker::new();
if let Err(e) = linker.link(&so, [&obj]) {
panic!("failed to link: {e}");
let mut linker = Linker::new();
let mut n = 0;
for driver in ["cc", "gcc", "clang"] {
if !command_v(driver) {
continue;
}
n += 1;

let _ = std::fs::remove_file(&so);
linker.cc = Some(driver.into());
if let Err(e) = linker.link(&so, [&obj]) {
panic!("failed to link with {driver}: {e}");
}
assert!(so.exists());
}
assert!(n > 0, "no C compiler found");
}

fn command_v(cmd: &str) -> bool {
let Ok(output) = std::process::Command::new(cmd).arg("--version").output() else {
return false;
};
if !output.status.success() {
eprintln!("command {cmd} failed: {output:#?}");
return false;
}
assert!(so.exists());
true
}
}