return isMacosxVersionLT(A, B);
}
-static bool isMacosxVersionGTE(unsigned(&A)[3],
- unsigned V0, unsigned V1=0, unsigned V2=0) {
- return !isMacosxVersionLT(A, V0, V1, V2);
-}
-
const toolchains::Darwin_X86 &darwin::Link::getDarwinToolChain() const {
return reinterpret_cast<const toolchains::Darwin_X86&>(getToolChain());
}
// Derived from startfile spec.
if (Args.hasArg(options::OPT_dynamiclib)) {
// Derived from darwin_dylib1 spec.
- if (Args.hasArg(options::OPT_miphoneos_version_min_EQ) ||
- isMacosxVersionLT(MacosxVersion, 10, 5))
+ if (isMacosxVersionLT(MacosxVersion, 10, 5))
CmdArgs.push_back("-ldylib1.o");
- else
+ else if (isMacosxVersionLT(MacosxVersion, 10, 6))
CmdArgs.push_back("-ldylib1.10.5.o");
} else {
if (Args.hasArg(options::OPT_bundle)) {
- if (!Args.hasArg(options::OPT_static))
- CmdArgs.push_back("-lbundle1.o");
+ if (!Args.hasArg(options::OPT_static)) {
+ // Derived from darwin_bundle1 spec.
+ if (isMacosxVersionLT(MacosxVersion, 10, 6))
+ CmdArgs.push_back("-lbundle1.o");
+ }
} else {
if (Args.hasArg(options::OPT_pg)) {
if (Args.hasArg(options::OPT_static) ||
CmdArgs.push_back("-lcrt0.o");
} else {
// Derived from darwin_crt1 spec.
- if (Args.hasArg(options::OPT_miphoneos_version_min_EQ) ||
- isMacosxVersionLT(MacosxVersion, 10, 5)) {
+ if (isMacosxVersionLT(MacosxVersion, 10, 5))
CmdArgs.push_back("-lcrt1.o");
- } else {
+ else if (isMacosxVersionLT(MacosxVersion, 10, 6))
CmdArgs.push_back("-lcrt1.10.5.o");
-
- // darwin_crt2 spec is empty.
- }
+ else
+ CmdArgs.push_back("-lcrt1.10.6.o");
+
+ // darwin_crt2 spec is empty.
}
}
}
!Args.hasArg(options::OPT_nodefaultlibs)) {
// link_ssp spec is empty.
- // Derived from libgcc spec.
+ // Derived from libgcc and lib specs but refactored.
if (Args.hasArg(options::OPT_static)) {
CmdArgs.push_back("-lgcc_static");
- } else if (Args.hasArg(options::OPT_static_libgcc)) {
- CmdArgs.push_back("-lgcc_eh");
- CmdArgs.push_back("-lgcc");
- } else if (Args.hasArg(options::OPT_miphoneos_version_min_EQ)) {
- // Derived from darwin_iphoneos_libgcc spec.
- CmdArgs.push_back("-lgcc_s.10.5");
- CmdArgs.push_back("-lgcc");
- } else if (Args.hasArg(options::OPT_shared_libgcc) ||
- Args.hasArg(options::OPT_fexceptions) ||
- Args.hasArg(options::OPT_fgnu_runtime)) {
- if (isMacosxVersionLT(MacosxVersion, 10, 5))
- CmdArgs.push_back("-lgcc_s.10.4");
- else
- CmdArgs.push_back("-lgcc_s.10.5");
- CmdArgs.push_back("-lgcc");
} else {
- if (isMacosxVersionLT(MacosxVersion, 10, 5) &&
- isMacosxVersionGTE(MacosxVersion, 10, 3, 9))
- CmdArgs.push_back("-lgcc_s.10.4");
- if (isMacosxVersionGTE(MacosxVersion, 10, 5))
+ if (Args.hasArg(options::OPT_static_libgcc)) {
+ CmdArgs.push_back("-lgcc_eh");
+ } else if (Args.hasArg(options::OPT_miphoneos_version_min_EQ)) {
+ // Derived from darwin_iphoneos_libgcc spec.
CmdArgs.push_back("-lgcc_s.10.5");
- CmdArgs.push_back("-lgcc");
- }
+ } else if (Args.hasArg(options::OPT_shared_libgcc) ||
+ Args.hasArg(options::OPT_fexceptions) ||
+ Args.hasArg(options::OPT_fgnu_runtime)) {
+ // FIXME: This is probably broken on 10.3?
+ if (isMacosxVersionLT(MacosxVersion, 10, 5))
+ CmdArgs.push_back("-lgcc_s.10.4");
+ else if (isMacosxVersionLT(MacosxVersion, 10, 6))
+ CmdArgs.push_back("-lgcc_s.10.5");
+ } else {
+ if (isMacosxVersionLT(MacosxVersion, 10, 3, 9))
+ ; // Do nothing.
+ else if (isMacosxVersionLT(MacosxVersion, 10, 5))
+ CmdArgs.push_back("-lgcc_s.10.4");
+ else if (isMacosxVersionLT(MacosxVersion, 10, 6))
+ CmdArgs.push_back("-lgcc_s.10.5");
+ }
- // Derived from lib spec.
- if (!Args.hasArg(options::OPT_static))
- CmdArgs.push_back("-lSystem");
+ if (isMacosxVersionLT(MacosxVersion, 10, 6)) {
+ CmdArgs.push_back("-lgcc");
+ CmdArgs.push_back("-lSystem");
+ } else {
+ CmdArgs.push_back("-lSystem");
+ CmdArgs.push_back("-lgcc");
+ }
+ }
}
if (!Args.hasArg(options::OPT_A) &&
// RUN: clang -ccc-host-triple i386-apple-darwin9 -arch i386 -arch x86_64 %s -### -o foo 2> %t.log &&
// RUN: grep '".*collect2" .*"-arch_multiple" "-final_output" "foo"' %t.log &&
+// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -filelist FOO -static 2> %t.log &&
+// RUN: grep '"-lcrt0.o" .*"-lgcc_static"' %t.log &&
+// RUN: grep '"-lgcc"' %t.log | count 0 &&
+// RUN: clang -ccc-host-triple i386-apple-darwin7 -### -filelist FOO 2> %t.log &&
+// RUN: grep '"-lcrt1.o" .*"-lgcc" "-lSystem"' %t.log &&
+// RUN: grep '"-lgcc_s"' %t.log | count 0 &&
+// RUN: clang -ccc-host-triple i386-apple-darwin8 -### -filelist FOO 2> %t.log &&
+// RUN: grep '"-lcrt1.o" .*"-lgcc_s.10.4" "-lgcc" "-lSystem"' %t.log &&
+// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -filelist FOO 2> %t.log &&
+// RUN: grep '"-lcrt1.10.5.o" .*"-lgcc_s.10.5" "-lgcc" "-lSystem"' %t.log &&
+// RUN: clang -ccc-host-triple i386-apple-darwin10 -### -filelist FOO 2> %t.log &&
+// RUN: grep '"-lcrt1.10.6.o" .*"-lSystem" "-lgcc"' %t.log &&
+// RUN: grep '"-lgcc_s"' %t.log | count 0 &&
+
// Splatter test case. This is gross, but it works for now. For the
// driver, just getting coverage of the tool code and checking the
// output options is nearly good enough. The main thing we are