Skip to content

Commit

Permalink
[PowerPC] Fix check for ieeelongdouble support
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nikic committed Oct 27, 2022
1 parent dda8fe6 commit 0cbf003
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion clang/lib/Driver/ToolChains/Gnu.cpp
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Driver/ToolChains/PPCLinux.cpp
Expand Up @@ -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);
}
Empty file.
5 changes: 5 additions & 0 deletions clang/test/Driver/ppc-float-abi-warning.cpp
Expand Up @@ -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 | \
Expand Down

0 comments on commit 0cbf003

Please sign in to comment.