From 708beb103ae9599f2404103e4f1c802f1f997d67 Mon Sep 17 00:00:00 2001 From: sgasho Date: Sun, 31 Aug 2025 14:44:47 +0900 Subject: [PATCH 01/12] ci: add ci to test rust std::autodiff --- .github/workflows/enzyme-rust.yml | 84 +++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/enzyme-rust.yml diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml new file mode 100644 index 000000000000..247e70c92782 --- /dev/null +++ b/.github/workflows/enzyme-rust.yml @@ -0,0 +1,84 @@ +name: Enzyme Rust CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + merge_group: + +jobs: + rust-autodiff: + name: Rust Autodiff ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [linux-x86-n2-32] + commit: [51ff895062ba60a7cba53f57af928c3fb7b0f2f4] + + timeout-minutes: 90 + + container: + image: ${{ (contains(matrix.os, 'linux') && 'ghcr.io/enzymead/reactant-docker-images@sha256:91e1edb7a7c869d5a70db06e417f22907be0e67ca86641d48adcea221fedc674' ) || '' }} + + steps: + - name: Install dependencies + run: | + apt-get update + apt-get install -y ninja-build cmake ccache nodejs + - name: Cache ccache + uses: actions/cache@v4 + with: + path: ~/.cache/ccache + key: ccache-${{ matrix.os }}-${{ matrix.commit }} + - name: Install Rust toolchain + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + . ~/.cargo/env + rustup toolchain install nightly + rustup default nightly + - uses: actions/checkout@v4 + name: Checkout Enzyme + - uses: actions/checkout@v4 + name: Checkout Rust compiler + with: + repository: rust-lang/rust + ref: ${{ matrix.commit }} + path: rust + - name: Configure Rust compiler + run: | + . ~/.cargo/env + cd rust + # Replace rustc's built-in Enzyme submodule with the Enzyme source code from this repository + rm -rf src/tools/enzyme/enzyme + ln -s "${GITHUB_WORKSPACE}/enzyme" src/tools/enzyme/enzyme + ./configure \ + --enable-llvm-link-shared \ + --enable-llvm-plugins \ + --enable-llvm-enzyme \ + --release-channel=nightly \ + --enable-llvm-assertions \ + --enable-clang \ + --enable-lld \ + --disable-optimize-llvm \ + --enable-option-checking \ + --enable-ninja \ + --disable-docs \ + --enable-ccache + - name: Build Rust compiler stage 1 + working-directory: rust + run: | + . ~/.cargo/env + ./x build --stage 1 library + - name: Run Rust autodiff tests + working-directory: rust + run: | + . ~/.cargo/env + ./x test --stage 1 tests/codegen-llvm/autodiff + ./x test --stage 1 tests/pretty/autodiff + ./x test --stage 1 tests/ui/autodiff + ./x test --stage 1 tests/ui/feature-gates/feature-gate-autodiff.rs From 29abf8cba0c392d6047549c4f99d7baea7df6230 Mon Sep 17 00:00:00 2001 From: sgasho Date: Sun, 5 Oct 2025 12:23:07 +0900 Subject: [PATCH 02/12] include rust in the key for the cache --- .github/workflows/enzyme-rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml index 247e70c92782..31bf588863f1 100644 --- a/.github/workflows/enzyme-rust.yml +++ b/.github/workflows/enzyme-rust.yml @@ -34,7 +34,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.cache/ccache - key: ccache-${{ matrix.os }}-${{ matrix.commit }} + key: ccache-rust-${{ matrix.os }}-${{ matrix.commit }} - name: Install Rust toolchain run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y From 871ef84fe699770f405faa46a82a95a84dbbc38f Mon Sep 17 00:00:00 2001 From: sgasho Date: Sun, 5 Oct 2025 12:30:11 +0900 Subject: [PATCH 03/12] update rust commit --- .github/workflows/enzyme-rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml index 31bf588863f1..cc3e19ffaa20 100644 --- a/.github/workflows/enzyme-rust.yml +++ b/.github/workflows/enzyme-rust.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [linux-x86-n2-32] - commit: [51ff895062ba60a7cba53f57af928c3fb7b0f2f4] + commit: [227ac7c3cd486872d5c2352b3df02b571500e53a] timeout-minutes: 90 From 99862d2d88e5e80398bce57da9329c410593e959 Mon Sep 17 00:00:00 2001 From: sgasho Date: Mon, 6 Oct 2025 08:46:58 +0900 Subject: [PATCH 04/12] update rust commit --- .github/workflows/enzyme-rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml index cc3e19ffaa20..3710db2a2ac7 100644 --- a/.github/workflows/enzyme-rust.yml +++ b/.github/workflows/enzyme-rust.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [linux-x86-n2-32] - commit: [227ac7c3cd486872d5c2352b3df02b571500e53a] + commit: [839222065a44ac21c15df68ed2f2f3c0127b0b8e] timeout-minutes: 90 From b5fa11e083f9c41c515ad3b6e8c106e936163728 Mon Sep 17 00:00:00 2001 From: sgasho Date: Wed, 8 Oct 2025 21:57:08 +0900 Subject: [PATCH 05/12] update rust commit --- .github/workflows/enzyme-rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml index 3710db2a2ac7..4efcdba015e6 100644 --- a/.github/workflows/enzyme-rust.yml +++ b/.github/workflows/enzyme-rust.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [linux-x86-n2-32] - commit: [839222065a44ac21c15df68ed2f2f3c0127b0b8e] + commit: [82224f6891c7e7aa0c6c865aa825100b3ea2d0fb] timeout-minutes: 90 From e6df833326866560398b526c46490b5979ea74cd Mon Sep 17 00:00:00 2001 From: William Moses Date: Wed, 8 Oct 2025 15:31:30 -0500 Subject: [PATCH 06/12] Add build step for Rust compiler stage 1 --- .github/workflows/enzyme-rust.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml index 4efcdba015e6..e01b0cfc6ab2 100644 --- a/.github/workflows/enzyme-rust.yml +++ b/.github/workflows/enzyme-rust.yml @@ -69,6 +69,7 @@ jobs: --enable-ninja \ --disable-docs \ --enable-ccache + - name: Build Rust compiler stage 1 working-directory: rust run: | From ba54026b0dbc6f39ce2cc7f14116f28b41faf409 Mon Sep 17 00:00:00 2001 From: sgasho Date: Fri, 10 Oct 2025 01:25:58 +0900 Subject: [PATCH 07/12] specify CCACHE_DIR --- .github/workflows/enzyme-rust.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml index e01b0cfc6ab2..3d7c6a837dd4 100644 --- a/.github/workflows/enzyme-rust.yml +++ b/.github/workflows/enzyme-rust.yml @@ -13,7 +13,6 @@ jobs: rust-autodiff: name: Rust Autodiff ${{ matrix.os }} runs-on: ${{ matrix.os }} - strategy: fail-fast: false matrix: @@ -26,14 +25,20 @@ jobs: image: ${{ (contains(matrix.os, 'linux') && 'ghcr.io/enzymead/reactant-docker-images@sha256:91e1edb7a7c869d5a70db06e417f22907be0e67ca86641d48adcea221fedc674' ) || '' }} steps: + - name: Prepare env + run: | + echo "CCACHE_DIR=${GITHUB_WORKSPACE}/.ccache" >> "${GITHUB_ENV}" - name: Install dependencies run: | apt-get update apt-get install -y ninja-build cmake ccache nodejs + - name: Prepare ccache directory + run: | + mkdir -p "$CCACHE_DIR" - name: Cache ccache uses: actions/cache@v4 with: - path: ~/.cache/ccache + path: ${{ env.CCACHE_DIR }} key: ccache-rust-${{ matrix.os }}-${{ matrix.commit }} - name: Install Rust toolchain run: | @@ -69,7 +74,6 @@ jobs: --enable-ninja \ --disable-docs \ --enable-ccache - - name: Build Rust compiler stage 1 working-directory: rust run: | From c423c2765c1124c1e83e0cccf543edb2a0df5ecb Mon Sep 17 00:00:00 2001 From: sgasho Date: Thu, 16 Oct 2025 22:44:28 +0900 Subject: [PATCH 08/12] ccache --show-stats --- .github/workflows/enzyme-rust.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml index 3d7c6a837dd4..40c7a511fa6b 100644 --- a/.github/workflows/enzyme-rust.yml +++ b/.github/workflows/enzyme-rust.yml @@ -32,6 +32,9 @@ jobs: run: | apt-get update apt-get install -y ninja-build cmake ccache nodejs + - name: ccache --show-stats + run: | + ccache --show-stats - name: Prepare ccache directory run: | mkdir -p "$CCACHE_DIR" @@ -87,3 +90,6 @@ jobs: ./x test --stage 1 tests/pretty/autodiff ./x test --stage 1 tests/ui/autodiff ./x test --stage 1 tests/ui/feature-gates/feature-gate-autodiff.rs + - name: ccache --show-stats + run: | + ccache --show-stats From e38b6dc644c5341c2b0c891b765452c0b02ccfd1 Mon Sep 17 00:00:00 2001 From: sgasho Date: Thu, 16 Oct 2025 22:47:45 +0900 Subject: [PATCH 09/12] add verbose for more information --- .github/workflows/enzyme-rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml index 40c7a511fa6b..86cc5e45d56d 100644 --- a/.github/workflows/enzyme-rust.yml +++ b/.github/workflows/enzyme-rust.yml @@ -34,7 +34,7 @@ jobs: apt-get install -y ninja-build cmake ccache nodejs - name: ccache --show-stats run: | - ccache --show-stats + ccache --show-stats --verbose - name: Prepare ccache directory run: | mkdir -p "$CCACHE_DIR" @@ -92,4 +92,4 @@ jobs: ./x test --stage 1 tests/ui/feature-gates/feature-gate-autodiff.rs - name: ccache --show-stats run: | - ccache --show-stats + ccache --show-stats --verbose From 0b6558820b1bdc62ac395f4b6b894b3e9e257cb6 Mon Sep 17 00:00:00 2001 From: sgasho Date: Thu, 16 Oct 2025 23:25:46 +0900 Subject: [PATCH 10/12] remove clang and reduce targets to x86 --- .github/workflows/enzyme-rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml index 86cc5e45d56d..9f12b6db4c94 100644 --- a/.github/workflows/enzyme-rust.yml +++ b/.github/workflows/enzyme-rust.yml @@ -70,13 +70,13 @@ jobs: --enable-llvm-enzyme \ --release-channel=nightly \ --enable-llvm-assertions \ - --enable-clang \ --enable-lld \ --disable-optimize-llvm \ --enable-option-checking \ --enable-ninja \ --disable-docs \ - --enable-ccache + --enable-ccache \ + --set=llvm.targets="X86" - name: Build Rust compiler stage 1 working-directory: rust run: | From 5e713377c42d2c4a9952b099710c6a561e72efb6 Mon Sep 17 00:00:00 2001 From: sgasho Date: Fri, 17 Oct 2025 23:08:08 +0900 Subject: [PATCH 11/12] move cache step after checkout --- .github/workflows/enzyme-rust.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml index 9f12b6db4c94..01d42be03c93 100644 --- a/.github/workflows/enzyme-rust.yml +++ b/.github/workflows/enzyme-rust.yml @@ -38,11 +38,6 @@ jobs: - name: Prepare ccache directory run: | mkdir -p "$CCACHE_DIR" - - name: Cache ccache - uses: actions/cache@v4 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-rust-${{ matrix.os }}-${{ matrix.commit }} - name: Install Rust toolchain run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y @@ -57,6 +52,11 @@ jobs: repository: rust-lang/rust ref: ${{ matrix.commit }} path: rust + - name: Cache ccache + uses: actions/cache@v4 + with: + path: ${{ env.CCACHE_DIR }} + key: ccache-rust-${{ matrix.os }}-${{ matrix.commit }} - name: Configure Rust compiler run: | . ~/.cargo/env From 7068f0a5549f469f583b88cb9efa900e07389871 Mon Sep 17 00:00:00 2001 From: sgasho Date: Fri, 17 Oct 2025 23:25:11 +0900 Subject: [PATCH 12/12] move ccache show-stats after Cache ccache step --- .github/workflows/enzyme-rust.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/enzyme-rust.yml b/.github/workflows/enzyme-rust.yml index 01d42be03c93..45e65b51598c 100644 --- a/.github/workflows/enzyme-rust.yml +++ b/.github/workflows/enzyme-rust.yml @@ -32,9 +32,6 @@ jobs: run: | apt-get update apt-get install -y ninja-build cmake ccache nodejs - - name: ccache --show-stats - run: | - ccache --show-stats --verbose - name: Prepare ccache directory run: | mkdir -p "$CCACHE_DIR" @@ -57,6 +54,9 @@ jobs: with: path: ${{ env.CCACHE_DIR }} key: ccache-rust-${{ matrix.os }}-${{ matrix.commit }} + - name: ccache --show-stats + run: | + ccache --show-stats --verbose - name: Configure Rust compiler run: | . ~/.cargo/env