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

Remove llvm patch #8

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
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
29 changes: 17 additions & 12 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ jobs:
include:
- runner: [runs-on, runner=32cpu-linux-x64, "run-id=${{ github.run_id }}"]
os: ubuntu
cachekey: ubuntu-x86
- runner: [runs-on, runner=32cpu-linux-arm64, "run-id=${{ github.run_id }}"]
os: ubuntu
cachekey: ubuntu-arm64
- runner: self-hosted
os: macos
cachekey: macos-arm64
- runner: macos-13
os: macos
cachekey: macos-x86

steps:
- name: Free Disk Space (Ubuntu)
Expand All @@ -70,18 +74,19 @@ jobs:

- uses: actions/checkout@v4

- name: Install ninja and riscv-tools
if: matrix.os == 'ubuntu'
run: |
sudo apt update
sudo apt-get -y install ninja-build gcc-riscv64-unknown-elf
- uses: actions/cache@v4
name: Cache Rust toolchain
with:
path: |
rust/build
rust/library
rust/src/doc
rust/src/llvm-project
rust/src/tools
key: ${{ matrix.cachekey }}-buildtoolchain-${{ env.RUST_COMMIT }}

- name: Install ninja and riscv-tools
if: matrix.os == 'macos'
run: |
brew install ninja
brew tap riscv-software-src/riscv
brew install riscv-tools
- name: Install ninja
uses: lukka/[email protected]

- name: Download source
run: ./clone.sh
Expand All @@ -92,7 +97,7 @@ jobs:
- name: Build toolchain
run: ./build.sh

# Push in the Github environment variable the name of the artifact
# Push the name of the artifact into the Github environment variable
- run: ./config.sh -artifact_name

- name: Package toolchain
Expand Down
66 changes: 53 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,86 @@ name: CI

on:
workflow_dispatch:
pull_request:
branches:
- "**"
paths-ignore:
- README.md

jobs:
build:
strategy:
fail-fast: false
matrix:
runner:
- [runs-on, runner=32cpu-linux-x64, "run-id=${{ github.run_id }}"]
- [runs-on, runner=32cpu-linux-arm64, "run-id=${{ github.run_id }}"]
- self-hosted
- macos-13
include:
- runner: [runs-on, runner=32cpu-linux-x64, "run-id=${{ github.run_id }}"]
os: ubuntu
cachekey: ubuntu-x86
- runner: [runs-on, runner=32cpu-linux-arm64, "run-id=${{ github.run_id }}"]
os: ubuntu
cachekey: ubuntu-arm64
- runner: self-hosted
os: macos
cachekey: macos-arm64
- runner: macos-13
os: macos
cachekey: macos-x86
runs-on: ${{ matrix.runner }}
timeout-minutes: 120
steps:
- name: Install nightly toolchain
id: rustc-toolchain
uses: actions-rs/toolchain@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly-2024-01-25
default: true
toolchain: nightly-2024-05-29

- uses: lukka/get-cmake@v3.27.4
- uses: lukka/get-cmake@v3.30.2

- name: Show rust version
run: |
cargo version
rustup toolchain list

- name: Check out athenavm/rustc-rv32e-toolchain
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
path: toolchain

- name: Check out athenavm/athena
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: athenavm/athena
ref: main
ref: fix-toolchain-build
path: athena

- name: Get Rust commit
run: |
RUST_COMMIT=$(cat toolchain/rust_commit.txt)
echo "Using Rust commit: $RUST_COMMIT"
echo "RUST_COMMIT=$RUST_COMMIT" >> $GITHUB_ENV

- uses: actions/cache@v4
name: Cache Athena build
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
athena/target/
key: ${{ matrix.cachekey }}-athenabuild-${{ hashFiles('athena/**/Cargo.toml') }}

