Author: Nikita Popov Date: 2022-10-27T10:36:37+02:00 New Revision: 0cbf003c78cdba5cc81b69ee4cd6cee53f2e2796
URL: https://github.com/llvm/llvm-project/commit/0cbf003c78cdba5cc81b69ee4cd6cee53f2e2796 DIFF: https://github.com/llvm/llvm-project/commit/0cbf003c78cdba5cc81b69ee4cd6cee53f2e2796.diff LOG: [PowerPC] Fix check for ieeelongdouble support Clang detects the GCC version from the libdir. However, modern GCC versions only include the major version in the libdir (something like lib/gcc/powerpc64le-linux-gnu/12/), not all version components. For this reason, even though the system has a supported libstdcxx, it will still fail the check against the 12.1.0 version requirement. Fix this by doing the same thing we do for patch versions: Assume that a missing minor version is larger than any specific version. To allow this to be tested, we need to fix two additional issues: First, the GCC toolchain directories used for testing need to contain a crtbegin.o file to be properly detected. The existing tests actually ended up using a 0.0.0 version, rather the intended one. Second, we also need to satisfy the glibc version check based on the dynamic linker. To do so, respect the --dyld-prefix argument and add the necessary file to the test toolchain directory. Differential Revision: https://reviews.llvm.org/D136258 Added: clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-11.2.0/lib/gcc/powerpc64le-linux-gnu/11.2.0/crtbegin.o clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-12/lib/gcc/powerpc64le-linux-gnu/12/crtbegin.o clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-12/lib64/ld64.so.2 Modified: clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/PPCLinux.cpp clang/test/Driver/ppc-float-abi-warning.cpp Removed: clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-11.2.0/lib/gcc/powerpc64le-linux-gnu/11.2.0/.keep ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index e592b7394d0b2..668a4498e8075 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -1884,8 +1884,15 @@ bool Generic_GCC::GCCVersion::isOlderThan(int RHSMajor, int RHSMinor, StringRef RHSPatchSuffix) const { if (Major != RHSMajor) return Major < RHSMajor; - if (Minor != RHSMinor) + if (Minor != RHSMinor) { + // Note that versions without a specified minor sort higher than those with + // a minor. + if (RHSMinor == -1) + return true; + if (Minor == -1) + return false; return Minor < RHSMinor; + } if (Patch != RHSPatch) { // Note that versions without a specified patch sort higher than those with // a patch. diff --git a/clang/lib/Driver/ToolChains/PPCLinux.cpp b/clang/lib/Driver/ToolChains/PPCLinux.cpp index 2fea262fd109c..de9c2955a3848 100644 --- a/clang/lib/Driver/ToolChains/PPCLinux.cpp +++ b/clang/lib/Driver/ToolChains/PPCLinux.cpp @@ -82,6 +82,7 @@ bool PPCLinuxToolChain::SupportIEEEFloat128( (StdLib == CST_Libstdcxx && GCCInstallation.getVersion().isOlderThan(12, 1, 0)); - return GlibcSupportsFloat128(Linux::getDynamicLinker(Args)) && + std::string Linker = Linux::getDynamicLinker(Args); + return GlibcSupportsFloat128((Twine(D.DyldPrefix) + Linker).str()) && !(D.CCCIsCXX() && HasUnsupportedCXXLib); } diff --git a/clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-11.2.0/lib/gcc/powerpc64le-linux-gnu/11.2.0/.keep b/clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-11.2.0/lib/gcc/powerpc64le-linux-gnu/11.2.0/crtbegin.o similarity index 100% rename from clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-11.2.0/lib/gcc/powerpc64le-linux-gnu/11.2.0/.keep rename to clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-11.2.0/lib/gcc/powerpc64le-linux-gnu/11.2.0/crtbegin.o diff --git a/clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-12/lib/gcc/powerpc64le-linux-gnu/12/crtbegin.o b/clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-12/lib/gcc/powerpc64le-linux-gnu/12/crtbegin.o new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-12/lib64/ld64.so.2 b/clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-12/lib64/ld64.so.2 new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/ppc-float-abi-warning.cpp b/clang/test/Driver/ppc-float-abi-warning.cpp index 3ccb9415a021d..729a3070396fb 100644 --- a/clang/test/Driver/ppc-float-abi-warning.cpp +++ b/clang/test/Driver/ppc-float-abi-warning.cpp @@ -3,6 +3,11 @@ // RUN: --gcc-toolchain=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-11.2.0 \ // RUN: -mabi=ieeelongdouble -stdlib=libstdc++ 2>&1 | FileCheck %s // RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s \ +// RUN: --gcc-toolchain=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-12 \ +// RUN: --dyld-prefix=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-12 \ +// RUN: -mabi=ieeelongdouble -stdlib=libstdc++ 2>&1 | \ +// RUN: FileCheck %s --check-prefix=NOWARN +// RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s \ // RUN: -mabi=ieeelongdouble -stdlib=libc++ 2>&1 | FileCheck %s // RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\ // RUN: -mabi=ieeelongdouble -stdlib=libc++ -Wno-unsupported-abi 2>&1 | \ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits