[PATCH] Driver: implement --dyld-prefix option.
Peter Collingbourne
peter at pcc.me.uk
Mon May 27 07:09:13 PDT 2013
- Rename flag to --dyld-prefix
Hi rafael,
http://llvm-reviews.chandlerc.com/D851
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D851?vs=2100&id=2137#toc
Files:
include/clang/Driver/Driver.h
include/clang/Driver/Options.td
lib/Driver/Driver.cpp
lib/Driver/Tools.cpp
test/Driver/dyld-prefix.c
Index: include/clang/Driver/Driver.h
===================================================================
--- include/clang/Driver/Driver.h
+++ include/clang/Driver/Driver.h
@@ -79,6 +79,9 @@
/// sysroot, if present
std::string SysRoot;
+ /// Dynamic loader prefix, if present
+ std::string DyldPrefix;
+
/// If the standard library is used
bool UseStdLib;
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1163,6 +1163,8 @@
def _define_macro_EQ : Joined<["--"], "define-macro=">, Alias<D>;
def _define_macro : Separate<["--"], "define-macro">, Alias<D>;
def _dependencies : Flag<["--"], "dependencies">, Alias<M>;
+def _dyld_prefix_EQ : Joined<["--"], "dyld-prefix=">;
+def _dyld_prefix : Separate<["--"], "dyld-prefix">, Alias<_dyld_prefix_EQ>;
def _encoding_EQ : Joined<["--"], "encoding=">, Alias<fencoding_EQ>;
def _encoding : Separate<["--"], "encoding">, Alias<fencoding_EQ>;
def _entry : Flag<["--"], "entry">, Alias<e>;
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -289,6 +289,8 @@
}
if (const Arg *A = Args->getLastArg(options::OPT__sysroot_EQ))
SysRoot = A->getValue();
+ if (const Arg *A = Args->getLastArg(options::OPT__dyld_prefix_EQ))
+ DyldPrefix = A->getValue();
if (Args->hasArg(options::OPT_nostdlib))
UseStdLib = false;
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -6003,35 +6003,39 @@
!Args.hasArg(options::OPT_shared))) {
CmdArgs.push_back("-dynamic-linker");
if (isAndroid)
- CmdArgs.push_back("/system/bin/linker");
+ CmdArgs.push_back(
+ Args.MakeArgString(D.DyldPrefix + "/system/bin/linker"));
else if (ToolChain.getArch() == llvm::Triple::x86)
- CmdArgs.push_back("/lib/ld-linux.so.2");
+ CmdArgs.push_back(
+ Args.MakeArgString(D.DyldPrefix + "/lib/ld-linux.so.2"));
else if (ToolChain.getArch() == llvm::Triple::aarch64)
- CmdArgs.push_back("/lib/ld-linux-aarch64.so.1");
+ CmdArgs.push_back(
+ Args.MakeArgString(D.DyldPrefix + "/lib/ld-linux-aarch64.so.1"));
else if (ToolChain.getArch() == llvm::Triple::arm ||
ToolChain.getArch() == llvm::Triple::thumb) {
if (ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUEABIHF)
- CmdArgs.push_back("/lib/ld-linux-armhf.so.3");
+ CmdArgs.push_back(
+ Args.MakeArgString(D.DyldPrefix + "/lib/ld-linux-armhf.so.3"));
else
- CmdArgs.push_back("/lib/ld-linux.so.3");
- }
- else if (ToolChain.getArch() == llvm::Triple::mips ||
- ToolChain.getArch() == llvm::Triple::mipsel)
- CmdArgs.push_back("/lib/ld.so.1");
+ CmdArgs.push_back(
+ Args.MakeArgString(D.DyldPrefix + "/lib/ld-linux.so.3"));
+ } else if (ToolChain.getArch() == llvm::Triple::mips ||
+ ToolChain.getArch() == llvm::Triple::mipsel)
+ CmdArgs.push_back(Args.MakeArgString(D.DyldPrefix + "/lib/ld.so.1"));
else if (ToolChain.getArch() == llvm::Triple::mips64 ||
ToolChain.getArch() == llvm::Triple::mips64el) {
if (hasMipsN32ABIArg(Args))
- CmdArgs.push_back("/lib32/ld.so.1");
+ CmdArgs.push_back(Args.MakeArgString(D.DyldPrefix + "/lib32/ld.so.1"));
else
- CmdArgs.push_back("/lib64/ld.so.1");
- }
- else if (ToolChain.getArch() == llvm::Triple::ppc)
- CmdArgs.push_back("/lib/ld.so.1");
+ CmdArgs.push_back(Args.MakeArgString(D.DyldPrefix + "/lib64/ld.so.1"));
+ } else if (ToolChain.getArch() == llvm::Triple::ppc)
+ CmdArgs.push_back(Args.MakeArgString(D.DyldPrefix + "/lib/ld.so.1"));
else if (ToolChain.getArch() == llvm::Triple::ppc64 ||
- ToolChain.getArch() == llvm::Triple::systemz)
- CmdArgs.push_back("/lib64/ld64.so.1");
+ ToolChain.getArch() == llvm::Triple::systemz)
+ CmdArgs.push_back(Args.MakeArgString(D.DyldPrefix + "/lib64/ld64.so.1"));
else
- CmdArgs.push_back("/lib64/ld-linux-x86-64.so.2");
+ CmdArgs.push_back(
+ Args.MakeArgString(D.DyldPrefix + "/lib64/ld-linux-x86-64.so.2"));
}
CmdArgs.push_back("-o");
Index: test/Driver/dyld-prefix.c
===================================================================
--- /dev/null
+++ test/Driver/dyld-prefix.c
@@ -0,0 +1,7 @@
+// RUN: touch %t.o
+
+// RUN: %clang -target i386-unknown-linux --dyld-prefix /foo -### %t.o 2>&1 | FileCheck --check-prefix=CHECK-32 %s
+// CHECK-32: "-dynamic-linker" "/foo/lib/ld-linux.so.2"
+
+// RUN: %clang -target x86_64-unknown-linux --dyld-prefix /foo -### %t.o 2>&1 | FileCheck --check-prefix=CHECK-64 %s
+// CHECK-64: "-dynamic-linker" "/foo/lib64/ld-linux-x86-64.so.2"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D851.2.patch
Type: text/x-patch
Size: 4965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130527/e26ca5fe/attachment.bin>
More information about the cfe-commits
mailing list