[PATCH] D80415: [AIX] Add '-bcdtors:all:0:s' to linker to gather static init functions
Steven Wan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 25 11:15:09 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5bf2409a4e4d: [AIX] Add '-bcdtors:all:0:s' to linker to gather static init functions (authored by stevewan).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80415/new/
https://reviews.llvm.org/D80415
Files:
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/aix-ld.c
Index: clang/test/Driver/aix-ld.c
===================================================================
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -175,3 +175,21 @@
// CHECK-LD64-NO-DEFAULT-LIBS: "-L[[SYSROOT]]/usr/lib"
// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads"
// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. 'bcdtors' and argument order.
+// RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \
+// RUN: -Wl,-bnocdtors \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD32-CXX-ARG-ORDER %s
+
+// CHECK-LD32-CXX-ARG-ORDER: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-CXX-ARG-ORDER: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-CXX-ARG-ORDER: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD32-CXX-ARG-ORDER-NOT: "-bnso"
+// 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: "-bcdtors:all:0:s"
+// CHECK-LD32-CXX-ARG-ORDER: "-bnocdtors"
+// CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -81,6 +81,7 @@
const InputInfoList &Inputs, const ArgList &Args,
const char *LinkingOutput) const {
const AIX &ToolChain = static_cast<const AIX &>(getToolChain());
+ const Driver &D = ToolChain.getDriver();
ArgStringList CmdArgs;
const bool IsArch32Bit = ToolChain.getTriple().isArch32Bit();
@@ -129,6 +130,12 @@
Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename())));
}
+ // Collect all static constructor and destructor functions in CXX mode. This
+ // has to come before AddLinkerInputs as the implied option needs to precede
+ // any other '-bcdtors' settings or '-bnocdtors' that '-Wl' might forward.
+ if (D.CCCIsCXX())
+ CmdArgs.push_back("-bcdtors:all:0:s");
+
// Specify linker input file(s).
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80415.266055.patch
Type: text/x-patch
Size: 2327 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200525/c7d0bb53/attachment-0001.bin>
More information about the cfe-commits
mailing list