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 @@ -24,6 +24,11 @@ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; + void + addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args, + Action::OffloadKind DeviceOffloadKind) const override; + private: bool SupportIEEEFloat128(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args) const; 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 @@ -13,6 +13,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" +using namespace clang::driver; using namespace clang::driver::toolchains; using namespace llvm::opt; using namespace llvm::sys; @@ -68,6 +69,14 @@ Linux::AddClangSystemIncludeArgs(DriverArgs, CC1Args); } +void PPCLinuxToolChain::addClangTargetOptions( + const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, + Action::OffloadKind DeviceOffloadKind) const { + if (SupportIEEEFloat128(getDriver(), getTriple(), DriverArgs) && + !DriverArgs.hasArg(options::OPT_mabi_EQ)) + CC1Args.push_back("-mabi=ieeelongdouble"); +} + bool PPCLinuxToolChain::SupportIEEEFloat128( const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args) const { diff --git a/clang/test/Driver/ppc-float-abi-warning.cpp b/clang/test/Driver/ppc-float-abi.cpp rename from clang/test/Driver/ppc-float-abi-warning.cpp rename to clang/test/Driver/ppc-float-abi.cpp --- a/clang/test/Driver/ppc-float-abi-warning.cpp +++ b/clang/test/Driver/ppc-float-abi.cpp @@ -7,7 +7,13 @@ // 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 -### -target powerpc64le-linux-gnu %s -nostdlib 2>&1 | \ +// RUN: FileCheck %s --check-prefix=IEEE +// RUN: %clang -### -target powerpc64le-linux-gnu %s -nostdlib \ +// RUN: -mabi=ibmlongdouble 2>&1 | FileCheck %s --check-prefix=NOIEEE // CHECK: warning: float ABI 'ieeelongdouble' is not supported by current library // NOWARN-NOT: warning: float ABI 'ieeelongdouble' is not supported by current library +// IEEE: -mabi=ieeelongdouble +// NOIEEE-NOT: -mabi=ieeelongdouble long double foo(long double x) { return x; }