about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManuel Drehwald <git@manuel.drehwald.info>2025-02-07 01:58:48 -0500
committerManuel Drehwald <git@manuel.drehwald.info>2025-02-07 01:58:48 -0500
commit8f87e8095e3f1ebb73ec738ddd26885fdbb75e37 (patch)
tree3db07e56494b8e7ef2c2423beda8d8adf3d778bf
parent70b9ba3d6e1d64e6b00da707e5b1b5127e63b1cf (diff)
downloadrust-8f87e8095e3f1ebb73ec738ddd26885fdbb75e37.tar.gz
rust-8f87e8095e3f1ebb73ec738ddd26885fdbb75e37.zip
get tests to work without -Z/-C flags
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp10
-rw-r--r--src/bootstrap/src/core/build_steps/compile.rs6
2 files changed, 13 insertions, 3 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
index 6447a9362b3..0063f262c9b 100644
--- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
@@ -688,6 +688,8 @@ struct LLVMRustSanitizerOptions {
   bool SanitizeKernelAddressRecover;
 };
 
+extern "C" void registerEnzyme(llvm::PassBuilder &PB);
+
 extern "C" LLVMRustResult LLVMRustOptimize(
     LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef,
     LLVMRustPassBuilderOptLevel OptLevelRust, LLVMRustOptStage OptStage,
@@ -1010,6 +1012,14 @@ extern "C" LLVMRustResult LLVMRustOptimize(
     MPM.addPass(NameAnonGlobalPass());
   }
 
+  // now load "-enzyme" pass:
+  registerEnzyme(PB);
+  if (auto Err = PB.parsePassPipeline(MPM, "enzyme")) {
+    std::string ErrMsg = toString(std::move(Err));
+    LLVMRustSetLastError(ErrMsg.c_str());
+    return LLVMRustResult::Failure;
+  }
+
   // Upgrade all calls to old intrinsics first.
   for (Module::iterator I = TheModule->begin(), E = TheModule->end(); I != E;)
     UpgradeCallsToIntrinsic(&*I++); // must be post-increment, as we remove
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index f447d186a52..4e360e94fd6 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -1052,9 +1052,9 @@ pub fn rustc_cargo(
     // We temporarily disable linking here as part of some refactoring.
     // This way, people can manually use -Z llvm-plugins and -C passes=enzyme for now.
     // In a follow-up PR, we will re-enable linking here and load the pass for them.
-    //if builder.config.llvm_enzyme {
-    //    cargo.rustflag("-l").rustflag("Enzyme-19");
-    //}
+    if builder.config.llvm_enzyme {
+        cargo.rustflag("-l").rustflag("Enzyme-19");
+    }
 
     // Building with protected visibility reduces the number of dynamic relocations needed, giving
     // us a faster startup time. However GNU ld < 2.40 will error if we try to link a shared object