[clang][driver][AIX] Add system libc++ header paths to driver

This change adds the system libc++ header location to the driver. As well we define
the `__LIBC_NO_CPP_MATH_OVERLOADS__` macro when using those headers, in order to suppress
conflicting C++ overloads in the system libc headers that were used by XL C++.

Reviewed By: ZarkoCA

Differential Revision: https://reviews.llvm.org/D109078
This commit is contained in:
David Tenty 2021-09-14 18:05:31 -04:00
parent b8d83e83be
commit 1f3925e25a
4 changed files with 91 additions and 13 deletions

View File

@ -218,15 +218,44 @@ void AIX::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
addSystemInclude(DriverArgs, CC1Args, UP.str());
}
void AIX::AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
DriverArgs.hasArg(options::OPT_nostdincxx) ||
DriverArgs.hasArg(options::OPT_nostdlibinc))
return;
switch (GetCXXStdlibType(DriverArgs)) {
case ToolChain::CST_Libstdcxx:
llvm::report_fatal_error(
"picking up libstdc++ headers is unimplemented on AIX");
case ToolChain::CST_Libcxx: {
llvm::StringRef Sysroot = GetHeaderSysroot(DriverArgs);
SmallString<128> PathCPP(Sysroot);
llvm::sys::path::append(PathCPP, "opt/IBM/openxlCSDK", "include", "c++",
"v1");
addSystemInclude(DriverArgs, CC1Args, PathCPP.str());
// Required in order to suppress conflicting C++ overloads in the system
// libc headers that were used by XL C++.
CC1Args.push_back("-D__LIBC_NO_CPP_MATH_OVERLOADS__");
return;
}
}
llvm_unreachable("Unexpected C++ library type; only libc++ is supported.");
}
void AIX::AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const {
switch (GetCXXStdlibType(Args)) {
case ToolChain::CST_Libstdcxx:
llvm::report_fatal_error("linking libstdc++ unimplemented on AIX");
case ToolChain::CST_Libcxx:
CmdArgs.push_back("-lc++");
CmdArgs.push_back("-lc++abi");
return;
case ToolChain::CST_Libstdcxx:
llvm::report_fatal_error("linking libstdc++ unimplemented on AIX");
}
llvm_unreachable("Unexpected C++ library type; only libc++ is supported.");

View File

@ -70,6 +70,10 @@ public:
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;

View File

@ -584,14 +584,14 @@
// Check powerpc-ibm-aix7.1.0.0, 32-bit. -stdlib=libstdc++ invokes fatal error.
// RUN: not --crash %clangxx -no-canonical-prefixes %s 2>&1 -### \
// RUN: -target powerpc-ibm-aix7.1.0.0 \
// RUN: -stdlib=libstdc++ \
// RUN: -stdlib=libstdc++ -nostdinc++ \
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
// RUN: | FileCheck --check-prefix=CHECK-LD-LIBSTDCXX %s
// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -stdlib=libstdc++ invokes fatal error.
// RUN: not --crash %clangxx -no-canonical-prefixes %s 2>&1 -### \
// RUN: -target powerpc64-ibm-aix7.1.0.0 \
// RUN: -stdlib=libstdc++ \
// RUN: -stdlib=libstdc++ -nostdinc++ \
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
// RUN: | FileCheck --check-prefix=CHECK-LD-LIBSTDCXX %s
// CHECK-LD-LIBSTDCXX: LLVM ERROR: linking libstdc++ unimplemented on AIX

View File

@ -5,13 +5,13 @@
// RUN: -target powerpc-ibm-aix \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --sysroot=%S/Inputs/basic_aix_tree \
// RUN: | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
// RUN: | FileCheck -check-prefixes=CHECK-INTERNAL-INCLUDE,CHECK-INTERNAL-INCLUDE-CXX %s
// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
// RUN: -target powerpc64-ibm-aix \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --sysroot=%S/Inputs/basic_aix_tree \
// RUN: | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
// RUN: | FileCheck -check-prefixes=CHECK-INTERNAL-INCLUDE,CHECK-INTERNAL-INCLUDE-CXX %s
// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
// RUN: -target powerpc-ibm-aix \
@ -28,6 +28,8 @@
// CHECK-INTERNAL-INCLUDE: {{.*}}clang{{.*}}" "-cc1"
// CHECK-INTERNAL-INCLUDE: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
// CHECK-INTERNAL-INCLUDE: "-isysroot" "[[SYSROOT:[^"]+]]"
// CHECK-INTERNAL-INCLUDE-CXX: "-internal-isystem" "[[SYSROOT]]{{(/|\\\\)}}opt{{(/|\\\\)}}IBM{{(/|\\\\)}}openxlCSDK{{(/|\\\\)}}include{{(/|\\\\)}}c++{{(/|\\\\)}}v1"
// CHECK-INTERNAL-INCLUDE-CXX: "-D__LIBC_NO_CPP_MATH_OVERLOADS__"
// CHECK-INTERNAL-INCLUDE: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
// CHECK-INTERNAL-INCLUDE: "-internal-isystem" "[[SYSROOT]]/usr/include"
@ -98,6 +100,8 @@
// CHECK-NOSTDLIBINC-INCLUDE: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
// CHECK-NOSTDLIBINC-INCLUDE: "-isysroot" "[[SYSROOT:[^"]+]]"
// CHECK-NOSTDLIBINC-INCLUDE: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
// CHECK-NOSTDLIBINC-INCLUDE-NOT: "-internal-isystem" "[[SYSROOT]]{{(/|\\\\)}}opt{{(/|\\\\)}}IBM{{(/|\\\\)}}openxlCSDK{{(/|\\\\)}}include{{(/|\\\\)}}c++{{(/|\\\\)}}v1"
// CHECK-NOSTDLIBINC-INCLUDE-NOT: "-D__LIBC_NO_CPP_MATH_OVERLOADS__"
// CHECK-NOSTDLIBINC-INCLUDE-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include"
// Check powerpc-ibm-aix, 32-bit/64-bit. -nobuiltininc option.
@ -106,14 +110,14 @@
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --sysroot=%S/Inputs/basic_aix_tree \
// RUN: -nobuiltininc \
// RUN: | FileCheck -check-prefix=CHECK-NOBUILTININC-INCLUDE %s
// RUN: | FileCheck -check-prefixes=CHECK-NOBUILTININC-INCLUDE,CHECK-NOBUILTININC-INCLUDE-CXX %s
// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
// RUN: -target powerpc64-ibm-aix \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --sysroot=%S/Inputs/basic_aix_tree \
// RUN: -nobuiltininc \
// RUN: | FileCheck -check-prefix=CHECK-NOBUILTININC-INCLUDE %s
// RUN: | FileCheck -check-prefixes=CHECK-NOBUILTININC-INCLUDE,CHECK-NOBUILTININC-INCLUDE-CXX %s
// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
// RUN: -target powerpc-ibm-aix \
@ -133,4 +137,45 @@
// CHECK-NOBUILTININC-INCLUDE: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
// CHECK-NOBUILTININC-INCLUDE: "-isysroot" "[[SYSROOT:[^"]+]]"
// CHECK-NOBUILTININC-INCLUDE-NOT: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
// CHECK-NOBUILTININC-INCLUDE-CXX: "-internal-isystem" "[[SYSROOT]]{{(/|\\\\)}}opt{{(/|\\\\)}}IBM{{(/|\\\\)}}openxlCSDK{{(/|\\\\)}}include{{(/|\\\\)}}c++{{(/|\\\\)}}v1"
// CHECK-NOBUILTININC-INCLUDE-CXX: "-D__LIBC_NO_CPP_MATH_OVERLOADS__"
// CHECK-NOBUILTININC-INCLUDE: "-internal-isystem" "[[SYSROOT]]/usr/include"
// Check powerpc-ibm-aix, 32-bit/64-bit. -nostdinc++ option.
// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
// RUN: -target powerpc-ibm-aix \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --sysroot=%S/Inputs/basic_aix_tree \
// RUN: -nostdinc++ \
// RUN: | FileCheck -check-prefix=CHECK-NOSTDINCXX-INCLUDE %s
// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
// RUN: -target powerpc64-ibm-aix \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --sysroot=%S/Inputs/basic_aix_tree \
// RUN: -nostdinc++ \
// RUN: | FileCheck -check-prefix=CHECK-NOSTDINCXX-INCLUDE %s
// CHECK-NOSTDINCXX-INCLUDE: {{.*}}clang{{.*}}" "-cc1"
// CHECK-NOSTDINCXX-INCLUDE: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
// CHECK-NOSTDINCXX-INCLUDE: "-isysroot" "[[SYSROOT:[^"]+]]"
// CHECK-NOSTDINCXX-INCLUDE: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
// CHECK-NOSTDINCXX-INCLUDE-NOT: "-internal-isystem" "[[SYSROOT]]{{(/|\\\\)}}opt{{(/|\\\\)}}IBM{{(/|\\\\)}}openxlCSDK{{(/|\\\\)}}include{{(/|\\\\)}}c++{{(/|\\\\)}}v1"
// CHECK-NOSTDINCXX-INCLUDE-NOT: "-D__LIBC_NO_CPP_MATH_OVERLOADS__"
// CHECK-NOSTDINCXX-INCLUDE: "-internal-isystem" "[[SYSROOT]]/usr/include"
// Check powerpc-ibm-aix, 32-bit. -stdlib=libstdc++ invokes fatal error.
// RUN: not --crash %clangxx -no-canonical-prefixes %s 2>&1 -### \
// RUN: -target powerpc-ibm-aix \
// RUN: -stdlib=libstdc++ \
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
// RUN: | FileCheck --check-prefix=CHECK-INCLUDE-LIBSTDCXX %s
// Check powerpc64-ibm-aix, 64-bit. -stdlib=libstdc++ invokes fatal error.
// RUN: not --crash %clangxx -no-canonical-prefixes %s 2>&1 -### \
// RUN: -target powerpc64-ibm-aix \
// RUN: -stdlib=libstdc++ \
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
// RUN: | FileCheck --check-prefix=CHECK-INCLUDE-LIBSTDCXX %s
// CHECK-INCLUDE-LIBSTDCXX: LLVM ERROR: picking up libstdc++ headers is unimplemented on AIX