Skip to content

Conversation

@sgasho
Copy link
Contributor

@sgasho sgasho commented Aug 31, 2025

closes: #2429
related: rust-lang/rust#145899

result of act dry-run

act -n -W .github/workflows/enzyme-rust.yml -P self-hosted=ubuntu-latest -P Linux=ubuntu-latest -P X64=ubuntu-latest -P 32-core=ubuntu-latest
INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' 
WARN  ⚠ You are using Apple M-series chip and you have not specified container architecture, you might encounter issues while running act. If so, try running it with '--container-architecture linux/amd64'. ⚠  
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] ⭐ Run Set up job
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] 🚀  Start image=ubuntu-latest
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] ⭐ Run Set up job
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] 🚀  Start image=ubuntu-latest
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   🐳  docker pull image=ubuntu-latest platform= username= forcePull=true
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   🐳  docker pull image=ubuntu-latest platform= username= forcePull=true
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   🐳  docker create image=ubuntu-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   🐳  docker run image=ubuntu-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   ✅  Success - Set up job
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   🐳  docker create image=ubuntu-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   🐳  docker run image=ubuntu-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   ✅  Success - Set up job
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] 🧪  Matrix: map[llvm:19]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] 🧪  Matrix: map[llvm:20]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] ⭐ Run Main Install LLVM and dependencies
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] ⭐ Run Main Install LLVM and dependencies
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   ✅  Success - Main Install LLVM and dependencies [3.041958ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   ✅  Success - Main Install LLVM and dependencies [3.560292ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] ⭐ Run Main Install Rust toolchain
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] ⭐ Run Main Install Rust toolchain
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   ✅  Success - Main Install Rust toolchain [2.436583ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   ✅  Success - Main Install Rust toolchain [2.396541ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] ⭐ Run Main Checkout Enzyme
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] ⭐ Run Main Checkout Enzyme
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   ✅  Success - Main Checkout Enzyme [1.037666ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   ✅  Success - Main Checkout Enzyme [1.382292ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] ⭐ Run Main Build Enzyme
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] ⭐ Run Main Build Enzyme
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   ✅  Success - Main Build Enzyme [2.28875ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   ✅  Success - Main Build Enzyme [2.499958ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] ⭐ Run Main Clone and configure Rust compiler
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] ⭐ Run Main Clone and configure Rust compiler
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   ✅  Success - Main Clone and configure Rust compiler [2.189917ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   ✅  Success - Main Clone and configure Rust compiler [2.093583ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] ⭐ Run Main Build Rust compiler stage 1
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] ⭐ Run Main Build Rust compiler stage 1
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   ✅  Success - Main Build Rust compiler stage 1 [2.484125ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   ✅  Success - Main Build Rust compiler stage 1 [2.589625ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] ⭐ Run Main Run Rust autodiff tests
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] ⭐ Run Main Run Rust autodiff tests
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   ✅  Success - Main Run Rust autodiff tests [2.293625ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] ⭐ Run Complete job
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] Cleaning up container for job Rust Autodiff Tests LLVM 20
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   ✅  Success - Main Run Rust autodiff tests [2.496792ms]
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] ⭐ Run Complete job
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] Cleaning up container for job Rust Autodiff Tests LLVM 19
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1]   ✅  Success - Complete job
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 19-1] 🏁  Job succeeded
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2]   ✅  Success - Complete job
*DRYRUN* [Enzyme Rust CI/Rust Autodiff Tests LLVM 20-2] 🏁  Job succeeded

run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source ~/.cargo/env
rustup toolchain install nightly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

until Rust adds CI for Enzyme, I think this should be fixed to a specific commit

jobs:
rust-autodiff:
name: Rust Autodiff Tests LLVM ${{ matrix.llvm }}
runs-on: [self-hosted, Linux, X64, 32-core]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not the correct setup for the runner, see https://github.com/EnzymeAD/Enzyme/blob/main/.github/workflows/enzyme-mlir.yml for an example

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it needs to run on linux-x86-n2-32

cmake ../enzyme -DLLVM_EXTERNAL_LIT=`which lit` -DCMAKE_BUILD_TYPE=Release -DLLVM_DIR=/usr/lib/llvm-${{ matrix.llvm }}/lib/cmake/llvm
make -j `nproc` LLVMEnzyme-${{ matrix.llvm }}
- name: Clone and configure Rust compiler
run: |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is never told to use the enzyme we built above?

