Skip to content

Commit 8f87e80

Browse files
committed
get tests to work without -Z/-C flags
1 parent 70b9ba3 commit 8f87e80

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Diff for: compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,8 @@ struct LLVMRustSanitizerOptions {
688688
bool SanitizeKernelAddressRecover;
689689
};
690690

691+
extern "C" void registerEnzyme(llvm::PassBuilder &PB);
692+
691693
extern "C" LLVMRustResult LLVMRustOptimize(
692694
LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef,
693695
LLVMRustPassBuilderOptLevel OptLevelRust, LLVMRustOptStage OptStage,
@@ -1010,6 +1012,14 @@ extern "C" LLVMRustResult LLVMRustOptimize(
10101012
MPM.addPass(NameAnonGlobalPass());
10111013
}
10121014

1015+
// now load "-enzyme" pass:
1016+
registerEnzyme(PB);
1017+
if (auto Err = PB.parsePassPipeline(MPM, "enzyme")) {
1018+
std::string ErrMsg = toString(std::move(Err));
1019+
LLVMRustSetLastError(ErrMsg.c_str());
1020+
return LLVMRustResult::Failure;
1021+
}
1022+
10131023
// Upgrade all calls to old intrinsics first.
10141024
for (Module::iterator I = TheModule->begin(), E = TheModule->end(); I != E;)
10151025
UpgradeCallsToIntrinsic(&*I++); // must be post-increment, as we remove

Diff for: src/bootstrap/src/core/build_steps/compile.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1052,9 +1052,9 @@ pub fn rustc_cargo(
10521052
// We temporarily disable linking here as part of some refactoring.
10531053
// This way, people can manually use -Z llvm-plugins and -C passes=enzyme for now.
10541054
// In a follow-up PR, we will re-enable linking here and load the pass for them.
1055-
//if builder.config.llvm_enzyme {
1056-
// cargo.rustflag("-l").rustflag("Enzyme-19");
1057-
//}
1055+
if builder.config.llvm_enzyme {
1056+
cargo.rustflag("-l").rustflag("Enzyme-19");
1057+
}
10581058

10591059
// Building with protected visibility reduces the number of dynamic relocations needed, giving
10601060
// us a faster startup time. However GNU ld < 2.40 will error if we try to link a shared object

0 commit comments

Comments
 (0)