[Clang] Add DriverKit support

This is the second patch that upstreams the support for Apple's DriverKit.

The first patch: https://reviews.llvm.org/D118046.

Differential Revision: https://reviews.llvm.org/D121911
This commit is contained in:
Egor Zhdan 2022-03-16 19:31:04 +00:00
parent a8abb69585
commit 2f04e703bf
42 changed files with 273 additions and 13 deletions

View File

@ -870,6 +870,7 @@ def Availability : InheritableAttr {
.Case("macos", "macOS")
.Case("tvos", "tvOS")
.Case("watchos", "watchOS")
.Case("driverkit", "DriverKit")
.Case("ios_app_extension", "iOS (App Extension)")
.Case("macos_app_extension", "macOS (App Extension)")
.Case("tvos_app_extension", "tvOS (App Extension)")

View File

@ -1555,6 +1555,10 @@ attributes are ignored. Supported platforms are:
``watchos``
Apple's watchOS operating system. The minimum deployment target is specified by
the ``-mwatchos-version-min=*version*`` command-line argument.
``driverkit``
Apple's DriverKit userspace kernel extensions. The minimum deployment target
is specified as part of the triple.
A declaration can typically be used even when deploying back to a platform
version prior to when the declaration was introduced. When this happens, the

View File

@ -61,6 +61,7 @@ FEATURE(attribute_availability_app_extension, true)
FEATURE(attribute_availability_with_version_underscores, true)
FEATURE(attribute_availability_tvos, true)
FEATURE(attribute_availability_watchos, true)
FEATURE(attribute_availability_driverkit, true)
FEATURE(attribute_availability_with_strict, true)
FEATURE(attribute_availability_with_replacement, true)
FEATURE(attribute_availability_in_templates, true)

View File

@ -3914,6 +3914,7 @@ def nogpulib : Flag<["-"], "nogpulib">, MarshallingInfoFlag<LangOpts<"NoGPULib">
Flags<[CC1Option]>, HelpText<"Do not link device library for CUDA/HIP device compilation">;
def : Flag<["-"], "nocudalib">, Alias<nogpulib>;
def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
def nodriverkitlib : Flag<["-"], "nodriverkitlib">;
def nofixprebinding : Flag<["-"], "nofixprebinding">;
def nolibc : Flag<["-"], "nolibc">;
def nomultidefs : Flag<["-"], "nomultidefs">;

View File

@ -76,7 +76,10 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang,
#if defined(CLANG_DEFAULT_STD_CXX)
return CLANG_DEFAULT_STD_CXX;
#else
return LangStandard::lang_gnucxx14;
if (T.isDriverKit())
return LangStandard::lang_gnucxx17;
else
return LangStandard::lang_gnucxx14;
#endif
case Language::RenderScript:
return LangStandard::lang_c99;

View File

@ -104,6 +104,19 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
Str[5] = '\0';
Builder.defineMacro("__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__", Str);
} else if (Triple.isDriverKit()) {
assert(OsVersion.getMajor() < 100 &&
OsVersion.getMinor().getValueOr(0) < 100 &&
OsVersion.getSubminor().getValueOr(0) < 100 && "Invalid version!");
char Str[7];
Str[0] = '0' + (OsVersion.getMajor() / 10);
Str[1] = '0' + (OsVersion.getMajor() % 10);
Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
Str[3] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
Str[5] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
Str[6] = '\0';
Builder.defineMacro("__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__", Str);
} else if (Triple.isMacOSX()) {
// Note that the Driver allows versions which aren't representable in the
// define (because we only get a single digit for the minor and micro

View File

@ -108,6 +108,8 @@ public:
this->TLSSupported = !Triple.isOSVersionLT(2);
else
this->TLSSupported = !Triple.isOSVersionLT(3);
} else if (Triple.isDriverKit()) {
// No TLS on DriverKit.
}
this->MCountName = "\01mcount";

View File

