Skip to content

Commit 6622d2b

Browse files
committed
Work around bug in LLVM 20
1 parent 651c428 commit 6622d2b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_middle::bug;
1616
use rustc_session::Session;
1717
use rustc_session::config::{PrintKind, PrintRequest};
1818
use rustc_target::spec::{
19-
Abi, Arch, Env, MergeFunctions, Os, PanicStrategy, SmallDataThresholdSupport,
19+
Abi, Arch, Env, MergeFunctions, Os, PanicStrategy, SanitizerSet, SmallDataThresholdSupport,
2020
};
2121
use smallvec::{SmallVec, smallvec};
2222

@@ -124,6 +124,16 @@ unsafe fn configure_llvm(sess: &Session) {
124124
add("-stats", false);
125125
}
126126

127+
// KHWASAN: In LLVM versions prior to 21.1.0, the HWAddressSanitizer pass incorrectly
128+
// ignores the pass-specific `CompileKernel` flag and only looks at the global command-line
129+
// flag `-hwasan-kernel`. To work around this, pass `-hwasan-kernel` on the relevant LLVM
130+
// versions.
131+
//
132+
// Fixed by: [HWASan][bugfix] Fix kernel check in ShadowMapping::init (#142226).
133+
if sess.sanitizers().contains(SanitizerSet::KERNELHWADDRESS) && get_version() < (21, 1, 0) {
134+
add("-hwasan-kernel", false);
135+
}
136+
127137
for arg in sess_args {
128138
add(&(*arg), true);
129139
}

0 commit comments

Comments
 (0)