[clang] [flang] [clang][driver] When -fveclib=ArmPL flag is in use, always link against libamath (PR #116432)
Paul Osmialowski via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 6 02:57:00 PST 2024
================
@@ -490,6 +490,35 @@ void tools::AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
else
A.renderAsInput(Args, CmdArgs);
}
+ if (const Arg *A = Args.getLastArg(options::OPT_fveclib)) {
+ const llvm::Triple &Triple = TC.getTriple();
+ StringRef V = A->getValue();
+ if (V == "ArmPL" && (Triple.isOSLinux() || Triple.isOSDarwin())) {
+ // To support -fveclib=ArmPL we need to link against libamath.
+ // Some of the libamath functions depend on libm, at the same time,
+ // libamath exports its own implementation of some of the libm
+ // functions. Since here we are interested only in the subset of
+ // libamath functions that is covered by the veclib mappings,
+ // we need to do the following:
+ //
+ // 1. On Linux, link only when actually needed.
+ //
+ // 2. Prefer libm functions over libamath.
+ //
+ // 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"));
----------------
pawosm-arm wrote:
No no, it isn't simply a dependency. It's a matter of prioritizing system-libm over libamath which contains faster (and potentially less accurate) implementations of some of the libm functions. I was advised, these should not be used in normal circumstances (it is just unfortunate that for historical reasons, this veclib provider isn't just veclib provider; but for -fveclib=ArmPL there is no other, and likely there will be no other). From the other side, some of the libamath-only functions depend on libm functions that are not in libamath. Is it certain that start/end-group algorithm would look into libraries in-order preferring library first to provide looked upon symbol (e.g. when given `--start-group -lm -lamath --end-group`)? Besides, Darwin's default ld doesn't seem to support --start-group.
https://github.com/llvm/llvm-project/pull/116432
More information about the cfe-commits
mailing list