[cfe-dev] Why does -nostdlib++ leave -lm on the link line?
Petr Hosek via cfe-dev
cfe-dev at lists.llvm.org
Sun Nov 18 19:13:12 PST 2018
D35780 has introduced the new -nostdlib++ flag that disables linking
of C++ standard library, but it still leaves -lm on the link line.
AFAIK the reason why -lm was on the link line in the first place is
because C++ standard libraries like libc++ and libstdc++ depend on -lm
and that dependency is needed when statically linking C++ standard
library.
Nico's argument on D35780 was that -nostdlib++ should only disable C++
standard library and nothing else, and that -lm is there not just for
the C++ standard library. Is that the case? Would C++ compiler ever
generate references directly against libm?
If not, then I'd argue that -nostdlib++ should drop -lm as well. If
users opt to provide their own C++ library which depends on -lm, it
should be their responsibility to include that link dependency. I have
implemented this change in D54681, reviews are welcome.
More information about the cfe-dev
mailing list