[clang] d854042 - [AIX][Clang][Driver] Add handling of shared option
David Tenty via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 21 11:03:15 PDT 2020
Author: David Tenty
Date: 2020-09-21T14:03:08-04:00
New Revision: d8540427419ec0c4b9bc02f432ef39c01898e826
URL: https://github.com/llvm/llvm-project/commit/d8540427419ec0c4b9bc02f432ef39c01898e826
DIFF: https://github.com/llvm/llvm-project/commit/d8540427419ec0c4b9bc02f432ef39c01898e826.diff
LOG: [AIX][Clang][Driver] Add handling of shared option
Reviewed By: jasonliu
Differential Revision: https://reviews.llvm.org/D87914
Added:
Modified:
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/aix-ld.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index e492cd7d196f..f4bab833fa9d 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -92,6 +92,12 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_static))
CmdArgs.push_back("-bnso");
+ // Add options for shared libraries.
+ if (Args.hasArg(options::OPT_shared)) {
+ CmdArgs.push_back("-bM:SRE");
+ CmdArgs.push_back("-bnoentry");
+ }
+
// Specify linker output file.
assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
if (Output.isFilename()) {
@@ -123,7 +129,8 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
return IsArch32Bit ? "crt0.o" : "crt0_64.o";
};
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+ options::OPT_shared)) {
CmdArgs.push_back(
Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename())));
}
diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 695260bbe2bd..22b0378aa3dd 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -377,3 +377,37 @@
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
// 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.
+// RUN: %clang -no-canonical-prefixes %s 2>&1 -### \
+// RUN: -shared \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD32-SHARED %s
+// CHECK-LD32-SHARED: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-SHARED: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-SHARED: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD32-SHARED: "-bM:SRE"
+// CHECK-LD32-SHARED: "-bnoentry"
+// CHECK-LD32-SHARED: "-b32"
+// CHECK-LD32-SHARED: "-bpT:0x10000000" "-bpD:0x20000000"
+// CHECK-LD32-SHARED-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o"
+// CHECK-LD32-SHARED: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD32-SHARED: "-lc"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -shared.
+// RUN: %clang -no-canonical-prefixes %s 2>&1 -### \
+// RUN: -shared \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD64-SHARED %s
+// CHECK-LD64-SHARED: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64-SHARED: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD64-SHARED: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD64-SHARED: "-bM:SRE"
+// CHECK-LD64-SHARED: "-bnoentry"
+// CHECK-LD64-SHARED: "-b64"
+// CHECK-LD64-SHARED: "-bpT:0x100000000" "-bpD:0x110000000"
+// CHECK-LD64-SHARED-NOT: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0_64.o"
+// CHECK-LD64-SHARED: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD64-SHARED: "-lc"
More information about the cfe-commits
mailing list