[clang] 2f04e70 - [Clang] Add DriverKit support
Egor Zhdan via cfe-commits
cfe-commits at lists.llvm.org
Fri May 13 12:35:08 PDT 2022
Author: Egor Zhdan
Date: 2022-05-13T20:34:57+01:00
New Revision: 2f04e703bff3d9858f53225fa7c780b240c3e247
URL: https://github.com/llvm/llvm-project/commit/2f04e703bff3d9858f53225fa7c780b240c3e247
DIFF: https://github.com/llvm/llvm-project/commit/2f04e703bff3d9858f53225fa7c780b240c3e247.diff
LOG: [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
Added:
clang/test/CodeGen/availability-check-driverkit.c
clang/test/Driver/Inputs/DriverKit19.0.sdk/SDKSettings.plist
clang/test/Driver/Inputs/DriverKit19.0.sdk/System/DriverKit/usr/include/.keep
clang/test/Driver/Inputs/basic_darwin_driverkit_sdk_usr_cxx_v1/System/DriverKit/usr/include/c++/v1/.keep
clang/test/Driver/Inputs/basic_darwin_driverkit_sdk_usr_cxx_v1/System/DriverKit/usr/lib/.keep
clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.driverkit.a
clang/test/Driver/darwin-ld-platform-version-driverkit.c
clang/test/Driver/driverkit-arm64.c
clang/test/Driver/driverkit-arm64e.c
clang/test/Driver/driverkit-armv7k.s
clang/test/Driver/driverkit-cplusplus.cpp
clang/test/Driver/driverkit-exceptions.cpp
clang/test/Driver/driverkit-framework.c
clang/test/Driver/driverkit-rtti.cpp
clang/test/Driver/driverkit-target-cpu.c
clang/test/Driver/driverkit-version-min.c
clang/test/Sema/attr-availability-driverkit.c
Modified:
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/Features.def
clang/include/clang/Driver/Options.td
clang/lib/Basic/LangStandards.cpp
clang/lib/Basic/Targets/OSTargets.cpp
clang/lib/Basic/Targets/OSTargets.h
clang/lib/CodeGen/CGObjC.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/test/Driver/darwin-ld.c
clang/test/Driver/darwin-version.c
clang/test/Driver/debug-options.c
clang/test/Driver/incompatible_sysroot.c
clang/test/Driver/instrprof-ld.c
clang/test/Driver/pic.c
clang/test/Driver/stack-protector.c
clang/test/Frontend/darwin-version.c
clang/test/Preprocessor/arm-target-features.c
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 3c41edb474e89..0c95adfa237d7 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -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)")
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index b389ff9c02c45..d635da6b84b84 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -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
diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def
index c3f3fe79770db..f241d68a23ed9 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -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)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index d1d7ca9698b14..ecdddff5b6831 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -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">;
diff --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp
index 2671217f3aa8c..11599cf96b33a 100644
--- a/clang/lib/Basic/LangStandards.cpp
+++ b/clang/lib/Basic/LangStandards.cpp
@@ -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;
diff --git a/clang/lib/Basic/Targets/OSTargets.cpp b/clang/lib/Basic/Targets/OSTargets.cpp
index f8f12daaa0722..6cf78fd4f2441 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -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
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
index 9dd5debf1c47a..e9832977c7fe8 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -108,6 +108,8 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public OSTargetInfo<Target> {
this->TLSSupported = !Triple.isOSVersionLT(2);
else
this->TLSSupported = !Triple.isOSVersionLT(3);
+ } else if (Triple.isDriverKit()) {
+ // No TLS on DriverKit.
}
this->MCountName = "\01mcount";
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index f0f4c4b8f4d3f..0c538860a10c5 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -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");
}
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e09070016001d..5884b096faab1 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -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:
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index d7d72153c78c0..1b221974a0147 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -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,
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 0dbb25de45a3d..68e8dc2e5f052 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -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;
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index de0725b8d6de6..993e13fdac307 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -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";
}
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index eec3c7b4ed218..75515469421b0 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -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);
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 28299f73ec949..2f342c59bda4e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -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)) {
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 237d0d9a4ae28..60346ee44e3a9 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -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 @@ struct DarwinPlatform {
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");
}
diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h
index a622024b79930..4535d021262e8 100644
--- a/clang/lib/Driver/ToolChains/Darwin.h
+++ b/clang/lib/Driver/ToolChains/Darwin.h
@@ -299,7 +299,8 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
IPhoneOS,
TvOS,
WatchOS,
- LastDarwinPlatform = WatchOS
+ DriverKit,
+ LastDarwinPlatform = DriverKit
};
enum DarwinEnvironmentKind {
NativeEnvironment,
@@ -349,7 +350,7 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
bool isKernelStatic() const override {
return (!(isTargetIPhoneOS() && !isIPhoneOSVersionLT(6, 0)) &&
- !isTargetWatchOS());
+ !isTargetWatchOS() && !isTargetDriverKit());
}
void addProfileRTLibs(const llvm::opt::ArgList &Args,
@@ -435,6 +436,11 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
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 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
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;
diff --git a/clang/test/CodeGen/availability-check-driverkit.c b/clang/test/CodeGen/availability-check-driverkit.c
new file mode 100644
index 0000000000000..707a12bad937f
--- /dev/null
+++ b/clang/test/CodeGen/availability-check-driverkit.c
@@ -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)
diff --git a/clang/test/Driver/Inputs/DriverKit19.0.sdk/SDKSettings.plist b/clang/test/Driver/Inputs/DriverKit19.0.sdk/SDKSettings.plist
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/DriverKit19.0.sdk/System/DriverKit/usr/include/.keep b/clang/test/Driver/Inputs/DriverKit19.0.sdk/System/DriverKit/usr/include/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_darwin_driverkit_sdk_usr_cxx_v1/System/DriverKit/usr/include/c++/v1/.keep b/clang/test/Driver/Inputs/basic_darwin_driverkit_sdk_usr_cxx_v1/System/DriverKit/usr/include/c++/v1/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/basic_darwin_driverkit_sdk_usr_cxx_v1/System/DriverKit/usr/lib/.keep b/clang/test/Driver/Inputs/basic_darwin_driverkit_sdk_usr_cxx_v1/System/DriverKit/usr/lib/.keep
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.driverkit.a b/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.driverkit.a
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/clang/test/Driver/darwin-ld-platform-version-driverkit.c b/clang/test/Driver/darwin-ld-platform-version-driverkit.c
new file mode 100644
index 0000000000000..f4fadc45079ed
--- /dev/null
+++ b/clang/test/Driver/darwin-ld-platform-version-driverkit.c
@@ -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"
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index a678bba7a8003..73840d1b56b63 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -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)?"}}
diff --git a/clang/test/Driver/darwin-version.c b/clang/test/Driver/darwin-version.c
index 130a66575a932..8b66aef489c9b 100644
--- a/clang/test/Driver/darwin-version.c
+++ b/clang/test/Driver/darwin-version.c
@@ -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
diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c
index 4b0d7912003d2..04004716aa501 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -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
diff --git a/clang/test/Driver/driverkit-arm64.c b/clang/test/Driver/driverkit-arm64.c
new file mode 100644
index 0000000000000..125df688976e6
--- /dev/null
+++ b/clang/test/Driver/driverkit-arm64.c
@@ -0,0 +1,4 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang %s -target arm64-apple-driverkit -### 2>&1 | FileCheck %s
+
+// CHECK: "-target-cpu" "apple-a7"
diff --git a/clang/test/Driver/driverkit-arm64e.c b/clang/test/Driver/driverkit-arm64e.c
new file mode 100644
index 0000000000000..d9ace1ea9e137
--- /dev/null
+++ b/clang/test/Driver/driverkit-arm64e.c
@@ -0,0 +1,4 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang %s -target arm64e-apple-driverkit -### 2>&1 | FileCheck %s
+
+// CHECK: "-target-cpu" "apple-a12"
diff --git a/clang/test/Driver/driverkit-armv7k.s b/clang/test/Driver/driverkit-armv7k.s
new file mode 100644
index 0000000000000..310ffafafbb86
--- /dev/null
+++ b/clang/test/Driver/driverkit-armv7k.s
@@ -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
\ No newline at end of file
diff --git a/clang/test/Driver/driverkit-cplusplus.cpp b/clang/test/Driver/driverkit-cplusplus.cpp
new file mode 100644
index 0000000000000..9f2e49f890316
--- /dev/null
+++ b/clang/test/Driver/driverkit-cplusplus.cpp
@@ -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; }
diff --git a/clang/test/Driver/driverkit-exceptions.cpp b/clang/test/Driver/driverkit-exceptions.cpp
new file mode 100644
index 0000000000000..76a39770338e6
--- /dev/null
+++ b/clang/test/Driver/driverkit-exceptions.cpp
@@ -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"
diff --git a/clang/test/Driver/driverkit-framework.c b/clang/test/Driver/driverkit-framework.c
new file mode 100644
index 0000000000000..654526bb7ae09
--- /dev/null
+++ b/clang/test/Driver/driverkit-framework.c
@@ -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"
diff --git a/clang/test/Driver/driverkit-rtti.cpp b/clang/test/Driver/driverkit-rtti.cpp
new file mode 100644
index 0000000000000..3d94ea09256e7
--- /dev/null
+++ b/clang/test/Driver/driverkit-rtti.cpp
@@ -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"
diff --git a/clang/test/Driver/driverkit-target-cpu.c b/clang/test/Driver/driverkit-target-cpu.c
new file mode 100644
index 0000000000000..f69e5edec0c9b
--- /dev/null
+++ b/clang/test/Driver/driverkit-target-cpu.c
@@ -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"
diff --git a/clang/test/Driver/driverkit-version-min.c b/clang/test/Driver/driverkit-version-min.c
new file mode 100644
index 0000000000000..9966152f11ce8
--- /dev/null
+++ b/clang/test/Driver/driverkit-version-min.c
@@ -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
diff --git a/clang/test/Driver/incompatible_sysroot.c b/clang/test/Driver/incompatible_sysroot.c
index 876f1f058dc99..b490f57b90ef5 100644
--- a/clang/test/Driver/incompatible_sysroot.c
+++ b/clang/test/Driver/incompatible_sysroot.c
@@ -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 '{{.*}}'
diff --git a/clang/test/Driver/instrprof-ld.c b/clang/test/Driver/instrprof-ld.c
index 4eec7aef102ff..d1b070ed59c3f 100644
--- a/clang/test/Driver/instrprof-ld.c
+++ b/clang/test/Driver/instrprof-ld.c
@@ -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
diff --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c
index 2124bf1b277b6..0ff07b0f0f453 100644
--- a/clang/test/Driver/pic.c
+++ b/clang/test/Driver/pic.c
@@ -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 \
diff --git a/clang/test/Driver/stack-protector.c b/clang/test/Driver/stack-protector.c
index a3e40b50eed87..169376919a717 100644
--- a/clang/test/Driver/stack-protector.c
+++ b/clang/test/Driver/stack-protector.c
@@ -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"
diff --git a/clang/test/Frontend/darwin-version.c b/clang/test/Frontend/darwin-version.c
index eb05a48cfd36e..4f38c90c15e73 100644
--- a/clang/test/Frontend/darwin-version.c
+++ b/clang/test/Frontend/darwin-version.c
@@ -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
diff --git a/clang/test/Preprocessor/arm-target-features.c b/clang/test/Preprocessor/arm-target-features.c
index 3a1f06041d35d..2caf68b848444 100644
--- a/clang/test/Preprocessor/arm-target-features.c
+++ b/clang/test/Preprocessor/arm-target-features.c
@@ -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
diff --git a/clang/test/Sema/attr-availability-driverkit.c b/clang/test/Sema/attr-availability-driverkit.c
new file mode 100644
index 0000000000000..7b41f33272037
--- /dev/null
+++ b/clang/test/Sema/attr-availability-driverkit.c
@@ -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);
+}
More information about the cfe-commits
mailing list