Skip to content

Commit 3f83ff5

Browse files
committed
export LLVM symbol when autodiff is enabled && on apple darwin platform
1 parent 9594f3c commit 3f83ff5

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

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
@@ -2367,6 +2367,8 @@ options! {
23672367
"enable default bounds for experimental group of auto traits"),
23682368
export_executable_symbols: bool = (false, parse_bool, [TRACKED],
23692369
"export symbols from executables, as if they were dynamic libraries"),
2370+
export_llvm_symbols: bool = (false, parse_bool, [TRACKED],
2371+
"export LLVM symbols from rustc_driver on darwin"),
23702372
external_clangrt: bool = (false, parse_bool, [UNTRACKED],
23712373
"rely on user specified linker commands to find clangrt"),
23722374
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
@@ -1261,6 +1261,10 @@ pub fn rustc_cargo(
12611261
cargo.rustflag("-Zdefault-visibility=protected");
12621262
}
12631263

1264+
if builder.config.llvm_enzyme && target.contains("apple") {
1265+
cargo.rustflag("-Zexport-llvm-symbols");
1266+
}
1267+
12641268
if is_lto_stage(build_compiler) {
12651269
match builder.config.rust_lto {
12661270
RustcLto::Thin | RustcLto::Fat => {

src/tools/enzyme

0 commit comments

Comments
 (0)