Support watchOS and tvOS driver options

This patch should add support for almost all command-line options and
driver tinkering necessary to produce a correct "clang -cc1"
invocation for watchOS and tvOS.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251706 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tim Northover 2015-10-30 16:30:27 +00:00
parent e8d1c0c78e
commit 56c5241273
15 changed files with 353 additions and 40 deletions

View File

@ -102,6 +102,8 @@ def err_drv_cc_print_options_failure : Error<
"unable to open CC_PRINT_OPTIONS file: %0">;
def err_drv_preamble_format : Error<
"incorrect format for -preamble-bytes=N,END">;
def err_drv_conflicting_deployment_targets : Error<
"conflicting deployment targets, both '%0' and '%1' are present in environment">;
def err_drv_objc_gc_arr : Error<
"cannot specify both '-fobjc-arc' and '%0'">;
def err_arc_unsupported_on_runtime : Error<

View File

@ -1227,6 +1227,13 @@ def malign_functions_EQ : Joined<["-"], "malign-functions=">, Group<clang_ignore
def malign_loops_EQ : Joined<["-"], "malign-loops=">, Group<clang_ignored_m_Group>;
def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, Group<clang_ignored_m_Group>;
def mfancy_math_387 : Flag<["-"], "mfancy-math-387">, Group<clang_ignored_m_Group>;
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 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 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>;

View File

@ -2225,6 +2225,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
case llvm::Triple::Darwin:
case llvm::Triple::MacOSX:
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
TC = new toolchains::DarwinClang(*this, Target, Args);
break;
case llvm::Triple::DragonFly:

View File