@ -3895,6 +3895,8 @@ static unsigned getBaseMachOPlatformID(const llvm::Triple &TT) {
return llvm::MachO::PLATFORM_TVOS;
case llvm::Triple::WatchOS:
return llvm::MachO::PLATFORM_WATCHOS;
case llvm::Triple::DriverKit:
return llvm::MachO::PLATFORM_DRIVERKIT;
default:
return /*Unknown platform*/ 0;
}
@ -3975,6 +3977,9 @@ static bool isFoundationNeededForDarwinAvailabilityCheck(
case llvm::Triple::MacOSX:
FoundationDroppedInVersion = VersionTuple(/*Major=*/10, /*Minor=*/15);
break;
case llvm::Triple::DriverKit:
// DriverKit doesn't need Foundation.
return false;
default:
llvm_unreachable("Unexpected OS");
}

View File

@ -5894,6 +5894,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
case llvm::Triple::DriverKit:
TC = std::make_unique<toolchains::DarwinClang>(*this, Target, Args);
break;
case llvm::Triple::DragonFly:

View File

@ -67,8 +67,9 @@ static ToolChain::RTTIMode CalculateRTTIMode(const ArgList &Args,
return ToolChain::RM_Disabled;
}
// -frtti is default, except for the PS4.
return (Triple.isPS4()) ? ToolChain::RM_Disabled : ToolChain::RM_Enabled;
// -frtti is default, except for the PS4 and DriverKit.
bool NoRTTI = Triple.isPS4() || Triple.isDriverKit();
return NoRTTI ? ToolChain::RM_Disabled : ToolChain::RM_Enabled;
}
ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,

View File

