diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -738,6 +738,9 @@ } static const char *getAsNeededOption(const ToolChain &TC, bool as_needed) { + assert(!TC.getTriple().isOSAIX() && + "AIX linker does not support any form of --as-needed option yet."); + // While the Solaris 11.2 ld added --as-needed/--no-as-needed as aliases // for the native forms -z ignore/-z record, they are missing in Illumos, // so always use the native form. @@ -1423,7 +1426,8 @@ LibGccType LGT = getLibGccType(TC, D, Args); bool AsNeeded = LGT == LibGccType::UnspecifiedLibGcc && - !TC.getTriple().isAndroid() && !TC.getTriple().isOSCygMing(); + !TC.getTriple().isAndroid() && + !TC.getTriple().isOSCygMing() && !TC.getTriple().isOSAIX(); if (AsNeeded) CmdArgs.push_back(getAsNeededOption(TC, true)); 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 @@ -20,7 +20,9 @@ // CHECK-LD32-NOT: "-lc++" // CHECK-LD32-NOT: "-lc++abi" // CHECK-LD32: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-NOT: "--as-needed" // CHECK-LD32: "-lunwind" +// CHECK-LD32-NOT: "--no-as-needed" // CHECK-LD32-NOT: "-lm" // CHECK-LD32: "-lc" @@ -43,7 +45,9 @@ // CHECK-LD64-NOT: "-lc++" // CHECK-LD64-NOT: "-lc++abi" // CHECK-LD64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-NOT: "--as-needed" // CHECK-LD64: "-lunwind" +// CHECK-LD64-NOT: "--no-as-needed" // CHECK-LD64-NOT: "-lm" // CHECK-LD64: "-lc" @@ -67,7 +71,9 @@ // CHECK-LD32-PTHREAD-NOT: "-lc++" // CHECK-LD32-PTHREAD-NOT: "-lc++abi" // CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-PTHREAD-NOT: "--as-needed" // CHECK-LD32-PTHREAD: "-lunwind" +// CHECK-LD32-PTHREAD-NOT: "--no-as-needed" // CHECK-LD32-PTHREAD: "-lpthreads" // CHECK-LD32-PTHREAD-NOT: "-lm" // CHECK-LD32-PTHREAD: "-lc" @@ -92,7 +98,9 @@ // CHECK-LD64-PTHREAD-NOT: "-lc++" // CHECK-LD64-PTHREAD-NOT: "-lc++abi" // CHECK-LD64-PTHREAD: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-PTHREAD-NOT: "--as-needed" // CHECK-LD64-PTHREAD: "-lunwind" +// CHECK-LD64-PTHREAD-NOT: "--no-as-needed" // CHECK-LD64-PTHREAD: "-lpthreads" // CHECK-LD64-PTHREAD-NOT: "-lm" // CHECK-LD64-PTHREAD: "-lc" @@ -117,7 +125,9 @@ // CHECK-LD32-PROF-NOT: "-lc++" // CHECK-LD32-PROF-NOT: "-lc++abi" // CHECK-LD32-PROF: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-PROF-NOT: "--as-needed" // CHECK-LD32-PROF: "-lunwind" +// CHECK-LD32-PROF-NOT: "--no-as-needed" // CHECK-LD32-PROF-NOT: "-lm" // CHECK-LD32-PROF: "-lc" @@ -141,7 +151,9 @@ // CHECK-LD64-GPROF-NOT: "-lc++" // CHECK-LD64-GPROF-NOT: "-lc++abi" // CHECK-LD64-GPROF: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-GPROF-NOT: "--as-needed" // CHECK-LD64-GPROF: "-lunwind" +// CHECK-LD64-GPROF-NOT: "--no-as-needed" // CHECK-LD64-GPROF-NOT: "-lm" // CHECK-LD64-GPROF: "-lc" @@ -165,7 +177,9 @@ // CHECK-LD32-STATIC-NOT: "-lc++" // CHECK-LD32-STATIC-NOT: "-lc++abi" // CHECK-LD32-STATIC: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-STATIC-NOT: "--as-needed" // CHECK-LD32-STATIC-NOT: "-lunwind" +// CHECK-LD32-STATIC-NOT: "--no-as-needed" // CHECK-LD32-STATIC-NOT: "-lm" // CHECK-LD32-STATIC: "-lc" @@ -190,7 +204,9 @@ // CHECK-LD32-LIBP-NOT: "-lc++" // CHECK-LD32-LIBP-NOT: "-lc++abi" // CHECK-LD32-LIBP: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-LIBP-NOT: "--as-needed" // CHECK-LD32-LIBP: "-lunwind" +// CHECK-LD32-LIBP-NOT: "--no-as-needed" // CHECK-LD32-LIBP-NOT: "-lm" // CHECK-LD32-LIBP: "-lc" @@ -215,7 +231,9 @@ // CHECK-LD32-NO-STD-LIB-NOT: "-lc++" // CHECK-LD32-NO-STD-LIB-NOT: "-lc++abi" // CHECK-LD32-NO-STD-LIB-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-NO-STD-LIB-NOT: "--as-needed" // CHECK-LD32-NO-STD-LIB-NOT: "-lunwind" +// CHECK-LD32-NO-STD-LIB-NOT: "--no-as-needed" // CHECK-LD32-NO-STD-LIB-NOT: "-lpthreads" // CHECK-LD32-NO-STD-LIB-NOT: "-lm" // CHECK-LD32-NO-STD-LIB-NOT: "-lc" @@ -241,7 +259,9 @@ // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc++" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc++abi" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "--as-needed" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lunwind" +// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "--no-as-needed" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lm" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc" @@ -268,7 +288,9 @@ // CHECK-LD32-ARG-ORDER-NOT: "-lc++" // CHECK-LD32-ARG-ORDER-NOT: "-lc++abi" // CHECK-LD32-ARG-ORDER: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-ARG-ORDER-NOT: "--as-needed" // CHECK-LD32-ARG-ORDER: "-lunwind" +// CHECK-LD32-ARG-ORDER-NOT: "--no-as-needed" // CHECK-LD32-ARG-ORDER-NOT: "-lm" // CHECK-LD32-ARG-ORDER: "-lc" @@ -294,7 +316,9 @@ // CHECK-LD32-CXX-ARG-ORDER: "-lc++" // CHECK-LD32-CXX-ARG-ORDER: "-lc++abi" // CHECK-LD32-CXX-ARG-ORDER: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-CXX-ARG-ORDER-NOT: "--as-needed" // CHECK-LD32-CXX-ARG-ORDER: "-lunwind" +// CHECK-LD32-CXX-ARG-ORDER-NOT: "--no-as-needed" // CHECK-LD32-CXX-ARG-ORDER: "-lm" // CHECK-LD32-CXX-ARG-ORDER: "-lc" @@ -315,7 +339,9 @@ // CHECK-LD32-CXX-ARG-LCXX: "-lc++" // CHECK-LD32-CXX-ARG-LCXX: "-lc++abi" // CHECK-LD32-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-CXX-ARG-LCXX-NOT: "--as-needed" // CHECK-LD32-CXX-ARG-LCXX: "-lunwind" +// CHECK-LD32-CXX-ARG-LCXX-NOT: "--no-as-needed" // CHECK-LD32-CXX-ARG-LCXX: "-lm" // CHECK-LD32-CXX-ARG-LCXX: "-lc" @@ -336,7 +362,9 @@ // CHECK-LD64-CXX-ARG-LCXX: "-lc++" // CHECK-LD64-CXX-ARG-LCXX: "-lc++abi" // CHECK-LD64-CXX-ARG-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-CXX-ARG-LCXX-NOT: "--as-needed" // CHECK-LD64-CXX-ARG-LCXX: "-lunwind" +// CHECK-LD64-CXX-ARG-LCXX-NOT: "--no-as-needed" // CHECK-LD64-CXX-ARG-LCXX: "-lm" // CHECK-LD64-CXX-ARG-LCXX: "-lc" @@ -358,7 +386,9 @@ // CHECK-LD32-NODEFLIB-LCXX-NOT: "-lc++" // CHECK-LD32-NODEFLIB-LCXX-NOT: "-lc++abi" // CHECK-LD32-NODEFLIB-LCXX-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-NODEFLIB-LCXX-NOT: "--as-needed" // CHECK-LD32-NODEFLIB-LCXX-NOT: "-lunwind" +// CHECK-LD32-NODEFLIB-LCXX-NOT: "--no-as-needed" // CHECK-LD32-NODEFLIB-LCXX-NOT: "-lm" // CHECK-LD32-NODEFLIB-LCXX-NOT: "-lc" @@ -380,7 +410,9 @@ // CHECK-LD64-NODEFLIB-LCXX-NOT: "-lc++" // CHECK-LD64-NODEFLIB-LCXX-NOT: "-lc++abi" // CHECK-LD64-NODEFLIB-LCXX-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-NODEFLIB-LCXX-NOT: "--as-needed" // CHECK-LD64-NODEFLIB-LCXX-NOT: "-lunwind" +// CHECK-LD64-NODEFLIB-LCXX-NOT: "--no-as-needed" // CHECK-LD64-NODEFLIB-LCXX-NOT: "-lm" // CHECK-LD64-NODEFLIB-LCXX-NOT: "-lc" @@ -402,7 +434,9 @@ // CHECK-LD32-NOSTDLIB-LCXX-NOT: "-lc++" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "-lc++abi" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-NOSTDLIB-LCXX-NOT: "--as-needed" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "-lunwind" +// CHECK-LD32-NOSTDLIB-LCXX-NOT: "--no-as-needed" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "-lm" // CHECK-LD32-NOSTDLIB-LCXX-NOT: "-lc" @@ -424,7 +458,9 @@ // CHECK-LD64-NOSTDLIB-LCXX-NOT: "-lc++" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "-lc++abi" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-NOSTDLIB-LCXX-NOT: "--as-needed" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "-lunwind" +// CHECK-LD64-NOSTDLIB-LCXX-NOT: "--no-as-needed" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "-lm" // CHECK-LD64-NOSTDLIB-LCXX-NOT: "-lc" @@ -447,7 +483,9 @@ // CHECK-LD32-NOSTDLIBXX-LCXX-NOT: "-lc++" // CHECK-LD32-NOSTDLIBXX-LCXX-NOT: "-lc++abi" // CHECK-LD32-NOSTDLIBXX-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-NOSTDLIBXX-LCXX-NOT: "--as-needed" // CHECK-LD32-NOSTDLIBXX-LCXX: "-lunwind" +// CHECK-LD32-NOSTDLIBXX-LCXX-NOT: "--no-as-needed" // CHECK-LD32-NOSTDLIBXX-LCXX: "-lm" // CHECK-LD32-NOSTDLIBXX-LCXX: "-lc" @@ -469,7 +507,9 @@ // CHECK-LD64-NOSTDLIBXX-LCXX-NOT: "-lc++" // CHECK-LD64-NOSTDLIBXX-LCXX-NOT: "-lc++abi" // CHECK-LD64-NOSTDLIBXX-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-NOSTDLIBXX-LCXX-NOT: "--as-needed" // CHECK-LD64-NOSTDLIBXX-LCXX: "-lunwind" +// CHECK-LD64-NOSTDLIBXX-LCXX-NOT: "--no-as-needed" // CHECK-LD64-NOSTDLIBXX-LCXX: "-lm" // CHECK-LD64-NOSTDLIBXX-LCXX: "-lc" @@ -491,7 +531,9 @@ // CHECK-LD32-NOSTARTFILES-LCXX: "-lc++" // CHECK-LD32-NOSTARTFILES-LCXX: "-lc++abi" // CHECK-LD32-NOSTARTFILES-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-NOSTARTFILES-LCXX-NOT: "--as-needed" // CHECK-LD32-NOSTARTFILES-LCXX: "-lunwind" +// CHECK-LD32-NOSTARTFILES-LCXX-NOT: "--no-as-needed" // CHECK-LD32-NOSTARTFILES-LCXX: "-lm" // CHECK-LD32-NOSTARTFILES-LCXX: "-lc" @@ -513,7 +555,9 @@ // CHECK-LD64-NOSTARTFILES-LCXX: "-lc++" // CHECK-LD64-NOSTARTFILES-LCXX: "-lc++abi" // CHECK-LD64-NOSTARTFILES-LCXX: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-NOSTARTFILES-LCXX-NOT: "--as-needed" // CHECK-LD64-NOSTARTFILES-LCXX: "-lunwind" +// CHECK-LD64-NOSTARTFILES-LCXX-NOT: "--no-as-needed" // CHECK-LD64-NOSTARTFILES-LCXX: "-lm" // CHECK-LD64-NOSTARTFILES-LCXX: "-lc" @@ -552,7 +596,9 @@ // CHECK-LD32-SHARED: "-lc++" // CHECK-LD32-SHARED: "-lc++abi" // CHECK-LD32-SHARED: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-SHARED-NOT: "--as-needed" // CHECK-LD32-SHARED: "-lunwind" +// CHECK-LD32-SHARED-NOT: "--no-as-needed" // CHECK-LD32-SHARED: "-lm" // CHECK-LD32-SHARED: "-lc" @@ -576,6 +622,8 @@ // CHECK-LD64-SHARED: "-lc++" // CHECK-LD64-SHARED: "-lc++abi" // CHECK-LD64-SHARED: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-SHARED-NOT: "--as-needed" // CHECK-LD64-SHARED: "-lunwind" +// CHECK-LD64-SHARED-NOT: "--no-as-needed" // CHECK-LD64-SHARED: "-lm" // CHECK-LD64-SHARED: "-lc"