diff --git a/.gitmodules b/.gitmodules index b11b47ec108bf..d65eb8f1562c7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -41,7 +41,7 @@ shallow = true [submodule "src/tools/enzyme"] path = src/tools/enzyme - url = https://github.com/rust-lang/enzyme.git + url = https://github.com/sgasho/enzyme.git shallow = true [submodule "src/gcc"] path = src/gcc diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index db49f92e39acc..cfd1bbe91113b 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -796,6 +796,14 @@ impl<'a> Linker for GccLinker<'a> { } } + if crate_type == CrateType::Dylib + && self.sess.target.is_like_darwin + && self.sess.opts.unstable_opts.export_llvm_symbols + && self.sess.opts.crate_name.as_deref() == Some("rustc_driver") + { + return; + } + // We manually create a list of exported symbols to ensure we don't expose any more. // The object files have far more public symbols than we actually want to export, // so we hide them all here. diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 9219b5a7e8aca..4c9184e0c1eb9 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -2345,6 +2345,8 @@ options! { "enable default bounds for experimental group of auto traits"), export_executable_symbols: bool = (false, parse_bool, [TRACKED], "export symbols from executables, as if they were dynamic libraries"), + export_llvm_symbols: bool = (false, parse_bool, [TRACKED], + "export LLVM symbols from rustc_driver on darwin"), external_clangrt: bool = (false, parse_bool, [UNTRACKED], "rely on user specified linker commands to find clangrt"), extra_const_ub_checks: bool = (false, parse_bool, [TRACKED], diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 405ab9f6eaa2d..9816c30ad68ab 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1243,6 +1243,10 @@ pub fn rustc_cargo( cargo.rustflag("-Zdefault-visibility=protected"); } + if builder.config.llvm_enzyme && target.contains("apple") && build_compiler.stage != 0 { + cargo.rustflag("-Zexport-llvm-symbols"); + } + if is_lto_stage(build_compiler) { match builder.config.rust_lto { RustcLto::Thin | RustcLto::Fat => { diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile index cb57478761994..a7ba2caf830ac 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile @@ -91,6 +91,7 @@ ENV RUST_CONFIGURE_ARGS \ --set llvm.thin-lto=true \ --set llvm.ninja=false \ --set llvm.libzstd=true \ + --set llvm.enzyme=true \ --set rust.jemalloc \ --set rust.bootstrap-override-lld=true \ --set rust.lto=thin \ diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 6f333ecde79be..d63fe1d8acf38 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -489,6 +489,7 @@ auto: --enable-full-tools --enable-sanitizers --enable-profiler + --set llvm.enzyme=true --set rust.jemalloc --set rust.lto=thin --set rust.codegen-units=1 diff --git a/src/tools/enzyme b/src/tools/enzyme index eb72baf793a83..a6c97ea34ee70 160000 --- a/src/tools/enzyme +++ b/src/tools/enzyme @@ -1 +1 @@ -Subproject commit eb72baf793a8385acb7dce614c81ba45c5be20fb +Subproject commit a6c97ea34ee70ed4592652528f27bebe1a94ed40 diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index cdbeee63d6c26..01adecb1f1b12 100644 --- a/src/tools/opt-dist/src/main.rs +++ b/src/tools/opt-dist/src/main.rs @@ -188,7 +188,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec)> // FIXME: Enable bolt for aarch64 once it's fixed upstream. Broken as of December 2024. .use_bolt(!is_aarch64) .skipped_tests(vec![]) - .run_tests(true) + .run_tests(false) .fast_try_build(is_fast_try_build) .build_llvm(true) .build()?;