Revert r142311, -mios-simulator-version-min does not work correctly.
llvm-svn: 142322
This commit is contained in:
parent
8211c051ca
commit
697729a7de
|
@ -117,11 +117,54 @@ public:
|
||||||
|
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
static inline StringRef SimulatorVersionDefineName() {
|
||||||
|
return "__IPHONE_OS_VERSION_MIN_REQUIRED=";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \brief Parse the simulator version define:
|
||||||
|
/// __IPHONE_OS_VERSION_MIN_REQUIRED=([0-9])([0-9][0-9])([0-9][0-9])
|
||||||
|
// and return the grouped values as integers, e.g:
|
||||||
|
// __IPHONE_OS_VERSION_MIN_REQUIRED=40201
|
||||||
|
// will return Major=4, Minor=2, Micro=1.
|
||||||
|
static bool GetVersionFromSimulatorDefine(StringRef define,
|
||||||
|
unsigned &Major, unsigned &Minor,
|
||||||
|
unsigned &Micro) {
|
||||||
|
assert(define.startswith(SimulatorVersionDefineName()));
|
||||||
|
StringRef name, version;
|
||||||
|
llvm::tie(name, version) = define.split('=');
|
||||||
|
if (version.empty())
|
||||||
|
return false;
|
||||||
|
std::string verstr = version.str();
|
||||||
|
char *end;
|
||||||
|
unsigned num = (unsigned) strtol(verstr.c_str(), &end, 10);
|
||||||
|
if (*end != '\0')
|
||||||
|
return false;
|
||||||
|
Major = num / 10000;
|
||||||
|
num = num % 10000;
|
||||||
|
Minor = num / 100;
|
||||||
|
Micro = num % 100;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool HasARCRuntime(CompilerInvocation &origCI) {
|
static bool HasARCRuntime(CompilerInvocation &origCI) {
|
||||||
// This duplicates some functionality from Darwin::AddDeploymentTarget
|
// This duplicates some functionality from Darwin::AddDeploymentTarget
|
||||||
// but this function is well defined, so keep it decoupled from the driver
|
// but this function is well defined, so keep it decoupled from the driver
|
||||||
// and avoid unrelated complications.
|
// and avoid unrelated complications.
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = origCI.getPreprocessorOpts().Macros.size();
|
||||||
|
i != e; ++i) {
|
||||||
|
StringRef define = origCI.getPreprocessorOpts().Macros[i].first;
|
||||||
|
bool isUndef = origCI.getPreprocessorOpts().Macros[i].second;
|
||||||
|
if (isUndef)
|
||||||
|
continue;
|
||||||
|
if (!define.startswith(SimulatorVersionDefineName()))
|
||||||
|
continue;
|
||||||
|
unsigned Major = 0, Minor = 0, Micro = 0;
|
||||||
|
if (GetVersionFromSimulatorDefine(define, Major, Minor, Micro) &&
|
||||||
|
Major < 10 && Minor < 100 && Micro < 100)
|
||||||
|
return Major >= 5;
|
||||||
|
}
|
||||||
|
|
||||||
llvm::Triple triple(origCI.getTargetOpts().Triple);
|
llvm::Triple triple(origCI.getTargetOpts().Triple);
|
||||||
|
|
||||||
if (triple.getOS() == llvm::Triple::IOS)
|
if (triple.getOS() == llvm::Triple::IOS)
|
||||||
|
|
|
@ -454,6 +454,35 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline StringRef SimulatorVersionDefineName() {
|
||||||
|
return "__IPHONE_OS_VERSION_MIN_REQUIRED";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \brief Parse the simulator version define:
|
||||||
|
/// __IPHONE_OS_VERSION_MIN_REQUIRED=([0-9])([0-9][0-9])([0-9][0-9])
|
||||||
|
// and return the grouped values as integers, e.g:
|
||||||
|
// __IPHONE_OS_VERSION_MIN_REQUIRED=40201
|
||||||
|
// will return Major=4, Minor=2, Micro=1.
|
||||||
|
static bool GetVersionFromSimulatorDefine(StringRef define,
|
||||||
|
unsigned &Major, unsigned &Minor,
|
||||||
|
unsigned &Micro) {
|
||||||
|
assert(define.startswith(SimulatorVersionDefineName()));
|
||||||
|
StringRef name, version;
|
||||||
|
llvm::tie(name, version) = define.split('=');
|
||||||
|
if (version.empty())
|
||||||
|
return false;
|
||||||
|
std::string verstr = version.str();
|
||||||
|
char *end;
|
||||||
|
unsigned num = (unsigned) strtol(verstr.c_str(), &end, 10);
|
||||||
|
if (*end != '\0')
|
||||||
|
return false;
|
||||||
|
Major = num / 10000;
|
||||||
|
num = num % 10000;
|
||||||
|
Minor = num / 100;
|
||||||
|
Micro = num % 100;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
|
void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
|
||||||
const OptTable &Opts = getDriver().getOpts();
|
const OptTable &Opts = getDriver().getOpts();
|
||||||
|
|
||||||
|
@ -462,6 +491,28 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
|
||||||
Arg *iOSSimVersion = Args.getLastArg(
|
Arg *iOSSimVersion = Args.getLastArg(
|
||||||
options::OPT_mios_simulator_version_min_EQ);
|
options::OPT_mios_simulator_version_min_EQ);
|
||||||
|
|
||||||
|
// FIXME: HACK! When compiling for the simulator we don't get a
|
||||||
|
// '-miphoneos-version-min' to help us know whether there is an ARC runtime
|
||||||
|
// or not; try to parse a __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||||
|
// define passed in command-line.
|
||||||
|
if (!iOSVersion) {
|
||||||
|
for (arg_iterator it = Args.filtered_begin(options::OPT_D),
|
||||||
|
ie = Args.filtered_end(); it != ie; ++it) {
|
||||||
|
StringRef define = (*it)->getValue(Args);
|
||||||
|
if (define.startswith(SimulatorVersionDefineName())) {
|
||||||
|
unsigned Major = 0, Minor = 0, Micro = 0;
|
||||||
|
if (GetVersionFromSimulatorDefine(define, Major, Minor, Micro) &&
|
||||||
|
Major < 10 && Minor < 100 && Micro < 100) {
|
||||||
|
ARCRuntimeForSimulator = Major < 5 ? ARCSimulator_NoARCRuntime
|
||||||
|
: ARCSimulator_HasARCRuntime;
|
||||||
|
LibCXXForSimulator = Major < 5 ? LibCXXSimulator_NotAvailable
|
||||||
|
: LibCXXSimulator_Available;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (OSXVersion && (iOSVersion || iOSSimVersion)) {
|
if (OSXVersion && (iOSVersion || iOSSimVersion)) {
|
||||||
getDriver().Diag(diag::err_drv_argument_not_allowed_with)
|
getDriver().Diag(diag::err_drv_argument_not_allowed_with)
|
||||||
<< OSXVersion->getAsString(Args)
|
<< OSXVersion->getAsString(Args)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// RUN: %clang -### -x objective-c -ccc-host-triple i386-apple-darwin10 -arch i386 -mios-simulator-version-min=4.2 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
|
// RUN: %clang -### -x objective-c -ccc-host-triple i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=40201 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
|
||||||
// RUN: %clang -### -x objective-c -ccc-host-triple i386-apple-darwin10 -arch i386 -mios-simulator-version-min=5 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
|
// RUN: %clang -### -x objective-c -ccc-host-triple i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
|
||||||
//
|
//
|
||||||
|
|
||||||
// CHECK-OPTIONS1-NOT: -fobjc-runtime-has-weak
|
// CHECK-OPTIONS1-NOT: -fobjc-runtime-has-weak
|
||||||
|
|
Loading…
Reference in New Issue