[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
Thu May 21 15:43:54 PDT 2020
stevewan created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
stevewan added reviewers: hubert.reinterpretcast, Xiangling_L, ZarkoCA, daltenty.
On AIX, add '-bcdtors:all:0:s' to linker implicitly through driver, so
that we can collect all static constructor and destructor functions.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80415
Files:
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/aix-ld.cpp
Index: clang/test/Driver/aix-ld.cpp
===================================================================
--- /dev/null
+++ clang/test/Driver/aix-ld.cpp
@@ -0,0 +1,18 @@
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. 'bcdtors' and Arguemnt order.
+// // RUN: %clang++ -no-canonical-prefixes %s -### -o %t.o 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-ARG-ORDER %s
+// // CHECK-LD32-ARG-ORDER-NOT: warning:
+// // CHECK-LD32-ARG-ORDER: {{.*}}clang++" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// // CHECK-LD32-ARG-ORDER: "-isysroot" "[[SYSROOT:[^"]+]]"
+// // CHECK-LD32-ARG-ORDER: "{{.*}}ld"
+// // CHECK-LD32-ARG-ORDER-NOT: "-bnso"
+// // CHECK-LD32-ARG-ORDER: "-b32"
+// // CHECK-LD32-ARG-ORDER: "-bpT:0x10000000" "-bpD:0x20000000"
+// // CHECK-LD32-ARG-ORDER: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o"
+// // CHECK-LD32-ARG-ORDER: "-bcdtors:all:0:s"
+// // CHECK-LD32-ARG-ORDER: "-bnocdtors"
+// // CHECK-LD32-ARG-ORDER: "-L[[SYSROOT]]/usr/lib"
+// // CHECK-LD32-ARG-ORDER: "-lc"
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.265631.patch
Type: text/x-patch
Size: 2197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200521/1137391a/attachment.bin>
More information about the cfe-commits
mailing list