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: ensure nightly and rustup are available #81

Merged
merged 5 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
33 changes: 25 additions & 8 deletions .github/workflows/enzyme-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,35 @@ jobs:

timeout-minutes: 600
steps:
- name: checkout the source code
uses: actions/checkout@v3
- name: Checkout Rust source
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: build
- uses: dtolnay/rust-toolchain@nightly
- name: Get LLVM commit hash
id: llvm-commit
run: echo "HEAD=$(git -C src/llvm-project rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Cache LLVM
id: cache-llvm
uses: actions/cache@v4
with:
path: build/build/x86_64-unknown-linux-gnu/llvm
key: ${{ matrix.os }}-llvm-${{ steps.llvm-commit.outputs.HEAD }}
- name: Build
run: |
mkdir build
mkdir -p build
cd build
rm -f config.toml
../configure --enable-llvm-link-shared --enable-llvm-plugins --enable-llvm-enzyme --release-channel=nightly --enable-llvm-assertions --enable-lld --enable-option-checking --enable-ninja --disable-docs
../x.py build --stage 1 library/std library/proc_macro library/test tools/rustdoc
rustup toolchain link enzyme `pwd`/build/`rustup target list --installed`/stage1
rustup toolchain install nightly # enables -Z unstable-options
- name: test
rustup toolchain link enzyme build/host/stage1
- name: checkout Enzyme/rustbook
uses: actions/checkout@v4
with:
repository: EnzymeAD/rustbook
ref: mdbook-test
path: rustbook
- name: test Enzyme/rustbook
working-directory: rustbook
run: |
cargo +enzyme test --examples
cargo +enzyme test --workspace
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Afterwards you can build rustc using:

Afterwards rustc toolchain link will allow you to use it through cargo:
```
rustup toolchain link enzyme `pwd`/build/`rustup target list --installed`/stage1
rustup toolchain link enzyme build/host/stage1
rustup toolchain install nightly # enables -Z unstable-options
```

Expand Down
28 changes: 25 additions & 3 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,13 +844,34 @@ impl Step for Enzyme {

let LlvmResult { llvm_config, llvm_cmake_dir } = builder.ensure(Llvm { target });

static STAMP_HASH_MEMO: OnceLock<String> = OnceLock::new();
let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| {
generate_smart_stamp_hash(
&builder.config.src.join("src/tools/enzyme"),
&builder.enzyme_info.sha().unwrap_or_default(),
)
});

let out_dir = builder.enzyme_out(target);
let done_stamp = out_dir.join("enzyme-finished-building");
if done_stamp.exists() {
let stamp = out_dir.join("enzyme-finished-building");
let stamp = HashStamp::new(stamp, Some(smart_stamp_hash));

if stamp.is_done() {
if stamp.hash.is_none() {
builder.info(
"Could not determine the Enzyme submodule commit hash. \
Assuming that an Enzyme rebuild is not necessary.",
);
builder.info(&format!(
"To force Enzyme to rebuild, remove the file `{}`",
stamp.path.display()
));
}
return out_dir;
}

builder.info(&format!("Building Enzyme for {}", target));
t!(stamp.remove());
let _time = helpers::timeit(&builder);
t!(fs::create_dir_all(&out_dir));

Expand Down Expand Up @@ -878,7 +899,8 @@ impl Step for Enzyme {

cfg.build();

t!(File::create(&done_stamp));
t!(stamp.write());

out_dir
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ pub struct Build {
clippy_info: GitInfo,
miri_info: GitInfo,
rustfmt_info: GitInfo,
enzyme_info: GitInfo,
in_tree_llvm_info: GitInfo,
local_rebuild: bool,
fail_fast: bool,
Expand Down Expand Up @@ -331,6 +332,7 @@ impl Build {
let clippy_info = GitInfo::new(omit_git_hash, &src.join("src/tools/clippy"));
let miri_info = GitInfo::new(omit_git_hash, &src.join("src/tools/miri"));
let rustfmt_info = GitInfo::new(omit_git_hash, &src.join("src/tools/rustfmt"));
let enzyme_info = GitInfo::new(omit_git_hash, &src.join("src/tools/enzyme"));

// we always try to use git for LLVM builds
let in_tree_llvm_info = GitInfo::new(false, &src.join("src/llvm-project"));
Expand Down Expand Up @@ -413,6 +415,7 @@ impl Build {
clippy_info,
miri_info,
rustfmt_info,
enzyme_info,
in_tree_llvm_info,
cc: RefCell::new(HashMap::new()),
cxx: RefCell::new(HashMap::new()),
Expand Down
Loading