summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-10-23 00:46:10 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-10-23 00:46:10 +0000
commitecfd5c84ca86f0419d15a2358bb06d6f758ff73b (patch)
treec2fef4d5d40985947ecd7c64940d9b764dcb85c1 /clang/lib
parentf299947bfaef176300de04c50e6dbbda863c2c96 (diff)
downloadbcm5719-llvm-ecfd5c84ca86f0419d15a2358bb06d6f758ff73b.tar.gz
bcm5719-llvm-ecfd5c84ca86f0419d15a2358bb06d6f758ff73b.zip
Revert r218541 - Don't link in sanitizer runtimes if -nostdlib/-nodefaultlibs is provided.
This is a sad thing to do, but all the alternatives look ugly. Looks like there are legitimate cases when users may want to link with sanitizer runtimes *and* -nodefaultlibs (and ensure they provide replacements for system libraries). For example, this happens in libc++ test suite. "-nodefaultlibs" is told to link only the libraries explicitly provided by the user, and providing "-fsanitize=address" is a clear indication of intention to link with ASan runtime. We can't easily introduce analogue of "-print-libgcc-name": linking with sanitizers runtimes is not trivial: some runtimes are split into several archive libraries, which are required to be wrapped in -whole-archive/-no-whole-archive. If "-fsanitize=whatever" and "-nodefaultlibs" are provided, system library dependencies of sanitizer runtimes (-lc/-ldl/-lpthread/-lrt) will *not* be linked, and user would have to link them in manually. Note that this can cause problems, as failing to provide "-lrt" might lead to crashes in runtime during ASan initialization. But looks like we should bite this bullet. See r218541 review thread for the discussion. llvm-svn: 220455
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/Tools.cpp4
1 files changed, 0 insertions, 4 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 6e7060fedd0..4a125f5a9da 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -2267,10 +2267,6 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
// C runtime, etc). Returns true if sanitizer system deps need to be linked in.
static bool addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
- // Don't link in any sanitizer runtimes if we have no system libraries.
- if (Args.hasArg(options::OPT_nostdlib) ||
- Args.hasArg(options::OPT_nodefaultlibs))
- return false;
SmallVector<StringRef, 4> SharedRuntimes, StaticRuntimes,
HelperStaticRuntimes;
collectSanitizerRuntimes(TC, Args, SharedRuntimes, StaticRuntimes,
OpenPOWER on IntegriCloud