Skip to content

Commit 1d21fd3

Browse files
Rollup merge of #152768 - ZuseZ4:autodiff-in-ci-for-all-os, r=Kobzol
Enable autodiff in ci for all major os *[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152768)* Follow-up attempt to #140064 after moving autodiff to dlopen. It covers Linux (x86_64+aarch64), MacOS (aarch64), Windows (mingw-llvm aarch64+x86_64) The extra build time for Enzyme are 180.27s on our slowest runner (aarch64-apple). The follow-up distribution via rustup probably still needs a small fix, see #151063 (comment) Placing the downloaded libEnzyme artifact on my local linux under `~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib` enables my nightly compiler to run autodiff. r? @Kobzol closes: #140064 closes: #151243 closes: #151063
2 parents 1894a0e + c033de9 commit 1d21fd3

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::core::config::{Config, TargetSelection};
2323
use crate::utils::build_stamp::{BuildStamp, generate_smart_stamp_hash};
2424
use crate::utils::exec::command;
2525
use crate::utils::helpers::{
26-
self, exe, get_clang_cl_resource_dir, t, unhashed_basename, up_to_date,
26+
self, exe, get_clang_cl_resource_dir, libdir, t, unhashed_basename, up_to_date,
2727
};
2828
use crate::{CLang, GitRepo, Kind, trace};
2929

@@ -561,7 +561,6 @@ impl Step for Llvm {
561561
}
562562
};
563563

564-
// FIXME(ZuseZ4): Do we need that for Enzyme too?
565564
// When building LLVM with LLVM_LINK_LLVM_DYLIB for macOS, an unversioned
566565
// libLLVM.dylib will be built. However, llvm-config will still look
567566
// for a versioned path like libLLVM-14.dylib. Manually create a symbolic
@@ -1167,7 +1166,7 @@ impl Step for Enzyme {
11671166
let llvm_version_major = llvm::get_llvm_version_major(builder, &host_llvm_config);
11681167
let lib_ext = std::env::consts::DLL_EXTENSION;
11691168
let libenzyme = format!("libEnzyme-{llvm_version_major}");
1170-
let build_dir = out_dir.join("lib");
1169+
let build_dir = out_dir.join(libdir(target));
11711170
let dylib = build_dir.join(&libenzyme).with_extension(lib_ext);
11721171

11731172
trace!("checking build stamp to see if we need to rebuild enzyme artifacts");
@@ -1205,7 +1204,16 @@ impl Step for Enzyme {
12051204
// hard to spot more relevant issues.
12061205
let mut cflags = CcFlags::default();
12071206
cflags.push_all("-Wno-deprecated");
1208-
configure_cmake(builder, target, &mut cfg, true, LdFlags::default(), cflags, &[]);
1207+
1208+
// Logic copied from `configure_llvm`
1209+
// ThinLTO is only available when building with LLVM, enabling LLD is required.
1210+
// Apple's linker ld64 supports ThinLTO out of the box though, so don't use LLD on Darwin.
1211+
let mut ldflags = LdFlags::default();
1212+
if builder.config.llvm_thin_lto && !target.contains("apple") {
1213+
ldflags.push_all("-fuse-ld=lld");
1214+
}
1215+
1216+
configure_cmake(builder, target, &mut cfg, true, ldflags, cflags, &[]);
12091217

12101218
// Re-use the same flags as llvm to control the level of debug information
12111219
// generated by Enzyme.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ ENV RUST_CONFIGURE_ARGS \
9797

9898
ENV SCRIPT python3 ../x.py build --set rust.debug=true opt-dist && \
9999
./build/$HOSTS/stage1-tools-bin/opt-dist linux-ci -- python3 ../x.py dist \
100-
--host $HOSTS --target $HOSTS --include-default-paths build-manifest bootstrap
100+
--host $HOSTS --target $HOSTS --include-default-paths build-manifest bootstrap enzyme
101101

102102
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=clang
103103
ENV LIBCURL_NO_PKG_CONFIG 1

src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ python3 ../x.py build --set rust.debug=true opt-dist
99
--include-default-paths \
1010
build-manifest \
1111
bootstrap \
12+
enzyme \
1213
rustc_codegen_gcc
1314

1415
# Use GCC for building GCC components, as it seems to behave badly when built with Clang

src/ci/github-actions/jobs.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ auto:
504504
- name: dist-aarch64-apple
505505
env:
506506
SCRIPT: >-
507-
./x.py dist bootstrap
507+
./x.py dist bootstrap enzyme
508508
--include-default-paths
509509
--host=aarch64-apple-darwin
510510
--target=aarch64-apple-darwin
@@ -513,6 +513,7 @@ auto:
513513
--enable-sanitizers
514514
--enable-profiler
515515
--set rust.jemalloc
516+
--set llvm.link-shared=true
516517
--set rust.lto=thin
517518
--set rust.codegen-units=1
518519
# Aarch64 tooling only needs to support macOS 11.0 and up as nothing else
@@ -706,7 +707,7 @@ auto:
706707
# i686 has no dedicated job, build it here because this job is fast
707708
- name: dist-aarch64-llvm-mingw
708709
env:
709-
SCRIPT: python x.py dist bootstrap --include-default-paths
710+
SCRIPT: python x.py dist bootstrap enzyme --include-default-paths
710711
RUST_CONFIGURE_ARGS: >-
711712
--build=aarch64-pc-windows-gnullvm
712713
--target=aarch64-pc-windows-gnullvm,i686-pc-windows-gnullvm
@@ -720,7 +721,7 @@ auto:
720721

721722
- name: dist-x86_64-llvm-mingw
722723
env:
723-
SCRIPT: python x.py dist bootstrap --include-default-paths
724+
SCRIPT: python x.py dist bootstrap enzyme --include-default-paths
724725
RUST_CONFIGURE_ARGS: >-
725726
--build=x86_64-pc-windows-gnullvm
726727
--enable-full-tools

0 commit comments

Comments
 (0)