@ -320,6 +320,7 @@ arm::FloatABI arm::getDefaultFloatABI(const llvm::Triple &Triple) {
case llvm::Triple::MacOSX:
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::DriverKit:
// Darwin defaults to "softfp" for v6 and v7.
if (Triple.isWatchABI())
return FloatABI::Hard;

View File

@ -84,6 +84,10 @@ std::string x86::getX86TargetCPU(const Driver &D, const ArgList &Args,
// Simulators can still run on 10.11 though, like Xcode.
if (Triple.isMacOSX() && !Triple.isOSVersionLT(10, 12))
return "penryn";
if (Triple.isDriverKit())
return "nehalem";
// The oldest x86_64 Macs have core2/Merom; the oldest x86 Macs have Yonah.
return Is64Bit ? "core2" : "yonah";
}

View File

@ -468,8 +468,8 @@ static bool addExceptionArgs(const ArgList &Args, types::ID InputType,
if (types::isCXX(InputType)) {
// Disable C++ EH by default on XCore and PS4/PS5.
bool CXXExceptionsEnabled =
Triple.getArch() != llvm::Triple::xcore && !Triple.isPS();
bool CXXExceptionsEnabled = Triple.getArch() != llvm::Triple::xcore &&
!Triple.isPS() && !Triple.isDriverKit();
Arg *ExceptionArg = Args.getLastArg(
options::OPT_fcxx_exceptions, options::OPT_fno_cxx_exceptions,
options::OPT_fexceptions, options::OPT_fno_exceptions);

View File

@ -1290,7 +1290,7 @@ tools::ParsePICArgs(const ToolChain &ToolChain, const ArgList &Args) {
// generation, independent of the argument order.
if (KernelOrKext &&
((!EffectiveTriple.isiOS() || EffectiveTriple.isOSVersionLT(6)) &&
!EffectiveTriple.isWatchOS()))
!EffectiveTriple.isWatchOS() && !EffectiveTriple.isDriverKit()))
PIC = PIE = false;
if (Arg *A = Args.getLastArg(options::OPT_mdynamic_no_pic)) {

View File

@ -712,6 +712,26 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}
// DriverKit's framework doesn't have the same layout as other frameworks.
// Add missing search paths if necessary.
if (getToolChain().getTriple().getOS() == llvm::Triple::DriverKit) {
if (const Arg *Root = Args.getLastArg(options::OPT_isysroot)) {
// ld64 fixed the implicit -F and -L paths in ld64-605.1+.
if (Version.getMajor() < 605 ||
(Version.getMajor() == 605 && Version.getMinor().getValueOr(0) < 1)) {
SmallString<128> L(Root->getValue());
llvm::sys::path::append(L, "System", "DriverKit", "usr", "lib");
CmdArgs.push_back(Args.MakeArgString(std::string("-L") + L));
SmallString<128> F(Root->getValue());
llvm::sys::path::append(F, "System", "DriverKit");
llvm::sys::path::append(F, "System", "Library", "Frameworks");
CmdArgs.push_back(Args.MakeArgString(std::string("-F") + F));
}
}
}
ResponseFileSupport ResponseSupport;
if (Version >= VersionTuple(705) || LinkerIsLLD) {
ResponseSupport = ResponseFileSupport::AtFileUTF8();
@ -891,7 +911,7 @@ 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 (isTargetWatchOSBased())
if (isTargetWatchOSBased() || isTargetDriverKit())
return true;
else if (isTargetIOSBased())
return !isIPhoneOSVersionLT(3, 2);
@ -1018,6 +1038,8 @@ std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args,
Str += "watchos";
else if (isTargetTvOSBased())
Str += "tvos";
else if (isTargetDriverKit())
Str += "driverkit";
else if (isTargetIOSBased() || isTargetMacCatalyst())
Str += "ios";
else
@ -1219,6 +1241,8 @@ StringRef Darwin::getPlatformFamily() const {
return "AppleTV";
case DarwinPlatformKind::WatchOS:
return "Watch";
case DarwinPlatformKind::DriverKit:
return "DriverKit";
}
llvm_unreachable("Unsupported platform");
}
@ -1250,6 +1274,8 @@ StringRef Darwin::getOSLibraryNameSuffix(bool IgnoreSim) const {
case DarwinPlatformKind::WatchOS:
return TargetEnvironment == NativeEnvironment || IgnoreSim ? "watchos"
: "watchossim";
case DarwinPlatformKind::DriverKit:
return "driverkit";
}
llvm_unreachable("Unsupported platform");
}
@ -1407,9 +1433,15 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
AddLinkRuntimeLib(Args, CmdArgs, "xray-fdr");
}
if (isTargetDriverKit() && !Args.hasArg(options::OPT_nodriverkitlib)) {
CmdArgs.push_back("-framework");
CmdArgs.push_back("DriverKit");
}
// Otherwise link libSystem, then the dynamic runtime library, and finally any
// target specific static runtime library.
CmdArgs.push_back("-lSystem");
if (!isTargetDriverKit())
CmdArgs.push_back("-lSystem");
// Select the dynamic runtime library and the target specific static library.
if (isTargetIOSBased()) {
@ -1524,6 +1556,9 @@ struct DarwinPlatform {
case DarwinPlatformKind::WatchOS:
Opt = options::OPT_mwatchos_version_min_EQ;
break;
case DarwinPlatformKind::DriverKit:
// DriverKit always explicitly provides a version in the triple.
return;
}
Argument = Args.MakeJoinedArg(nullptr, Opts.getOption(Opt), OSVersion);
Args.append(Argument);
@ -1663,6 +1698,8 @@ private:
return DarwinPlatformKind::TvOS;
case llvm::Triple::WatchOS:
return DarwinPlatformKind::WatchOS;
case llvm::Triple::DriverKit:
return DarwinPlatformKind::DriverKit;
default:
llvm_unreachable("Unable to infer Darwin variant");
}
@ -1732,6 +1769,7 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver,
"IPHONEOS_DEPLOYMENT_TARGET",
"TVOS_DEPLOYMENT_TARGET",
"WATCHOS_DEPLOYMENT_TARGET",
"DRIVERKIT_DEPLOYMENT_TARGET",
};
static_assert(llvm::array_lengthof(EnvVars) == Darwin::LastDarwinPlatform + 1,
"Missing platform");
@ -1830,6 +1868,8 @@ inferDeploymentTargetFromSDK(DerivedArgList &Args,
return DarwinPlatform::createFromSDK(
Darwin::TvOS, Version,
/*IsSimulator=*/SDK.startswith("AppleTVSimulator"));
else if (SDK.startswith("DriverKit"))
return DarwinPlatform::createFromSDK(Darwin::DriverKit, Version);
return None;
};
if (auto Result = CreatePlatformFromSDKName(SDK))
@ -1866,6 +1906,9 @@ std::string getOSVersion(llvm::Triple::OSType OS, const llvm::Triple &Triple,
case llvm::Triple::WatchOS:
OsVersion = Triple.getWatchOSVersion();
break;
case llvm::Triple::DriverKit:
OsVersion = Triple.getDriverKitVersion();
break;
default:
llvm_unreachable("Unexpected OS type");
break;
@ -2160,13 +2203,20 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
HadExtra || Major >= 10 || Minor >= 100 || Micro >= 100)
getDriver().Diag(diag::err_drv_invalid_version_number)
<< OSTarget->getAsString(Args, Opts);
} else if (Platform == DriverKit) {
if (!Driver::GetReleaseVersion(OSTarget->getOSVersion(), Major, Minor,
Micro, HadExtra) ||
HadExtra || Major < 19 || Major >= 100 || Minor >= 100 || Micro >= 100)
getDriver().Diag(diag::err_drv_invalid_version_number)
<< OSTarget->getAsString(Args, Opts);
} else
llvm_unreachable("unknown kind of Darwin platform");
DarwinEnvironmentKind Environment = OSTarget->getEnvironment();
// Recognize iOS targets with an x86 architecture as the iOS simulator.
if (Environment == NativeEnvironment && Platform != MacOS &&
OSTarget->canInferSimulatorFromArch() && getTriple().isX86())
Platform != DriverKit && OSTarget->canInferSimulatorFromArch() &&
getTriple().isX86())
Environment = Simulator;
VersionTuple NativeTargetVersion;
@ -2453,6 +2503,8 @@ void DarwinClang::AddCCKextLibArgs(const ArgList &Args,
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 if (isTargetDriverKit()) {
// DriverKit doesn't want extra runtime support.
} else {
llvm::sys::path::append(P, "libclang_rt.cc_kext.a");
}
@ -2667,6 +2719,8 @@ bool Darwin::isAlignedAllocationUnavailable() const {
case WatchOS: // Earlier than 4.0.
OS = llvm::Triple::WatchOS;
break;
case DriverKit: // Always available.
return false;
}
return TargetVersion < alignedAllocMinVersion(OS);
@ -2766,7 +2820,7 @@ Darwin::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch,
// 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 (isTargetWatchOSBased() ||
if (isTargetWatchOSBased() || isTargetDriverKit() ||
(isTargetIOSBased() && !isIPhoneOSVersionLT(6, 0))) {
for (ArgList::iterator it = DAL->begin(), ie = DAL->end(); it != ie; ) {
Arg *A = *it;
@ -2882,6 +2936,8 @@ void Darwin::addMinVersionArgs(const ArgList &Args,
CmdArgs.push_back("-tvos_version_min");
else if (isTargetTvOSSimulator())
CmdArgs.push_back("-tvos_simulator_version_min");
else if (isTargetDriverKit())
CmdArgs.push_back("-driverkit_version_min");
else if (isTargetIOSSimulator())
CmdArgs.push_back("-ios_simulator_version_min");
else if (isTargetIOSBased())
@ -2931,6 +2987,8 @@ static const char *getPlatformName(Darwin::DarwinPlatformKind Platform,
return "tvos";
case Darwin::WatchOS:
return "watchos";
case Darwin::DriverKit:
return "driverkit";
}
llvm_unreachable("invalid platform");
}

View File

@ -299,7 +299,8 @@ public:
IPhoneOS,
TvOS,
WatchOS,
LastDarwinPlatform = WatchOS
DriverKit,
LastDarwinPlatform = DriverKit
};
enum DarwinEnvironmentKind {
NativeEnvironment,
@ -349,7 +350,7 @@ public:
bool isKernelStatic() const override {
return (!(isTargetIPhoneOS() && !isIPhoneOSVersionLT(6, 0)) &&
!isTargetWatchOS());
!isTargetWatchOS() && !isTargetDriverKit());
}
void addProfileRTLibs(const llvm::opt::ArgList &Args,
@ -435,6 +436,11 @@ public:
return TargetPlatform == WatchOS;
}
bool isTargetDriverKit() const {
assert(TargetInitialized && "Target not initialized!");
return TargetPlatform == DriverKit;
}
bool isTargetMacCatalyst() const {
return TargetPlatform == IPhoneOS && TargetEnvironment == MacCatalyst;
}
@ -544,7 +550,7 @@ public:
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() || isTargetWatchOSBased())
if (isTargetIOSBased() || isTargetWatchOSBased() || isTargetDriverKit())
return LangOptions::SSPOn;
else if (isTargetMacOSBased() && !isMacosxVersionLT(10, 6))
return LangOptions::SSPOn;

View File

@ -0,0 +1,10 @@
// RUN: %clang_cc1 -triple x86_64-apple-driverkit19.0 -emit-llvm -o - %s | FileCheck %s
void use_at_available() {
// CHECK: call i32 @__isPlatformVersionAtLeast(i32 10, i32 19, i32 1, i32 0)
// CHECK-NEXT: icmp ne
if (__builtin_available(driverkit 19.1, *))
;
}
// CHECK: declare i32 @__isPlatformVersionAtLeast(i32, i32, i32, i32)

View File

@ -0,0 +1,20 @@
// RUN: touch %t.o
// RUN: %clang -target x86_64-apple-driverkit10.15 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
// RUN: | FileCheck %s
// RUN: mkdir -p %t.sdk
// RUN: %clang -target x86_64-apple-driverkit19 -isysroot %t.sdk -mlinker-version=520 -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=MISSING-SDK-JSON-WORKAROUND %s
// RUN: %clang -target arm64-apple-driverkit19 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=ARM64_NEW %s
// RUN: %clang -target arm64-apple-driverkit19 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=400 -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=ARM64_OLD %s
// RUN: %clang -target arm64e-apple-driverkit19 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=ARM64_NEW %s
// CHECK: "-platform_version" "driverkit" "10.15.0" "10.14"
// MISSING-SDK-JSON-WORKAROUND: "-platform_version" "driverkit" "19.0.0" "19.0.0"
// ARM64_NEW: "-platform_version" "driverkit" "20.0.0" "10.14"
// ARM64_OLD: "-driverkit_version_min" "20.0.0"

View File

@ -185,6 +185,15 @@
// LINK_TVOS_KEXT: libclang_rt.cc_kext_tvos.a
// LINK_TVOS_KEXT: libclang_rt.tvos.a
// RUN: %clang -target x86-64-apple-driverkit19.0 -mlinker-version=400 -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_DRIVERKIT %s < %t.log
// LINK_DRIVERKIT: {{ld(.exe)?"}}
// LINK_DRIVERKIT: -driverkit_version_min
// LINK_DRIVERKIT-NOT: crt
// LINK_DRIVERKIT-NOT: lgcc_s.1
// LINK_DRIVERKIT-NOT: lSystem
// LINK_DRIVERKIT: libclang_rt.driverkit.a
// RUN: %clang -target armv7k-apple-watchos2.0 -fuse-ld= -mlinker-version=400 -mwatchos-version-min=2.0 -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_WATCHOS_ARM %s < %t.log
// LINK_WATCHOS_ARM: {{ld(.exe)?"}}

View File

@ -98,6 +98,10 @@
// RUN: FileCheck --check-prefix=CHECK-VERSION-WATCHSIM20 %s
// CHECK-VERSION-WATCHSIM20: "i386-apple-watchos2.0.0-simulator"
// RUN: %clang -target x86_64-apple-driverkit19.0 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-DRIVERKIT190 %s
// CHECK-VERSION-DRIVERKIT190: "x86_64-apple-driverkit19.0.0"
// Check environment variable gets interpreted correctly
// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
// RUN: %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \
@ -145,6 +149,15 @@
// RUN: FileCheck --check-prefix=CHECK-VERSION-WATCHOS-TARGET %s
// CHECK-VERSION-WATCHOS-TARGET: "x86_64-apple-watchos4.0.0-simulator"
// RUN: env DRIVERKIT_DEPLOYMENT_TARGET=19.0 \
// RUN: %clang -target x86_64-apple-darwin -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-DRIVERKIT %s
// CHECK-VERSION-DRIVERKIT: "x86_64-apple-driverkit19.0.0"
//
// Make sure stdlib is not mistaken
// RUN: env DRIVERKIT_DEPLOYMENT_TARGET=2.0 \
// RUN: %clang -target arm64-apple-darwin -c -x c++ %s -stdlib=libc++ -### 2>&1
// RUN: env MACOSX_DEPLOYMENT_TARGET=1000.1000 \
// RUN: %clang -target x86_64-apple-darwin -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-INVALID-ENV %s

View File

@ -66,6 +66,9 @@
// RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \
// RUN: | FileCheck -check-prefix=G_STANDALONE \
// RUN: -check-prefix=G_DWARF4 %s
// RUN: %clang -### -c -g %s -target x86_64-apple-driverkit19.0 2>&1 \
// RUN: | FileCheck -check-prefix=G_STANDALONE \
// RUN: -check-prefix=G_DWARF4 %s
// RUN: %clang -### -c -fsave-optimization-record %s \
// RUN: -target x86_64-apple-darwin 2>&1 \
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s

View File

@ -0,0 +1,4 @@
// REQUIRES: aarch64-registered-target
// RUN: %clang %s -target arm64-apple-driverkit -### 2>&1 | FileCheck %s
// CHECK: "-target-cpu" "apple-a7"

View File

@ -0,0 +1,4 @@
// REQUIRES: aarch64-registered-target
// RUN: %clang %s -target arm64e-apple-driverkit -### 2>&1 | FileCheck %s
// CHECK: "-target-cpu" "apple-a12"

View File

@ -0,0 +1,5 @@
// RUN: %clang -c -x assembler-with-cpp -target armv7k-apple-driverkit21.0 -### %s 2>&1 | FileCheck %s
// CHECK: -cc1as
// CHECK-SAME: "-target-cpu" "cortex-a7"
.foo:
vfms.f64 d1, d0, d3

View File

@ -0,0 +1,8 @@
// REQUIRES: x86-registered-target
// RUN: %clang %s -target x86_64-apple-driverkit19.0 -fsyntax-only
#if __cplusplus != 201703L
#error DriverKit should be on C++17.
#endif
int main() { return 0; }

View File

@ -0,0 +1,9 @@
// REQUIRES: x86-registered-target
// RUN: %clang %s -target x86_64-apple-driverkit19.0 -### 2>&1 | FileCheck %s -check-prefix=DEFAULT
// RUN: %clang %s -target x86_64-apple-driverkit19.0 -fexceptions -### 2>&1 | FileCheck %s -check-prefix=USERPROVIDED
int main() { return 0; }
// DEFAULT-NOT: "-fcxx-exceptions"
// DEFAULT-NOT: "-fexceptions"
// USERPROVIDED: "-fcxx-exceptions"
// USERPROVIDED: "-fexceptions"

View File

@ -0,0 +1,13 @@
// RUN: %clang %s -target x86_64-apple-driverkit19.0 \
// RUN: -isysroot %S/Inputs/DriverKit19.0.sdk -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-DEFAULT
// RUN: %clang %s -target x86_64-apple-driverkit19.0 -nodriverkitlib \
// RUN: -isysroot %S/Inputs/DriverKit19.0.sdk -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-NO-DRIVERKIT
int main() { return 0; }
// CHECK-DEFAULT: "-framework" "DriverKit"
// CHECK-NO-DRIVERKIT-NOT: "-framework" "DriverKit"

View File

@ -0,0 +1,5 @@
// REQUIRES: x86-registered-target
// RUN: %clang %s -target x86_64-apple-driverkit19.0 -### 2>&1 | FileCheck %s
int main() { return 0; }
// CHECK: "-fno-rtti"

View File

@ -0,0 +1,5 @@
// REQUIRES: x86-registered-target
// RUN: %clang %s -target x86_64-apple-driverkit19.0 -### 2>&1 | FileCheck %s
int main() { return 0; }
// CHECK: "-target-cpu" "nehalem"

View File

@ -0,0 +1,5 @@
// REQUIRES: x86-registered-target
// RUN: %clang -target x86_64-apple-driverkit19.0 -S -o - %s | FileCheck %s
int main() { return 0; }
// CHECK: .build_version driverkit, 19, 0

View File

@ -4,6 +4,8 @@
// RUN: %clang -target x86_64-apple-darwin -Wincompatible-sysroot -isysroot SDKs/MacOSX10.9.sdk -mios-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-OSX-IOS %s
// RUN: %clang -target arm64-apple-darwin -Wincompatible-sysroot -isysroot SDKs/iPhoneOS9.2.sdk -mwatchos-version-min=2.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-WATCHOS %s
// RUN: %clang -target arm64-apple-darwin -Wincompatible-sysroot -isysroot SDKs/iPhoneOS9.2.sdk -mtvos-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-TVOS %s
// RUN: %clang -target x86_64-apple-driverkit19.0 -Wincompatible-sysroot -isysroot SDKs/MacOSX10.9.sdk -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-OSX-DRIVERKIT %s
// RUN: %clang -target x86_64-apple-driverkit19.0 -Wincompatible-sysroot -isysroot SDKs/iPhoneOS9.2.sdk -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-DRIVERKIT %s
// RUN: %clang -target x86_64-apple-darwin -Wincompatible-sysroot -isysroot SDKs/iPhoneSimulator9.2.sdk -mios-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-IOSSIM %s
// RUN: %clang -target x86_64-apple-darwin -Wno-incompatible-sysroot -isysroot SDKs/MacOSX10.9.sdk -mios-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-OSX-IOS-DISABLED %s
@ -11,5 +13,7 @@ int main() { return 0; }
// CHECK-OSX-IOS: warning: using sysroot for 'MacOSX' but targeting 'iPhone'
// CHECK-IOS-WATCHOS: warning: using sysroot for 'iPhoneOS' but targeting 'Watch'
// CHECK-IOS-TVOS: warning: using sysroot for 'iPhoneOS' but targeting 'AppleTV'
// CHECK-OSX-DRIVERKIT: warning: using sysroot for 'MacOSX' but targeting 'DriverKit'
// CHECK-IOS-DRIVERKIT: warning: using sysroot for 'iPhoneOS' but targeting 'DriverKit'
// CHECK-IOS-IOSSIM-NOT: warning: using sysroot for '{{.*}}' but targeting '{{.*}}'
// CHECK-OSX-IOS-DISABLED-NOT: warning: using sysroot for '{{.*}}' but targeting '{{.*}}'

View File

@ -107,6 +107,14 @@
// CHECK-WATCHOS-ARMV7: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}darwin{{/|\\\\}}libclang_rt.profile_watchos.a"
//
// RUN: %clang -### %s 2>&1 \
// RUN: -target x86_64-apple-driverkit19.0 -arch x86_64 -fprofile-instr-generate -fuse-ld=ld \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: | FileCheck --check-prefix=CHECK-DRIVERKIT-X86_64 %s
//
// CHECK-DRIVERKIT-X86_64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
// CHECK-DRIVERKIT-X86_64: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}darwin{{/|\\\\}}libclang_rt.profile_driverkit.a"
//
// RUN: %clang -### %s 2>&1 \
// RUN: --target=i386-pc-win32 -fprofile-instr-generate \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: | FileCheck --check-prefix=CHECK-WINDOWS-I386 %s

View File

@ -231,6 +231,8 @@
// RUN: | FileCheck %s --check-prefix=CHECK-NO-STATIC
// RUN: %clang -c %s -target armv7k-apple-watchos1 -fapple-kext -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
// RUN: %clang -c %s -target x86_64-apple-driverkit -fapple-kext -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
// RUN: %clang -c %s -target armv7-apple-ios5 -fapple-kext -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
// RUN: %clang -c %s -target armv7-apple-ios6 -fapple-kext -static -### 2>&1 \

View File

@ -38,6 +38,8 @@
// RUN: %clang -target armv7k-apple-watchos2.0 -### %s 2>&1 | FileCheck %s -check-prefix=SSP_WATCHOS
// RUN: %clang -ffreestanding -target armv7k-apple-watchos2.0 -### %s 2>&1 | FileCheck %s -check-prefix=SSP_WATCHOS
// SSP_WATCHOS: "-stack-protector" "1"
// RUN: %clang -target x86_64-apple-driverkit19.0 -### %s 2>&1 | FileCheck %s -check-prefix=SSP_DRIVERKIT
// SSP_DRIVERKIT: "-stack-protector" "1"
// RUN: %clang -target arm64-apple-ios8.0.0 -### %s 2>&1 | FileCheck %s -check-prefix=SSP_IOS
// RUN: %clang -ffreestanding -target arm64-apple-ios8.0.0 -### %s 2>&1 | FileCheck %s -check-prefix=SSP_IOS
// SSP_IOS: "-stack-protector" "1"

View File

@ -51,3 +51,8 @@
// RUN: grep '__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__' %t | grep '20100' | count 1
// RUN: not grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t
// RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t
// RUN: %clang_cc1 -triple x86_64-apple-driverkit19.0 -dM -E -o %t %s
// RUN: grep '__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__' %t | grep '1900' | count 1
// RUN: not grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t
// RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t

View File

@ -834,6 +834,9 @@
// CHECK-V82A: #define __ARM_FEATURE_QRDMX 1
// CHECK-V82A: #define __ARM_FP 0xe
// RUN: %clang -target armv7-apple-driverkit21.0 -x c %s -dM -E -o - | FileCheck -match-full-lines --check-prefix=CHECK-DRIVERKIT %s
// CHECK-DRIVERKIT-NOT: #define __ARM_PCS_VFP 1
// RUN: %clang -target armv8.3a-none-none-eabi -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V83A %s
// CHECK-V83A: #define __ARM_ARCH 8
// CHECK-V83A: #define __ARM_ARCH_8_3A__ 1

View File

@ -0,0 +1,22 @@
// RUN: %clang_cc1 "-triple" "x86_64-apple-driverkit20.0" -fsyntax-only -verify %s
void f0(int) __attribute__((availability(driverkit,introduced=19.0,deprecated=20.0))); // expected-note {{'f0' has been explicitly marked deprecated here}}
void f1(int) __attribute__((availability(driverkit,introduced=20.0)));
void f2(int) __attribute__((availability(driverkit,introduced=19.0,deprecated=20.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}
void f3(int) __attribute__((availability(driverkit,introduced=20.0)));
void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(driverkit,introduced=19.0,deprecated=19.5,obsoleted=20.0))); // expected-note{{explicitly marked unavailable}}
void f5(int) __attribute__((availability(driverkit,introduced=19.0))) __attribute__((availability(driverkit,deprecated=20.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
void f6(int) __attribute__((availability(driverkit,deprecated=20.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
void f7(int) __attribute__((availability(driverkit,introduced=19.0)));
void test() {
f0(0); // expected-warning{{'f0' is deprecated: first deprecated in DriverKit 20.0}}
f1(0);
f2(0); // expected-warning{{'f2' is deprecated: first deprecated in DriverKit 20.0}}
f3(0);
f4(0); // expected-error{{f4' is unavailable: obsoleted in DriverKit 20.0}}
f5(0); // expected-warning{{'f5' is deprecated: first deprecated in DriverKit 20.0}}
f6(0); // expected-warning{{'f6' is deprecated: first deprecated in DriverKit 20.0}}
f7(0);
}