diff options
author | Alex Lorenz <arphaman@gmail.com> | 2018-04-25 22:23:26 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2018-04-25 22:23:26 +0000 |
commit | 4e9e0e6011b2ac3fd5b18672906a95a7d65843d3 (patch) | |
tree | e6066d8140333bd35d51a91e507fa5bc74749e8d /lib/Driver/ToolChains/Darwin.cpp | |
parent | 948124636bd04f1a994eb419b5ede526b0d9de82 (diff) |
[driver][darwin] Do not infer -simulator environment for OS version env vars
with non-simulator SDKs
rdar://37955008
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330878 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains/Darwin.cpp')
-rw-r--r-- | lib/Driver/ToolChains/Darwin.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Driver/ToolChains/Darwin.cpp b/lib/Driver/ToolChains/Darwin.cpp index 2c1234c83a..394a43e835 100644 --- a/lib/Driver/ToolChains/Darwin.cpp +++ b/lib/Driver/ToolChains/Darwin.cpp @@ -1197,6 +1197,11 @@ struct DarwinPlatform { DarwinEnvironmentKind getEnvironment() const { return Environment; } + void setEnvironment(DarwinEnvironmentKind Kind) { + Environment = Kind; + InferSimulatorFromArch = false; + } + StringRef getOSVersion() const { if (Kind == OSVersionArg) return Argument->getValue(); @@ -1214,7 +1219,7 @@ struct DarwinPlatform { bool isExplicitlySpecified() const { return Kind <= DeploymentTargetEnv; } /// Returns true if the simulator environment can be inferred from the arch. - bool canInferSimulatorFromArch() const { return Kind != InferredFromSDK; } + bool canInferSimulatorFromArch() const { return InferSimulatorFromArch; } /// Adds the -m<os>-version-min argument to the compiler invocation. void addOSVersionMinArgument(DerivedArgList &Args, const OptTable &Opts) { @@ -1290,6 +1295,7 @@ struct DarwinPlatform { DarwinPlatform Result(InferredFromSDK, Platform, Value); if (IsSimulator) Result.Environment = DarwinEnvironmentKind::Simulator; + Result.InferSimulatorFromArch = false; return Result; } static DarwinPlatform createFromArch(llvm::Triple::OSType OS, @@ -1324,7 +1330,7 @@ private: DarwinPlatformKind Platform; DarwinEnvironmentKind Environment = DarwinEnvironmentKind::NativeEnvironment; std::string OSVersion; - bool HasOSVersion = true; + bool HasOSVersion = true, InferSimulatorFromArch = true; Arg *Argument; StringRef EnvVarName; }; @@ -1593,9 +1599,16 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { OSTarget = getDeploymentTargetFromOSVersionArg(Args, getDriver()); // If no deployment target was specified on the command line, check for // environment defines. - if (!OSTarget) + if (!OSTarget) { OSTarget = getDeploymentTargetFromEnvironmentVariables(getDriver(), getTriple()); + if (OSTarget) { + // Don't infer simulator from the arch when the SDK is also specified. + Optional<DarwinPlatform> SDKTarget = inferDeploymentTargetFromSDK(Args); + if (SDKTarget) + OSTarget->setEnvironment(SDKTarget->getEnvironment()); + } + } // If there is no command-line argument to specify the Target version and // no environment variable defined, see if we can set the default based // on -isysroot. |