Skip to content

Commit 5f68c41

Browse files
tuliomecnelises
authored andcommitted
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
1 parent 8be3133 commit 5f68c41

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed

clang/lib/Driver/ToolChains/PPCLinux.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ PPCLinuxToolChain::PPCLinuxToolChain(const Driver &D,
4949
: Linux(D, Triple, Args) {
5050
if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
5151
StringRef ABIName = A->getValue();
52-
if (ABIName == "ieeelongdouble" && !SupportIEEEFloat128(D, Triple, Args))
52+
53+
if ((ABIName == "ieeelongdouble" &&
54+
!SupportIEEEFloat128(D, Triple, Args)) ||
55+
(ABIName == "ibmlongdouble" && !supportIBMLongDouble(D, Args)))
5356
D.Diag(diag::warn_drv_unsupported_float_abi_by_lib) << ABIName;
5457
}
5558
}
@@ -67,6 +70,18 @@ void PPCLinuxToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
6770
Linux::AddClangSystemIncludeArgs(DriverArgs, CC1Args);
6871
}
6972

73+
bool PPCLinuxToolChain::supportIBMLongDouble(
74+
const Driver &D, const llvm::opt::ArgList &Args) const {
75+
if (Args.hasArg(options::OPT_nostdlib, options::OPT_nostdlibxx))
76+
return true;
77+
78+
CXXStdlibType StdLib = ToolChain::GetCXXStdlibType(Args);
79+
if (StdLib == CST_Libstdcxx)
80+
return true;
81+
82+
return StdLib == CST_Libcxx && !defaultToIEEELongDouble();
83+
}
84+
7085
bool PPCLinuxToolChain::SupportIEEEFloat128(
7186
const Driver &D, const llvm::Triple &Triple,
7287
const llvm::opt::ArgList &Args) const {
@@ -78,7 +93,7 @@ bool PPCLinuxToolChain::SupportIEEEFloat128(
7893

7994
CXXStdlibType StdLib = ToolChain::GetCXXStdlibType(Args);
8095
bool HasUnsupportedCXXLib =
81-
StdLib == CST_Libcxx ||
96+
(StdLib == CST_Libcxx && !defaultToIEEELongDouble()) ||
8297
(StdLib == CST_Libstdcxx &&
8398
GCCInstallation.getVersion().isOlderThan(12, 1, 0));
8499

clang/lib/Driver/ToolChains/PPCLinux.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class LLVM_LIBRARY_VISIBILITY PPCLinuxToolChain : public Linux {
2727
private:
2828
bool SupportIEEEFloat128(const Driver &D, const llvm::Triple &Triple,
2929
const llvm::opt::ArgList &Args) const;
30+
bool supportIBMLongDouble(const Driver &D,
31+
const llvm::opt::ArgList &Args) const;
3032
};
3133

3234
} // end namespace toolchains

clang/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ llvm_canonicalize_cmake_booleans(
1515
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
1616
LLVM_ENABLE_THREADS
1717
LLVM_WITH_Z3
18+
PPC_LINUX_DEFAULT_IEEELONGDOUBLE
1819
)
1920

2021
configure_lit_site_cfg(

clang/test/Driver/lit.local.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ for name in driver_overwrite_env_vars:
2121

2222
if llvm_config.use_lld(required=False):
2323
config.available_features.add('lld')
24+
25+
if config.ppc_linux_default_ieeelongdouble:
26+
config.available_features.add('ppc_linux_default_ieeelongdouble')

clang/test/Driver/ppc-float-abi-warning.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,23 @@
77
// RUN: --dyld-prefix=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-12 \
88
// RUN: -mabi=ieeelongdouble -stdlib=libstdc++ 2>&1 | \
99
// RUN: FileCheck %s --check-prefix=NOWARN
10-
// RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s \
11-
// RUN: -mabi=ieeelongdouble -stdlib=libc++ 2>&1 | FileCheck %s
10+
// RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
11+
// RUN: -stdlib=libc++ 2>&1 | \
12+
// RUN: FileCheck %s --check-prefix=NOWARN
13+
// RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
14+
// RUN: -mabi=ibmlongdouble -stdlib=libc++ -Wno-unsupported-abi 2>&1 | \
15+
// RUN: FileCheck %s --check-prefix=NOWARN
1216
// RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
1317
// RUN: -mabi=ieeelongdouble -stdlib=libc++ -Wno-unsupported-abi 2>&1 | \
1418
// RUN: FileCheck %s --check-prefix=NOWARN
19+
// RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
20+
// RUN: -mabi=%if ppc_linux_default_ieeelongdouble %{ieeelongdouble%} \
21+
// RUN: %else %{ibmlongdouble%} -stdlib=libc++ 2>&1 | \
22+
// RUN: FileCheck %s --check-prefix=NOWARN
23+
// RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
24+
// RUN: -mabi=%if ppc_linux_default_ieeelongdouble %{ibmlongdouble%} \
25+
// RUN: %else %{ieeelongdouble%} -stdlib=libc++ 2>&1 | FileCheck %s
1526

16-
// CHECK: warning: float ABI 'ieeelongdouble' is not supported by current library
17-
// NOWARN-NOT: warning: float ABI 'ieeelongdouble' is not supported by current library
27+
// CHECK: warning: float ABI '{{.*}}' is not supported by current library
28+
// NOWARN-NOT: warning: float ABI '{{.*}}' is not supported by current library
1829
long double foo(long double x) { return x; }

clang/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ config.has_plugins = @CLANG_PLUGIN_SUPPORT@
3838
config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
3939
config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@")
4040
config.standalone_build = @CLANG_BUILT_STANDALONE@
41+
config.ppc_linux_default_ieeelongdouble = @PPC_LINUX_DEFAULT_IEEELONGDOUBLE@
4142

4243
import lit.llvm
4344
lit.llvm.initialize(lit_config, config)

0 commit comments

Comments
 (0)