[PATCH] D35780: Introduce -nostdlib++ flag to disable linking the C++ standard library.

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 23 16:06:25 PDT 2017

On Jul 23, 2017 4:51 PM, "Joerg Sonnenberger" <joerg at bec.de> wrote:

On Sun, Jul 23, 2017 at 03:17:32PM -0400, Nico Weber via cfe-commits wrote:
> On Sun, Jul 23, 2017 at 3:08 PM, Joerg Sonnenberger via Phabricator via
> cfe-commits <cfe-commits at lists.llvm.org> wrote:
> > joerg added a comment.
> >
> > I don't really like this.
> That's cool, you don't need to use the flag.

I'm not talking about the flag, but the implementation.

> > The reason why -lm is added explicitly on many targets is because the
> > STL typically depends on it and that means for static linking and broken
> > ELF linkers, it will be necessary to link against it explicitly.
> >
> The driver adds -lm at the end, so it'll work if you add your static
> flag in user flags, and then -lm gets added at the end. But from what I
> understand, -lm is also there as a usability thing to make c++ a bit more
> accessible than c in this regard, not just for the c++ standard library.
> (Also, if you're trying to statically link your c++ lib, it's possible you
> have some influence on your linker as well.)

I don't think so, it strongly seems to be an implementation detail of
the STL interaction.

> > There is also the question on whether any platform we have currently
> > separate STL and ABI libraries and it is not clear whether the flag
> > handle both.
> >
> Yes, it should handle both.

If you update the comments and documentation accordingly and stop the
current passing of -lm

If you need this behavior for something, that sounds like something a
-nodefaultlibs++ could do. -nostdlib++ is really meant to disable the c++
stdlib and nothing else.

, it is fine with me. I don't think the libmath
handling should be forced on other STL implementations.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170723/51c44b5f/attachment.html>

More information about the cfe-commits mailing list