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 @@ -133,6 +133,10 @@ options::OPT_shared)) { CmdArgs.push_back( Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename()))); + + if (D.CCCIsCXX()) + CmdArgs.push_back(Args.MakeArgString( + ToolChain.GetFilePath(IsArch32Bit ? "crti.o" : "crti_64.o"))); } // Collect all static constructor and destructor functions in CXX mode. This 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 @@ -199,6 +199,7 @@ // CHECK-LD32-CXX-ARG-ORDER: "-b32" // CHECK-LD32-CXX-ARG-ORDER: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-CXX-ARG-ORDER: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" +// CHECK-LD32-CXX-ARG-ORDER: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-CXX-ARG-ORDER: "-bcdtors:all:0:s" // CHECK-LD32-CXX-ARG-ORDER: "-bnocdtors" // CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s" @@ -216,6 +217,7 @@ // CHECK-LD32-CXX-ARG-LCXX: "-b32" // CHECK-LD32-CXX-ARG-LCXX: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-CXX-ARG-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" +// CHECK-LD32-CXX-ARG-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-CXX-ARG-LCXX: "-lc++" // CHECK-LD32-CXX-ARG-LCXX: "-lc" @@ -231,6 +233,7 @@ // CHECK-LD64-CXX-ARG-LCXX: "-b64" // CHECK-LD64-CXX-ARG-LCXX: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-CXX-ARG-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" +// CHECK-LD64-CXX-ARG-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-CXX-ARG-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-CXX-ARG-LCXX: "-lc++" // CHECK-LD64-CXX-ARG-LCXX: "-lc" @@ -247,6 +250,7 @@ // CHECK-LD32-NODEFLIB-LCXX: "-b32" // CHECK-LD32-NODEFLIB-LCXX: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-NODEFLIB-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" +// CHECK-LD32-NODEFLIB-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-NODEFLIB-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-NODEFLIB-LCXX-NOT: "-lc++" // CHECK-LD32-NODEFLIB-LCXX-NOT: "-lc" @@ -263,6 +267,7 @@ // CHECK-LD64-NODEFLIB-LCXX: "-b64" // CHECK-LD64-NODEFLIB-LCXX: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-NODEFLIB-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" +// CHECK-LD64-NODEFLIB-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-NODEFLIB-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NODEFLIB-LCXX-NOT: "-lc++" // CHECK-LD64-NODEFLIB-LCXX-NOT: "-lc" @@ -279,6 +284,7 @@ // CHECK-LD32-NOSTDLIB-LCXX: "-b32" // CHECK-LD32-NOSTDLIB-LCXX: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" +// CHECK-LD32-NOSTDLIB-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-NOSTDLIB-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "-lc++" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "-lc" @@ -295,6 +301,7 @@ // CHECK-LD64-NOSTDLIB-LCXX: "-b64" // CHECK-LD64-NOSTDLIB-LCXX: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" +// CHECK-LD64-NOSTDLIB-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-NOSTDLIB-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "-lc++" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "-lc" @@ -311,6 +318,7 @@ // CHECK-LD32-NOSTDLIBXX-LCXX: "-b32" // CHECK-LD32-NOSTDLIBXX-LCXX: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-NOSTDLIBXX-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" +// CHECK-LD32-NOSTDLIBXX-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-NOSTDLIBXX-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-NOSTDLIBXX-LCXX-NOT: "-lc++" // CHECK-LD32-NOSTDLIBXX-LCXX: "-lc" @@ -327,6 +335,7 @@ // CHECK-LD64-NOSTDLIBXX-LCXX: "-b64" // CHECK-LD64-NOSTDLIBXX-LCXX: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-NOSTDLIBXX-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" +// CHECK-LD64-NOSTDLIBXX-LCXX: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-NOSTDLIBXX-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NOSTDLIBXX-LCXX-NOT: "-lc++" // CHECK-LD64-NOSTDLIBXX-LCXX: "-lc" @@ -343,6 +352,7 @@ // CHECK-LD32-NOSTARTFILES-LCXX: "-b32" // CHECK-LD32-NOSTARTFILES-LCXX: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-NOSTARTFILES-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" +// CHECK-LD32-NOSTARTFILES-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-NOSTARTFILES-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-NOSTARTFILES-LCXX "-lc++" // CHECK-LD32-NOSTARTFILES-LCXX: "-lc" @@ -359,6 +369,7 @@ // CHECK-LD64-NOSTARTFILES-LCXX: "-b64" // CHECK-LD64-NOSTARTFILES-LCXX: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-NOSTARTFILES-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" +// CHECK-LD64-NOSTARTFILES-LCXX-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-NOSTARTFILES-LCXX: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NOSTARTFILES-LCXX: "-lc++" // CHECK-LD64-NOSTARTFILES-LCXX: "-lc" @@ -379,7 +390,7 @@ // CHECK-LD-LIBSTDCXX: LLVM ERROR: linking libstdc++ unimplemented on AIX // Check powerpc64-ibm-aix7.1.0.0, 32-bit. -shared. -// RUN: %clang -no-canonical-prefixes %s 2>&1 -### \ +// RUN: %clangxx -x c++ -no-canonical-prefixes %s 2>&1 -### \ // RUN: -shared \ // RUN: -target powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ @@ -392,11 +403,14 @@ // CHECK-LD32-SHARED: "-b32" // CHECK-LD32-SHARED: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-LD32-SHARED-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" +// CHECK-LD32-SHARED-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" // CHECK-LD32-SHARED: "-L[[SYSROOT]]/usr/lib" +// CHECK-LD32-SHARED: "-lc++" // CHECK-LD32-SHARED: "-lc" + // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared. -// RUN: %clang -no-canonical-prefixes %s 2>&1 -### \ +// RUN: %clangxx -x c++ -no-canonical-prefixes %s 2>&1 -### \ // RUN: -shared \ // RUN: -target powerpc64-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ @@ -409,5 +423,7 @@ // CHECK-LD64-SHARED: "-b64" // CHECK-LD64-SHARED: "-bpT:0x100000000" "-bpD:0x110000000" // CHECK-LD64-SHARED-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" +// CHECK-LD64-SHARED-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" // CHECK-LD64-SHARED: "-L[[SYSROOT]]/usr/lib" +// CHECK-LD64-SHARED: "-lc++" // CHECK-LD64-SHARED: "-lc"