[PATCH] D156718: [ASanStableABI][Driver] Stop linking to asan dylib when stable abi is enabled

2023-08-02 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG11b7ce26f2a2: [ASanStableABI][Driver] Stop linking to asan 
dylib when stable abi is enabled (authored by Blue Gaston 
bgast...@apple.com).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156718/new/

https://reviews.llvm.org/D156718

Files:
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/test/asan_abi/CMakeLists.txt
  compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
  compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
  compiler-rt/test/asan_abi/lit.site.cfg.py.in


Index: compiler-rt/test/asan_abi/lit.site.cfg.py.in
===
--- compiler-rt/test/asan_abi/lit.site.cfg.py.in
+++ compiler-rt/test/asan_abi/lit.site.cfg.py.in
@@ -8,7 +8,6 @@
 config.arm_thumb = "@COMPILER_RT_ARM_THUMB@"
 config.apple_platform = "@ASAN_ABI_TEST_APPLE_PLATFORM@"
 config.apple_platform_min_deployment_target_flag = 
"@ASAN_ABI_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
-config.asan_abi_dynamic = @ASAN_ABI_TEST_DYNAMIC@
 config.target_arch = "@ASAN_ABI_TEST_TARGET_ARCH@"
 
 # Load common config for all compiler-rt lit tests.
Index: compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
===
--- compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
+++ compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_asan_abi  -O2 -c -fsanitize-stable-abi -fsanitize=address -O0 
%s -o %t.o
 // RUN: %clangxx -c %p/../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o
-// RUN: %clangxx -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1
+// RUN: %clangxx -o %t %t.o -fsanitize-stable-abi -fsanitize=address 
asan_abi.o && %run %t 2>&1
 
 int main() { return 0; }
Index: compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
===
--- compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
+++ compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_asan_abi -O0 -c -fsanitize-stable-abi -fsanitize=address %s -o 
%t.o
 // RUN: %clangxx -c %p/../../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o
-// RUN: %clangxx -dead_strip -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1
+// RUN: %clangxx -dead_strip -o %t %t.o -fsanitize-stable-abi 
-fsanitize=address asan_abi.o && %run %t 2>&1
 // RUN: %clangxx -x c++-header -o - -E 
%p/../../../../lib/asan/asan_interface.inc \
 // RUN: | sed "s/INTERFACE_FUNCTION/\nINTERFACE_FUNCTION/g" > 
%t.asan_interface.inc
 // RUN: llvm-nm -g %libasan_abi   \
@@ -22,6 +22,9 @@
 // RUN: sort %t.exports | uniq > %t.exports-sorted
 // RUN: diff %t.imports-sorted %t.exports-sorted
 
+// Ensure that there is no dynamic dylib linked.
+// RUN: otool -L %t | (! grep -q "dynamic.dylib")
+
 // UNSUPPORTED: ios
 
 int main() { return 0; }
Index: compiler-rt/test/asan_abi/CMakeLists.txt
===
--- compiler-rt/test/asan_abi/CMakeLists.txt
+++ compiler-rt/test/asan_abi/CMakeLists.txt
@@ -13,7 +13,6 @@
 if(NOT COMPILER_RT_STANDALONE_BUILD)
   list(APPEND ASAN_ABI_TEST_DEPS asan_abi)
 endif()
-set(ASAN_ABI_DYNAMIC_TEST_DEPS ${ASAN_ABI_TEST_DEPS})
 
 set(ASAN_ABI_TEST_ARCH ${ASAN_ABI_SUPPORTED_ARCH})
 if(APPLE)
