aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/ToolChains.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-09-18 08:15:13 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-09-18 08:15:13 +0000
commit1d4612b829500cbe04a2eafca74afac703e34934 (patch)
treee3ab74a0bab68748207828bca6659fbdf661d7e7 /lib/Driver/ToolChains.cpp
parent6cd4154b9088fa18ae05d11c0f3140fafd76c734 (diff)
Split Darwin toolchain into Clang and GCC Darwin toolchains with a common base.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82213 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains.cpp')
-rw-r--r--lib/Driver/ToolChains.cpp78
1 files changed, 63 insertions, 15 deletions
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 5db58c1691..3d692b0404 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -29,23 +29,31 @@ using namespace clang::driver::toolchains;
/// Darwin - Darwin tool chain for i386 and x86_64.
Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&_DarwinVersion)[3],
- const unsigned (&_GCCVersion)[3],
- bool _IsIPhone)
- : ToolChain(Host, Triple) {
+ const unsigned (&_DarwinVersion)[3], bool _IsIPhoneOS)
+ : ToolChain(Host, Triple),
+ IsIPhoneOS(_IsIPhoneOS)
+{
DarwinVersion[0] = _DarwinVersion[0];
DarwinVersion[1] = _DarwinVersion[1];
DarwinVersion[2] = _DarwinVersion[2];
- GCCVersion[0] = _GCCVersion[0];
- GCCVersion[1] = _GCCVersion[1];
- GCCVersion[2] = _GCCVersion[2];
- IsIPhone = _IsIPhone;
llvm::raw_string_ostream(MacosxVersionMin)
<< "10." << DarwinVersion[0] - 4 << '.' << DarwinVersion[1];
// FIXME: Lift default up.
IPhoneOSVersionMin = "3.0";
+}
+
+DarwinGCC::DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple,
+ const unsigned (&DarwinVersion)[3],
+ const unsigned (&_GCCVersion)[3], bool IsIPhoneOS)
+ : Darwin(Host, Triple, DarwinVersion, IsIPhoneOS)
+{
+ GCCVersion[0] = _GCCVersion[0];
+ GCCVersion[1] = _GCCVersion[1];
+ GCCVersion[2] = _GCCVersion[2];
+
+ // Set up the tool chain paths to match gcc.
ToolChainDir = "i686-apple-darwin";
ToolChainDir += llvm::utostr(DarwinVersion[0]);
@@ -134,8 +142,8 @@ Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA) const {
return *T;
}
-void Darwin::AddLinkSearchPathArgs(const ArgList &Args,
- ArgStringList &CmdArgs) const {
+void DarwinGCC::AddLinkSearchPathArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
// FIXME: Derive these correctly.
if (getArchName() == "x86_64") {
CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc/" + ToolChainDir +
@@ -154,8 +162,8 @@ void Darwin::AddLinkSearchPathArgs(const ArgList &Args,
"/../../.."));
}
-void Darwin::AddLinkRuntimeLibArgs(const ArgList &Args,
- ArgStringList &CmdArgs) const {
+void DarwinGCC::AddLinkRuntimeLibArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
unsigned MacosxVersionMin[3];
getMacosxVersionMin(Args, MacosxVersionMin);
@@ -167,7 +175,7 @@ void Darwin::AddLinkRuntimeLibArgs(const ArgList &Args,
CmdArgs.push_back("-lgcc_eh");
} else if (Args.hasArg(options::OPT_miphoneos_version_min_EQ)) {
// Derived from darwin_iphoneos_libgcc spec.
- if (isIPhone()) {
+ if (isIPhoneOS()) {
CmdArgs.push_back("-lgcc_s.1");
} else {
CmdArgs.push_back("-lgcc_s.10.5");
@@ -190,7 +198,7 @@ void Darwin::AddLinkRuntimeLibArgs(const ArgList &Args,
CmdArgs.push_back("-lgcc_s.10.5");
}
- if (isIPhone() || isMacosxVersionLT(MacosxVersionMin, 10, 6)) {
+ if (isIPhoneOS() || isMacosxVersionLT(MacosxVersionMin, 10, 6)) {
CmdArgs.push_back("-lgcc");
CmdArgs.push_back("-lSystem");
} else {
@@ -200,6 +208,46 @@ void Darwin::AddLinkRuntimeLibArgs(const ArgList &Args,
}
}
+DarwinClang::DarwinClang(const HostInfo &Host, const llvm::Triple& Triple,
+ const unsigned (&DarwinVersion)[3],
+ bool IsIPhoneOS)
+ : Darwin(Host, Triple, DarwinVersion, IsIPhoneOS)
+{
+ // We expect 'as', 'ld', etc. to be adjacent to our install dir.
+ getProgramPaths().push_back(getHost().getDriver().Dir);
+}
+
+void DarwinClang::AddLinkSearchPathArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+ // The Clang toolchain uses explicit paths for internal libraries.
+}
+
+void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+ // Check for static linking.
+ if (Args.hasArg(options::OPT_static)) {
+ // FIXME: We need to have compiler-rt available (perhaps as
+ // libclang_static.a) to link against.
+ return;
+ }
+
+ // Reject -static-libgcc for now, we can deal with this when and if someone
+ // cares. This is useful in situations where someone wants to statically link
+ // something like libstdc++, and needs its runtime support routines.
+ if (const Arg *A = Args.getLastArg(options::OPT_static_libgcc)) {
+ getHost().getDriver().Diag(clang::diag::err_drv_unsupported_opt)
+ << A->getAsString(Args);
+ return;
+ }
+
+ // Otherwise link libSystem, which should have the support routines.
+ //
+ // FIXME: This is only true for 10.6 and beyond. Legacy support isn't
+ // critical, but it should work... we should just link in the static
+ // compiler-rt library.
+ CmdArgs.push_back("-lSystem");
+}
+
void Darwin::getMacosxVersionMin(const ArgList &Args,
unsigned (&Res)[3]) const {
if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ)) {
@@ -240,7 +288,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args,
//
// FIXME: Are there iPhone overrides for this?
- if (!isIPhone()) {
+ if (!isIPhoneOS()) {
// Look for MACOSX_DEPLOYMENT_TARGET, otherwise use the version
// from the host.
const char *Version = ::getenv("MACOSX_DEPLOYMENT_TARGET");