[clang] 5f68c41 - Warn about unsupported ibmlongdouble

Qiu Chaofan via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 13 19:15:29 PST 2022


Author: Tulio Magno Quites Machado Filho
Date: 2022-12-14T11:13:54+08:00
New Revision: 5f68c4111ab9c79b902723df3986dd1033813c01

URL: https://github.com/llvm/llvm-project/commit/5f68c4111ab9c79b902723df3986dd1033813c01
DIFF: https://github.com/llvm/llvm-project/commit/5f68c4111ab9c79b902723df3986dd1033813c01.diff

LOG: Warn about unsupported ibmlongdouble

When -mabi=ieeelongdouble is enabled by default, libc++ does not support
-mabi=ibmlongdouble.

Reviewed By: qiucf

Differential Revision: https://reviews.llvm.org/D139450

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/PPCLinux.cpp
    clang/lib/Driver/ToolChains/PPCLinux.h
    clang/test/CMakeLists.txt
    clang/test/Driver/lit.local.cfg
    clang/test/Driver/ppc-float-abi-warning.cpp
    clang/test/lit.site.cfg.py.in

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/PPCLinux.cpp b/clang/lib/Driver/ToolChains/PPCLinux.cpp
index de9c2955a3848..bdbecaef60405 100644
--- a/clang/lib/Driver/ToolChains/PPCLinux.cpp
+++ b/clang/lib/Driver/ToolChains/PPCLinux.cpp
@@ -49,7 +49,10 @@ PPCLinuxToolChain::PPCLinuxToolChain(const Driver &D,
     : Linux(D, Triple, Args) {
   if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
     StringRef ABIName = A->getValue();
-    if (ABIName == "ieeelongdouble" && !SupportIEEEFloat128(D, Triple, Args))
+
+    if ((ABIName == "ieeelongdouble" &&
+         !SupportIEEEFloat128(D, Triple, Args)) ||
+        (ABIName == "ibmlongdouble" && !supportIBMLongDouble(D, Args)))
       D.Diag(diag::warn_drv_unsupported_float_abi_by_lib) << ABIName;
   }
 }
@@ -67,6 +70,18 @@ void PPCLinuxToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   Linux::AddClangSystemIncludeArgs(DriverArgs, CC1Args);
 }
 
+bool PPCLinuxToolChain::supportIBMLongDouble(
+    const Driver &D, const llvm::opt::ArgList &Args) const {
+  if (Args.hasArg(options::OPT_nostdlib, options::OPT_nostdlibxx))
+    return true;
+
+  CXXStdlibType StdLib = ToolChain::GetCXXStdlibType(Args);
+  if (StdLib == CST_Libstdcxx)
+    return true;
+
+  return StdLib == CST_Libcxx && !defaultToIEEELongDouble();
+}
+
 bool PPCLinuxToolChain::SupportIEEEFloat128(
     const Driver &D, const llvm::Triple &Triple,
     const llvm::opt::ArgList &Args) const {
@@ -78,7 +93,7 @@ bool PPCLinuxToolChain::SupportIEEEFloat128(
 
   CXXStdlibType StdLib = ToolChain::GetCXXStdlibType(Args);
   bool HasUnsupportedCXXLib =
-      StdLib == CST_Libcxx ||
+      (StdLib == CST_Libcxx && !defaultToIEEELongDouble()) ||
       (StdLib == CST_Libstdcxx &&
        GCCInstallation.getVersion().isOlderThan(12, 1, 0));
 

diff  --git a/clang/lib/Driver/ToolChains/PPCLinux.h b/clang/lib/Driver/ToolChains/PPCLinux.h
index e0318ae8a3a2a..63adaff6be9c2 100644
--- a/clang/lib/Driver/ToolChains/PPCLinux.h
+++ b/clang/lib/Driver/ToolChains/PPCLinux.h
@@ -27,6 +27,8 @@ class LLVM_LIBRARY_VISIBILITY PPCLinuxToolChain : public Linux {
 private:
   bool SupportIEEEFloat128(const Driver &D, const llvm::Triple &Triple,
                            const llvm::opt::ArgList &Args) const;
+  bool supportIBMLongDouble(const Driver &D,
+                            const llvm::opt::ArgList &Args) const;
 };
 
 } // end namespace toolchains

diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index bd325285636e9..b963a75425896 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -15,6 +15,7 @@ llvm_canonicalize_cmake_booleans(
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
   LLVM_ENABLE_THREADS
   LLVM_WITH_Z3
+  PPC_LINUX_DEFAULT_IEEELONGDOUBLE
   )
 
 configure_lit_site_cfg(

diff  --git a/clang/test/Driver/lit.local.cfg b/clang/test/Driver/lit.local.cfg
index 36e7ca4c2edf1..3eefff7bfedc7 100644
--- a/clang/test/Driver/lit.local.cfg
+++ b/clang/test/Driver/lit.local.cfg
@@ -21,3 +21,6 @@ for name in driver_overwrite_env_vars:
 
 if llvm_config.use_lld(required=False):
     config.available_features.add('lld')
+
+if config.ppc_linux_default_ieeelongdouble:
+  config.available_features.add('ppc_linux_default_ieeelongdouble')

diff  --git a/clang/test/Driver/ppc-float-abi-warning.cpp b/clang/test/Driver/ppc-float-abi-warning.cpp
index 729a3070396fb..e3baa9f4c059d 100644
--- a/clang/test/Driver/ppc-float-abi-warning.cpp
+++ b/clang/test/Driver/ppc-float-abi-warning.cpp
@@ -7,12 +7,23 @@
 // 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:  -stdlib=libc++ 2>&1 | \
+// RUN:  FileCheck %s --check-prefix=NOWARN
+// RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
+// RUN:  -mabi=ibmlongdouble -stdlib=libc++ -Wno-unsupported-abi 2>&1 | \
+// RUN:  FileCheck %s --check-prefix=NOWARN
 // RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
 // RUN:  -mabi=ieeelongdouble -stdlib=libc++ -Wno-unsupported-abi 2>&1 | \
 // RUN:  FileCheck %s --check-prefix=NOWARN
+// RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
+// RUN:  -mabi=%if ppc_linux_default_ieeelongdouble %{ieeelongdouble%} \
+// RUN:  %else %{ibmlongdouble%} -stdlib=libc++ 2>&1 | \
+// RUN:  FileCheck %s --check-prefix=NOWARN
+// RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
+// RUN:  -mabi=%if ppc_linux_default_ieeelongdouble %{ibmlongdouble%} \
+// RUN:  %else %{ieeelongdouble%} -stdlib=libc++ 2>&1 | FileCheck %s
 
-// CHECK: warning: float ABI 'ieeelongdouble' is not supported by current library
-// NOWARN-NOT: warning: float ABI 'ieeelongdouble' is not supported by current library
+// CHECK: warning: float ABI '{{.*}}' is not supported by current library
+// NOWARN-NOT: warning: float ABI '{{.*}}' is not supported by current library
 long double foo(long double x) { return x; }

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 8ea359dcf3c5b..b9ddd0392c2f9 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -38,6 +38,7 @@ config.has_plugins = @CLANG_PLUGIN_SUPPORT@
 config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
 config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@")
 config.standalone_build = @CLANG_BUILT_STANDALONE@
+config.ppc_linux_default_ieeelongdouble = @PPC_LINUX_DEFAULT_IEEELONGDOUBLE@
 
 import lit.llvm
 lit.llvm.initialize(lit_config, config)


        


More information about the cfe-commits mailing list