source ~/.cargo/env
git clone --depth 1 --branch master https://github.com/rust-lang/rust.git
cd rust
./configure --enable-llvm-link-shared --enable-llvm-plugins --enable-llvm-enzyme --release-channel=nightly --enable-llvm-assertions --enable-clang --enable-lld --enable-option-checking --enable-ninja --disable-docs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should also use ccache here, and cache intermediate artifacts

@sgasho
Copy link
Contributor Author

sgasho commented Sep 1, 2025

@wsmoses @ZuseZ4
Thank you so much for the review!
However, I'm sorry for being a beginner at GitHub Actions and Enzyme and I'm not sure how to properly fix about some comments, especially

#2430 (comment)
#2430 (comment)
#2430 (comment)

Could you give me some hints, examples, suggestions, or something I should study?
I did some commits, but I'm not confident, especially wip

@wsmoses
Copy link
Member

wsmoses commented Sep 2, 2025

@ZuseZ4 can you help @sgasho understand the next steps from the comments?

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Sep 2, 2025

I have no experience with ccache and to me it sounds like something that should be added in a follow-up pr to avoid feature creep. But it looks like you've already added it in your last commit? If it works I guess it should stay.

For the pinning of the version, I would assume we want to fix the rustc we build, and not necessarily the rust version we use to build rustc. It's fine to do both, but right now you only pin the version used to build. You should also check out a specific commit of github.com/rust-lang/rust instead of just the master branch. This way, we can verify that new Enzyme versions don't break support. We would update the rustc commit every once in a while. This way, an update to rustc can't break Enzyme CI.

I don't know whats the relevant difference between your. yml file and the mlir example given, so I'd leave that for Billy to answer.

Comment on lines 60 to 61
echo "CC=ccache gcc" >> $GITHUB_ENV
echo "CXX=ccache g++" >> $GITHUB_ENV

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who uses this? What exactly is built using GCC? I think Rust still uses LLVM. The rust invocation will prefix its invocations with ccache by itself as far as I can see, thanks to the --enable-ccache a few lines above.

run: |
. ~/.cargo/env
rm -rf build && mkdir build && cd build
RUST_LLVM_DIR=${GITHUB_WORKSPACE}/rust/build/x86_64-unknown-linux-gnu/llvm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would shell-quote this. GitHub probably has no space or special chars in the checkout dir, but better be safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shell-quoted it in this commit!
use quotes

run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. ~/.cargo/env
# Pin to specific nightly commit for reproducibility

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this used for? Rustc bootstrap? Might be worth it to add a comment saying what is now reproducible. Enzyme itself is built against the latest rust compiler (you check out the main branch of rust-lang/rust), so I imagine it won't really help there?