@@ -27,7 +26,6 @@
   string(TOLOWER "-${arch}-${OS_NAME}" ASAN_ABI_TEST_CONFIG_SUFFIX)
   get_bits_for_arch(${arch} ASAN_ABI_TEST_BITS)
   get_test_cc_for_arch(${arch} ASAN_ABI_TEST_TARGET_CC 
ASAN_ABI_TEST_TARGET_CFLAGS)
-  set(ASAN_ABI_TEST_DYNAMIC True)
 
   string(TOUPPER ${arch} ARCH_UPPER_CASE)
   set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1484,9 +1484,13 @@
 
   if (Sanitize.linkRuntimes()) {
 if (Sanitize.needsAsanRt()) {
-  assert(Sanitize.needsSharedRt() &&
- "Static sanitizer runtimes not supported");
-  AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  if (Sanitize.needsStableAbi()) {
+AddLinkSanitizerLibArgs(Args, CmdArgs, "asan_abi", /*shared=*/false);
+  } else {
+assert(Sanitize.needsSharedRt() &&
+   "Static sanitizer runtimes not supported");
+AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  }
 }
 if (Sanitize.needsLsanRt())
   AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
Index: clang/include/clang/Driver/SanitizerArgs.h
===
--- clang/include/clang/Driver/SanitizerArgs.h
+++ clang/include/clang/Driver/SanitizerArgs.h
@@ -76,6 +76,7 @@
 bool 

[PATCH] D156718: [ASanStableABI][Driver] Stop linking to asan dylib when stable abi is enabled

2023-08-01 Thread Mariusz Borsa via Phabricator via cfe-commits
wrotki accepted this revision.
wrotki added a comment.

Yes, it looks good. I downloaded the patch and ran the test - had some doubts 
about 'otool -L %t |grep -q "dynamic.dylib"' - but verified with other ASAN 
tests binaries  and convinced myself that it's the right thing to do.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156718/new/

https://reviews.llvm.org/D156718

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156718: [ASanStableABI][Driver] Stop linking to asan dylib when stable abi is enabled

2023-08-01 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl accepted this revision.
rsundahl added a comment.
This revision is now accepted and ready to land.

This looks good to me. Thanks for the additional clean-up @thetruestblue.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156718/new/

https://reviews.llvm.org/D156718

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156718: [ASanStableABI][Driver] Stop linking to asan dylib when stable abi is enabled

2023-08-01 Thread Brittany Blue Gaston via Phabricator via cfe-commits
thetruestblue updated this revision to Diff 546199.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156718/new/

https://reviews.llvm.org/D156718

Files:
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/test/asan_abi/CMakeLists.txt
  compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
  compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
  compiler-rt/test/asan_abi/lit.site.cfg.py.in


Index: compiler-rt/test/asan_abi/lit.site.cfg.py.in
===
--- compiler-rt/test/asan_abi/lit.site.cfg.py.in
+++ compiler-rt/test/asan_abi/lit.site.cfg.py.in
@@ -8,7 +8,6 @@
 config.arm_thumb = "@COMPILER_RT_ARM_THUMB@"
 config.apple_platform = "@ASAN_ABI_TEST_APPLE_PLATFORM@"
 config.apple_platform_min_deployment_target_flag = 
"@ASAN_ABI_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
-config.asan_abi_dynamic = @ASAN_ABI_TEST_DYNAMIC@
 config.target_arch = "@ASAN_ABI_TEST_TARGET_ARCH@"
 
 # Load common config for all compiler-rt lit tests.
Index: compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
===
--- compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
+++ compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_asan_abi  -O2 -c -fsanitize-stable-abi -fsanitize=address -O0 
%s -o %t.o
 // RUN: %clangxx -c %p/../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o
-// RUN: %clangxx -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1
+// RUN: %clangxx -o %t %t.o -fsanitize-stable-abi -fsanitize=address 
asan_abi.o && %run %t 2>&1
 
 int main() { return 0; }
Index: compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
===
--- compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
+++ compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_asan_abi -O0 -c -fsanitize-stable-abi -fsanitize=address %s -o 
%t.o
 // RUN: %clangxx -c %p/../../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o
-// RUN: %clangxx -dead_strip -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1
+// RUN: %clangxx -dead_strip -o %t %t.o -fsanitize-stable-abi 
-fsanitize=address asan_abi.o && %run %t 2>&1
 // RUN: %clangxx -x c++-header -o - -E 
%p/../../../../lib/asan/asan_interface.inc \
 // RUN: | sed "s/INTERFACE_FUNCTION/\nINTERFACE_FUNCTION/g" > 
%t.asan_interface.inc
 // RUN: llvm-nm -g %libasan_abi   \
@@ -22,6 +22,9 @@
 // RUN: sort %t.exports | uniq > %t.exports-sorted
 // RUN: diff %t.imports-sorted %t.exports-sorted
 
+// Ensure that there is no dynamic dylib linked.
+// RUN: otool -L %t | (! grep -q "dynamic.dylib")
+
 // UNSUPPORTED: ios
 
 int main() { return 0; }
Index: compiler-rt/test/asan_abi/CMakeLists.txt
===
--- compiler-rt/test/asan_abi/CMakeLists.txt
+++ compiler-rt/test/asan_abi/CMakeLists.txt
@@ -13,7 +13,6 @@
 if(NOT COMPILER_RT_STANDALONE_BUILD)
   list(APPEND ASAN_ABI_TEST_DEPS asan_abi)
 endif()
-set(ASAN_ABI_DYNAMIC_TEST_DEPS ${ASAN_ABI_TEST_DEPS})
 
 set(ASAN_ABI_TEST_ARCH ${ASAN_ABI_SUPPORTED_ARCH})
 if(APPLE)
@@ -27,7 +26,6 @@
   string(TOLOWER "-${arch}-${OS_NAME}" ASAN_ABI_TEST_CONFIG_SUFFIX)
   get_bits_for_arch(${arch} ASAN_ABI_TEST_BITS)
   get_test_cc_for_arch(${arch} ASAN_ABI_TEST_TARGET_CC 
ASAN_ABI_TEST_TARGET_CFLAGS)
-  set(ASAN_ABI_TEST_DYNAMIC True)
 
   string(TOUPPER ${arch} ARCH_UPPER_CASE)
   set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1484,9 +1484,13 @@
 
   if (Sanitize.linkRuntimes()) {
 if (Sanitize.needsAsanRt()) {
-  assert(Sanitize.needsSharedRt() &&
- "Static sanitizer runtimes not supported");
-  AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  if (Sanitize.needsStableAbi()) {
+AddLinkSanitizerLibArgs(Args, CmdArgs, "asan_abi", /*shared=*/false);
+  } else {
+assert(Sanitize.needsSharedRt() &&
+   "Static sanitizer runtimes not supported");
+AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  }
 }
 if (Sanitize.needsLsanRt())
   AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
Index: clang/include/clang/Driver/SanitizerArgs.h
===
--- clang/include/clang/Driver/SanitizerArgs.h
+++ clang/include/clang/Driver/SanitizerArgs.h
@@ -76,6 +76,7 @@
 bool DiagnoseErrors = true);
 
   bool needsSharedRt() const { return SharedRuntime; }
+  bool needsStableAbi() const { return StableABI; }
 
   bool needsMemProfRt() const { return NeedsMemProfRt; }
   bool needsAsanRt() const { return 

[PATCH] D156718: [ASanStableABI][Driver] Stop linking to asan dylib when stable abi is enabled

2023-07-31 Thread Brittany Blue Gaston via Phabricator via cfe-commits
thetruestblue created this revision.
thetruestblue added reviewers: yln, rsundahl, usama54321, wrotki, kubamracek, 
vitalybuka, MaskRay.
Herald added a subscriber: Enna1.
Herald added a project: All.
thetruestblue requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

This patch enables linking of the static archive when fsanitize-stable-abi is 
set and stops linking to the asan dylib.

To link to the Address Sanitizer stable abi static library use 
"-fsanitize=address -fsanitize-stable-abi"

Updates a test with these flags.

rdar://112480890


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156718

Files:
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/test/asan_abi/CMakeLists.txt
  compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
  compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp


Index: compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
===
--- compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
+++ compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_asan_abi  -O2 -c -fsanitize-stable-abi -fsanitize=address -O0 
%s -o %t.o
 // RUN: %clangxx -c %p/../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o
-// RUN: %clangxx -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1
+// RUN: %clangxx -o %t %t.o -fsanitize-stable-abi -fsanitize=address 
asan_abi.o && %run %t 2>&1
 
 int main() { return 0; }
Index: compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
===
--- compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
+++ compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_asan_abi -O0 -c -fsanitize-stable-abi -fsanitize=address %s -o 
%t.o
 // RUN: %clangxx -c %p/../../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o
-// RUN: %clangxx -dead_strip -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1
+// RUN: %clangxx -dead_strip -o %t %t.o -fsanitize-stable-abi 
-fsanitize=address asan_abi.o && %run %t 2>&1
 // RUN: %clangxx -x c++-header -o - -E 
%p/../../../../lib/asan/asan_interface.inc \
 // RUN: | sed "s/INTERFACE_FUNCTION/\nINTERFACE_FUNCTION/g" > 
%t.asan_interface.inc
 // RUN: llvm-nm -g %libasan_abi   \
@@ -22,6 +22,9 @@
 // RUN: sort %t.exports | uniq > %t.exports-sorted
 // RUN: diff %t.imports-sorted %t.exports-sorted
 
+// Ensure that there is no dynamic dylib linked.
+// RUN: otool -L %t | (! grep -q "dynamic.dylib")
+
 // UNSUPPORTED: ios
 
 int main() { return 0; }
Index: compiler-rt/test/asan_abi/CMakeLists.txt
===
--- compiler-rt/test/asan_abi/CMakeLists.txt
+++ compiler-rt/test/asan_abi/CMakeLists.txt
@@ -13,7 +13,6 @@
 if(NOT COMPILER_RT_STANDALONE_BUILD)
   list(APPEND ASAN_ABI_TEST_DEPS asan_abi)
 endif()
-set(ASAN_ABI_DYNAMIC_TEST_DEPS ${ASAN_ABI_TEST_DEPS})
 
 set(ASAN_ABI_TEST_ARCH ${ASAN_ABI_SUPPORTED_ARCH})
 if(APPLE)
@@ -27,7 +26,7 @@
   string(TOLOWER "-${arch}-${OS_NAME}" ASAN_ABI_TEST_CONFIG_SUFFIX)
   get_bits_for_arch(${arch} ASAN_ABI_TEST_BITS)
   get_test_cc_for_arch(${arch} ASAN_ABI_TEST_TARGET_CC 
ASAN_ABI_TEST_TARGET_CFLAGS)
-  set(ASAN_ABI_TEST_DYNAMIC True)
+  set(ASAN_ABI_TEST_DYNAMIC False)
 
   string(TOUPPER ${arch} ARCH_UPPER_CASE)
   set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1484,9 +1484,13 @@
 
   if (Sanitize.linkRuntimes()) {
 if (Sanitize.needsAsanRt()) {
-  assert(Sanitize.needsSharedRt() &&
- "Static sanitizer runtimes not supported");
-  AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  if (Sanitize.needsStableAbi()) {
+AddLinkSanitizerLibArgs(Args, CmdArgs, "asan_abi", /*shared=*/false);
+  } else {
+assert(Sanitize.needsSharedRt() &&
+   "Static sanitizer runtimes not supported");
+AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  }
 }
 if (Sanitize.needsLsanRt())
   AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
Index: clang/include/clang/Driver/SanitizerArgs.h
===
--- clang/include/clang/Driver/SanitizerArgs.h
+++ clang/include/clang/Driver/SanitizerArgs.h
@@ -76,6 +76,7 @@
 bool DiagnoseErrors = true);
 
   bool needsSharedRt() const { return SharedRuntime; }
+  bool needsStableAbi() const { return StableABI; }
 
   bool needsMemProfRt() const { return NeedsMemProfRt; }
   bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }


Index: