diff --git a/clang/lib/Driver/ToolChains/AIX.h b/clang/lib/Driver/ToolChains/AIX.h --- a/clang/lib/Driver/ToolChains/AIX.h +++ b/clang/lib/Driver/ToolChains/AIX.h @@ -70,6 +70,10 @@ 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; diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp --- a/clang/lib/Driver/ToolChains/AIX.cpp +++ b/clang/lib/Driver/ToolChains/AIX.cpp @@ -218,6 +218,33 @@ 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_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()); + CC1Args.push_back("-D__LIBC_NO_CPP_MATH_OVERLOADS__"); + return; + } + case ToolChain::CST_Libstdcxx: + llvm::report_fatal_error( + "picking up libstdc++ headers is unimplemented on AIX"); + } + + 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)) { diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c --- a/clang/test/Driver/aix-ld.c +++ b/clang/test/Driver/aix-ld.c @@ -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 diff --git a/clang/test/Driver/aix-toolchain-include.cpp b/clang/test/Driver/aix-toolchain-include.cpp --- a/clang/test/Driver/aix-toolchain-include.cpp +++ b/clang/test/Driver/aix-toolchain-include.cpp @@ -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 \ @@ -25,11 +25,13 @@ // RUN: --sysroot=%S/Inputs/basic_aix_tree \ // RUN: | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s -// CHECK-INTERNAL-INCLUDE: {{.*}}clang{{.*}}" "-cc1" -// CHECK-INTERNAL-INCLUDE: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" -// CHECK-INTERNAL-INCLUDE: "-isysroot" "[[SYSROOT:[^"]+]]" -// CHECK-INTERNAL-INCLUDE: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include" -// CHECK-INTERNAL-INCLUDE: "-internal-isystem" "[[SYSROOT]]/usr/include" +// 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" // Check powerpc-ibm-aix, 32-bit/64-bit. -nostdinc option. // RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \ @@ -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