Skip to content

Commit dde726a

Browse files
committed
[clang][driver] When -fveclib=ArmPL flag is in use, always link against libamath
Using `-fveclib=ArmPL` without `-lamath` likely effects in the link-time errors.
1 parent 9a5e5e2 commit dde726a

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,16 @@ void tools::AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
490490
else
491491
A.renderAsInput(Args, CmdArgs);
492492
}
493+
if (const Arg *A = Args.getLastArg(options::OPT_fveclib)) {
494+
if (A->getNumValues() == 1) {
495+
StringRef V = A->getValue();
496+
if (V == "ArmPL") {
497+
CmdArgs.push_back(Args.MakeArgString("-lamath"));
498+
CmdArgs.push_back(Args.MakeArgString("-lm"));
499+
addArchSpecificRPath(TC, Args, CmdArgs);
500+
}
501+
}
502+
}
493503
}
494504

495505
void tools::addLinkerCompressDebugSectionsOption(

clang/test/Driver/fveclib.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,14 @@
102102
/* Verify no warning when math-errno is re-enabled for a different veclib (that does not imply -fno-math-errno). */
103103
// RUN: %clang -### --target=aarch64-linux-gnu -fveclib=ArmPL -fmath-errno -fveclib=LIBMVEC %s 2>&1 | FileCheck --check-prefix=CHECK-REPEAT-VECLIB %s
104104
// CHECK-REPEAT-VECLIB-NOT: math errno enabled
105+
106+
/* Verify that vectorized routines library is being linked in. */
107+
// RUN: %clang -### --target=aarch64-linux-gnu -fveclib=ArmPL %s 2>&1 | FileCheck --check-prefix=CHECK-LINKING-ARMPL %s
108+
// CHECK-LINKING-ARMPL: "-lamath"
109+
// CHECK-LINKING-ARMPL-SAME: "-lm"
110+
111+
/* Verify that the RPATH is being set when needed. */
112+
// RUN: %clang -### --target=aarch64-linux-gnu -resource-dir=%S -frtlib-add-rpath -fveclib=ArmPL %s 2>&1 | FileCheck --check-prefix=CHECK-RPATH-ARMPL %s
113+
// CHECK-RPATH-ARMPL: "-lamath"
114+
// CHECK-RPATH-ARMPL-SAME: "-lm"
115+
// CHECK-RPATH-ARMPL-SAME: "-rpath"

flang/test/Driver/fveclib.f90

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@
3030

3131
! TODO: if we add support for -nostdlib or -nodefaultlibs we need to test that
3232
! these prevent "-framework Accelerate" being added on Darwin
33+
34+
! RUN: %flang -### --target=aarch64-linux-gnu -fveclib=ArmPL %s 2>&1 | FileCheck --check-prefix=CHECK-LINKING-ARMPL %s
35+
! CHECK-LINKING-ARMPL: "-lamath"
36+
! CHECK-LINKING-ARMPL-SAME: "-lm"
37+
38+
! RUN: %flang -### --target=aarch64-linux-gnu -resource-dir=%S -frtlib-add-rpath -fveclib=ArmPL %s 2>&1 | FileCheck --check-prefix=CHECK-RPATH-ARMPL %s
39+
! CHECK-RPATH-ARMPL: "-lamath"
40+
! CHECK-RPATH-ARMPL-SAME: "-lm"
41+
! We need to see "-rpath" at least twice, one for veclib, one for the Fortran runtime
42+
! CHECK-RPATH-ARMPL-SAME: "-rpath"
43+
! CHECK-RPATH-ARMPL-SAME: "-rpath"

0 commit comments

Comments
 (0)