================
@@ -515,17 +515,19 @@ void tools::AddLinkerInputs(const ToolChain &TC, const
InputInfoList &Inputs,
//
// 1. On Linux, link only when actually needed.
//
- // 2. Prefer libm functions over libamath.
+ // 2. Prefer libm functions over libamath (when no -nostdlib in use).
//
// 3. Link against libm to resolve libamath dependencies.
//
if (Triple.isOSLinux()) {
CmdArgs.push_back(Args.MakeArgString("--push-state"));
CmdArgs.push_back(Args.MakeArgString("--as-needed"));
}
- CmdArgs.push_back(Args.MakeArgString("-lm"));
+ if (!Args.hasArg(options::OPT_nostdlib))
+ CmdArgs.push_back(Args.MakeArgString("-lm"));
CmdArgs.push_back(Args.MakeArgString("-lamath"));
----------------
pawosm-arm wrote:
There was a very long story behind this which has been discussed while this
code has been introduced. In short: libamath replaces some of the libm
functions, but at the same time, some of the libamath functions depend on libm.
In this case, we don't want to outshadow libm (we only want to provide vector
implementations on as-needed basis), and at the same time we want to produce a
valid binary with no missing symbols (and that's wehre libm is needed) as long
as no `-nostdlib` flag is given.
https://github.com/llvm/llvm-project/pull/133578
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits