]> granicus.if.org Git - clang/commit
Revert r218541 - Don't link in sanitizer runtimes if -nostdlib/-nodefaultlibs is...
authorAlexey Samsonov <vonosmas@gmail.com>
Thu, 23 Oct 2014 00:46:10 +0000 (00:46 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Thu, 23 Oct 2014 00:46:10 +0000 (00:46 +0000)
commitc6bf3853b257c9a0cbd78f9592eac8486268aef1
tree5f5f94df104b288ccc452337528aca3a54954b7e
parent1183ce584f8d2883adc1cfe48a357cce21edd4dd
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220455 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Driver/Tools.cpp
test/Driver/sanitizer-ld.c