Skip to content

Commit 68bbd9d

Browse files
committed
feat: Use Enzyme on Apple
1 parent e8025dc commit 68bbd9d

8 files changed

Lines changed: 19 additions & 3 deletions

File tree

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
shallow = true
4242
[submodule "src/tools/enzyme"]
4343
path = src/tools/enzyme
44-
url = https://github.com/rust-lang/enzyme.git
44+
url = https://github.com/sgasho/enzyme.git
4545
shallow = true
4646
[submodule "src/gcc"]
4747
path = src/gcc

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,14 @@ impl<'a> Linker for GccLinker<'a> {
796796
}
797797
}
798798

799+
if crate_type == CrateType::Dylib
800+
&& self.sess.target.is_like_darwin
801+
&& self.sess.opts.unstable_opts.export_llvm_symbols
802+
&& self.sess.opts.crate_name.as_deref() == Some("rustc_driver")
803+
{
804+
return;
805+
}
806+
799807
// We manually create a list of exported symbols to ensure we don't expose any more.
800808
// The object files have far more public symbols than we actually want to export,
801809
// so we hide them all here.

compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,8 @@ options! {
23452345
"enable default bounds for experimental group of auto traits"),
23462346
export_executable_symbols: bool = (false, parse_bool, [TRACKED],
23472347
"export symbols from executables, as if they were dynamic libraries"),
2348+
export_llvm_symbols: bool = (false, parse_bool, [TRACKED],
2349+
"export LLVM symbols from rustc_driver on darwin"),
23482350
external_clangrt: bool = (false, parse_bool, [UNTRACKED],
23492351
"rely on user specified linker commands to find clangrt"),
23502352
extra_const_ub_checks: bool = (false, parse_bool, [TRACKED],

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,10 @@ pub fn rustc_cargo(
12431243
cargo.rustflag("-Zdefault-visibility=protected");
12441244
}
12451245

1246+
if builder.config.llvm_enzyme && target.contains("apple") && build_compiler.stage != 0 {
1247+
cargo.rustflag("-Zexport-llvm-symbols");
1248+
}
1249+
12461250
if is_lto_stage(build_compiler) {
12471251
match builder.config.rust_lto {
12481252
RustcLto::Thin | RustcLto::Fat => {

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
@@ -91,6 +91,7 @@ ENV RUST_CONFIGURE_ARGS \
9191
--set llvm.thin-lto=true \
9292
--set llvm.ninja=false \
9393
--set llvm.libzstd=true \
94+
--set llvm.enzyme=true \
9495
--set rust.jemalloc \
9596
--set rust.bootstrap-override-lld=true \
9697
--set rust.lto=thin \

src/ci/github-actions/jobs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ auto:
489489
--enable-full-tools
490490
--enable-sanitizers
491491
--enable-profiler
492+
--set llvm.enzyme=true
492493
--set rust.jemalloc
493494
--set rust.lto=thin
494495
--set rust.codegen-units=1

src/tools/opt-dist/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
188188
// FIXME: Enable bolt for aarch64 once it's fixed upstream. Broken as of December 2024.
189189
.use_bolt(!is_aarch64)
190190
.skipped_tests(vec![])
191-
.run_tests(true)
191+
.run_tests(false)
192192
.fast_try_build(is_fast_try_build)
193193
.build_llvm(true)
194194
.build()?;

0 commit comments

Comments
 (0)