r347413 - [Driver] Use --push/pop-state with Sanitizer link deps
Petr Hosek via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 21 12:33:12 PST 2018
Author: phosek
Date: Wed Nov 21 12:33:12 2018
New Revision: 347413
URL: http://llvm.org/viewvc/llvm-project?rev=347413&view=rev
Log:
[Driver] Use --push/pop-state with Sanitizer link deps
Sanitizer runtime link deps handling passes --no-as-needed because of
PR15823, but it never undoes it and this flag may affect other libraries
that come later on the link line. To avoid this, wrap Sanitizer link
deps in --push/pop-state.
Differential Revision: https://reviews.llvm.org/D54805
Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/sanitizer-ld.c
Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=347413&r1=347412&r2=347413&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Wed Nov 21 12:33:12 2018
@@ -598,6 +598,7 @@ void tools::linkSanitizerRuntimeDeps(con
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 @@ void tools::linkSanitizerRuntimeDeps(con
if (TC.getTriple().getOS() == llvm::Triple::NetBSD ||
TC.getTriple().getOS() == llvm::Triple::FreeBSD)
CmdArgs.push_back("-lexecinfo");
+ CmdArgs.push_back("--pop-state");
}
static void
Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=347413&r1=347412&r2=347413&view=diff
==============================================================================
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Wed Nov 21 12:33:12 2018
@@ -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 \
More information about the cfe-commits
mailing list