summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2015-06-18 21:46:05 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2015-06-18 21:46:05 +0000
commit905c802f5ba5322ee1df53c410ab9f1a14c028fc (patch)
treee8bd48cabd091e65fdf2fb43de30a963d0ab0ea3
parentcf5c220da52ecd820e9abddcd5b8823b6a4ddd59 (diff)
downloadbcm5719-llvm-905c802f5ba5322ee1df53c410ab9f1a14c028fc.tar.gz
bcm5719-llvm-905c802f5ba5322ee1df53c410ab9f1a14c028fc.zip
[Driver] Compute MacOS/iOS version from triple if/when we actually need it. NFC.
llvm-svn: 240065
-rw-r--r--clang/lib/Driver/ToolChains.cpp43
-rw-r--r--clang/lib/Driver/ToolChains.h9
2 files changed, 19 insertions, 33 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index 314621d4afc..5bf96a2a4b6 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -49,22 +49,8 @@ MachO::MachO(const Driver &D, const llvm::Triple &Triple,
}
/// Darwin - Darwin tool chain for i386 and x86_64.
-Darwin::Darwin(const Driver & D, const llvm::Triple & Triple,
- const ArgList & Args)
- : MachO(D, Triple, Args), TargetInitialized(false) {
- // Compute the initial Darwin version from the triple
- unsigned Major, Minor, Micro;
- if (!Triple.getMacOSXVersion(Major, Minor, Micro))
- getDriver().Diag(diag::err_drv_invalid_darwin_version) <<
- Triple.getOSName();
- llvm::raw_string_ostream(MacosxVersionMin)
- << Major << '.' << Minor << '.' << Micro;
-
- // Compute the initial iOS version from the triple
- Triple.getiOSVersion(Major, Minor, Micro);
- llvm::raw_string_ostream(iOSVersionMin)
- << Major << '.' << Minor << '.' << Micro;
-}
+Darwin::Darwin(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+ : MachO(D, Triple, Args), TargetInitialized(false) {}
types::ID MachO::LookupTypeForExtension(const char *Ext) const {
types::ID Ty = types::lookupTypeForExtension(Ext);
@@ -489,8 +475,8 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
} else if (!OSXVersion && !iOSVersion) {
// If no deployment target was specified on the command line, check for
// environment defines.
- StringRef OSXTarget;
- StringRef iOSTarget;
+ std::string OSXTarget;
+ std::string iOSTarget;
if (char *env = ::getenv("MACOSX_DEPLOYMENT_TARGET"))
OSXTarget = env;
if (char *env = ::getenv("IPHONEOS_DEPLOYMENT_TARGET"))
@@ -510,15 +496,24 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
}
// If no OSX or iOS target has been specified, try to guess platform
- // from arch name.
+ // from arch name and compute the version from the triple.
if (OSXTarget.empty() && iOSTarget.empty()) {
StringRef MachOArchName = getMachOArchName(Args);
+ unsigned Major, Minor, Micro;
if (MachOArchName == "armv7" || MachOArchName == "armv7s" ||
- MachOArchName == "arm64")
- iOSTarget = iOSVersionMin;
- else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
- MachOArchName != "armv7em")
- OSXTarget = MacosxVersionMin;
+ MachOArchName == "arm64") {
+ getTriple().getiOSVersion(Major, Minor, Micro);
+ llvm::raw_string_ostream(iOSTarget) << Major << '.' << Minor << '.'
+ << Micro;
+ } else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
+ MachOArchName != "armv7em") {
+ if (!getTriple().getMacOSXVersion(Major, Minor, Micro)) {
+ getDriver().Diag(diag::err_drv_invalid_darwin_version)
+ << getTriple().getOSName();
+ }
+ llvm::raw_string_ostream(OSXTarget) << Major << '.' << Minor << '.'
+ << Micro;
+ }
}
// Allow conflicts among OSX and iOS for historical reasons, but choose the
diff --git a/clang/lib/Driver/ToolChains.h b/clang/lib/Driver/ToolChains.h
index 1141b312c42..178734ba150 100644
--- a/clang/lib/Driver/ToolChains.h
+++ b/clang/lib/Driver/ToolChains.h
@@ -335,15 +335,6 @@ public:
mutable VersionTuple TargetVersion;
private:
- /// The default macosx-version-min of this tool chain; empty until
- /// initialized.
- std::string MacosxVersionMin;
-
- /// The default ios-version-min of this tool chain; empty until
- /// initialized.
- std::string iOSVersionMin;
-
-private:
void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const;
public:
OpenPOWER on IntegriCloud