[clang] 7c4a70f - [Driver] Add crtfastmath.o on Solaris if appropriate
Rainer Orth via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 13 01:09:02 PST 2023
Author: Rainer Orth
Date: 2023-01-13T10:08:33+01:00
New Revision: 7c4a70f8f6f37c0d22770fa60e079aaf8928a01c
URL: https://github.com/llvm/llvm-project/commit/7c4a70f8f6f37c0d22770fa60e079aaf8928a01c
DIFF: https://github.com/llvm/llvm-project/commit/7c4a70f8f6f37c0d22770fa60e079aaf8928a01c.diff
LOG: [Driver] Add crtfastmath.o on Solaris if appropriate
`Flang :: Driver/fast_math.f90` `FAIL`s on Solaris because `crtfastmath.o`
is missing from the link line.
This patch adds it as appropriate.
Tested on `amd64-pc-solaris2.11`.
Differential Revision: https://reviews.llvm.org/D141596
Added:
clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtfastmath.o
clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtfastmath.o
clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtfastmath.o
clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtfastmath.o
Modified:
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp b/clang/lib/Driver/ToolChains/Solaris.cpp
index c75375ac95f7b..7cc872c717759 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -115,6 +115,8 @@ void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,
Args.MakeArgString(getToolChain().GetFilePath(values_xpg)));
CmdArgs.push_back(
Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
+ // Add crtfastmath.o if available and fast math is enabled.
+ getToolChain().addFastMathRuntimeIfAvailable(Args, CmdArgs);
}
getToolChain().AddFilePathLibArgs(Args, CmdArgs);
diff --git a/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtfastmath.o b/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtfastmath.o
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtfastmath.o b/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtfastmath.o
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtfastmath.o b/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtfastmath.o
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtfastmath.o b/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtfastmath.o
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 2193f35ac0545..2127ad5ded074 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -114,3 +114,57 @@
// CHECK-RELOCATABLE-NOT: "-l
// CHECK-RELOCATABLE-NOT: /crt{{[^.]+}}.o
// CHECK-RELOCATABLE-NOT: /values-{{[^.]+}}.o
+
+// Check that crtfastmath.o is linked with -ffast-math.
+
+// Check sparc-sun-solaris2.11, 32bit
+// RUN: %clang --target=sparc-sun-solaris2.11 -### %s \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC32 %s
+// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -ffast-math \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC32 %s
+// CHECK-CRTFASTMATH-SPARC32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-SPARC32: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-SPARC32-NOT: crtfastmath.o
+
+// Check sparc-pc-solaris2.11, 64bit
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC64 %s
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s -ffast-math \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC64 %s
+// CHECK-CRTFASTMATH-SPARC64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-SPARC64: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|\\\\}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-SPARC64-NOT: crtfastmath.o
+
+// Check i386-pc-solaris2.11, 32bit
+// RUN: %clang --target=i386-pc-solaris2.11 -### %s \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-X32 %s
+// RUN: %clang --target=i386-pc-solaris2.11 -### %s -ffast-math \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-X32 %s
+// CHECK-CRTFASTMATH-X32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-X32: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|\\\\}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-X32-NOT: crtfastmath.o
+
+// Check i386-pc-solaris2.11, 64bit
+// RUN: %clang -m64 --target=i386-pc-solaris2.11 -### %s \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-X64 %s
+// RUN: %clang -m64 --target=i386-pc-solaris2.11 -### %s -ffast-math \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-X64 %s
+// CHECK-CRTFASTMATH-X64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-X64: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|\\\\}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-X64-NOT: crtfastmath.o
More information about the cfe-commits
mailing list