[PATCH] D41500: ananas: Add shared library support
Ed Schouten via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 9 01:19:29 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC322064: ananas: Add shared library support (authored by ed, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D41500?vs=127907&id=129045#toc
Repository:
rC Clang
https://reviews.llvm.org/D41500
Files:
lib/Driver/ToolChains/Ananas.cpp
test/Driver/ananas.c
Index: test/Driver/ananas.c
===================================================================
--- test/Driver/ananas.c
+++ test/Driver/ananas.c
@@ -7,3 +7,11 @@
// CHECK-STATIC: crtbegin.o
// CHECK-STATIC: crtend.o
// CHECK-STATIC: crtn.o
+
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-ananas -shared %s \
+// RUN: --sysroot=%S/Inputs/ananas-tree -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SHARED %s
+// CHECK-SHARED: crti.o
+// CHECK-SHARED: crtbeginS.o
+// CHECK-SHARED: crtendS.o
+// CHECK-SHARED: crtn.o
Index: lib/Driver/ToolChains/Ananas.cpp
===================================================================
--- lib/Driver/ToolChains/Ananas.cpp
+++ lib/Driver/ToolChains/Ananas.cpp
@@ -64,8 +64,19 @@
if (!D.SysRoot.empty())
CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
- // Ananas only supports static linkage for now.
- CmdArgs.push_back("-Bstatic");
+ if (Args.hasArg(options::OPT_static)) {
+ CmdArgs.push_back("-Bstatic");
+ } else {
+ if (Args.hasArg(options::OPT_rdynamic))
+ CmdArgs.push_back("-export-dynamic");
+ if (Args.hasArg(options::OPT_shared)) {
+ CmdArgs.push_back("-Bshareable");
+ } else {
+ Args.AddAllArgs(CmdArgs, options::OPT_pie);
+ CmdArgs.push_back("-dynamic-linker");
+ CmdArgs.push_back("/lib/ld-ananas.so");
+ }
+ }
if (Output.isFilename()) {
CmdArgs.push_back("-o");
@@ -75,9 +86,15 @@
}
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
- CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+ if (!Args.hasArg(options::OPT_shared)) {
+ CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+ }
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
- CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+ if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie)) {
+ CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbeginS.o")));
+ } else {
+ CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+ }
}
Args.AddAllArgs(CmdArgs, options::OPT_L);
@@ -97,7 +114,10 @@
CmdArgs.push_back("-lc");
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
- CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
+ if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
+ CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtendS.o")));
+ else
+ CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41500.129045.patch
Type: text/x-patch
Size: 2750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180109/80d79f79/attachment-0001.bin>
More information about the cfe-commits
mailing list