Move isMacosxVersionLT helpers to Darwin tool chain.

llvm-svn: 82211
This commit is contained in:
Daniel Dunbar 2009-09-18 08:14:55 +00:00
parent 510d8a8dd8
commit d5bd81e869
2 changed files with 32 additions and 26 deletions

View File

@ -95,6 +95,20 @@ public:
/// either the -mmacosx-version-min, or the current version if unspecified. /// either the -mmacosx-version-min, or the current version if unspecified.
void getMacosxVersionMin(const ArgList &Args, unsigned (&Res)[3]) const; void getMacosxVersionMin(const ArgList &Args, unsigned (&Res)[3]) const;
static bool isMacosxVersionLT(unsigned (&A)[3], unsigned (&B)[3]) {
for (unsigned i=0; i < 3; ++i) {
if (A[i] > B[i]) return false;
if (A[i] < B[i]) return true;
}
return false;
}
static bool isMacosxVersionLT(unsigned (&A)[3],
unsigned V0, unsigned V1=0, unsigned V2=0) {
unsigned B[3] = { V0, V1, V2 };
return isMacosxVersionLT(A, B);
}
const char *getMacosxVersionStr() const { const char *getMacosxVersionStr() const {
return MacosxVersionMin.c_str(); return MacosxVersionMin.c_str();
} }

View File

@ -1644,20 +1644,6 @@ static bool isSourceSuffix(const char *Str) {
} }
} }
static bool isMacosxVersionLT(unsigned (&A)[3], unsigned (&B)[3]) {
for (unsigned i=0; i < 3; ++i) {
if (A[i] > B[i]) return false;
if (A[i] < B[i]) return true;
}
return false;
}
static bool isMacosxVersionLT(unsigned (&A)[3],
unsigned V0, unsigned V1=0, unsigned V2=0) {
unsigned B[3] = { V0, V1, V2 };
return isMacosxVersionLT(A, B);
}
// FIXME: Can we tablegen this? // FIXME: Can we tablegen this?
static const char *GetArmArchForMArch(llvm::StringRef Value) { static const char *GetArmArchForMArch(llvm::StringRef Value) {
if (Value == "armv6k") if (Value == "armv6k")
@ -1928,6 +1914,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-o"); CmdArgs.push_back("-o");
CmdArgs.push_back(Output.getFilename()); CmdArgs.push_back(Output.getFilename());
unsigned MacosxVersionMin[3]; unsigned MacosxVersionMin[3];
getDarwinToolChain().getMacosxVersionMin(Args, MacosxVersionMin); getDarwinToolChain().getMacosxVersionMin(Args, MacosxVersionMin);
@ -1937,15 +1924,15 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
// Derived from startfile spec. // Derived from startfile spec.
if (Args.hasArg(options::OPT_dynamiclib)) { if (Args.hasArg(options::OPT_dynamiclib)) {
// Derived from darwin_dylib1 spec. // Derived from darwin_dylib1 spec.
if (isMacosxVersionLT(MacosxVersionMin, 10, 5)) if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5))
CmdArgs.push_back("-ldylib1.o"); CmdArgs.push_back("-ldylib1.o");
else if (isMacosxVersionLT(MacosxVersionMin, 10, 6)) else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6))
CmdArgs.push_back("-ldylib1.10.5.o"); CmdArgs.push_back("-ldylib1.10.5.o");
} else { } else {
if (Args.hasArg(options::OPT_bundle)) { if (Args.hasArg(options::OPT_bundle)) {
if (!Args.hasArg(options::OPT_static)) { if (!Args.hasArg(options::OPT_static)) {
// Derived from darwin_bundle1 spec. // Derived from darwin_bundle1 spec.
if (isMacosxVersionLT(MacosxVersionMin, 10, 6)) if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6))
CmdArgs.push_back("-lbundle1.o"); CmdArgs.push_back("-lbundle1.o");
} }
} else { } else {
@ -1968,9 +1955,11 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
// Derived from darwin_crt1 spec. // Derived from darwin_crt1 spec.
if (getDarwinToolChain().isIPhone()) { if (getDarwinToolChain().isIPhone()) {
CmdArgs.push_back("-lcrt1.o"); CmdArgs.push_back("-lcrt1.o");
} else if (isMacosxVersionLT(MacosxVersionMin, 10, 5)) } else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
10, 5))
CmdArgs.push_back("-lcrt1.o"); CmdArgs.push_back("-lcrt1.o");
else if (isMacosxVersionLT(MacosxVersionMin, 10, 6)) else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
10, 6))
CmdArgs.push_back("-lcrt1.10.5.o"); CmdArgs.push_back("-lcrt1.10.5.o");
else else
CmdArgs.push_back("-lcrt1.10.6.o"); CmdArgs.push_back("-lcrt1.10.6.o");
@ -1983,7 +1972,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_shared_libgcc) && if (Args.hasArg(options::OPT_shared_libgcc) &&
!Args.hasArg(options::OPT_miphoneos_version_min_EQ) && !Args.hasArg(options::OPT_miphoneos_version_min_EQ) &&
isMacosxVersionLT(MacosxVersionMin, 10, 5)) { getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5)) {
const char *Str = const char *Str =
Args.MakeArgString(getToolChain().GetFilePath(C, "crt3.o")); Args.MakeArgString(getToolChain().GetFilePath(C, "crt3.o"));
CmdArgs.push_back(Str); CmdArgs.push_back(Str);
@ -2049,21 +2038,24 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
Args.hasArg(options::OPT_fexceptions) || Args.hasArg(options::OPT_fexceptions) ||
Args.hasArg(options::OPT_fgnu_runtime)) { Args.hasArg(options::OPT_fgnu_runtime)) {
// FIXME: This is probably broken on 10.3? // FIXME: This is probably broken on 10.3?
if (isMacosxVersionLT(MacosxVersionMin, 10, 5)) if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5))
CmdArgs.push_back("-lgcc_s.10.4"); CmdArgs.push_back("-lgcc_s.10.4");
else if (isMacosxVersionLT(MacosxVersionMin, 10, 6)) else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
10, 6))
CmdArgs.push_back("-lgcc_s.10.5"); CmdArgs.push_back("-lgcc_s.10.5");
} else { } else {
if (isMacosxVersionLT(MacosxVersionMin, 10, 3, 9)) if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 3, 9))
; // Do nothing. ; // Do nothing.
else if (isMacosxVersionLT(MacosxVersionMin, 10, 5)) else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
10, 5))
CmdArgs.push_back("-lgcc_s.10.4"); CmdArgs.push_back("-lgcc_s.10.4");
else if (isMacosxVersionLT(MacosxVersionMin, 10, 6)) else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
10, 6))
CmdArgs.push_back("-lgcc_s.10.5"); CmdArgs.push_back("-lgcc_s.10.5");
} }
if (getDarwinToolChain().isIPhone() || if (getDarwinToolChain().isIPhone() ||
isMacosxVersionLT(MacosxVersionMin, 10, 6)) { getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6)) {
CmdArgs.push_back("-lgcc"); CmdArgs.push_back("-lgcc");
CmdArgs.push_back("-lSystem"); CmdArgs.push_back("-lSystem");
} else { } else {