Author: ahatanak Date: Wed Mar 15 13:04:13 2017 New Revision: 297866 URL: http://llvm.org/viewvc/llvm-project?rev=297866&view=rev Log: [Driver] Define macro __APPLE_EMBEDDED_SIMULATOR__ when option -m(i|tv|watch)os-simulator-version-min is on the command line.
Previously the driver would treat -m(i|tv|watch)os-simulator-version-min as an alias of -m(i|tv|watch)os-version-min. This no longer works since we now need to distinguish between the two options (the latter is used for iOS running in a VM, for example). This commit stops making the simulator options the aliases of the OS options and defines a macro to differentiate between the two groups of options. rdar://problem/28872911 Added: cfe/trunk/test/Driver/darwin-simulator-macro.c Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=297866&r1=297865&r2=297866&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Wed Mar 15 13:04:13 2017 @@ -1603,11 +1603,11 @@ def mpure_code : Flag<["-"], "mpure-code def mno_pure_code : Flag<["-"], "mno-pure-code">, Alias<mno_execute_only>; def mtvos_version_min_EQ : Joined<["-"], "mtvos-version-min=">, Group<m_Group>; def mappletvos_version_min_EQ : Joined<["-"], "mappletvos-version-min=">, Alias<mtvos_version_min_EQ>; -def mtvos_simulator_version_min_EQ : Joined<["-"], "mtvos-simulator-version-min=">, Alias<mtvos_version_min_EQ>; -def mappletvsimulator_version_min_EQ : Joined<["-"], "mappletvsimulator-version-min=">, Alias<mtvos_version_min_EQ>; +def mtvos_simulator_version_min_EQ : Joined<["-"], "mtvos-simulator-version-min=">; +def mappletvsimulator_version_min_EQ : Joined<["-"], "mappletvsimulator-version-min=">, Alias<mtvos_simulator_version_min_EQ>; def mwatchos_version_min_EQ : Joined<["-"], "mwatchos-version-min=">, Group<m_Group>; -def mwatchos_simulator_version_min_EQ : Joined<["-"], "mwatchos-simulator-version-min=">, Alias<mwatchos_version_min_EQ>; -def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min=">, Alias<mwatchos_version_min_EQ>; +def mwatchos_simulator_version_min_EQ : Joined<["-"], "mwatchos-simulator-version-min=">; +def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min=">, Alias<mwatchos_simulator_version_min_EQ>; def march_EQ : Joined<["-"], "march=">, Group<m_Group>; def masm_EQ : Joined<["-"], "masm=">, Group<m_Group>, Flags<[DriverOption]>; def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group<m_Group>; @@ -1636,8 +1636,8 @@ def mhard_float : Flag<["-"], "mhard-flo def miphoneos_version_min_EQ : Joined<["-"], "miphoneos-version-min=">, Group<m_Group>; def mios_version_min_EQ : Joined<["-"], "mios-version-min=">, Alias<miphoneos_version_min_EQ>, HelpText<"Set iOS deployment target">; -def mios_simulator_version_min_EQ : Joined<["-"], "mios-simulator-version-min=">, Alias<miphoneos_version_min_EQ>; -def miphonesimulator_version_min_EQ : Joined<["-"], "miphonesimulator-version-min=">, Alias<miphoneos_version_min_EQ>; +def mios_simulator_version_min_EQ : Joined<["-"], "mios-simulator-version-min=">; +def miphonesimulator_version_min_EQ : Joined<["-"], "miphonesimulator-version-min=">, Alias<mios_simulator_version_min_EQ>; def mkernel : Flag<["-"], "mkernel">, Group<m_Group>; def mlinker_version_EQ : Joined<["-"], "mlinker-version=">, Flags<[DriverOption]>; Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=297866&r1=297865&r2=297866&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Wed Mar 15 13:04:13 2017 @@ -1125,9 +1125,22 @@ void Darwin::AddDeploymentTarget(Derived } Arg *OSXVersion = Args.getLastArg(options::OPT_mmacosx_version_min_EQ); - Arg *iOSVersion = Args.getLastArg(options::OPT_miphoneos_version_min_EQ); - Arg *TvOSVersion = Args.getLastArg(options::OPT_mtvos_version_min_EQ); - Arg *WatchOSVersion = Args.getLastArg(options::OPT_mwatchos_version_min_EQ); + Arg *iOSVersion = Args.getLastArg(options::OPT_miphoneos_version_min_EQ, + options::OPT_mios_simulator_version_min_EQ); + Arg *TvOSVersion = + Args.getLastArg(options::OPT_mtvos_version_min_EQ, + options::OPT_mtvos_simulator_version_min_EQ); + Arg *WatchOSVersion = + Args.getLastArg(options::OPT_mwatchos_version_min_EQ, + options::OPT_mwatchos_simulator_version_min_EQ); + + // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y and + // -m(iphone|tv|watch)simulator-version-min=X.Y. + if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ) || + Args.hasArg(options::OPT_mtvos_simulator_version_min_EQ) || + Args.hasArg(options::OPT_mwatchos_simulator_version_min_EQ)) + Args.append(Args.MakeSeparateArg(nullptr, Opts.getOption(options::OPT_D), + " __APPLE_EMBEDDED_SIMULATOR__=1")); if (OSXVersion && (iOSVersion || TvOSVersion || WatchOSVersion)) { getDriver().Diag(diag::err_drv_argument_not_allowed_with) Added: cfe/trunk/test/Driver/darwin-simulator-macro.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-simulator-macro.c?rev=297866&view=auto ============================================================================== --- cfe/trunk/test/Driver/darwin-simulator-macro.c (added) +++ cfe/trunk/test/Driver/darwin-simulator-macro.c Wed Mar 15 13:04:13 2017 @@ -0,0 +1,12 @@ +// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mios-simulator-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s +// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -miphonesimulator-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s +// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mtvos-simulator-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s +// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mappletvsimulator-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s +// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mwatchos-simulator-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s +// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mwatchsimulator-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s +// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mios-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=DEV %s +// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mtvos-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=DEV %s +// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mwatchos-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=DEV %s + +// SIM: #define __APPLE_EMBEDDED_SIMULATOR__ 1 +// DEV-NOT: __APPLE_EMBEDDED_SIMULATOR__ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits