diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -159,6 +159,9 @@ AIX Support ----------- +* When using `-shared`, the clang driver now invokes llvm-nm to create an + export list if the user doesn't specify one via linker flag or pass an + alternative export control option. C Language Changes in Clang --------------------------- diff --git a/clang/include/clang/Driver/Job.h b/clang/include/clang/Driver/Job.h --- a/clang/include/clang/Driver/Job.h +++ b/clang/include/clang/Driver/Job.h @@ -141,6 +141,9 @@ /// See Command::setEnvironment std::vector Environment; + /// Optional redirection for stdin, stdout, stderr. + std::vector> RedirectFiles; + /// Information on executable run provided by OS. mutable Optional ProcStat; @@ -204,6 +207,8 @@ /// from the parent process will be used. virtual void setEnvironment(llvm::ArrayRef NewEnvironment); + void setRedirectFiles(const std::vector> &Redirects); + void replaceArguments(llvm::opt::ArgStringList List) { Arguments = std::move(List); } diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp --- a/clang/lib/Driver/Job.cpp +++ b/clang/lib/Driver/Job.cpp @@ -301,6 +301,11 @@ Environment.push_back(nullptr); } +void Command::setRedirectFiles( + const std::vector> &Redirects) { + RedirectFiles = Redirects; +} + void Command::PrintFileNames() const { if (PrintInputFilenames) { for (const auto &Arg : InputInfoList) @@ -352,6 +357,22 @@ } auto Args = llvm::toStringRefArray(Argv.data()); + + // Use Job-specific redirect files if they are present. + if (!RedirectFiles.empty()) { + std::vector> RedirectFilesOptional; + for (const auto &Ele : RedirectFiles) + if (Ele) + RedirectFilesOptional.push_back(Optional(*Ele)); + else + RedirectFilesOptional.push_back(None); + + return llvm::sys::ExecuteAndWait(Executable, Args, Env, + makeArrayRef(RedirectFilesOptional), + /*secondsToWait=*/0, /*memoryLimit=*/0, + ErrMsg, ExecutionFailed, &ProcStat); + } + return llvm::sys::ExecuteAndWait(Executable, Args, Env, Redirects, /*secondsToWait*/ 0, /*memoryLimit*/ 0, ErrMsg, ExecutionFailed, &ProcStat); 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 @@ -74,6 +74,29 @@ Exec, CmdArgs, Inputs, Output)); } +// Determine whether there are any linker options that supply an export list +// (or equivalent information about what to export) being sent to the linker. +static bool hasExportListLinkerOpts(const ArgStringList &CmdArgs) { + for (size_t i = 0, Size = CmdArgs.size(); i < Size; ++i) { + llvm::StringRef ArgString(CmdArgs[i]); + + if (ArgString.startswith("-bE:") || ArgString.startswith("-bexport:") || + ArgString == "-bexpall" || ArgString == "-bexpfull") + return true; + + // If we split -b option, check the next opt. + if (ArgString == "-b" && i + 1 < Size) { + ++i; + llvm::StringRef ArgNextString(CmdArgs[i]); + if (ArgNextString.startswith("E:") || + ArgNextString.startswith("export:") || ArgNextString == "expall" || + ArgNextString == "expfull") + return true; + } + } + return false; +} + void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const ArgList &Args, @@ -168,6 +191,39 @@ // Specify linker input file(s). AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); + if (Args.hasArg(options::OPT_shared) && !hasExportListLinkerOpts(CmdArgs)) { + + const char *CreateExportListExec = Args.MakeArgString( + path::parent_path(ToolChain.getDriver().ClangExecutable) + + "/llvm-nm"); + ArgStringList CreateExportCmdArgs; + + std::string CreateExportListPath = + C.getDriver().GetTemporaryPath("CreateExportList", "exp"); + const char *ExportList = + C.addTempFile(C.getArgs().MakeArgString(CreateExportListPath)); + + for (const auto &II : Inputs) + if (II.isFilename()) + CreateExportCmdArgs.push_back(II.getFilename()); + + CreateExportCmdArgs.push_back("--export-symbols"); + CreateExportCmdArgs.push_back("-X"); + if (IsArch32Bit) { + CreateExportCmdArgs.push_back("32"); + } else { + // Must be 64-bit, otherwise asserted already. + CreateExportCmdArgs.push_back("64"); + } + + auto ExpCommand = std::make_unique( + JA, *this, ResponseFileSupport::None(), CreateExportListExec, + CreateExportCmdArgs, Inputs, Output); + ExpCommand->setRedirectFiles({None, std::string(ExportList), None}); + C.addCommand(std::move(ExpCommand)); + CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList)); + } + // Add directory to library search path. Args.AddAllArgs(CmdArgs, options::OPT_L); ToolChain.AddFilePathLibArgs(Args, CmdArgs); 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 @@ -596,17 +596,29 @@ // RUN: | FileCheck --check-prefix=CHECK-LD-LIBSTDCXX %s // CHECK-LD-LIBSTDCXX: LLVM ERROR: linking libstdc++ unimplemented on AIX -// Check powerpc64-ibm-aix7.1.0.0, 32-bit. -shared. +// Check powerpc-ibm-aix7.1.0.0, 32-bit. -shared. // RUN: %clangxx -x c++ %s 2>&1 -### \ -// RUN: -resource-dir=%S/Inputs/resource_dir \ -// RUN: -shared \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: --unwindlib=libunwind \ +// RUN: | FileCheck --check-prefix=CHECK-LD32-SHARED %s + +// Check powerpc-ibm-aix7.1.0.0, 32-bit. -shared (with exp option strings in other opt). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ // RUN: --target=powerpc-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: --unwindlib=libunwind \ +// RUN: -Wl,-Z/expall/expfull/a-bE:/a-bexport:/ \ // RUN: | FileCheck --check-prefix=CHECK-LD32-SHARED %s + // CHECK-LD32-SHARED: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-LD32-SHARED: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD32-SHARED: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-LD32-SHARED: "{{.*}}llvm-nm" +// CHECK-LD32-SHARED: "--export-symbols" +// CHECK-LD32-SHARED: "-X" "32" // CHECK-LD32-SHARED: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-SHARED: "-bM:SRE" // CHECK-LD32-SHARED: "-bnoentry" @@ -623,10 +635,53 @@ // CHECK-LD32-SHARED: "-lm" // CHECK-LD32-SHARED: "-lc" +// Check powerpc-ibm-aix7.1.0.0, 32-bit. -shared with export list. +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -Wl,-bE:input.exp \ +// RUN: | FileCheck --check-prefix=CHECK-LD32-SHARED-EXPORTS %s + +// Check powerpc-ibm-aix7.1.0.0, 32-bit. -shared with export list (no -Wl, variant). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -bE:input.exp \ +// RUN: | FileCheck --check-prefix=CHECK-LD32-SHARED-EXPORTS %s + +// Check powerpc-ibm-aix7.1.0.0, 32-bit. -shared with export list (-Xlinker variant). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -Xlinker -bE:input.exp \ +// RUN: | FileCheck --check-prefix=CHECK-LD32-SHARED-EXPORTS %s + +// CHECK-LD32-SHARED-EXPORTS: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" +// CHECK-LD32-SHARED-EXPORTS: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" +// CHECK-LD32-SHARED-EXPORTS: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-LD32-SHARED-EXPORTS-NOT: "{{.*}}llvm-nm" +// CHECK-LD32-SHARED-EXPORTS-NOT: "-X" +// CHECK-LD32-SHARED-EXPORTS-NOT: "32" +// CHECK-LD32-SHARED-EXPORTS: "{{.*}}ld{{(.exe)?}}" +// CHECK-LD32-SHARED-EXPORTS: "-bM:SRE" +// CHECK-LD32-SHARED-EXPORTS: "-bnoentry" +// CHECK-LD32-SHARED-EXPORTS: "-b32" +// CHECK-LD32-SHARED-EXPORTS: "-bpT:0x10000000" "-bpD:0x20000000" +// CHECK-LD32-SHARED-EXPORTS-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" +// CHECK-LD32-SHARED-EXPORTS-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" +// CHECK-LD32-SHARED-EXPORTS: "-b{{(" ")?}}E:input.exp" +// CHECK-LD32-SHARED-EXPORTS-NOT: "-bE:{{[^"]+}}" +// CHECK-LD32-SHARED-EXPORTS: "-lc++" +// CHECK-LD32-SHARED-EXPORTS: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-SHARED-EXPORTS: "-lm" +// CHECK-LD32-SHARED-EXPORTS: "-lc" + // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared. // RUN: %clangxx -x c++ %s 2>&1 -### \ -// RUN: -resource-dir=%S/Inputs/resource_dir \ -// RUN: -shared \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ // RUN: --target=powerpc64-ibm-aix7.1.0.0 \ // RUN: --sysroot %S/Inputs/aix_ppc_tree \ // RUN: --unwindlib=libunwind \ @@ -634,6 +689,9 @@ // CHECK-LD64-SHARED: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-LD64-SHARED: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-LD64-SHARED: "-isysroot" "[[SYSROOT:[^"]+]]" +//CHECK-LD64-SHARED: "{{.*}}llvm-nm" +// CHECK-LD64-SHARED: "--export-symbols" +// CHECK-LD64-SHARED: "-X" "64" // CHECK-LD64-SHARED: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-SHARED: "-bM:SRE" // CHECK-LD64-SHARED: "-bnoentry" @@ -650,6 +708,114 @@ // CHECK-LD64-SHARED: "-lm" // CHECK-LD64-SHARED: "-lc" +// Check powerpc-ibm-aix7.1.0.0, 32-bit. -fno-exceptions. +// RUN: %clangxx %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir \ +// RUN: -fno-exceptions \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: | FileCheck --check-prefix=CHECK-LD32-NOEXCEPTIONS %s +// CHECK-LD32-NOEXCEPTIONS: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" +// CHECK-LD32-NOEXCEPTIONS: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" +// CHECK-LD32-NOEXCEPTIONS: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-LD32-NOEXCEPTIONS: "{{.*}}ld{{(.exe)?}}" +// CHECK-LD32-NOEXCEPTIONS: "-b32" +// CHECK-LD32-NOEXCEPTIONS: "-bpT:0x10000000" "-bpD:0x20000000" +// CHECK-LD32-NOEXCEPTIONS: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o" +// CHECK-LD32-NOEXCEPTIONS: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o" +// CHECK-LD32-NOEXCEPTIONS: "-lc++" +// CHECK-LD32-NOEXCEPTIONS: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a" +// CHECK-LD32-NOEXCEPTIONS: "-lm" +// CHECK-LD32-NOEXCEPTIONS: "-lc" + +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with export list. +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -Wl,-bE:input.exp \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPORTS %s + +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with export list (no -Wl, variant). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -bE:input.exp \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPORTS %s + +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with export list (-Xlinker variant). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -Xlinker -bE:input.exp \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPORTS %s + +// CHECK-LD64-SHARED-EXPORTS: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" +// CHECK-LD64-SHARED-EXPORTS: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" +// CHECK-LD64-SHARED-EXPORTS: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-LD64-SHARED-EXPORTS-NOT: "{{.*}}llvm-nm" +// CHECK-LD64-SHARED-EXPORTS-NOT: "-X" +// CHECK-LD64-SHARED-EXPORTS-NOT: "64" +// CHECK-LD64-SHARED-EXPORTS: "{{.*}}ld{{(.exe)?}}" +// CHECK-LD64-SHARED-EXPORTS: "-bM:SRE" +// CHECK-LD64-SHARED-EXPORTS: "-bnoentry" +// CHECK-LD64-SHARED-EXPORTS: "-b64" +// CHECK-LD64-SHARED-EXPORTS: "-bpT:0x100000000" "-bpD:0x110000000" +// CHECK-LD64-SHARED-EXPORTS-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" +// CHECK-LD64-SHARED-EXPORTS-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" +// CHECK-LD64-SHARED-EXPORTS: "-b{{(" ")?}}E:input.exp" +// CHECK-LD64-SHARED-EXPORTS-NOT: "-bE:{{[^"]+}}" +// CHECK-LD64-SHARED-EXPORTS: "-lc++" +// CHECK-LD64-SHARED-EXPORTS: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-SHARED-EXPORTS: "-lm" +// CHECK-LD64-SHARED-EXPORTS: "-lc" + +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with alternate export list. +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -Wl,-bexport:input.exp \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPORTS-ALT %s + +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with alternate export list (no -Wl, variant). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -bexport:input.exp \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPORTS-ALT %s + +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with alternate export list (-Xlinker variant). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -Xlinker -bexport:input.exp \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPORTS-ALT %s + +// CHECK-LD64-SHARED-EXPORTS-ALT: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" +// CHECK-LD64-SHARED-EXPORTS-ALT: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" +// CHECK-LD64-SHARED-EXPORTS-ALT: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-LD64-SHARED-EXPORTS-ALT-NOT: "{{.*}}llvm-nm" +// CHECK-LD64-SHARED-EXPORTS-ALT-NOT: "-X" +// CHECK-LD64-SHARED-EXPORTS-ALT-NOT: "64" +// CHECK-LD64-SHARED-EXPORTS-ALT: "{{.*}}ld{{(.exe)?}}" +// CHECK-LD64-SHARED-EXPORTS-ALT: "-bM:SRE" +// CHECK-LD64-SHARED-EXPORTS-ALT: "-bnoentry" +// CHECK-LD64-SHARED-EXPORTS-ALT: "-b64" +// CHECK-LD64-SHARED-EXPORTS-ALT: "-bpT:0x100000000" "-bpD:0x110000000" +// CHECK-LD64-SHARED-EXPORTS-ALT-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" +// CHECK-LD64-SHARED-EXPORTS-ALT-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" +// CHECK-LD64-SHARED-EXPORTS-ALT: "-b{{(" ")?}}export:input.exp" +// CHECK-LD64-SHARED-EXPORTS-ALT-NOT: "-bE:{{[^"]+}}" +// CHECK-LD64-SHARED-EXPORTS-ALT: "-lc++" +// CHECK-LD64-SHARED-EXPORTS-ALT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-SHARED-EXPORTS-ALT: "-lm" +// CHECK-LD64-SHARED-EXPORTS-ALT: "-lc" + // Check powerpc-ibm-aix7.3.0.0, -fprofile-generate // RUN: %clang %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ @@ -677,6 +843,50 @@ // CHECK-PGO-NON-LTO-NOT: "-lm" // CHECK-PGO-NON-LTO: "-lc" +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with -bexpall. +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -Wl,-bexpall \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPALL %s + +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with -bexpall (no -Wl, variant). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -bexpall \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPALL %s + +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with -bexpall (-Xlinker variant). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -Xlinker -bexpall \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPALL %s + +// CHECK-LD64-SHARED-EXPALL: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" +// CHECK-LD64-SHARED-EXPALL: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" +// CHECK-LD64-SHARED-EXPALL: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-LD64-SHARED-EXPALL-NOT: "{{.*}}llvm-nm" +// CHECK-LD64-SHARED-EXPALL-NOT: "-X" +// CHECK-LD64-SHARED-EXPALL-NOT: "64" +// CHECK-LD64-SHARED-EXPALL: "{{.*}}ld{{(.exe)?}}" +// CHECK-LD64-SHARED-EXPALL: "-bM:SRE" +// CHECK-LD64-SHARED-EXPALL: "-bnoentry" +// CHECK-LD64-SHARED-EXPALL: "-b64" +// CHECK-LD64-SHARED-EXPALL: "-bpT:0x100000000" "-bpD:0x110000000" +// CHECK-LD64-SHARED-EXPALL-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" +// CHECK-LD64-SHARED-EXPALL-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" +// CHECK-LD64-SHARED-EXPALL: "-b{{(" ")?}}expall" +// CHECK-LD64-SHARED-EXPALL-NOT: "-bE:{{[^"]+}}" +// CHECK-LD64-SHARED-EXPALL: "-lc++" +// CHECK-LD64-SHARED-EXPALL: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-SHARED-EXPALL: "-lm" +// CHECK-LD64-SHARED-EXPALL: "-lc" + // Check powerpc-ibm-aix7.2.5.3, -fprofile-generate, -flto // RUN: %clang %s -### 2>&1 \ // RUN: -resource-dir=%S/Inputs/resource_dir \ @@ -704,3 +914,47 @@ // CHECK-PGO-LTO-NOT: "--no-as-needed" // CHECK-PGO-LTO-NOT: "-lm" // CHECK-PGO-LTO: "-lc" + +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with -bexpfull (no -Wl, variant). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -Wl,-bexpfull \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPFULL %s + +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with -bexpfull (no -Wl, variant). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -bexpfull \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPFULL %s + +// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared with -bexpfull (-Xlinker variant). +// RUN: %clangxx -x c++ %s 2>&1 -### \ +// RUN: -resource-dir=%S/Inputs/resource_dir -shared \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: -Xlinker -bexpfull \ +// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED-EXPFULL %s + +// CHECK-LD64-SHARED-EXPFULL: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" +// CHECK-LD64-SHARED-EXPFULL: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" +// CHECK-LD64-SHARED-EXPFULL: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-LD64-SHARED-EXPFULL-NOT: "{{.*}}llvm-nm" +// CHECK-LD64-SHARED-EXPFULL-NOT: "-X" +// CHECK-LD64-SHARED-EXPFULL-NOT: "64" +// CHECK-LD64-SHARED-EXPFULL: "{{.*}}ld{{(.exe)?}}" +// CHECK-LD64-SHARED-EXPFULL: "-bM:SRE" +// CHECK-LD64-SHARED-EXPFULL: "-bnoentry" +// CHECK-LD64-SHARED-EXPFULL: "-b64" +// CHECK-LD64-SHARED-EXPFULL: "-bpT:0x100000000" "-bpD:0x110000000" +// CHECK-LD64-SHARED-EXPFULL-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o" +// CHECK-LD64-SHARED-EXPFULL-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti_64.o" +// CHECK-LD64-SHARED-EXPFULL: "-b{{(" ")?}}expfull" +// CHECK-LD64-SHARED-EXPFULL-NOT: "-bE:{{[^"]+}}" +// CHECK-LD64-SHARED-EXPFULL: "-lc++" +// CHECK-LD64-SHARED-EXPFULL: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a" +// CHECK-LD64-SHARED-EXPFULL: "-lm" +// CHECK-LD64-SHARED-EXPFULL: "-lc"