Skip to content

Commit 2804527

Browse files
Merge pull request #7142 from apple/cp/stableabilink
[ASanStableABI][Driver] Stop linking to asan dylib when stable abi is…
2 parents d341379 + 09d6a51 commit 2804527

File tree

6 files changed

+13
-7
lines changed

6 files changed

+13
-7
lines changed

clang/include/clang/Driver/SanitizerArgs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class SanitizerArgs {
7474
bool DiagnoseErrors = true);
7575

7676
bool needsSharedRt() const { return SharedRuntime; }
77+
bool needsStableAbi() const { return StableABI; }
7778

7879
bool needsMemProfRt() const { return NeedsMemProfRt; }
7980
bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,8 +1619,13 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
16191619
}
16201620

16211621
if (Sanitize.linkRuntimes()) {
1622-
if (Sanitize.needsAsanRt())
1623-
AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
1622+
if (Sanitize.needsAsanRt()) {
1623+
if (Sanitize.needsStableAbi()) {
1624+
AddLinkSanitizerLibArgs(Args, CmdArgs, "asan_abi", /*shared=*/false);
1625+
} else {
1626+
AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
1627+
}
1628+
}
16241629
if (Sanitize.needsLsanRt())
16251630
AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
16261631
if (Sanitize.needsUbsanRt()) {

compiler-rt/test/asan_abi/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ set(ASAN_ABI_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
1313
if(NOT COMPILER_RT_STANDALONE_BUILD)
1414
list(APPEND ASAN_ABI_TEST_DEPS asan_abi)
1515
endif()
16-
set(ASAN_ABI_DYNAMIC_TEST_DEPS ${ASAN_ABI_TEST_DEPS})
1716

1817
set(ASAN_ABI_TEST_ARCH ${ASAN_ABI_SUPPORTED_ARCH})
1918
if(APPLE)
@@ -27,7 +26,6 @@ foreach(arch ${ASAN_ABI_TEST_ARCH})
2726
string(TOLOWER "-${arch}-${OS_NAME}" ASAN_ABI_TEST_CONFIG_SUFFIX)
2827
get_bits_for_arch(${arch} ASAN_ABI_TEST_BITS)
2928
get_test_cc_for_arch(${arch} ASAN_ABI_TEST_TARGET_CC ASAN_ABI_TEST_TARGET_CFLAGS)
30-
set(ASAN_ABI_TEST_DYNAMIC True)
3129

3230
string(TOUPPER ${arch} ARCH_UPPER_CASE)
3331
set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)

compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_asan_abi -O0 -c -fsanitize-stable-abi -fsanitize=address %s -o %t.o
22
// RUN: %clangxx -c %p/../../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o
3-
// RUN: %clangxx -dead_strip -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1
3+
// RUN: %clangxx -dead_strip -o %t %t.o -fsanitize-stable-abi -fsanitize=address asan_abi.o && %run %t 2>&1
44
// RUN: %clangxx -x c++-header -o - -E %p/../../../../lib/asan/asan_interface.inc \
55
// RUN: | sed "s/INTERFACE_FUNCTION/\nINTERFACE_FUNCTION/g" > %t.asan_interface.inc
66
// RUN: llvm-nm -g %libasan_abi \
@@ -22,6 +22,9 @@
2222
// RUN: sort %t.exports | uniq > %t.exports-sorted
2323
// RUN: diff %t.imports-sorted %t.exports-sorted
2424

25+
// Ensure that there is no dynamic dylib linked.
26+
// RUN: otool -L %t | (! grep -q "dynamic.dylib")
27+
2528
// UNSUPPORTED: ios
2629

2730
int main() { return 0; }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clang_asan_abi -O2 -c -fsanitize-stable-abi -fsanitize=address -O0 %s -o %t.o
22
// RUN: %clangxx -c %p/../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o
3-
// RUN: %clangxx -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1
3+
// RUN: %clangxx -o %t %t.o -fsanitize-stable-abi -fsanitize=address asan_abi.o && %run %t 2>&1
44

55
int main() { return 0; }

compiler-rt/test/asan_abi/lit.site.cfg.py.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ config.bits = "@ASAN_ABI_TEST_BITS@"
88
config.arm_thumb = "@COMPILER_RT_ARM_THUMB@"
99
config.apple_platform = "@ASAN_ABI_TEST_APPLE_PLATFORM@"
1010
config.apple_platform_min_deployment_target_flag = "@ASAN_ABI_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
11-
config.asan_abi_dynamic = @ASAN_ABI_TEST_DYNAMIC@
1211
config.target_arch = "@ASAN_ABI_TEST_TARGET_ARCH@"
1312

1413
# Load common config for all compiler-rt lit tests.

0 commit comments

Comments
 (0)