[cfe-dev] Problems linking compiler-rt and libc++ with -nodefaultlibs; Could -stdlib=none be a solution?

Eric Fiselier eric at efcs.ca
Wed Jan 14 08:31:55 PST 2015


Hi All,

Currently we cannot use sanitizers and other instrumentation when
building and testing libc++ on OS X. For obvious reasons we have to
use '-nodefaultlibs' to ensure that clang doesn't link in another
standard library. On linux using '-fsanitize=...' and '-nodefaultlibs'
will link compiler-rt but on OS X it will not. I imagine other
platforms might also have this problem.

Manually linking compiler-rt is hard if not impossible and it would be
nice if we could have the linker driver do it for us. The changes
required to allow OS X to link compiler-rt with '-nodefaultlibs' seem
quite complicated and I don't think I would be able to make the
changes myself.

Should compiler-rt be linked when '-fsanitize=...' and
'-nodefaultlibs' are given? This behavior should be uniform across all
platforms. If not then how can we make manually linking compiler-rt
easier?

As an aside libc++ probably doesn't need to drop all default
libraries, just the standard library. Currently there is no way to do
this. One option that would fit our use case would be to add the
'-stdlib=none' option that only prevented linking (and including) the
standard library.

Are there any thoughts on adding '-stdlib=none'?

Related discussions can be found below:

[cfe-dev] Linking ProfileRT when using -nodefaultlibs
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-November/039873.html

r218541 - Don't link in sanitizer runtimes if -nostdlib/-nodefaultlibs
is provided.
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20141020/116984.html

/Eric



More information about the cfe-dev mailing list