aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2012-01-31 21:30:03 +0000
committerBob Wilson <bob.wilson@apple.com>2012-01-31 21:30:03 +0000
commit9d3f7af8c3387de94b93e60e8e44ce8b91f81e31 (patch)
tree20d775431c38edfedd150f76b6a3af5405dcb509
parent896e4bd7d570036e98a628288f218fd70e2faf1f (diff)
downloadllvm-9d3f7af8c3387de94b93e60e8e44ce8b91f81e31.zip
llvm-9d3f7af8c3387de94b93e60e8e44ce8b91f81e31.tar.gz
llvm-9d3f7af8c3387de94b93e60e8e44ce8b91f81e31.tar.bz2
Fix more fallout from the introduction of "macosx" and "ios" triples.
The Darwin toolchain constructor was assuming that all Darwin triples would have an OS string starting with "darwin". Triples starting with "macosx" would misinterpret the version number, and "ios" triples would completely miss the version number (or worse) because the OS name is not 6 characters long. We lose some sanity checking of triple strings here, since the Triple.getOSVersion function doesn't do all the checking that the previous code did, but this still seems like a step in the right direction. llvm-svn: 149422
-rw-r--r--clang/lib/Driver/ToolChains.cpp47
-rw-r--r--clang/test/Driver/darwin-ld.c8
-rw-r--r--clang/test/Driver/rewrite-objc.m2
3 files changed, 46 insertions, 11 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index b4273f8..9cc29cd 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -50,17 +50,44 @@ Darwin::Darwin(const Driver &D, const llvm::Triple& Triple)
ARCRuntimeForSimulator(ARCSimulator_None),
LibCXXForSimulator(LibCXXSimulator_None)
{
- // Compute the initial Darwin version based on the host.
- bool HadExtra;
- std::string OSName = Triple.getOSName();
- if (!Driver::GetReleaseVersion(&OSName.c_str()[6],
- DarwinVersion[0], DarwinVersion[1],
- DarwinVersion[2], HadExtra))
- getDriver().Diag(diag::err_drv_invalid_darwin_version) << OSName;
-
+ // Compute the initial Darwin version from the triple
+ unsigned Major, Minor, Micro;
+ Triple.getOSVersion(Major, Minor, Micro);
+ switch (Triple.getOS()) {
+ default: assert(0 && "unexpected OS for Darwin triple");
+ case llvm::Triple::Darwin:
+ // Default to darwin4, i.e., MacOSX 10.0.0.
+ if (Major == 0)
+ Major = 4;
+ if (Major < 4)
+ getDriver().Diag(diag::err_drv_invalid_darwin_version) <<
+ Triple.getOSName();
+ Micro = 0;
+ Minor = Major - 4;
+ Major = 10;
+ break;
+ case llvm::Triple::MacOSX:
+ // Default to MacOSX 10.
+ if (Major == 0)
+ Major = 10;
+ if (Major != 10)
+ getDriver().Diag(diag::err_drv_invalid_darwin_version) <<
+ Triple.getOSName();
+ break;
+ case llvm::Triple::IOS:
+ // Ignore the version from the triple.
+ Major = 10;
+ Minor = 0;
+ Micro = 0;
+ break;
+ }
+ // FIXME: DarwinVersion is only used to find GCC's libexec directory.
+ // It should be removed when we stop supporting that.
+ DarwinVersion[0] = Minor + 4;
+ DarwinVersion[1] = Micro;
+ DarwinVersion[2] = 0;
llvm::raw_string_ostream(MacosxVersionMin)
- << "10." << std::max(0, (int)DarwinVersion[0] - 4) << '.'
- << DarwinVersion[1];
+ << Major << '.' << Minor << '.' << Micro;
}
types::ID Darwin::LookupTypeForExtension(const char *Ext) const {
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index da8f4e0..056d347 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -109,3 +109,11 @@
// RUN: FileCheck -check-prefix=LINK_LAZY_LIBRARY %s < %t.log
// LINK_LAZY_LIBRARY: {{ld(.exe)?"}}
// LINK_LAZY_LIBRARY: "-lazy_library" "Library"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
+// RUN: FileCheck -check-prefix=LINK_VERSION_MIN %s < %t.log
+// LINK_VERSION_MIN: {{ld(.exe)?"}}
+// LINK_VERSION_MIN: "-macosx_version_min" "10.6.0"
+// LINK_VERSION_MIN: {{ld(.exe)?"}}
+// LINK_VERSION_MIN: "-macosx_version_min" "10.7.0"
diff --git a/clang/test/Driver/rewrite-objc.m b/clang/test/Driver/rewrite-objc.m
index c1336ac..9e779f7 100644
--- a/clang/test/Driver/rewrite-objc.m
+++ b/clang/test/Driver/rewrite-objc.m
@@ -3,7 +3,7 @@
// TEST0: clang{{.*}}" "-cc1"
// TEST0: "-rewrite-objc"
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-fragile-abi" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-fragile-abi" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
// TEST0: rewrite-objc.m"
// RUN: not %clang -ccc-no-clang -target unknown -rewrite-objc %s -o - -### 2>&1 | \