Skip to content

Commit 1573cc1

Browse files
committed
Auto merge of #140064 - EnzymeAD:enable-autodiff-in-ci, r=<try>
[DO NOT MERGE] start building Enzyme in CI My goal is to put this in CI on April 26, to have a week to land some of the outstanding PRs (removed # in front of it to avoid spamming them every time I do a try build in this PR): 139700 [Landed] 139308 [Landed] 140104 [Landed] 140030 [Landed] 140049 [Almost ready] 140244 [Closed due to design changes] 140697[WIP] The autodiff flags PR should land first, but otherwise they don't overlap and are mostly ready, so it shouldn't be too hard to land them. In the meantime, I'll experiment here with some builders. There are some related CMake PRs which I also made in the Enzyme repo. I can temporarily merge them into the r-l/Enzyme fork, so we are not blocked on them. A fix for 140137 (Apple CI) would be nice, but I'm also happy to start with the working linux (x86-64 + aarch) as the most common target, and expand from there. r? `@oli-obk` Tracking: - 124509 **Linux** succeeded try with plugins and without plugins & with llvm-enzyme enabled: dist-x86_64-linux succeeded try with plugins and without plugins & with llvm-enzyme enabled: dist-aarch64-linux **MacOS** failed try with plugins & llvm-enzyme enabled: dist-x86_64-apple (#140064 (comment)) failed try with plugins & llvm-enzyme enabled: dist-apple-various (#140064 (comment)) failed try with plugins & llvm-enzyme enabled: dist-aarch64-apple (#140064 (comment)) **Windows** failed try with plugins & llvm-enzyme enabled: dist-x86_64-mingw (#140064 (comment)) try-job: dist-aarch64-apple
2 parents 2805e1d + bc1210b commit 1573cc1

File tree

13 files changed

+25
-117
lines changed

13 files changed

+25
-117
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,8 @@ pub fn rustc_cargo(
11871187
// functionality from Enzyme core. For that we need to link against Enzyme.
11881188
if builder.config.llvm_enzyme {
11891189
let arch = builder.build.build;
1190-
let enzyme_dir = builder.build.out.join(arch).join("enzyme").join("lib");
1191-
cargo.rustflag("-L").rustflag(enzyme_dir.to_str().expect("Invalid path"));
1190+
let _enzyme_dir = builder.build.out.join(arch).join("enzyme").join("lib");
1191+
//cargo.rustflag("-L").rustflag(enzyme_dir.to_str().expect("Invalid path"));
11921192

11931193
if let Some(llvm_config) = builder.llvm_config(builder.config.build) {
11941194
let llvm_version_major = llvm::get_llvm_version_major(builder, &llvm_config);
@@ -2068,7 +2068,7 @@ impl Step for Assemble {
20682068
let enzyme_install = builder.ensure(llvm::Enzyme { target: build_compiler.host });
20692069
let llvm_config = builder.llvm_config(builder.config.build).unwrap();
20702070
let llvm_version_major = llvm::get_llvm_version_major(builder, &llvm_config);
2071-
let lib_ext = std::env::consts::DLL_EXTENSION;
2071+
let lib_ext = "so";
20722072
let libenzyme = format!("libEnzyme-{llvm_version_major}");
20732073
let src_lib =
20742074
enzyme_install.join("build/Enzyme").join(&libenzyme).with_extension(lib_ext);
@@ -2079,6 +2079,12 @@ impl Step for Assemble {
20792079
let target_dst_lib = target_libdir.join(&libenzyme).with_extension(lib_ext);
20802080
builder.copy_link(&src_lib, &dst_lib, FileType::NativeLibrary);
20812081
builder.copy_link(&src_lib, &target_dst_lib, FileType::NativeLibrary);
2082+
//add_to_sysroot(
2083+
// builder,
2084+
// &src_lib,
2085+
// &target_dst_lib,
2086+
// &build_stamp::librustc_stamp(builder, build_compiler, target_compiler.host),
2087+
//);
20822088
}
20832089

20842090
// Build the libraries for this compiler to link to (i.e., the libraries

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,8 @@ impl Step for Enzyme {
970970
.env("LLVM_CONFIG_REAL", &llvm_config)
971971
.define("LLVM_ENABLE_ASSERTIONS", "ON")
972972
.define("ENZYME_EXTERNAL_SHARED_LIB", "ON")
973-
.define("LLVM_DIR", builder.llvm_out(target));
973+
.define("ENZYME_STATIC_LIB", "ON")
974+
.define("LLVM_DIR", builder.llvm_out(target).join("build"));
974975

975976
cfg.build();
976977

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,9 +993,15 @@ impl Builder<'_> {
993993
let llvm_libdir =
994994
command(llvm_config).arg("--libdir").run_capture_stdout(self).stdout();
995995
if target.is_msvc() {
996+
// FIXME(autodiff): Enzyme does currently not support MSVC.
996997
rustflags.arg(&format!("-Clink-arg=-LIBPATH:{llvm_libdir}"));
997998
} else {
998999
rustflags.arg(&format!("-Clink-arg=-L{llvm_libdir}"));
1000+
if self.config.llvm_enzyme {
1001+
let arch = self.build.build;
1002+
let enzyme_dir = self.build.out.join(arch).join("enzyme").join("lib");
1003+
rustflags.arg(&format!("-Clink-arg=-L{}", enzyme_dir.display()));
1004+
}
9991005
}
10001006
}
10011007
}

src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ ENV RUST_CONFIGURE_ARGS \
8989
--set llvm.thin-lto=true \
9090
--set llvm.libzstd=true \
9191
--set llvm.ninja=false \
92+
--set llvm.enzyme=true \
9293
--set rust.debug-assertions=false \
9394
--set rust.jemalloc \
9495
--set rust.use-lld=true \

src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ ENV RUST_CONFIGURE_ARGS \
9090
--set target.x86_64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib \
9191
--set llvm.thin-lto=true \
9292
--set llvm.ninja=false \
93+
--set llvm.enzyme=true \
9394
--set llvm.libzstd=true \
9495
--set rust.jemalloc \
9596
--set rust.use-lld=true \

src/ci/docker/host-x86_64/x86_64-gnu/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ ENV RUST_CONFIGURE_ARGS \
3030
--enable-profiler \
3131
--enable-compiler-docs \
3232
--set llvm.libzstd=true
33+
--set llvm.enzyme=true \
3334
ENV SCRIPT python3 ../x.py --stage 2 test

src/ci/github-actions/jobs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ auto:
391391
- name: dist-x86_64-apple
392392
env:
393393
SCRIPT: ./x.py dist bootstrap --include-default-paths --host=x86_64-apple-darwin --target=x86_64-apple-darwin
394-
RUST_CONFIGURE_ARGS: --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set rust.lto=thin --set rust.codegen-units=1
394+
RUST_CONFIGURE_ARGS: --enable-full-tools --enable-sanitizers --enable-profiler --set llvm.enzyme=true --set rust.jemalloc --set rust.lto=thin --set rust.codegen-units=1
395395
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
396396
# Ensure that host tooling is built to support our minimum support macOS version.
397397
MACOSX_DEPLOYMENT_TARGET: 10.12
@@ -409,7 +409,7 @@ auto:
409409
SCRIPT: ./x.py dist bootstrap --include-default-paths --host='' --target=aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim,aarch64-apple-ios-macabi,x86_64-apple-ios-macabi
410410
# Mac Catalyst cannot currently compile the sanitizer:
411411
# https://github.com/rust-lang/rust/issues/129069
412-
RUST_CONFIGURE_ARGS: --enable-sanitizers --enable-profiler --set rust.jemalloc --set target.aarch64-apple-ios-macabi.sanitizers=false --set target.x86_64-apple-ios-macabi.sanitizers=false
412+
RUST_CONFIGURE_ARGS: --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.enzyme=true --set target.aarch64-apple-ios-macabi.sanitizers=false --set target.x86_64-apple-ios-macabi.sanitizers=false
413413
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
414414
# Ensure that host tooling is built to support our minimum support macOS version.
415415
# FIXME(madsmtm): This might be redundant, as we're not building host tooling here (?)
@@ -441,6 +441,7 @@ auto:
441441
--enable-profiler
442442
--set rust.jemalloc
443443
--set llvm.ninja=false
444+
--set llvm.enzyme=true
444445
--set rust.lto=thin
445446
--set rust.codegen-units=1
446447
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
@@ -627,6 +628,7 @@ auto:
627628
SCRIPT: python x.py dist bootstrap --include-default-paths
628629
RUST_CONFIGURE_ARGS: >-
629630
--build=x86_64-pc-windows-gnu
631+
--set llvm.enzyme=true
630632
--enable-full-tools
631633
DIST_REQUIRE_ALL_TOOLS: 1
632634
CODEGEN_BACKENDS: llvm,cranelift

src/tools/enzyme

Submodule enzyme updated 128 files

tests/ui/autodiff/visibility.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/ui/autodiff/visibility.std_autodiff.stderr

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/ui/feature-gates/feature-gate-autodiff-use.has_support.stderr

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/ui/feature-gates/feature-gate-autodiff-use.no_support.stderr

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/ui/feature-gates/feature-gate-autodiff-use.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)