container:
image: ${{ (contains(matrix.os, 'linux') && 'ghcr.io/enzymead/reactant-docker-images@sha256:91e1edb7a7c869d5a70db06e417f22907be0e67ca86641d48adcea221fedc674' ) || '' }}
image: ${{ (contains(matrix.os, 'linux') && 'ghcr.io/enzymead/reactant-docker-images:main' ) || '' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use the specific hash, not main

- name: Install dependencies
run: |
apt-get update
apt-get install -y binutils ninja-build cmake gcc g++ python3 python3-dev ccache nodejs npm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need all these deps?

. ~/.cargo/env
git clone https://github.com/rust-lang/rust.git
cd rust
git checkout 51ff895062ba60a7cba53f57af928c3fb7b0f2f4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move the commit to the matrix? that'll make it easier to update, and or if in the future we want to checkout multiple and/or stable tags

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Sep 5, 2025

This currently builds Enzyme twice, once as part of rustc and once standalone.
Unfortunately it uses the old one from rustc for testing.
Is there a way to delete the default Enzyme submodule and re-add it using the new Enzyme source code which we have here (e.g. through ln -s or copying)? Then you can stop to build it seperately and we use the normal rust infra for building it.

- name: Clone and configure Rust compiler
run: |
. ~/.cargo/env
git clone https://github.com/rust-lang/rust.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should use another actions/checkout for this [and can give it the relevant tag/commit]

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Sep 10, 2025

@wsmoses this looks ready? Can you run CI, I don't have permission

@ZuseZ4 ZuseZ4 requested a review from wsmoses September 20, 2025 22:25
--enable-clang \
--enable-lld \
--disable-optimize-llvm \
--enable-option-checking \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use the github actions cache here, but lets see if it builds first

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise ccache doesn't do anything as the run is ephemeral

@wsmoses
Copy link
Member

wsmoses commented Sep 20, 2025

fails

CMAKE_TOOLCHAIN_FILE_x86_64-unknown-linux-gnu = None
CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_gnu = None
HOST_CMAKE_TOOLCHAIN_FILE = None
CMAKE_TOOLCHAIN_FILE = None
CMAKE_PREFIX_PATH_x86_64-unknown-linux-gnu = None
CMAKE_PREFIX_PATH_x86_64_unknown_linux_gnu = None
HOST_CMAKE_PREFIX_PATH = None
CMAKE_PREFIX_PATH = None
CMAKE_x86_64-unknown-linux-gnu = None
CMAKE_x86_64_unknown_linux_gnu = None
HOST_CMAKE = None
CMAKE = None
running: cd "/__w/Enzyme/Enzyme/rust/build/x86_64-unknown-linux-gnu/enzyme/build" && CMAKE_PREFIX_PATH="" DESTDIR="" LC_ALL="C" LLVM_CONFIG_REAL="/__w/Enzyme/Enzyme/rust/build/x86_64-unknown-linux-gnu/llvm/bin/llvm-config" "cmake" "/__w/Enzyme/Enzyme/rust/src/tools/enzyme/enzyme/" "-G" "Ninja" "-DCMAKE_INSTALL_MESSAGE=LAZY" "-DCMAKE_C_COMPILER_LAUNCHER=ccache" "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache" "-DCMAKE_C_COMPILER=cc" "-DCMAKE_CXX_COMPILER=c++" "-DCMAKE_ASM_COMPILER=cc" "-DCMAKE_C_FLAGS=-ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_FLAGS=-ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_SHARED_LINKER_FLAGS=" "-DCMAKE_MODULE_LINKER_FLAGS=" "-DCMAKE_EXE_LINKER_FLAGS=" "-DLLVM_ENABLE_ASSERTIONS=ON" "-DENZYME_EXTERNAL_SHARED_LIB=ON" "-DENZYME_BC_LOADER=OFF" "-DLLVM_DIR=/__w/Enzyme/Enzyme/rust/build/x86_64-unknown-linux-gnu/llvm" "-DCMAKE_INSTALL_PREFIX=/__w/Enzyme/Enzyme/rust/build/x86_64-unknown-linux-gnu/enzyme" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_BUILD_TYPE=Debug"
CMake Error: The source directory "/__w/Enzyme/Enzyme/rust/src/tools/enzyme/enzyme" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

thread 'main' panicked at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cmake-0.1.54/src/lib.rs:1119:5:

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Sep 26, 2025

@sgasho Not sure if it's related, or needed but you can also try to do a submodule update for enzyme and commit it.

@wsmoses
Copy link
Member

wsmoses commented Sep 26, 2025

Run source ~/.cargo/env
Run '/home/runner/k8s/index.js'
using script executor
/__w/_temp/4f4ab6b8-84af-4b9c-8304-d6f25cfb5572.sh: 1: source: not found
Error: Error: ScriptExecutorError when trying to execute: "Error: Job failed with exit code 127."
Error: Process completed with exit code 1.
Error: Executing the custom container implementation failed. Please contact your self hosted runner admini

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Oct 1, 2025

@sgasho Looks like you managed it! The last test is failing, but that one frequently changes the IR generated, not sure if it's because of rustc, LLVM, or Enzyme changing. I'll look into making it more robust, it's not like that feature (batching) is well tested in Rust atm anyway.

From my side that sounds like it's good to merge?

Also side note, we'll probably switch from linking against Enzyme to just dlopen'ing Enzyme, which should make this CI even simpler in the future: rust-lang/rust#146623

@wsmoses
Copy link
Member

wsmoses commented Oct 1, 2025

while @ZuseZ4 fixes the last test to pass, @sgasho can you get the ccache stuff working?

I think those are the last two things in order to merge!

Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 4, 2025
…youxu

bless autodiff batching test

This pr blesses a broken test and unblocks running rust in the Enzyme CI: EnzymeAD/Enzyme#2430
Enzyme is the plugin used by our std::autodiff and (future) std::batching modules, both of which are not build by default.
In the near future we also hope to enable std::autodiff in the Rust CI.

This test is the only one to combine two features, automatic differentiation and batching/vectorization. This combination is even more experimental than either feature on its own. I have a wip branch in which I enable more vectorization/batching and as part of that I'll think more about how to write those tests in a robust way (and likely change the interface). Until that lands, I don't care too much about what specific IR we generate here; it's just nice to track changes.

r? compiler
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 4, 2025
…youxu

bless autodiff batching test

This pr blesses a broken test and unblocks running rust in the Enzyme CI: EnzymeAD/Enzyme#2430
Enzyme is the plugin used by our std::autodiff and (future) std::batching modules, both of which are not build by default.
In the near future we also hope to enable std::autodiff in the Rust CI.

This test is the only one to combine two features, automatic differentiation and batching/vectorization. This combination is even more experimental than either feature on its own. I have a wip branch in which I enable more vectorization/batching and as part of that I'll think more about how to write those tests in a robust way (and likely change the interface). Until that lands, I don't care too much about what specific IR we generate here; it's just nice to track changes.

r? compiler
@sgasho
Copy link
Contributor Author

sgasho commented Oct 17, 2025

Does "Deleting the contents of '/__w/Enzyme/Enzyme'" below have to do with this low hit rate?
ccache is under /__w/Enzyme/Enzyme/.ccache, so cache might be deleted before the build step....
Placing the “Cache ccache” step after actions/checkout@v4 might resolve this issue?

スクリーンショット 2025-10-17 22 58 12

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Oct 17, 2025

Not sure about that part.
@I-Al-Istannen mentioned though that it would be good to move the first show stats a little bit down, to run after the Cache ccache step where the cache gets restored.

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Oct 19, 2025

I'm not sure why it's still not caching, but at this point it's probably easier to wait for my fix on the rustc side to land.
Due to some past work std::autodiff/enzyme now also works with download-ci-llvm=true.
Download-LLVM optionally also ships with llvm assertions, so we don't loose anything.

rust-lang/rust#147888

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Oct 20, 2025

@sgasho The PR landed. If you update again and use the new build command from that PR it shouldn't build LLVM anymore. I'd also remove ccache now, since it seems unreliable. We should be fast enough without it.

@wsmoses
Copy link
Member

wsmoses commented Oct 21, 2025

I would still keep ccache, can you restore that?

@giordano
Copy link
Member

https://github.com/EnzymeAD/Enzyme/actions/runs/18688055156/job/53367987961?pr=2430#step:8:460

thread 'main' (2614) panicked at src/bootstrap/src/core/config/config.rs:1768:22:
called `Result::unwrap()` on an `Err` value: "command did not execute successfully: cd \"/__w/Enzyme/Enzyme/rust\" && \"git\" \"rev-parse\" \"HEAD^1\"\nexpected success, got: exit status: 128\n"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@sgasho
Copy link
Contributor Author

sgasho commented Oct 22, 2025

thread 'main' (2614) panicked at src/bootstrap/src/core/config/config.rs:1768:22:
called Result::unwrap() on an Err value: "command did not execute successfully: cd "/__w/Enzyme/Enzyme/rust" && "git" "rev-parse" "HEAD^1"\nexpected success, got: exit status: 128\n"
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

hmm....I couldn't reproduce this on my local machine using act.
I explicitly set fetch-depth to 0 for now.

specify fetch-depth

@sgasho
Copy link
Contributor Author

sgasho commented Oct 22, 2025

git rev-parse HEAD^1 problem has been resolved.
Another error occurred. I'll check it tomorrow.

-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
LLVM_SHLIBEXT=.so
LLVM ABS DIR /__w/Enzyme/Enzyme/rust/build/x86_64-unknown-linux-gnu/ci-llvm
CMAKE_PREFIX_PATH 
CMake Error at CMakeLists.txt:74 (find_package):
  Could not find a package configuration file provided by "LLVM" with any of
  the following names:

    LLVMConfig.cmake
    llvm-config.cmake

  Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set
  "LLVM_DIR" to a directory containing one of the above files.  If "LLVM"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!

thread 'main' (2652) panicked at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cmake-0.1.54/src/lib.rs:1119:5:

command did not execute successfully, got: exit status: 1

build script failed, must exit now
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
	finished in 0.289 seconds
Build completed unsuccessfully in 0:01:42
Error: Error: ScriptExecutorError when trying to execute: "Error: Job failed with exit code 1."
Error: Process completed with exit code 1.
Error: Executing the custom container implementation failed. Please contact your self hosted runner administrator.

Comment on lines 44 to 46
- uses: actions/checkout@v4
name: Checkout Enzyme
- uses: actions/checkout@v4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/checkout@v4
name: Checkout Enzyme
- uses: actions/checkout@v4
- uses: actions/checkout@v5
name: Checkout Enzyme
- uses: actions/checkout@v5

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Oct 22, 2025

The second error looks familiar, https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/distribute.20LLVM.20CMake.20modules.3F/near/420114940
Hopefully, adding these files to an existing component is easy. Let's see what the infra people say.

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Oct 23, 2025

This PR could be a potential solution @sgasho @I-Al-Istannen.
I'm not super sure what's the best way to test it, I wrote an option in the PR but maybe you have a better idea?
rust-lang/rust#148027

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Oct 24, 2025

It looks like the cmake files alone are not enough and people are not keen on shipping additional things just for one user, so Enzyme should just build it's own LLVM. Even with a cache that barely has any cache hits, the last run was only 23 minutes once we remove cland and lld. That's already at the lower end of what the Julia runners need, so from a Rust point I'd recommend to land that and open an issue for someone to investigate why ccache has a low hitrate, to make it even faster.

@wsmoses
Copy link
Member

wsmoses commented Oct 24, 2025

What was the error message when cmake was shipped?

1 similar comment
@wsmoses
Copy link
Member

wsmoses commented Oct 24, 2025

What was the error message when cmake was shipped?

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Oct 24, 2025

rust-lang/rust#148027 (comment), and looking at the corresponding CMake file it would have looked for all other archives next (if I read cmake correctly).

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Oct 24, 2025

We just added Rust CI to our Enzyme fork at rust-lang/enzyme.
It unfortunately doesn't use download-ci-llvm=true due to the issues mentioned above, but even on the slow public runners it finishes in 18 minutes, so on the better runners it should be significantly faster than some of the other langs and should not be a bottleneck. rust-lang@098e4da

@sgasho I'm not sure what's the difference and why the rust-lang/enzyme had a much higher cache hit rate, but maybe the PR helps you to figure out the difference? Can you try to update your pr (while still keeping the faster custom runners)?
Then we're hopefully able to get this pr landed soon!

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Oct 25, 2025

My guess is that you're missing the --enable-llvm-link-shared flag, which was in the last revision of the docs (which I guess I'll need to revert). Without it rust might build llvm as static, in which case it never generates an llvm.a file, but rather a lot of individual archives. Enzyme incorrectly tries to link llvm, and then fails.

I have a bugfix in the rust fork for it, which is likely why CI there doesn't need it. Upstreaming unfortunately seems blocked on some julia failure, hopefully someone will pick it up.

@sgasho
Copy link
Contributor Author

sgasho commented Oct 27, 2025

32 minutes for the first run, without cache.
190MB cache has been created.

スクリーンショット 2025-10-27 22 47 14

@wsmoses @giordano
Could you run it again? Now we can see how much faster it gets

@sgasho
Copy link
Contributor Author

sgasho commented Oct 27, 2025

@giordano

Could you run it again? Now we can see how much faster it gets

Thanks!

The second run took 10 minutes, which was three times faster than without the cache.

スクリーンショット 2025-10-27 23 12 10

Copy link
Member

@wsmoses wsmoses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, @giordano can you also give this a once over

Copy link
Member

@giordano giordano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@wsmoses wsmoses merged commit aecafad into EnzymeAD:main Oct 27, 2025
26 checks passed
@sgasho
Copy link
Contributor Author

sgasho commented Oct 27, 2025

@wsmoses @giordano @ZuseZ4 @I-Al-Istannen
Thank you so much for your support!

@I-Al-Istannen
Copy link

I-Al-Istannen commented Oct 27, 2025

Congrats on the merge and grit to keep at it :)

@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Oct 27, 2025

Agree, thanks a lot for having the patience to work two months on it! Let's hope that we'll soon get ci (and thus nightly support) within rust as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CI to test Rust std::autodiff

5 participants