@ -67,6 +67,10 @@ bool MachO::HasNativeLLVMSupport() const { return true; }
/// Darwin provides an ARC runtime starting in MacOS X 10.7 and iOS 5.0.
ObjCRuntime Darwin::getDefaultObjCRuntime(bool isNonFragile) const {
if (isTargetWatchOSBased())
// FIXME: not quite iOS because of version mismatch. Choose something for
// now.
return ObjCRuntime(ObjCRuntime::iOS, TargetVersion);
if (isTargetIOSBased())
return ObjCRuntime(ObjCRuntime::iOS, TargetVersion);
if (isNonFragile)
@ -76,7 +80,9 @@ ObjCRuntime Darwin::getDefaultObjCRuntime(bool isNonFragile) const {
/// Darwin provides a blocks runtime starting in MacOS X 10.6 and iOS 3.2.
bool Darwin::hasBlocksRuntime() const {
if (isTargetIOSBased())
if (isTargetWatchOSBased())
return true;
else if (isTargetIOSBased())
return !isIPhoneOSVersionLT(3, 2);
else {
assert(isTargetMacOS() && "unexpected darwin target");
@ -178,7 +184,14 @@ std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args,
return Triple.getTriple();
SmallString<16> Str;
Str += isTargetIOSBased() ? "ios" : "macosx";
if (isTargetWatchOSBased())
Str += "watchos";
else if (isTargetTvOSBased())
Str += "tvos";
else if (isTargetIOSBased())
Str += "ios";
else
Str += "macosx";
Str += getTargetVersion().getAsString();
Triple.setOSName(Str);
@ -217,16 +230,17 @@ DarwinClang::DarwinClang(const Driver &D, const llvm::Triple &Triple,
: Darwin(D, Triple, Args) {}
void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const {
// For iOS, 64-bit, promote certain warnings to errors.
if (!isTargetMacOS() && getTriple().isArch64Bit()) {
// For modern targets, promote certain warnings to errors.
if (isTargetWatchOSBased() || getTriple().isArch64Bit()) {
// Always enable -Wdeprecated-objc-isa-usage and promote it
// to an error.
CC1Args.push_back("-Wdeprecated-objc-isa-usage");
CC1Args.push_back("-Werror=deprecated-objc-isa-usage");
// Also error about implicit function declarations, as that
// can impact calling conventions.
CC1Args.push_back("-Werror=implicit-function-declaration");
// For iOS and watchOS, also error about implicit function declarations,
// as that can impact calling conventions.
if (!isTargetMacOS())
CC1Args.push_back("-Werror=implicit-function-declaration");
}
}
@ -254,7 +268,15 @@ void DarwinClang::AddLinkARCArgs(const ArgList &Args,
llvm::sys::path::remove_filename(P); // 'bin'
llvm::sys::path::append(P, "lib", "arc", "libarclite_");
// Mash in the platform.
if (isTargetIOSSimulator())
if (isTargetWatchOSSimulator())
P += "watchsimulator";
else if (isTargetWatchOS())
P += "watchos";
else if (isTargetTvOSSimulator())
P += "appletvsimulator";
else if (isTargetTvOS())
P += "appletvos";
else if (isTargetIOSSimulator())
P += "iphonesimulator";
else if (isTargetIPhoneOS())
P += "iphoneos";
@ -321,6 +343,7 @@ void DarwinClang::AddLinkSanitizerLibArgs(const ArgList &Args,
// Sanitizer runtime libraries requires C++.
AddCXXStdlibLibArgs(Args, CmdArgs);
}
// ASan is not supported on watchOS.
assert(isTargetMacOS() || isTargetIOSSimulator());
StringRef OS = isTargetMacOS() ? "osx" : "iossim";
AddLinkRuntimeLib(
@ -374,7 +397,13 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
CmdArgs.push_back("-lSystem");
// Select the dynamic runtime library and the target specific static library.
if (isTargetIOSBased()) {
if (isTargetWatchOSBased()) {
// We currently always need a static runtime library for watchOS.
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.watchos.a");
} else if (isTargetTvOSBased()) {
// We currently always need a static runtime library for tvOS.
AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.tvos.a");
} else if (isTargetIOSBased()) {
// If we are compiling as iOS / simulator, don't attempt to link libgcc_s.1,
// it never went into the SDK.
// Linking against libgcc_s.1 isn't needed for iOS 5.0+
@ -435,25 +464,46 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
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);
if (OSXVersion && iOSVersion) {
if (OSXVersion && (iOSVersion || TvOSVersion || WatchOSVersion)) {
getDriver().Diag(diag::err_drv_argument_not_allowed_with)
<< OSXVersion->getAsString(Args) << iOSVersion->getAsString(Args);
iOSVersion = nullptr;
} else if (!OSXVersion && !iOSVersion) {
<< OSXVersion->getAsString(Args)
<< (iOSVersion ? iOSVersion :
TvOSVersion ? TvOSVersion : WatchOSVersion)->getAsString(Args);
iOSVersion = TvOSVersion = WatchOSVersion = nullptr;
} else if (iOSVersion && (TvOSVersion || WatchOSVersion)) {
getDriver().Diag(diag::err_drv_argument_not_allowed_with)
<< iOSVersion->getAsString(Args)
<< (TvOSVersion ? TvOSVersion : WatchOSVersion)->getAsString(Args);
TvOSVersion = WatchOSVersion = nullptr;
} else if (TvOSVersion && WatchOSVersion) {
getDriver().Diag(diag::err_drv_argument_not_allowed_with)
<< TvOSVersion->getAsString(Args)
<< WatchOSVersion->getAsString(Args);
WatchOSVersion = nullptr;
} else if (!OSXVersion && !iOSVersion && !TvOSVersion && !WatchOSVersion) {
// If no deployment target was specified on the command line, check for
// environment defines.
std::string OSXTarget;
std::string iOSTarget;
std::string TvOSTarget;
std::string WatchOSTarget;
if (char *env = ::getenv("MACOSX_DEPLOYMENT_TARGET"))
OSXTarget = env;
if (char *env = ::getenv("IPHONEOS_DEPLOYMENT_TARGET"))
iOSTarget = env;
if (char *env = ::getenv("TVOS_DEPLOYMENT_TARGET"))
TvOSTarget = env;
if (char *env = ::getenv("WATCHOS_DEPLOYMENT_TARGET"))
WatchOSTarget = env;
// 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.
if (iOSTarget.empty() && OSXTarget.empty() &&
if (OSXTarget.empty() && iOSTarget.empty() && WatchOSTarget.empty() &&
Args.hasArg(options::OPT_isysroot)) {
if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
StringRef isysroot = A->getValue();
@ -473,6 +523,12 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
iOSTarget = Version;
else if (SDK.startswith("MacOSX"))
OSXTarget = Version;
else if (SDK.startswith("WatchOS") ||
SDK.startswith("WatchSimulator"))
WatchOSTarget = Version;
else if (SDK.startswith("AppleTVOS") ||
SDK.startswith("AppleTVSimulator"))
TvOSTarget = Version;
}
}
}
@ -480,7 +536,8 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
// If no OSX or iOS target has been specified, try to guess platform
// from arch name and compute the version from the triple.
if (OSXTarget.empty() && iOSTarget.empty()) {
if (OSXTarget.empty() && iOSTarget.empty() && TvOSTarget.empty() &&
WatchOSTarget.empty()) {
StringRef MachOArchName = getMachOArchName(Args);
unsigned Major, Minor, Micro;
if (MachOArchName == "armv7" || MachOArchName == "armv7s" ||
@ -488,6 +545,10 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
getTriple().getiOSVersion(Major, Minor, Micro);
llvm::raw_string_ostream(iOSTarget) << Major << '.' << Minor << '.'
<< Micro;
} else if (MachOArchName == "armv7k") {
getTriple().getWatchOSVersion(Major, Minor, Micro);
llvm::raw_string_ostream(WatchOSTarget) << Major << '.' << Minor << '.'
<< Micro;
} else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
MachOArchName != "armv7em") {
if (!getTriple().getMacOSXVersion(Major, Minor, Micro)) {
@ -499,15 +560,32 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
}
}
// Do not allow conflicts with the watchOS target.
if (!WatchOSTarget.empty() && (!iOSTarget.empty() || !TvOSTarget.empty())) {
getDriver().Diag(diag::err_drv_conflicting_deployment_targets)
<< "WATCHOS_DEPLOYMENT_TARGET"
<< (!iOSTarget.empty() ? "IPHONEOS_DEPLOYMENT_TARGET" :
"TVOS_DEPLOYMENT_TARGET");
}
// Do not allow conflicts with the tvOS target.
if (!TvOSTarget.empty() && !iOSTarget.empty()) {
getDriver().Diag(diag::err_drv_conflicting_deployment_targets)
<< "TVOS_DEPLOYMENT_TARGET"
<< "IPHONEOS_DEPLOYMENT_TARGET";
}
// Allow conflicts among OSX and iOS for historical reasons, but choose the
// default platform.
if (!OSXTarget.empty() && !iOSTarget.empty()) {
if (!OSXTarget.empty() && (!iOSTarget.empty() ||
!WatchOSTarget.empty() ||
!TvOSTarget.empty())) {
if (getTriple().getArch() == llvm::Triple::arm ||
getTriple().getArch() == llvm::Triple::aarch64 ||
getTriple().getArch() == llvm::Triple::thumb)
OSXTarget = "";
else
iOSTarget = "";
iOSTarget = WatchOSTarget = TvOSTarget = "";
}
if (!OSXTarget.empty()) {
@ -518,6 +596,14 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
const Option O = Opts.getOption(options::OPT_miphoneos_version_min_EQ);
iOSVersion = Args.MakeJoinedArg(nullptr, O, iOSTarget);
Args.append(iOSVersion);
} else if (!TvOSTarget.empty()) {
const Option O = Opts.getOption(options::OPT_mtvos_version_min_EQ);
TvOSVersion = Args.MakeJoinedArg(nullptr, O, TvOSTarget);
Args.append(TvOSVersion);
} else if (!WatchOSTarget.empty()) {
const Option O = Opts.getOption(options::OPT_mwatchos_version_min_EQ);
WatchOSVersion = Args.MakeJoinedArg(nullptr, O, WatchOSTarget);
Args.append(WatchOSVersion);
}
}
@ -526,6 +612,10 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
Platform = MacOS;
else if (iOSVersion)
Platform = IPhoneOS;
else if (TvOSVersion)
Platform = TvOS;
else if (WatchOSVersion)
Platform = WatchOS;
else
llvm_unreachable("Unable to infer Darwin variant");
@ -533,7 +623,8 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
unsigned Major, Minor, Micro;
bool HadExtra;
if (Platform == MacOS) {
assert(!iOSVersion && "Unknown target platform!");
assert((!iOSVersion && !TvOSVersion && !WatchOSVersion) &&
"Unknown target platform!");
if (!Driver::GetReleaseVersion(OSXVersion->getValue(), Major, Minor, Micro,
HadExtra) ||
HadExtra || Major != 10 || Minor >= 100 || Micro >= 100)
@ -546,6 +637,18 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
HadExtra || Major >= 10 || Minor >= 100 || Micro >= 100)
getDriver().Diag(diag::err_drv_invalid_version_number)
<< iOSVersion->getAsString(Args);
} else if (Platform == TvOS) {
if (!Driver::GetReleaseVersion(TvOSVersion->getValue(), Major, Minor,
Micro, HadExtra) || HadExtra ||
Major >= 10 || Minor >= 100 || Micro >= 100)
getDriver().Diag(diag::err_drv_invalid_version_number)
<< TvOSVersion->getAsString(Args);
} else if (Platform == WatchOS) {
if (!Driver::GetReleaseVersion(WatchOSVersion->getValue(), Major, Minor,
Micro, HadExtra) || HadExtra ||
Major >= 10 || Minor >= 100 || Micro >= 100)
getDriver().Diag(diag::err_drv_invalid_version_number)
<< WatchOSVersion->getAsString(Args);
} else
llvm_unreachable("unknown kind of Darwin platform");
@ -553,6 +656,12 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
if (iOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||
getTriple().getArch() == llvm::Triple::x86_64))
Platform = IPhoneOSSimulator;
if (TvOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||
getTriple().getArch() == llvm::Triple::x86_64))
Platform = TvOSSimulator;
if (WatchOSVersion && (getTriple().getArch() == llvm::Triple::x86 ||
getTriple().getArch() == llvm::Triple::x86_64))
Platform = WatchOSSimulator;
setTarget(Platform, Major, Minor, Micro);
}
@ -613,7 +722,11 @@ void DarwinClang::AddCCKextLibArgs(const ArgList &Args,
llvm::sys::path::append(P, "lib", "darwin");
// Use the newer cc_kext for iOS ARM after 6.0.
if (isTargetIPhoneOS()) {
if (isTargetWatchOS()) {
llvm::sys::path::append(P, "libclang_rt.cc_kext_watchos.a");
} else if (isTargetTvOS()) {
llvm::sys::path::append(P, "libclang_rt.cc_kext_tvos.a");
} else if (isTargetIPhoneOS()) {
llvm::sys::path::append(P, "libclang_rt.cc_kext_ios.a");
} else {
llvm::sys::path::append(P, "libclang_rt.cc_kext.a");
@ -874,8 +987,9 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
// FIXME: It would be far better to avoid inserting those -static arguments,
// but we can't check the deployment target in the translation code until
// it is set here.
if (isTargetIOSBased() && !isIPhoneOSVersionLT(6, 0)) {
for (ArgList::iterator it = DAL->begin(), ie = DAL->end(); it != ie;) {
if (isTargetWatchOSBased() ||
(isTargetIOSBased() && !isIPhoneOSVersionLT(6, 0))) {
for (ArgList::iterator it = DAL->begin(), ie = DAL->end(); it != ie; ) {
Arg *A = *it;
++it;
if (A->getOption().getID() != options::OPT_mkernel &&
@ -891,7 +1005,8 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
// Default to use libc++ on OS X 10.9+ and iOS 7+.
if (((isTargetMacOS() && !isMacosxVersionLT(10, 9)) ||
(isTargetIOSBased() && !isIPhoneOSVersionLT(7, 0))) &&
(isTargetIOSBased() && !isIPhoneOSVersionLT(7, 0)) ||
isTargetWatchOSBased()) &&
!Args.getLastArg(options::OPT_stdlib_EQ))
DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_stdlib_EQ),
"libc++");
@ -948,7 +1063,15 @@ void Darwin::addMinVersionArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
VersionTuple TargetVersion = getTargetVersion();
if (isTargetIOSSimulator())
if (isTargetWatchOS())
CmdArgs.push_back("-watchos_version_min");
else if (isTargetWatchOSSimulator())
CmdArgs.push_back("-watchos_simulator_version_min");
else if (isTargetTvOS())
CmdArgs.push_back("-tvos_version_min");
else if (isTargetTvOSSimulator())
CmdArgs.push_back("-tvos_simulator_version_min");
else if (isTargetIOSSimulator())
CmdArgs.push_back("-ios_simulator_version_min");
else if (isTargetIOSBased())
CmdArgs.push_back("-iphoneos_version_min");
@ -965,7 +1088,9 @@ void Darwin::addStartObjectFileArgs(const ArgList &Args,
// Derived from startfile spec.
if (Args.hasArg(options::OPT_dynamiclib)) {
// Derived from darwin_dylib1 spec.
if (isTargetIOSSimulator()) {
if (isTargetWatchOSBased()) {
; // watchOS does not need dylib1.o.
} else if (isTargetIOSSimulator()) {
; // iOS simulator does not need dylib1.o.
} else if (isTargetIPhoneOS()) {
if (isIPhoneOSVersionLT(3, 1))
@ -980,7 +1105,9 @@ void Darwin::addStartObjectFileArgs(const ArgList &Args,
if (Args.hasArg(options::OPT_bundle)) {
if (!Args.hasArg(options::OPT_static)) {
// Derived from darwin_bundle1 spec.
if (isTargetIOSSimulator()) {
if (isTargetWatchOSBased()) {
; // watchOS does not need bundle1.o.
} else if (isTargetIOSSimulator()) {
; // iOS simulator does not need bundle1.o.
} else if (isTargetIPhoneOS()) {
if (isIPhoneOSVersionLT(3, 1))
@ -1015,7 +1142,9 @@ void Darwin::addStartObjectFileArgs(const ArgList &Args,
CmdArgs.push_back("-lcrt0.o");
} else {
// Derived from darwin_crt1 spec.
if (isTargetIOSSimulator()) {
if (isTargetWatchOSBased()) {
; // watchOS does not need crt1.o.
} else if (isTargetIOSSimulator()) {
; // iOS simulator does not need crt1.o.
} else if (isTargetIPhoneOS()) {
if (getArch() == llvm::Triple::aarch64)
@ -1040,6 +1169,7 @@ void Darwin::addStartObjectFileArgs(const ArgList &Args,
}
if (!isTargetIPhoneOS() && Args.hasArg(options::OPT_shared_libgcc) &&
!isTargetWatchOS() &&
isMacosxVersionLT(10, 5)) {
const char *Str = Args.MakeArgString(GetFilePath("crt3.o"));
CmdArgs.push_back(Str);
@ -1049,7 +1179,8 @@ void Darwin::addStartObjectFileArgs(const ArgList &Args,
bool Darwin::SupportsObjCGC() const { return isTargetMacOS(); }
void Darwin::CheckObjCARC() const {
if (isTargetIOSBased() || (isTargetMacOS() && !isMacosxVersionLT(10, 6)))
if (isTargetIOSBased() || isTargetWatchOSBased() ||
(isTargetMacOS() && !isMacosxVersionLT(10, 6)))
return;
getDriver().Diag(diag::err_arc_unsupported_on_toolchain);
}

View File

@ -354,7 +354,15 @@ public:
// the argument translation business.
mutable bool TargetInitialized;
enum DarwinPlatformKind { MacOS, IPhoneOS, IPhoneOSSimulator };
enum DarwinPlatformKind {
MacOS,
IPhoneOS,
IPhoneOSSimulator,
TvOS,
TvOSSimulator,
WatchOS,
WatchOSSimulator
};
mutable DarwinPlatformKind TargetPlatform;
@ -382,7 +390,8 @@ public:
llvm::opt::ArgStringList &CmdArgs) const override;
bool isKernelStatic() const override {
return !isTargetIPhoneOS() || isIPhoneOSVersionLT(6, 0);
return (!(isTargetIPhoneOS() && !isIPhoneOSVersionLT(6, 0)) &&
!isTargetWatchOS());
}
void addProfileRTLibs(const llvm::opt::ArgList &Args,
@ -411,12 +420,13 @@ protected:
bool isTargetIPhoneOS() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == IPhoneOS;
return TargetPlatform == IPhoneOS || TargetPlatform == TvOS;
}
bool isTargetIOSSimulator() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == IPhoneOSSimulator;
return TargetPlatform == IPhoneOSSimulator ||
TargetPlatform == TvOSSimulator;
}
bool isTargetIOSBased() const {
@ -424,6 +434,36 @@ protected:
return isTargetIPhoneOS() || isTargetIOSSimulator();
}
bool isTargetTvOS() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == TvOS;
}
bool isTargetTvOSSimulator() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == TvOSSimulator;
}
bool isTargetTvOSBased() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == TvOS || TargetPlatform == TvOSSimulator;
}
bool isTargetWatchOS() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == WatchOS;
}
bool isTargetWatchOSSimulator() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == WatchOSSimulator;
}
bool isTargetWatchOSBased() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == WatchOS || TargetPlatform == WatchOSSimulator;
}
bool isTargetMacOS() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == MacOS;
@ -474,7 +514,7 @@ public:
unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
// Stack protectors default to on for user code on 10.5,
// and for everything in 10.6 and beyond
if (isTargetIOSBased())
if (isTargetIOSBased() || isTargetWatchOSBased())
return 1;
else if (isTargetMacOS() && !isMacosxVersionLT(10, 6))
return 1;

View File

@ -3128,7 +3128,8 @@ ParsePICArgs(const ToolChain &ToolChain, const llvm::Triple &Triple,
// This kernel flags are a trump-card: they will disable PIC/PIE
// generation, independent of the argument order.
if (KernelOrKext && (!Triple.isiOS() || Triple.isOSVersionLT(6)))
if (KernelOrKext && ((!Triple.isiOS() || Triple.isOSVersionLT(6)) &&
!Triple.isWatchOS()))
PIC = PIE = false;
if (Arg *A = Args.getLastArg(options::OPT_mdynamic_no_pic)) {
@ -6232,7 +6233,11 @@ StringRef arm::getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch,
// extract arch from default cpu of the Triple
ArchKind = llvm::ARM::parseCPUArch(Triple.getARMCPUForArch(ARMArch));
} else {
ArchKind = llvm::ARM::parseCPUArch(CPU);
// FIXME: horrible hack to get around the fact that Cortex-A7 is only an
// armv7k triple if it's actually been specified via "-arch armv7k".
ArchKind = (Arch == "armv7k" || Arch == "thumbv7k")
? llvm::ARM::AK_ARMV7K
: llvm::ARM::parseCPUArch(CPU);
}
if (ArchKind == llvm::ARM::AK_INVALID)
return "";

View File

@ -522,7 +522,8 @@ void CallAndMessageChecker::emitNilReceiverBug(CheckerContext &C,
static bool supportsNilWithFloatRet(const llvm::Triple &triple) {
return (triple.getVendor() == llvm::Triple::Apple &&
(triple.isiOS() || !triple.isMacOSXVersionLT(10,5)));
(triple.isiOS() || triple.isWatchOS() ||
!triple.isMacOSXVersionLT(10,5)));
}
void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C,

View File

@ -26,3 +26,7 @@
// RUN: %clang -target x86_64-apple-darwin10 \
// RUN: -Werror -fno-builtin -fno-exceptions -fno-common -fno-rtti \
// RUN: -mkernel -fsyntax-only %s
// RUN: %clang -c %s -target armv7k-apple-watchos -fapple-kext -mwatchos-version-min=1.0.0 -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-WATCH
// CHECK-WATCH-NOT: "-backend-option" "-arm-long-calls"

View File

@ -0,0 +1,4 @@
// Tests that make sure armv7k is mapped to the correct CPU
// RUN: %clang -target x86_64-apple-macosx10.9 -arch armv7k -c %s -### 2>&1 | FileCheck %s
// CHECK: "-cc1"{{.*}} "-target-cpu" "cortex-a7"

View File

@ -152,6 +152,70 @@
// RUN: FileCheck -check-prefix=LINK_NO_IOS_ARM64_CRT1 %s < %t.log
// LINK_NO_IOS_ARM64_CRT1-NOT: crt
// RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
// LINK_TVOS_ARM64: {{ld(.exe)?"}}
// LINK_TVOS_ARM64: -tvos_version_min
// LINK_TVOS_ARM64-NOT: crt
// LINK_TVOS_ARM64-NOT: lgcc_s.1
// FIXME: This library does not get built unless the tvOS SDK is
// installed, and the driver will not try to link it if it does not exist.
// This should be reenabled when the tvOS SDK becomes a standard part
// of Xcode.
// FIXME_LINK_TVOS_ARM64: libclang_rt.tvos.a
// RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -fprofile-instr-generate -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_TVOS_PROFILE %s < %t.log
// LINK_TVOS_PROFILE: {{ld(.exe)?"}}
// FIXME: These libraries do not get built unless the tvOS SDK is
// installed, and the driver will not try to link them if they do not exist.
// This should be reenabled when the tvOS SDK becomes a standard part
// of Xcode.
// FIXME_LINK_TVOS_PROFILE: libclang_rt.profile_tvos.a
// FIXME_LINK_TVOS_PROFILE: libclang_rt.tvos.a
// RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -### %t.o -lcc_kext 2> %t.log
// RUN: FileCheck -check-prefix=LINK_TVOS_KEXT %s < %t.log
// LINK_TVOS_KEXT: {{ld(.exe)?"}}
// FIXME: These libraries do not get built unless the tvOS SDK is
// installed, and the driver will not try to link them if they do not exist.
// This should be reenabled when the tvOS SDK becomes a standard part
// of Xcode.
// FIXME_LINK_TVOS_KEXT: libclang_rt.cc_kext_tvos.a
// FIXME_LINK_TVOS_KEXT: libclang_rt.tvos.a
// RUN: %clang -target armv7k-apple-watchos2.0 -mwatchos-version-min=2.0 -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_WATCHOS_ARM %s < %t.log
// LINK_WATCHOS_ARM: {{ld(.exe)?"}}
// LINK_WATCHOS_ARM: -watchos_version_min
// LINK_WATCHOS_ARM-NOT: crt
// LINK_WATCHOS_ARM-NOT: lgcc_s.1
// FIXME: This library does not get built unless the watchOS SDK is
// installed, and the driver will not try to link it if it does not exist.
// This should be reenabled when the watchOS SDK becomes a standard part
// of Xcode.
// FIXME_LINK_WATCHOS_ARM: libclang_rt.watchos.a
// RUN: %clang -target armv7k-apple-watchos2.0 -mwatchos-version-min=2.0 -fprofile-instr-generate -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_WATCHOS_PROFILE %s < %t.log
// LINK_WATCHOS_PROFILE: {{ld(.exe)?"}}
// FIXME: These libraries do not get built unless the watchOS SDK is
// installed, and the driver will not try to link them if they do not exist.
// This should be reenabled when the watchOS SDK becomes a standard part
// of Xcode.
// FIXME_LINK_WATCHOS_PROFILE: libclang_rt.profile_watchos.a
// FIXME_LINK_WATCHOS_PROFILE: libclang_rt.watchos.a
// RUN: %clang -target armv7k-apple-watchos2.0 -mwatchos-version-min=2.0 -### %t.o -lcc_kext 2> %t.log
// RUN: FileCheck -check-prefix=LINK_WATCHOS_KEXT %s < %t.log
// LINK_WATCHOS_KEXT: {{ld(.exe)?"}}
// FIXME: These libraries do not get built unless the watchOS SDK is
// installed, and the driver will not try to link them if they do not exist.
// This should be reenabled when the watchOS SDK becomes a standard part
// of Xcode.
// FIXME_LINK_WATCHOS_KEXT: libclang_rt.cc_kext_watchos.a
// FIXME_LINK_WATCHOS_KEXT: libclang_rt.watchos.a
// RUN: %clang -target i386-apple-darwin12 -pg -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_PG %s < %t.log
// LINK_PG: -lgcrt1.o
@ -205,6 +269,26 @@
// LINK_IPHONEOS_VERSION_MIN: -iphoneos_version_min
// LINK_IOS_SIMULATOR_VERSION_MIN: -ios_simulator_version_min
// Ditto for tvOS....
// RUN: env TVOS_DEPLOYMENT_TARGET=7.0 \
// RUN: %clang -target armv7-apple-darwin -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_TVOS_VERSION_MIN %s < %t.log
// RUN: env TVOS_DEPLOYMENT_TARGET=7.0 \
// RUN: %clang -target x86_64-apple-darwin -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_TVOS_SIMULATOR_VERSION_MIN %s < %t.log
// LINK_TVOS_VERSION_MIN: -tvos_version_min
// LINK_TVOS_SIMULATOR_VERSION_MIN: -tvos_simulator_version_min
// ...and for watchOS.
// RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
// RUN: %clang -target armv7k-apple-darwin -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_WATCHOS_VERSION_MIN %s < %t.log
// RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
// RUN: %clang -target i386-apple-darwin -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_WATCHOS_SIMULATOR_VERSION_MIN %s < %t.log
// LINK_WATCHOS_VERSION_MIN: -watchos_version_min
// LINK_WATCHOS_SIMULATOR_VERSION_MIN: -watchos_simulator_version_min
// Check -iframework gets forward to ld as -F
// RUN: %clang -target x86_64-apple-darwin %s -iframework Bar -framework Foo -### 2>&1 | \
// RUN: FileCheck --check-prefix=LINK-IFRAMEWORK %s

View File

@ -33,12 +33,24 @@
// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min= -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-MISSING %s
// CHECK-VERSION-MISSING: invalid version number
// RUN: %clang -target armv7k-apple-darwin -mwatchos-version-min=2.0 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-WATCHOS20 %s
// RUN: %clang -target armv7-apple-darwin -mtvos-version-min=8.3 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-TVOS83 %s
// CHECK-VERSION-TVOS83: "thumbv7-apple-tvos8.3.0"
// RUN: %clang -target i386-apple-darwin -mtvos-simulator-version-min=8.3 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-TVSIM83 %s
// CHECK-VERSION-TVSIM83: "i386-apple-tvos8.3.0"
// CHECK-VERSION-WATCHOS20: "thumbv7k-apple-watchos2.0.0"
// RUN: %clang -target i386-apple-darwin -mwatchos-simulator-version-min=2.0 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-WATCHSIM20 %s
// CHECK-VERSION-WATCHSIM20: "i386-apple-watchos2.0.0"
// Check environment variable gets interpreted correctly
// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 \
// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
// RUN: %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
// RUN: env IPHONEOS_DEPLOYMENT_TARGET=2.0 \
// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
// RUN: %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS2 %s
@ -50,3 +62,21 @@
// RUN: %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS231 %s
// CHECK-VERSION-IOS231: "armv6k-apple-ios2.3.1"
// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 TVOS_DEPLOYMENT_TARGET=8.3.1 \
// RUN: %clang -target armv7-apple-darwin9 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-TVOS %s
// CHECK-VERSION-TVOS: "thumbv7-apple-tvos8.3.1"
// RUN: env TVOS_DEPLOYMENT_TARGET=8.3.1 \
// RUN: %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-TVOSSIM %s
// CHECK-VERSION-TVOSSIM: "i386-apple-tvos8.3.1"
// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 WATCHOS_DEPLOYMENT_TARGET=2.0 \
// RUN: %clang -target armv7-apple-darwin9 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-WATCHOS %s
// CHECK-VERSION-WATCHOS: "thumbv7-apple-watchos2.0.0"
// RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
// RUN: %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-WATCHOSSIM %s
// CHECK-VERSION-WATCHOSSIM: "i386-apple-watchos2.0.0"

View File

@ -212,6 +212,8 @@
// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
// RUN: %clang -x assembler -c %s -target arm64-apple-ios -mkernel -miphoneos-version-min=7.0.0 -no-integrated-as -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-NO-STATIC
// RUN: %clang -c %s -target armv7k-apple-watchos -fapple-kext -mwatchos-version-min=1.0.0 -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
// RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=5.0.0 -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
// RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=6.0.0 -static -### 2>&1 \

BIN
test/Modules/modules.idx Normal file

Binary file not shown.

View File

@ -210,10 +210,9 @@
// A5:#define __ARM_FP 0xE
// Test whether predefines are as expected when targeting cortex-a7.
// RUN: %clang -target armv7 -mcpu=cortex-a7 -x c -E -dM %s -o - | FileCheck --check-prefix=A7 %s
// RUN: %clang -target armv7 -mthumb -mcpu=cortex-a7 -x c -E -dM %s -o - | FileCheck --check-prefix=A7 %s
// RUN: %clang -target armv7k -mcpu=cortex-a7 -x c -E -dM %s -o - | FileCheck --check-prefix=A7 %s
// RUN: %clang -target armv7k -mthumb -mcpu=cortex-a7 -x c -E -dM %s -o - | FileCheck --check-prefix=A7 %s
// A7:#define __ARM_ARCH 7
// A7:#define __ARM_ARCH_7A__ 1
// A7:#define __ARM_ARCH_EXT_IDIV__ 1
// A7:#define __ARM_ARCH_PROFILE 'A'
// A7:#define __ARM_FEATURE_DSP

View File

@ -1,7 +1,9 @@
// RUN: %clang -target x86_64-apple-darwin -arch arm64 -mios-version-min=7 -fsyntax-only -Wdeprecated-objc-isa-usage %s -Xclang -verify
// RUN: %clang -target x86_64-apple-darwin -arch arm64 -mios-version-min=7 -fsyntax-only %s -Xclang -verify
// RUN: %clang -target x86_64-apple-darwin -mios-simulator-version-min=7 -fsyntax-only -Wdeprecated-objc-isa-usage %s -Xclang -verify
// RUN: %clang -target x86_64-apple-darwin -arch armv7k -mwatchos-version-min=2 -fsyntax-only -Wdeprecated-objc-isa-usage %s -Xclang -verify
// rdar://10709102
// RUN: %clang -target x86_64-apple-darwin -arch x86_64 -fsyntax-only -Wdeprecated-objc-isa-usage %s -Xclang -verify
typedef struct objc_object {
struct objc_class *isa;