diff --git a/clang/lib/Driver/ToolChains/PPCLinux.h b/clang/lib/Driver/ToolChains/PPCLinux.h --- a/clang/lib/Driver/ToolChains/PPCLinux.h +++ b/clang/lib/Driver/ToolChains/PPCLinux.h @@ -27,6 +27,8 @@ 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/lib/Driver/ToolChains/PPCLinux.cpp b/clang/lib/Driver/ToolChains/PPCLinux.cpp --- a/clang/lib/Driver/ToolChains/PPCLinux.cpp +++ b/clang/lib/Driver/ToolChains/PPCLinux.cpp @@ -49,7 +49,10 @@ : 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 @@ 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 @@ 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/test/CMakeLists.txt b/clang/test/CMakeLists.txt --- a/clang/test/CMakeLists.txt +++ b/clang/test/CMakeLists.txt @@ -15,6 +15,7 @@ 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 --- a/clang/test/Driver/lit.local.cfg +++ b/clang/test/Driver/lit.local.cfg @@ -21,3 +21,6 @@ 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 --- 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 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -38,6 +38,7 @@ 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)