aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2026-02-04 08:59:23 +0000
committerGitHub <noreply@github.com>2026-02-04 08:59:23 +0000
commit61f3d45fa7cf3993a42ad122d450f5629d704720 (patch)
tree7b8783d43193c16e4ef393a175fede50a8fe52dd /src/llvm_backend.cpp
parent270df36468df8f89e1ac944205272469142c7a65 (diff)
parentb8276065f9296754d1e76e25d6661b7b5567e3e1 (diff)
Merge pull request #6227 from JesseRMeyer/lto-support
Fix LTO on Windows
Diffstat (limited to 'src/llvm_backend.cpp')
-rw-r--r--src/llvm_backend.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp
index 43f6f8f03..931813f42 100644
--- a/src/llvm_backend.cpp
+++ b/src/llvm_backend.cpp
@@ -2454,14 +2454,21 @@ gb_internal WORKER_TASK_PROC(lb_llvm_module_pass_worker_proc) {
// tsan - Linux, Darwin
// ubsan - Linux, Darwin, Windows (NOT SUPPORTED WITH LLVM C-API)
- if (build_context.sanitizer_flags & SanitizerFlag_Address) {
- array_add(&passes, "asan");
- }
- if (build_context.sanitizer_flags & SanitizerFlag_Memory) {
- array_add(&passes, "msan");
- }
- if (build_context.sanitizer_flags & SanitizerFlag_Thread) {
- array_add(&passes, "tsan");
+ // With LTO, sanitizer passes run at link time (via -fsanitize= linker flags)
+ // where the linker has whole-program visibility. Running them here too would
+ // double-instrument every module, producing "Redundant instrumentation" warnings.
+ // Per-function sanitize attributes in the bitcode are preserved and respected
+ // by the linker's sanitizer pass.
+ if (build_context.lto_kind == LTO_None) {
+ if (build_context.sanitizer_flags & SanitizerFlag_Address) {
+ array_add(&passes, "asan");
+ }
+ if (build_context.sanitizer_flags & SanitizerFlag_Memory) {
+ array_add(&passes, "msan");
+ }
+ if (build_context.sanitizer_flags & SanitizerFlag_Thread) {
+ array_add(&passes, "tsan");
+ }
}
if (passes.count == 0) {