This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Avoid including -lm on the link line with -nostdlib++
Needs ReviewPublic

Authored by phosek on Nov 18 2018, 7:11 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

Drivers include -lm because standard C++ libraries such as libc++
and libstdc++ depend on libmath and when statically linking C++
library, this dependency is needed. However, when -nostdlib++ is
used, there's no reason to include -lm anymore.

Diff Detail

Repository
rC Clang

Event Timeline

phosek created this revision.Nov 18 2018, 7:11 PM
thakis added a subscriber: thakis.Dec 12 2018, 7:01 PM

-lm is kind of the reason -nostdlib++ exists at all -- if you don't want _any_ stdlibs, you can just -nostdlib, no?

-lm is kind of the reason -nostdlib++ exists at all -- if you don't want _any_ stdlibs, you can just -nostdlib, no?

We still want standard libraries like -lc and compiler builtins, -nostdlib would remove those. Keeping -lm around is assuming that user is going to link against C++ library that needs -lm which is a lot of assumptions that IMHO driver shouldn't be doing.