- uses: actions/cache@v4
name: Cache Rust toolchain
with:
path: |
toolchain/rust/**
# toolchain/rust/library
# toolchain/rust/src/doc
# toolchain/rust/src/llvm-project
# toolchain/rust/src/tools
key: ${{ matrix.cachekey }}-rusttoolchain-${{ env.RUST_COMMIT }}

- name: Build
run:
GITHUB_ACTIONS=false ATHENA_BUILD_DIR=$GITHUB_WORKSPACE/toolchain cargo run --bin cargo-athena -- athena
Expand Down
20 changes: 15 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@ set -euo pipefail
source config.sh

# Fail fast if these tools aren't properly installed and in the path
need_cmd riscv64-unknown-elf-gcc
need_cmd riscv64-unknown-elf-g++
need_cmd riscv32-unknown-elf-clang
need_cmd riscv32-unknown-elf-clang++

# Rust requires a custom target file to exist for our custom target as part of the bootstrap build,
# but it doesn't actually look at the contents.
touch /tmp/riscv32em-athena-zkvm-elf.json
export RUST_TARGET_PATH="/tmp"

# Explicitly set CFLAGS without the problematic flags
export CFLAGS_riscv32em_athena_zkvm_elf="-ffunction-sections -fdata-sections -fPIC -target riscv32-unknown-elf"

# Set Rust flags
export CARGO_TARGET_RISCV32EM_ATHENA_ZKVM_ELF_RUSTFLAGS="-Cpasses=loweratomic -Clink-arg=-march=rv32em -Clink-arg=-mabi=ilp32e"
# export COMPILER_RT_DEFAULT_TARGET_TRIPLE="riscv32-unknown-elf"
# export CC_riscv32em_athena_zkvm_elf="clang"
# export CXX_riscv32em_athena_zkvm_elf="clang++"

# Prevent the build system from adding --target flag
export RUSTC_TARGET_ARG=""

# Will create component archives (dists) ./rust/build/dist
cd rust
RUST_TARGET_PATH="/tmp" \
CARGO_TARGET_RISCV32EM_ATHENA_ZKVM_ELF_RUSTFLAGS="-Cpasses=loweratomic" \
CFLAGS_riscv32em_athena_zkvm_elf="-ffunction-sections -fdata-sections -fPIC -march=rv32em -mabi=ilp32e" \
./x build --stage 2
2 changes: 1 addition & 1 deletion config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

param1=${1:-}

export RUST_COMMIT=051478957371ee0084a7c0913941d2a8c4757bb9
export RUST_COMMIT=$(cat rust_commit.txt)

# If -rust_commit specified then only export the rust commit variable
if [ "$param1" == "-rust_commit" ]; then
Expand Down
5 changes: 1 addition & 4 deletions patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@
set -euo pipefail

cd rust
patch -p1 < ../patches/rust.patch
patch -N -p1 < ../patches/rust.patch
cp ../patches/config.toml ./

cd src/llvm-project
patch -p1 < ../../../patches/llvm.patch
4 changes: 2 additions & 2 deletions patches/config.ci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ configure-args = []
cargo-native-static = true

[target.riscv32em-athena-zkvm-elf]
cc = "riscv64-unknown-elf-gcc"
cxx = "riscv64-unknown-elf-g++"
cc = "clang"
cxx = "clang++"

[rust]
lld = true
Expand Down
6 changes: 4 additions & 2 deletions patches/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ tools = ["cargo", "cargo-clippy", "clippy", "rustfmt"]
configure-args = []

[target.riscv32em-athena-zkvm-elf]
cc = "riscv64-unknown-elf-gcc"
cxx = "riscv64-unknown-elf-g++"
cc = "riscv32-unknown-elf-clang"
cxx = "riscv32-unknown-elf-clang++"
# linker = "riscv32-unknown-elf-gcc"
# ar = "riscv32-unknown-elf-ar"

[rust]
lld = true
Expand Down
17 changes: 0 additions & 17 deletions patches/llvm.patch

This file was deleted.

1 change: 1 addition & 0 deletions rust_commit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
051478957371ee0084a7c0913941d2a8c4757bb9
1 change: 0 additions & 1 deletion version.txt

This file was deleted.

Loading