Skip to content

Commit 911289a

Browse files
authored
[CompilerRT][ASan] Add new substitutions for tests while using lto to (#78523)
explicitly pass libLTO path. This fixes a failure in swift-ci where libLTO was being picked from the system instead which was an older version and caused issues. rdar://117474861
1 parent cfc9f36 commit 911289a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

compiler-rt/test/asan/TestCases/Darwin/odr-lto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// RUN: %clangxx_asan -DPART=0 -c %s -o %t-1.o -flto -mllvm -asan-use-private-alias
77
// RUN: %clangxx_asan -DPART=1 -c %s -o %t-2.o -flto -mllvm -asan-use-private-alias
8-
// RUN: %clangxx_asan %t-1.o %t-2.o -o %t -flto -mlinker-version=133
8+
// RUN: %clangxx_asan_lto %t-1.o %t-2.o -o %t -flto -mlinker-version=133
99
// RUN: %run %t 2>&1 | FileCheck %s
1010

1111
#include <stdio.h>

compiler-rt/test/asan/lit.cfg.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,24 @@ def get_required_attr(config, attr_name):
101101
config.available_features.add(win_runtime_feature)
102102

103103

104-
def build_invocation(compile_flags):
105-
return " " + " ".join([config.clang] + compile_flags) + " "
104+
def build_invocation(compile_flags, with_lto=False):
105+
lto_flags = []
106+
if with_lto and config.lto_supported:
107+
lto_flags += config.lto_flags
108+
109+
return " " + " ".join([config.clang] + lto_flags + compile_flags) + " "
106110

107111

108112
config.substitutions.append(("%clang ", build_invocation(target_cflags)))
109113
config.substitutions.append(("%clangxx ", build_invocation(target_cxxflags)))
110114
config.substitutions.append(("%clang_asan ", build_invocation(clang_asan_cflags)))
111115
config.substitutions.append(("%clangxx_asan ", build_invocation(clang_asan_cxxflags)))
116+
config.substitutions.append(
117+
("%clang_asan_lto ", build_invocation(clang_asan_cflags, True))
118+
)
119+
config.substitutions.append(
120+
("%clangxx_asan_lto ", build_invocation(clang_asan_cxxflags, True))
121+
)
112122
if config.asan_dynamic:
113123
if config.host_os in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
114124
shared_libasan_path = os.path.join(

0 commit comments

Comments
 (0)