[PATCH] D54805: [Driver] Use --push/pop-state with Sanitizer link deps

Petr Hosek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 21 12:36:00 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC347413: [Driver] Use --push/pop-state with Sanitizer link deps (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54805?vs=174952&id=174966#toc

Repository:
  rC Clang

https://reviews.llvm.org/D54805

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===================================================================
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -220,6 +220,20 @@
 // CHECK-ASAN-MYRIAD-NOT: "-lc"
 // CHECK-ASAN-MYRIAD: libclang_rt.asan-sparcel.a"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -static \
+// RUN:     -resource-dir=%S/Inputs/resource_dir \
+// RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-STATIC %s
+//
+// CHECK-ASAN-LINUX-STATIC: "--push-state"
+// CHECK-ASAN-LINUX-STATIC: "--no-as-needed"
+// CHECK-ASAN-LINUX-STATIC: "-lpthread"
+// CHECK-ASAN-LINUX-STATIC: "-lrt"
+// CHECK-ASAN-LINUX-STATIC: "-lm"
+// CHECK-ASAN-LINUX-STATIC: "-ldl"
+// CHECK-ASAN-LINUX-STATIC: "--pop-state"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
 // RUN:     -fsanitize=thread \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -598,6 +598,7 @@
                                      ArgStringList &CmdArgs) {
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
+  CmdArgs.push_back("--push-state");
   CmdArgs.push_back("--no-as-needed");
   // There's no libpthread or librt on RTEMS & Android.
   if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
@@ -617,6 +618,7 @@
   if (TC.getTriple().getOS() == llvm::Triple::NetBSD ||
       TC.getTriple().getOS() == llvm::Triple::FreeBSD)
     CmdArgs.push_back("-lexecinfo");
+  CmdArgs.push_back("--pop-state");
 }
 
 static void


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54805.174966.patch
Type: text/x-patch
Size: 1858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181121/046beef4/attachment-0001.bin>


More information about the cfe-commits mailing list