diff --git a/CMakeLists.txt b/CMakeLists.txt index d181545c2ac58..931008da73ab6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,7 @@ set(SWIFT_DARWIN_EMBEDDED_VARIANTS "^(iphoneos|iphonesimulator|appletvos|appletv # if("${SWIFT_HOST_VARIANT_SDK}" IN_LIST SWIFT_DARWIN_PLATFORMS) # ... # endif() -set(SWIFT_DARWIN_PLATFORMS "IOS" "IOS_SIMULATOR" "TVOS" "TVOS_SIMULATOR" "WATCHOS" "WATCHOS_SIMULATOR" "OSX") +set(SWIFT_DARWIN_PLATFORMS "IOS" "IOS_SIMULATOR" "TVOS" "TVOS_SIMULATOR" "WATCHOS" "WATCHOS_SIMULATOR" "OSX" "XROS" "XROS_SIMULATOR") set(SWIFT_APPLE_PLATFORMS ${SWIFT_DARWIN_PLATFORMS}) if(SWIFT_FREESTANDING_FLAVOR STREQUAL "apple") @@ -542,6 +542,9 @@ set(SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS "11.0" CACHE STRING set(SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS "4.0" CACHE STRING "Minimum deployment target version for watchOS") +set(SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS "1.0" CACHE STRING + "Minimum deployment target version for xrOS") + # # Compatibility library deployment versions # @@ -550,6 +553,7 @@ set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX "10.9") set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS "7.0") set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS "9.0") set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS "2.0") +set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS "1.0") set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_MACCATALYST "13.1") # @@ -595,7 +599,7 @@ option(SWIFT_REPORT_STATISTICS FALSE) # Only Darwin platforms enable ObjC interop by default. -if("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)") +if("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*|XROS*)") set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default TRUE) else() set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default FALSE) @@ -1139,7 +1143,7 @@ elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WASI") set(SWIFT_PRIMARY_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}") set(SWIFT_PRIMARY_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}") -elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)") +elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*|XROS*)") set(SWIFT_HOST_VARIANT "macosx" CACHE STRING "Deployment OS for Swift host tools (the compiler) [macosx, iphoneos].") diff --git a/cmake/modules/DarwinSDKs.cmake b/cmake/modules/DarwinSDKs.cmake index 32c020425747e..558771b1516db 100644 --- a/cmake/modules/DarwinSDKs.cmake +++ b/cmake/modules/DarwinSDKs.cmake @@ -15,6 +15,8 @@ set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64;arm64") set(SUPPORTED_WATCHOS_ARCHS "armv7k;arm64_32") set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;x86_64;arm64") set(SUPPORTED_OSX_ARCHS "x86_64;arm64") +set(SUPPORTED_XROS_ARCHS "arm64;arm64e") +set(SUPPORTED_XROS_SIMULATOR_ARCHS "arm64") is_sdk_requested(OSX swift_build_osx) if(swift_build_osx) @@ -50,7 +52,8 @@ if(swift_build_freestanding AND (SWIFT_FREESTANDING_FLAVOR STREQUAL "apple")) endif() # Compatible cross-compile SDKS for Darwin OSes: IOS, IOS_SIMULATOR, TVOS, -# TVOS_SIMULATOR, WATCHOS, WATCHOS_SIMULATOR (archs hardcoded below). +# TVOS_SIMULATOR, WATCHOS, WATCHOS_SIMULATOR, XROS, XROS_SIMULATOR +# (archs hardcoded below). is_sdk_requested(IOS swift_build_ios) if(swift_build_ios) @@ -120,3 +123,28 @@ if(swift_build_watchos_simulator) configure_target_variant(WATCHOS_SIMULATOR-RA "watchOS Release+Asserts" WATCHOS_SIMULATOR RA "Release+Asserts") configure_target_variant(WATCHOS_SIMULATOR-R "watchOS Release" WATCHOS_SIMULATOR R "Release") endif() + +is_sdk_requested(XROS swift_build_xros) +if(swift_build_xros) + configure_sdk_darwin( + XROS "xrOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}" + xros xros xros "${SUPPORTED_XROS_ARCHS}") + configure_target_variant(XROS-DA "xrOS Debug+Asserts" XROS DA "Debug+Asserts") + configure_target_variant(XROS-RA "xrOS Release+Asserts" XROS RA "Release+Asserts") + configure_target_variant(XROS-R "xrOS Release" XROS R "Release") +endif() + +is_sdk_requested(XROS_SIMULATOR swift_build_xros_simulator) +if(swift_build_xros_simulator) + configure_sdk_darwin( + XROS_SIMULATOR "xrOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}" + xrsimulator xros xros-simulator + "${SUPPORTED_XROS_SIMULATOR_ARCHS}") + + configure_target_variant( + XROS_SIMULATOR-DA "xrOS Simulator Debug+Asserts" XROS_SIMULATOR DA "Debug+Asserts") + configure_target_variant( + XROS_SIMULATOR-RA "xrOS Simulator Release+Asserts" XROS_SIMULATOR RA "Release+Asserts") + configure_target_variant( + XROS_SIMULATOR-R "xrOS Simulator Release" XROS_SIMULATOR R "Release") +endif() diff --git a/cmake/modules/StandaloneOverlay.cmake b/cmake/modules/StandaloneOverlay.cmake index debf5c543d8eb..0b75224f2112b 100644 --- a/cmake/modules/StandaloneOverlay.cmake +++ b/cmake/modules/StandaloneOverlay.cmake @@ -100,7 +100,7 @@ set(CMAKE_INSTALL_PREFIX set(SWIFT_DARWIN_PLATFORMS - OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR) + OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR XROS XROS_SIMULATOR) # Flags used to indicate we are building a standalone overlay. # FIXME: We should cut this down to a single flag. diff --git a/include/swift/AST/ASTContext.h b/include/swift/AST/ASTContext.h index f636aa382903f..4447782e8dc7f 100644 --- a/include/swift/AST/ASTContext.h +++ b/include/swift/AST/ASTContext.h @@ -34,6 +34,7 @@ #include "swift/Basic/BlockList.h" #include "swift/SymbolGraphGen/SymbolGraphOptions.h" #include "clang/AST/DeclTemplate.h" +#include "clang/Basic/DarwinSDKInfo.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" @@ -948,6 +949,12 @@ class ASTContext final { return getMultiPayloadEnumTagSinglePayloadAvailability(); } + /// Test support utility for loading a platform remap file + /// in case an SDK is not specified to the compilation. + const clang::DarwinSDKInfo::RelatedTargetVersionMapping * + getAuxiliaryDarwinPlatformRemapInfo( + clang::DarwinSDKInfo::OSEnvPair Kind) const; + //===--------------------------------------------------------------------===// // Diagnostics Helper functions //===--------------------------------------------------------------------===// @@ -1511,6 +1518,9 @@ class ASTContext final { /// Provide context-level uniquing for SIL lowered type layouts and boxes. friend SILLayout; friend SILBoxType; + +public: + clang::DarwinSDKInfo *getDarwinSDKInfo() const; }; } // end namespace swift diff --git a/include/swift/AST/Availability.h b/include/swift/AST/Availability.h index f1a4ce0475948..8e21d27137197 100644 --- a/include/swift/AST/Availability.h +++ b/include/swift/AST/Availability.h @@ -25,6 +25,7 @@ namespace swift { class ASTContext; class AvailableAttr; +class BackDeployedAttr; class Decl; /// A lattice of version ranges of the form [x.y.z, +Inf). @@ -380,6 +381,39 @@ class AvailabilityInference { static AvailabilityContext annotatedAvailableRangeForAttr(const SpecializeAttr *attr, ASTContext &ctx); + + /// For the attribute's introduction version, update the platform and version + /// values to the re-mapped platform's, if using a fallback platform. + /// Returns `true` if a remap occured. + static bool updateIntroducedPlatformForFallback( + const AvailableAttr *attr, const ASTContext &Ctx, + llvm::StringRef &Platform, llvm::VersionTuple &PlatformVer); + + /// For the attribute's deprecation version, update the platform and version + /// values to the re-mapped platform's, if using a fallback platform. + /// Returns `true` if a remap occured. + static bool updateDeprecatedPlatformForFallback( + const AvailableAttr *attr, const ASTContext &Ctx, + llvm::StringRef &Platform, llvm::VersionTuple &PlatformVer); + + /// For the attribute's obsoletion version, update the platform and version + /// values to the re-mapped platform's, if using a fallback platform. + /// Returns `true` if a remap occured. + static bool updateObsoletedPlatformForFallback( + const AvailableAttr *attr, const ASTContext &Ctx, + llvm::StringRef &Platform, llvm::VersionTuple &PlatformVer); + + static void updatePlatformStringForFallback( + const AvailableAttr *attr, const ASTContext &Ctx, + llvm::StringRef &Platform); + + /// For the attribute's before version, update the platform and version + /// values to the re-mapped platform's, if using a fallback platform. + /// Returns `true` if a remap occured. + static bool updateBeforePlatformForFallback(const BackDeployedAttr *attr, + const ASTContext &Ctx, + llvm::StringRef &Platform, + llvm::VersionTuple &PlatformVer); }; /// Given a declaration upon which an availability attribute would appear in diff --git a/include/swift/AST/PlatformKind.h b/include/swift/AST/PlatformKind.h index cfc78467ccf31..cb59c440784d6 100644 --- a/include/swift/AST/PlatformKind.h +++ b/include/swift/AST/PlatformKind.h @@ -78,7 +78,7 @@ inline bool isApplicationExtensionPlatform(PlatformKind Platform) { /// triple will be used rather than the target to determine whether the /// platform is active. bool isPlatformActive(PlatformKind Platform, const LangOptions &LangOpts, - bool ForTargetVariant = false); + bool ForTargetVariant = false, bool ForRuntimeQuery = false); /// Returns the target platform for the given language options. PlatformKind targetPlatform(const LangOptions &LangOpts); diff --git a/include/swift/AST/PlatformKinds.def b/include/swift/AST/PlatformKinds.def index 017f09b7abe44..dd10bf495b65b 100644 --- a/include/swift/AST/PlatformKinds.def +++ b/include/swift/AST/PlatformKinds.def @@ -25,10 +25,12 @@ AVAILABILITY_PLATFORM(iOS, "iOS") AVAILABILITY_PLATFORM(tvOS, "tvOS") AVAILABILITY_PLATFORM(watchOS, "watchOS") +AVAILABILITY_PLATFORM(visionOS, "visionOS") AVAILABILITY_PLATFORM(macOS, "macOS") AVAILABILITY_PLATFORM(iOSApplicationExtension, "application extensions for iOS") AVAILABILITY_PLATFORM(tvOSApplicationExtension, "application extensions for tvOS") AVAILABILITY_PLATFORM(watchOSApplicationExtension, "application extensions for watchOS") +AVAILABILITY_PLATFORM(visionOSApplicationExtension, "application extensions for visionOS") AVAILABILITY_PLATFORM(macOSApplicationExtension, "application extensions for macOS") AVAILABILITY_PLATFORM(macCatalyst, "Mac Catalyst") AVAILABILITY_PLATFORM(macCatalystApplicationExtension, "application extensions for Mac Catalyst") diff --git a/include/swift/AST/RuntimeVersions.def b/include/swift/AST/RuntimeVersions.def index 3223756a6dcb5..2aa07fee075e3 100644 --- a/include/swift/AST/RuntimeVersions.def +++ b/include/swift/AST/RuntimeVersions.def @@ -135,6 +135,7 @@ RUNTIME_VERSION( PLATFORM(macOS, (14, 4, 0)) PLATFORM(iOS, (17, 4, 0)) PLATFORM(watchOS, (10, 4, 0)) + PLATFORM(xrOS, (1, 0, 0)) ) RUNTIME_VERSION( diff --git a/include/swift/AST/SearchPathOptions.h b/include/swift/AST/SearchPathOptions.h index dd7debcce1351..166107440504a 100644 --- a/include/swift/AST/SearchPathOptions.h +++ b/include/swift/AST/SearchPathOptions.h @@ -500,6 +500,10 @@ class SearchPathOptions { /// A file containing a list of protocols whose conformances require const value extraction. std::string ConstGatherProtocolListFilePath; + /// Path to the file that defines platform mapping for availability + /// version inheritance. + std::optional PlatformAvailabilityInheritanceMapPath; + /// Debug path mappings to apply to serialized search paths. These are /// specified in LLDB from the target.source-map entries. PathRemapper SearchPathRemapper; diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h index 38aeb2ec20b7c..c2805ac1011b9 100644 --- a/include/swift/Basic/LangOptions.h +++ b/include/swift/Basic/LangOptions.h @@ -635,6 +635,8 @@ namespace swift { return Target.getiOSVersion(); } else if (Target.isWatchOS()) { return Target.getOSVersion(); + } else if (Target.isXROS()) { + return Target.getOSVersion(); } return llvm::VersionTuple(/*Major=*/0, /*Minor=*/0, /*Subminor=*/0); } diff --git a/include/swift/Basic/Platform.h b/include/swift/Basic/Platform.h index 6eff7622ea2e2..2a1b984087e70 100644 --- a/include/swift/Basic/Platform.h +++ b/include/swift/Basic/Platform.h @@ -33,7 +33,9 @@ namespace swift { TvOS, TvOSSimulator, WatchOS, - WatchOSSimulator + WatchOSSimulator, + VisionOS, + VisionOSSimulator }; /// Returns true if the given triple represents iOS running in a simulator. @@ -48,6 +50,9 @@ namespace swift { /// Returns true if the given triple represents a macCatalyst environment. bool tripleIsMacCatalystEnvironment(const llvm::Triple &triple); + /// Returns true if the given triple represents visionOS running in a simulator. + bool tripleIsVisionSimulator(const llvm::Triple &triple); + /// Determine whether the triple infers the "simulator" environment. bool tripleInfersSimulatorEnvironment(const llvm::Triple &triple); diff --git a/include/swift/Frontend/Frontend.h b/include/swift/Frontend/Frontend.h index 6531a2e07adcd..5c1d54f002375 100644 --- a/include/swift/Frontend/Frontend.h +++ b/include/swift/Frontend/Frontend.h @@ -233,6 +233,8 @@ class CompilerInvocation { void setRuntimeResourcePath(StringRef Path); + void setPlatformAvailabilityInheritanceMapPath(StringRef Path); + /// Compute the default prebuilt module cache path for a given resource path /// and SDK version. This function is also used by LLDB. static std::string diff --git a/include/swift/Option/FrontendOptions.td b/include/swift/Option/FrontendOptions.td index 27098b7cd1a37..a80f5ea99b870 100644 --- a/include/swift/Option/FrontendOptions.td +++ b/include/swift/Option/FrontendOptions.td @@ -1343,4 +1343,8 @@ def module_load_mode: Separate<["-"], "module-load-mode">, MetaVarName<"only-interface|prefer-interface|prefer-serialized|only-serialized">, HelpText<"Module loading mode">; +def platform_availability_inheritance_map_path + : Separate<["-"], "platform-availability-inheritance-map-path">, MetaVarName<"">, + HelpText<"Path of the platform inheritance platform map">; + } // end let Flags = [FrontendOption, NoDriverOption, HelpHidden] diff --git a/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/MachO.h b/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/MachO.h index 35b6bce574bab..ca4d9cdb99ff4 100644 --- a/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/MachO.h +++ b/include/swift/RemoteInspection/RuntimeHeaders/llvm/BinaryFormat/MachO.h @@ -508,6 +508,8 @@ enum PlatformType { PLATFORM_TVOSSIMULATOR = 8, PLATFORM_WATCHOSSIMULATOR = 9, PLATFORM_DRIVERKIT = 10, + PLATFORM_XROS = 11, + PLATFORM_XROS_SIMULATOR = 12 }; // Values for tools enum in build_tool_version. diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index fce435171b1eb..dd8fbbdf5d29e 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -657,6 +657,8 @@ struct ASTContext::Implementation { /// The scratch context used to allocate intrinsic data on behalf of \c swift::IntrinsicInfo std::unique_ptr IntrinsicScratchContext; + mutable std::optional> SDKInfo; + /// Memory allocation arena for the term rewriting system. std::unique_ptr TheRewriteContext; @@ -6399,6 +6401,44 @@ bool ASTContext::isASCIIString(StringRef s) const { return true; } +clang::DarwinSDKInfo *ASTContext::getDarwinSDKInfo() const { + if (!getImpl().SDKInfo) { + auto SDKInfoOrErr = clang::parseDarwinSDKInfo( + *llvm::vfs::getRealFileSystem(), + SearchPathOpts.SDKPath); + if (!SDKInfoOrErr) { + llvm::handleAllErrors(SDKInfoOrErr.takeError(), + [](const llvm::ErrorInfoBase &) { + // Ignore the error for now.. + }); + getImpl().SDKInfo.emplace(); + } else if (!*SDKInfoOrErr) { + getImpl().SDKInfo.emplace(); + } else { + getImpl().SDKInfo.emplace(std::make_unique(**SDKInfoOrErr)); + } + } + + return getImpl().SDKInfo->get(); +} + +const clang::DarwinSDKInfo::RelatedTargetVersionMapping +*ASTContext::getAuxiliaryDarwinPlatformRemapInfo(clang::DarwinSDKInfo::OSEnvPair Kind) const { + if (SearchPathOpts.PlatformAvailabilityInheritanceMapPath) { + auto SDKInfoOrErr = clang::parseDarwinSDKInfo( + *llvm::vfs::getRealFileSystem(), + *SearchPathOpts.PlatformAvailabilityInheritanceMapPath); + if (!SDKInfoOrErr || !*SDKInfoOrErr) { + llvm::handleAllErrors(SDKInfoOrErr.takeError(), + [](const llvm::ErrorInfoBase &) { + // Ignore the error for now.. + }); + } + return (*SDKInfoOrErr)->getVersionMapping(Kind); + } + return nullptr; +} + /// The special Builtin.TheTupleType, which parents tuple extensions and /// conformances. BuiltinTupleDecl *ASTContext::getBuiltinTupleDecl() { diff --git a/lib/AST/Attr.cpp b/lib/AST/Attr.cpp index 631056e6675f3..f80257ff0d3a7 100644 --- a/lib/AST/Attr.cpp +++ b/lib/AST/Attr.cpp @@ -497,6 +497,13 @@ DeclAttributes::getDeprecated(const ASTContext &ctx) const { return AvAttr; std::optional DeprecatedVersion = AvAttr->Deprecated; + + StringRef DeprecatedPlatform = AvAttr->prettyPlatformString(); + llvm::VersionTuple RemappedDeprecatedVersion; + if (AvailabilityInference::updateDeprecatedPlatformForFallback( + AvAttr, ctx, DeprecatedPlatform, RemappedDeprecatedVersion)) + DeprecatedVersion = RemappedDeprecatedVersion; + if (!DeprecatedVersion.has_value()) continue; @@ -2335,18 +2342,32 @@ AvailableVersionComparison AvailableAttr::getVersionAvailability( return AvailableVersionComparison::Unavailable; llvm::VersionTuple queryVersion = getActiveVersion(ctx); + std::optional ObsoletedVersion = Obsoleted; + + StringRef ObsoletedPlatform = prettyPlatformString(); + llvm::VersionTuple RemappedObsoletedVersion; + if (AvailabilityInference::updateObsoletedPlatformForFallback( + this, ctx, ObsoletedPlatform, RemappedObsoletedVersion)) + ObsoletedVersion = RemappedObsoletedVersion; // If this entity was obsoleted before or at the query platform version, // consider it obsolete. - if (Obsoleted && *Obsoleted <= queryVersion) + if (ObsoletedVersion && *ObsoletedVersion <= queryVersion) return AvailableVersionComparison::Obsoleted; + std::optional IntroducedVersion = Introduced; + StringRef IntroducedPlatform = prettyPlatformString(); + llvm::VersionTuple RemappedIntroducedVersion; + if (AvailabilityInference::updateIntroducedPlatformForFallback( + this, ctx, IntroducedPlatform, RemappedIntroducedVersion)) + IntroducedVersion = RemappedIntroducedVersion; + // If this entity was introduced after the query version and we're doing a // platform comparison, true availability can only be determined dynamically; // if we're doing a _language_ version check, the query version is a // static requirement, so we treat "introduced later" as just plain // unavailable. - if (Introduced && *Introduced > queryVersion) { + if (IntroducedVersion && *IntroducedVersion > queryVersion) { if (isLanguageVersionSpecific() || isPackageDescriptionVersionSpecific()) return AvailableVersionComparison::Unavailable; else diff --git a/lib/AST/Availability.cpp b/lib/AST/Availability.cpp index 80c118c205836..3a580c9bfd923 100644 --- a/lib/AST/Availability.cpp +++ b/lib/AST/Availability.cpp @@ -251,6 +251,123 @@ static bool isBetterThan(const AvailableAttr *newAttr, prevAttr->Platform); } +static const clang::DarwinSDKInfo::RelatedTargetVersionMapping * +getFallbackVersionMapping(const ASTContext &Ctx, + clang::DarwinSDKInfo::OSEnvPair Kind) { + auto *SDKInfo = Ctx.getDarwinSDKInfo(); + if (SDKInfo) + return SDKInfo->getVersionMapping(Kind); + + return Ctx.getAuxiliaryDarwinPlatformRemapInfo(Kind); +} + +static std::optional +getRemappedIntroducedVersionForFallbackPlatform( + const ASTContext &Ctx, const llvm::VersionTuple &Version) { + const auto *Mapping = getFallbackVersionMapping( + Ctx, clang::DarwinSDKInfo::OSEnvPair( + llvm::Triple::IOS, llvm::Triple::UnknownEnvironment, + llvm::Triple::XROS, llvm::Triple::UnknownEnvironment)); + if (!Mapping) + return std::nullopt; + return Mapping->mapIntroducedAvailabilityVersion(Version); +} + +static std::optional +getRemappedDeprecatedObsoletedVersionForFallbackPlatform( + const ASTContext &Ctx, const llvm::VersionTuple &Version) { + const auto *Mapping = getFallbackVersionMapping( + Ctx, clang::DarwinSDKInfo::OSEnvPair( + llvm::Triple::IOS, llvm::Triple::UnknownEnvironment, + llvm::Triple::XROS, llvm::Triple::UnknownEnvironment)); + if (!Mapping) + return std::nullopt; + return Mapping->mapDeprecatedObsoletedAvailabilityVersion(Version); +} + +bool AvailabilityInference::updateIntroducedPlatformForFallback( + const AvailableAttr *attr, const ASTContext &Ctx, llvm::StringRef &Platform, + llvm::VersionTuple &PlatformVer) { + std::optional IntroducedVersion = attr->Introduced; + if (attr->Platform == PlatformKind::iOS && IntroducedVersion.has_value() && + isPlatformActive(PlatformKind::visionOS, Ctx.LangOpts)) { + // We re-map the iOS introduced version to the corresponding visionOS version + auto PotentiallyRemappedIntroducedVersion = + getRemappedIntroducedVersionForFallbackPlatform(Ctx, + *IntroducedVersion); + if (PotentiallyRemappedIntroducedVersion.has_value()) { + Platform = swift::prettyPlatformString(PlatformKind::visionOS); + PlatformVer = PotentiallyRemappedIntroducedVersion.value(); + return true; + } + } + return false; +} + +bool AvailabilityInference::updateDeprecatedPlatformForFallback( + const AvailableAttr *attr, const ASTContext &Ctx, llvm::StringRef &Platform, + llvm::VersionTuple &PlatformVer) { + std::optional DeprecatedVersion = attr->Deprecated; + if (attr->Platform == PlatformKind::iOS && DeprecatedVersion.has_value() && + isPlatformActive(PlatformKind::visionOS, Ctx.LangOpts)) { + // We re-map the iOS deprecated version to the corresponding visionOS version + auto PotentiallyRemappedDeprecatedVersion = + getRemappedDeprecatedObsoletedVersionForFallbackPlatform( + Ctx, *DeprecatedVersion); + if (PotentiallyRemappedDeprecatedVersion.has_value()) { + Platform = swift::prettyPlatformString(PlatformKind::visionOS); + PlatformVer = PotentiallyRemappedDeprecatedVersion.value(); + return true; + } + } + return false; +} + +bool AvailabilityInference::updateObsoletedPlatformForFallback( + const AvailableAttr *attr, const ASTContext &Ctx, llvm::StringRef &Platform, + llvm::VersionTuple &PlatformVer) { + std::optional ObsoletedVersion = attr->Obsoleted; + if (attr->Platform == PlatformKind::iOS && ObsoletedVersion.has_value() && + isPlatformActive(PlatformKind::visionOS, Ctx.LangOpts)) { + // We re-map the iOS obsoleted version to the corresponding visionOS version + auto PotentiallyRemappedObsoletedVersion = + getRemappedDeprecatedObsoletedVersionForFallbackPlatform( + Ctx, *ObsoletedVersion); + if (PotentiallyRemappedObsoletedVersion.has_value()) { + Platform = swift::prettyPlatformString(PlatformKind::visionOS); + PlatformVer = PotentiallyRemappedObsoletedVersion.value(); + return true; + } + } + return false; +} + +void AvailabilityInference::updatePlatformStringForFallback( + const AvailableAttr *attr, const ASTContext &Ctx, llvm::StringRef &Platform) { + if (attr->Platform == PlatformKind::iOS && + isPlatformActive(PlatformKind::visionOS, Ctx.LangOpts)) { + Platform = swift::prettyPlatformString(PlatformKind::visionOS); + } +} + +bool AvailabilityInference::updateBeforePlatformForFallback( + const BackDeployedAttr *attr, const ASTContext &Ctx, + llvm::StringRef &Platform, llvm::VersionTuple &PlatformVer) { + auto BeforeVersion = attr->Version; + if (attr->Platform == PlatformKind::iOS && + isPlatformActive(PlatformKind::visionOS, Ctx.LangOpts)) { + // We re-map the iOS before version to the corresponding visionOS version + auto PotentiallyRemappedIntroducedVersion = + getRemappedIntroducedVersionForFallbackPlatform(Ctx, BeforeVersion); + if (PotentiallyRemappedIntroducedVersion.has_value()) { + Platform = swift::prettyPlatformString(PlatformKind::visionOS); + PlatformVer = PotentiallyRemappedIntroducedVersion.value(); + return true; + } + } + return false; +} + const AvailableAttr * AvailabilityInference::attrForAnnotatedAvailableRange(const Decl *D, ASTContext &Ctx) { @@ -369,6 +486,14 @@ getEffectiveUnavailableDeclOptimization(ASTContext &ctx) { if (ctx.LangOpts.UnavailableDeclOptimizationMode.has_value()) return *ctx.LangOpts.UnavailableDeclOptimizationMode; + // FIXME: Allow unavailable decl optimization on visionOS. + // visionOS must be ABI compatible with iOS. Enabling unavailable declaration + // optimizations naively would break compatibility since declarations marked + // unavailable on visionOS would be optimized regardless of whether they are + // available on iOS. rdar://116742214 + if (ctx.LangOpts.Target.isXROS()) + return UnavailableDeclOptimization::None; + return UnavailableDeclOptimization::None; } @@ -456,7 +581,15 @@ AvailabilityContext AvailabilityInference::availableRange(const AvailableAttr *attr, ASTContext &Ctx) { assert(attr->isActivePlatform(Ctx)); - return AvailabilityContext{VersionRange::allGTE(attr->Introduced.value()), + + llvm::VersionTuple IntroducedVersion = attr->Introduced.value(); + StringRef Platform = attr->prettyPlatformString(); + llvm::VersionTuple RemappedIntroducedVersion; + if (AvailabilityInference::updateIntroducedPlatformForFallback( + attr, Ctx, Platform, RemappedIntroducedVersion)) + IntroducedVersion = RemappedIntroducedVersion; + + return AvailabilityContext{VersionRange::allGTE(IntroducedVersion), attr->IsSPI}; } @@ -533,6 +666,7 @@ ASTContext::getSwiftAvailability(unsigned major, unsigned minor) const { #define PLATFORM_TEST_macOS target.isMacOSX() #define PLATFORM_TEST_iOS target.isiOS() #define PLATFORM_TEST_watchOS target.isWatchOS() +#define PLATFORM_TEST_xrOS target.isXROS() #define _SECOND(A, B) B #define SECOND(T) _SECOND T @@ -547,6 +681,7 @@ ASTContext::getSwiftAvailability(unsigned major, unsigned minor) const { #undef PLATFORM_TEST_macOS #undef PLATFORM_TEST_iOS #undef PLATFORM_TEST_watchOS +#undef PLATFORM_TEST_xrOS #undef _SECOND #undef SECOND diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 28f98e37c1a09..2c211b80faa5b 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -567,6 +567,15 @@ std::optional Decl::getBackDeployedBeforeOSVersion(ASTContext &Ctx) const { if (auto *attr = getAttrs().getBackDeployed(Ctx)) { auto version = attr->Version; + StringRef ignoredPlatformString; + AvailabilityInference::updateBeforePlatformForFallback( + attr, getASTContext(), ignoredPlatformString, version); + + // If the remap for fallback resulted in 1.0, then the + // backdeployment prior to that is not meaningful. + if (version == clang::VersionTuple(1, 0, 0, 0)) + return std::nullopt; + return version; } diff --git a/lib/AST/PlatformKind.cpp b/lib/AST/PlatformKind.cpp index e856a9e046e03..31af9b088a69d 100644 --- a/lib/AST/PlatformKind.cpp +++ b/lib/AST/PlatformKind.cpp @@ -107,11 +107,14 @@ swift::basePlatformForExtensionPlatform(PlatformKind Platform) { return PlatformKind::tvOS; case PlatformKind::watchOSApplicationExtension: return PlatformKind::watchOS; + case PlatformKind::visionOSApplicationExtension: + return PlatformKind::visionOS; case PlatformKind::macOS: case PlatformKind::iOS: case PlatformKind::macCatalyst: case PlatformKind::tvOS: case PlatformKind::watchOS: + case PlatformKind::visionOS: case PlatformKind::OpenBSD: case PlatformKind::Windows: case PlatformKind::none: @@ -122,7 +125,8 @@ swift::basePlatformForExtensionPlatform(PlatformKind Platform) { static bool isPlatformActiveForTarget(PlatformKind Platform, const llvm::Triple &Target, - bool EnableAppExtensionRestrictions) { + bool EnableAppExtensionRestrictions, + bool ForRuntimeQuery) { if (Platform == PlatformKind::none) return true; @@ -137,6 +141,9 @@ static bool isPlatformActiveForTarget(PlatformKind Platform, return Target.isMacOSX(); case PlatformKind::iOS: case PlatformKind::iOSApplicationExtension: + if (!ForRuntimeQuery && Target.isXROS()) { + return true; + } return Target.isiOS() && !Target.isTvOS(); case PlatformKind::macCatalyst: case PlatformKind::macCatalystApplicationExtension: @@ -147,6 +154,9 @@ static bool isPlatformActiveForTarget(PlatformKind Platform, case PlatformKind::watchOS: case PlatformKind::watchOSApplicationExtension: return Target.isWatchOS(); + case PlatformKind::visionOS: + case PlatformKind::visionOSApplicationExtension: + return Target.isXROS(); case PlatformKind::OpenBSD: return Target.isOSOpenBSD(); case PlatformKind::Windows: @@ -158,15 +168,16 @@ static bool isPlatformActiveForTarget(PlatformKind Platform, } bool swift::isPlatformActive(PlatformKind Platform, const LangOptions &LangOpts, - bool ForTargetVariant) { + bool ForTargetVariant, bool ForRuntimeQuery) { if (ForTargetVariant) { assert(LangOpts.TargetVariant && "Must have target variant triple"); return isPlatformActiveForTarget(Platform, *LangOpts.TargetVariant, - LangOpts.EnableAppExtensionRestrictions); + LangOpts.EnableAppExtensionRestrictions, + ForRuntimeQuery); } return isPlatformActiveForTarget(Platform, LangOpts.Target, - LangOpts.EnableAppExtensionRestrictions); + LangOpts.EnableAppExtensionRestrictions, ForRuntimeQuery); } PlatformKind swift::targetPlatform(const LangOptions &LangOpts) { @@ -198,6 +209,12 @@ PlatformKind swift::targetPlatform(const LangOptions &LangOpts) { : PlatformKind::iOS); } + if (LangOpts.Target.isXROS()) { + return (LangOpts.EnableAppExtensionRestrictions + ? PlatformKind::visionOSApplicationExtension + : PlatformKind::visionOS); + } + return PlatformKind::none; } @@ -218,6 +235,16 @@ bool swift::inheritsAvailabilityFromPlatform(PlatformKind Child, } } + if (Child == PlatformKind::visionOS && Parent == PlatformKind::iOS) + return true; + + if (Child == PlatformKind::visionOSApplicationExtension) { + if (Parent == PlatformKind::iOS || + Parent == PlatformKind::iOSApplicationExtension) { + return true; + } + } + return false; } diff --git a/lib/Basic/LangOptions.cpp b/lib/Basic/LangOptions.cpp index 13441dc76ae50..5c9918dc1e577 100644 --- a/lib/Basic/LangOptions.cpp +++ b/lib/Basic/LangOptions.cpp @@ -72,6 +72,8 @@ static const SupportedConditionalValue SupportedConditionalCompilationOSs[] = { "tvOS", "watchOS", "iOS", + "visionOS", + "xrOS", "Linux", "FreeBSD", "OpenBSD", @@ -440,6 +442,10 @@ std::pair LangOptions::setTarget(llvm::Triple triple) { case llvm::Triple::IOS: addPlatformConditionValue(PlatformConditionKind::OS, "iOS"); break; + case llvm::Triple::XROS: + addPlatformConditionValue(PlatformConditionKind::OS, "xrOS"); + addPlatformConditionValue(PlatformConditionKind::OS, "visionOS"); + break; case llvm::Triple::Linux: if (Target.getEnvironment() == llvm::Triple::Android) addPlatformConditionValue(PlatformConditionKind::OS, "Android"); diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp index 40b266caa0dd1..5916e5ad74352 100644 --- a/lib/Basic/Platform.cpp +++ b/lib/Basic/Platform.cpp @@ -37,6 +37,10 @@ bool swift::tripleIsMacCatalystEnvironment(const llvm::Triple &triple) { triple.getEnvironment() == llvm::Triple::MacABI; } +bool swift::tripleIsVisionSimulator(const llvm::Triple &triple) { + return triple.isXROS() && triple.isSimulatorEnvironment(); +} + bool swift::tripleInfersSimulatorEnvironment(const llvm::Triple &triple) { switch (triple.getOS()) { case llvm::Triple::IOS: @@ -123,6 +127,10 @@ bool swift::tripleRequiresRPathForSwiftLibrariesInOS( return triple.isOSVersionLT(8, 0); } + if (triple.isXROS()) { + return triple.isOSVersionLT(1, 0); + } + // Other platforms don't have Swift installed as part of the OS by default. return false; } @@ -150,6 +158,12 @@ DarwinPlatformKind swift::getDarwinPlatformKind(const llvm::Triple &triple) { if (triple.isMacOSX()) return DarwinPlatformKind::MacOS; + if (triple.isXROS()) { + if (tripleIsVisionSimulator(triple)) + return DarwinPlatformKind::VisionOSSimulator; + return DarwinPlatformKind::VisionOS; + } + llvm_unreachable("Unsupported Darwin platform"); } @@ -169,6 +183,10 @@ static StringRef getPlatformNameForDarwin(const DarwinPlatformKind platform) { return "watchos"; case DarwinPlatformKind::WatchOSSimulator: return "watchsimulator"; + case DarwinPlatformKind::VisionOS: + return "xros"; + case DarwinPlatformKind::VisionOSSimulator: + return "xrsimulator"; } llvm_unreachable("Unsupported Darwin platform"); } @@ -180,7 +198,6 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) { case llvm::Triple::CloudABI: case llvm::Triple::DragonFly: case llvm::Triple::DriverKit: - case llvm::Triple::XROS: case llvm::Triple::Emscripten: case llvm::Triple::Fuchsia: case llvm::Triple::KFreeBSD: @@ -208,6 +225,7 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) { case llvm::Triple::IOS: case llvm::Triple::TvOS: case llvm::Triple::WatchOS: + case llvm::Triple::XROS: return getPlatformNameForDarwin(getDarwinPlatformKind(triple)); case llvm::Triple::Linux: return triple.isAndroid() ? "android" : "linux"; @@ -513,6 +531,9 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget( return floorFor64bits(llvm::VersionTuple(5, 7)); } } + else if (Triple.isXROS()) { + return std::nullopt; + } return std::nullopt; } diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index ec580ce31c305..9028f5485f50a 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -616,6 +616,13 @@ importer::getNormalInvocationArguments( if (clangSupportsPragmaAttributeWithSwiftAttr()) invocationArgStrs.push_back("-D__SWIFT_ATTR_SUPPORTS_SENDABLE_DECLS=1"); + if (triple.isXROS()) { + // FIXME: This is a gnarly hack until some macros get adjusted in the SDK. + invocationArgStrs.insert(invocationArgStrs.end(), { + "-DOS_OBJECT_HAVE_OBJC_SUPPORT=1", + }); + } + // Get the version of this compiler and pass it to C/Objective-C // declarations. auto V = version::getCurrentCompilerVersion(); @@ -820,6 +827,9 @@ importer::addCommonInvocationArguments( else if (triple.isAArch64() && triple.isSimulatorEnvironment() && (triple.isiOS() || triple.isWatchOS())) invocationArgStrs.push_back("-mcpu=apple-a12"); + else if (triple.isAArch64() && triple.isSimulatorEnvironment() && + triple.isXROS()) + invocationArgStrs.push_back("-mcpu=apple-a12"); else if (triple.getArch() == llvm::Triple::aarch64 || triple.getArch() == llvm::Triple::aarch64_32 || triple.getArch() == llvm::Triple::aarch64_be) { @@ -2445,6 +2455,10 @@ PlatformAvailability::PlatformAvailability(const LangOptions &langOpts) "'async'"; break; + case PlatformKind::visionOS: + case PlatformKind::visionOSApplicationExtension: + break; + case PlatformKind::OpenBSD: deprecatedAsUnavailableMessage = ""; break; @@ -2486,6 +2500,12 @@ bool PlatformAvailability::isPlatformRelevant(StringRef name) const { case PlatformKind::watchOSApplicationExtension: return name == "watchos" || name == "watchos_app_extension"; + case PlatformKind::visionOS: + return name == "xros" || name == "visionos"; + case PlatformKind::visionOSApplicationExtension: + return name == "xros" || name == "xros_app_extension" || + name == "visionos" || name == "visionos_app_extension"; + case PlatformKind::OpenBSD: return name == "openbsd"; @@ -2552,6 +2572,11 @@ bool PlatformAvailability::treatDeprecatedAsUnavailable( // No deprecation filter on watchOS return false; + case PlatformKind::visionOS: + case PlatformKind::visionOSApplicationExtension: + // No deprecation filter on xrOS + return false; + case PlatformKind::OpenBSD: // No deprecation filter on OpenBSD return false; diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 9e47837fc3931..c6b2efa143c91 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -8313,6 +8313,8 @@ void ClangImporter::Implementation::importAttributes( .Case("maccatalyst", PlatformKind::macCatalyst) .Case("tvos", PlatformKind::tvOS) .Case("watchos", PlatformKind::watchOS) + .Case("xros", PlatformKind::visionOS) + .Case("visionos", PlatformKind::visionOS) .Case("ios_app_extension", PlatformKind::iOSApplicationExtension) .Case("maccatalyst_app_extension", PlatformKind::macCatalystApplicationExtension) @@ -8322,6 +8324,8 @@ void ClangImporter::Implementation::importAttributes( PlatformKind::tvOSApplicationExtension) .Case("watchos_app_extension", PlatformKind::watchOSApplicationExtension) + .Case("xros_app_extension", + PlatformKind::visionOSApplicationExtension) .Default(std::nullopt); if (!platformK) continue; diff --git a/lib/Driver/DarwinToolChains.cpp b/lib/Driver/DarwinToolChains.cpp index 432534ff0163c..727e8d56ecdca 100644 --- a/lib/Driver/DarwinToolChains.cpp +++ b/lib/Driver/DarwinToolChains.cpp @@ -112,6 +112,10 @@ getDarwinLibraryNameSuffixForTriple(const llvm::Triple &triple) { return "watchos"; case DarwinPlatformKind::WatchOSSimulator: return "watchossim"; + case DarwinPlatformKind::VisionOS: + return "xros"; + case DarwinPlatformKind::VisionOSSimulator: + return "xrossim"; } llvm_unreachable("Unsupported Darwin platform"); } @@ -502,6 +506,8 @@ toolchains::Darwin::addProfileGenerationArgs(ArgStringList &Arguments, RT = "ios"; } else if (Triple.isWatchOS()) { RT = "watchos"; + } else if (Triple.isXROS()) { + RT = "xros"; } else { assert(Triple.isMacOSX()); RT = "osx"; @@ -563,6 +569,12 @@ toolchains::Darwin::addDeploymentTargetArgs(ArgStringList &Arguments, case DarwinPlatformKind::WatchOSSimulator: platformName = "watchos-simulator"; break; + case DarwinPlatformKind::VisionOS: + platformName = "xros"; + break; + case DarwinPlatformKind::VisionOSSimulator: + platformName = "xros-simulator"; + break; } } @@ -611,6 +623,17 @@ toolchains::Darwin::addDeploymentTargetArgs(ArgStringList &Arguments, case DarwinPlatformKind::WatchOS: case DarwinPlatformKind::WatchOSSimulator: osVersion = triple.getOSVersion(); + break; + case DarwinPlatformKind::VisionOS: + case DarwinPlatformKind::VisionOSSimulator: + osVersion = triple.getOSVersion(); + + // The first deployment of 64-bit xrOS simulator is version 1.0. + if (triple.isArch64Bit() && triple.isSimulatorEnvironment() && + osVersion.getMajor() < 1) { + osVersion = llvm::VersionTuple(/*Major=*/1, /*Minor=*/0); + } + break; } } diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 1cedad0a2fc32..9e2544b181327 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -340,6 +340,7 @@ Driver::buildToolChain(const llvm::opt::InputArgList &ArgList) { } switch (target.getOS()) { + case llvm::Triple::XROS: case llvm::Triple::IOS: case llvm::Triple::TvOS: case llvm::Triple::WatchOS: diff --git a/lib/DriverTool/swift_api_digester_main.cpp b/lib/DriverTool/swift_api_digester_main.cpp index bf3e9faf4ac81..792219929ecd2 100644 --- a/lib/DriverTool/swift_api_digester_main.cpp +++ b/lib/DriverTool/swift_api_digester_main.cpp @@ -2177,6 +2177,8 @@ static StringRef getBaselineFilename(llvm::Triple Triple) { return "linux.json"; else if (Triple.isOSWindows()) return "windows.json"; + else if (Triple.isXROS()) + return "xros.json"; else { llvm::errs() << "Unsupported triple target\n"; exit(1); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index a8d3f2547737b..7ed4e2e6d0a44 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -305,6 +305,10 @@ void CompilerInvocation::setRuntimeResourcePath(StringRef Path) { updateRuntimeLibraryPaths(SearchPathOpts, FrontendOpts, LangOpts); } +void CompilerInvocation::setPlatformAvailabilityInheritanceMapPath(StringRef Path) { + SearchPathOpts.PlatformAvailabilityInheritanceMapPath = Path.str(); +} + void CompilerInvocation::setTargetTriple(StringRef Triple) { setTargetTriple(llvm::Triple(Triple)); } @@ -1180,6 +1184,24 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args, Target = llvm::Triple(A->getValue()); TargetArg = A->getValue(); + const bool targetNeedsRemapping = Target.isXROS(); + if (targetNeedsRemapping && Target.getOSMajorVersion() == 0) { + // FIXME(xrOS): Work around an LLVM-ism until we have something + // akin to Target::get*Version for this platform. The Clang driver + // also has to pull version numbers up to 1.0.0 when a triple for an + // unknown platform with no explicit version number is passed. + if (Target.getEnvironmentName().empty()) { + Target = llvm::Triple(Target.getArchName(), + Target.getVendorName(), + Target.getOSName() + "1.0"); + } else { + Target = llvm::Triple(Target.getArchName(), + Target.getVendorName(), + Target.getOSName() + "1.0", + Target.getEnvironmentName()); + } + } + // Backward compatibility hack: infer "simulator" environment for x86 // iOS/tvOS/watchOS. The driver takes care of this for the frontend // most of the time, but loading of old .swiftinterface files goes @@ -2015,6 +2037,9 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args, if (const Arg *A = Args.getLastArg(OPT_const_gather_protocols_file)) Opts.ConstGatherProtocolListFilePath = A->getValue(); + if (const Arg *A = Args.getLastArg(OPT_platform_availability_inheritance_map_path)) + Opts.PlatformAvailabilityInheritanceMapPath = A->getValue(); + for (auto A : Args.getAllArgValues(options::OPT_serialized_path_obfuscate)) { auto SplitMap = StringRef(A).split('='); Opts.DeserializedPathRecoverer.addMapping(SplitMap.first, SplitMap.second); diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp index d065f3837d1f6..952fa247afb4e 100644 --- a/lib/Frontend/ModuleInterfaceLoader.cpp +++ b/lib/Frontend/ModuleInterfaceLoader.cpp @@ -1690,6 +1690,12 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface( genericSubInvocation.setSDKPath(SearchPathOpts.getSDKPath().str()); } + if (SearchPathOpts.PlatformAvailabilityInheritanceMapPath) { + GenericArgs.push_back("-platform-availability-inheritance-map-path"); + GenericArgs.push_back(ArgSaver.save(*SearchPathOpts.PlatformAvailabilityInheritanceMapPath)); + genericSubInvocation.setPlatformAvailabilityInheritanceMapPath(*SearchPathOpts.PlatformAvailabilityInheritanceMapPath); + } + genericSubInvocation.getFrontendOptions().InputMode = FrontendOptions::ParseInputMode::SwiftModuleInterface; if (!SearchPathOpts.RuntimeResourcePath.empty()) { diff --git a/lib/IDE/CodeCompletionDiagnostics.cpp b/lib/IDE/CodeCompletionDiagnostics.cpp index d82484ff26420..6f8bae705a649 100644 --- a/lib/IDE/CodeCompletionDiagnostics.cpp +++ b/lib/IDE/CodeCompletionDiagnostics.cpp @@ -94,6 +94,11 @@ bool CodeCompletionDiagnostics::getDiagnosticForDeprecated( if (Attr->Deprecated) DeprecatedVersion = Attr->Deprecated.value(); + llvm::VersionTuple RemappedDeprecatedVersion; + if (AvailabilityInference::updateDeprecatedPlatformForFallback( + Attr, Ctx, Platform, RemappedDeprecatedVersion)) + DeprecatedVersion = RemappedDeprecatedVersion; + if (!isSoftDeprecated) { if (Attr->Message.empty() && Attr->Rename.empty()) { getDiagnostics(severity, Out, diag::availability_deprecated, diff --git a/lib/IRGen/IRGenFunction.cpp b/lib/IRGen/IRGenFunction.cpp index e2baf08b3c703..463cf1d9a9084 100644 --- a/lib/IRGen/IRGenFunction.cpp +++ b/lib/IRGen/IRGenFunction.cpp @@ -290,6 +290,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::XROS: + return llvm::MachO::PLATFORM_XROS; default: return /*Unknown platform*/ 0; } diff --git a/lib/IRGen/TBDGen.cpp b/lib/IRGen/TBDGen.cpp index 267c8b0f924aa..f265153e5e135 100644 --- a/lib/IRGen/TBDGen.cpp +++ b/lib/IRGen/TBDGen.cpp @@ -264,6 +264,10 @@ getLinkerPlatformId(OriginallyDefinedInAttr::ActiveVersion Ver, case swift::PlatformKind::macCatalyst: case swift::PlatformKind::macCatalystApplicationExtension: return LinkerPlatformId::macCatalyst; + case swift::PlatformKind::visionOS: + case swift::PlatformKind::visionOSApplicationExtension: + return isSimulator ? LinkerPlatformId::xrOS_sim: + LinkerPlatformId::xrOS; } llvm_unreachable("invalid platform kind"); } diff --git a/lib/IRGen/ldPlatformKinds.def b/lib/IRGen/ldPlatformKinds.def index 46ab4d99c7dc8..5f25cac1168d4 100644 --- a/lib/IRGen/ldPlatformKinds.def +++ b/lib/IRGen/ldPlatformKinds.def @@ -26,5 +26,7 @@ LD_PLATFORM(macCatalyst, 6) LD_PLATFORM(iOS_sim, 7) LD_PLATFORM(tvOS_sim, 8) LD_PLATFORM(watchOS_sim, 9) +LD_PLATFORM(xrOS, 11) +LD_PLATFORM(xrOS_sim, 12) #undef LD_PLATFORM diff --git a/lib/PrintAsClang/DeclAndTypePrinter.cpp b/lib/PrintAsClang/DeclAndTypePrinter.cpp index 165fb7b1787d7..bfdb64d212524 100644 --- a/lib/PrintAsClang/DeclAndTypePrinter.cpp +++ b/lib/PrintAsClang/DeclAndTypePrinter.cpp @@ -1715,6 +1715,9 @@ class DeclAndTypePrinter::Implementation case PlatformKind::watchOS: plat = "watchos"; break; + case PlatformKind::visionOS: + plat = "visionos"; + break; case PlatformKind::macOSApplicationExtension: plat = "macos_app_extension"; break; @@ -1730,6 +1733,9 @@ class DeclAndTypePrinter::Implementation case PlatformKind::watchOSApplicationExtension: plat = "watchos_app_extension"; break; + case PlatformKind::visionOSApplicationExtension: + plat = "visionos_app_extension"; + break; case PlatformKind::OpenBSD: plat = "openbsd"; break; diff --git a/lib/Sema/DerivedConformanceRawRepresentable.cpp b/lib/Sema/DerivedConformanceRawRepresentable.cpp index 56824ea6f756d..ea960ef510257 100644 --- a/lib/Sema/DerivedConformanceRawRepresentable.cpp +++ b/lib/Sema/DerivedConformanceRawRepresentable.cpp @@ -249,6 +249,14 @@ checkAvailability(const EnumElementDecl *elt, ASTContext &C, if (!attr) return true; + // For type-checking purposes, iOS availability is inherited for visionOS + // targets. However, it is not inherited for the sake of code-generation + // of runtime availability queries, and is assumed to be available. + if ((attr->Platform == PlatformKind::iOS || + attr->Platform == PlatformKind::iOSApplicationExtension) && + C.LangOpts.Target.isXROS()) + return true; + AvailableVersionComparison availability = attr->getVersionAvailability(C); assert(availability != AvailableVersionComparison::Available && diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index 7d115c2c5853b..c6c1cb6bf59ad 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -705,6 +705,9 @@ static bool iswatchOS(ASTContext &ctx) { } static bool isRelaxedIBAction(ASTContext &ctx) { + if (ctx.LangOpts.Target.isXROS()) + return true; + return isiOS(ctx) || iswatchOS(ctx); } @@ -2055,6 +2058,13 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *attr) { } } + if (attr->Platform == PlatformKind::iOS && + isPlatformActive(PlatformKind::visionOS, Ctx.LangOpts)) { + if (attr != D->getAttrs().findMostSpecificActivePlatform(Ctx)) { + return; + } + } + SourceLoc attrLoc = attr->getLocation(); auto versionAvailability = attr->getVersionAvailability(Ctx); if (versionAvailability == AvailableVersionComparison::Obsoleted || @@ -4588,6 +4598,11 @@ void AttributeChecker::checkBackDeployedAttrs( Attr->Platform)) { auto platformString = prettyPlatformString(Attr->Platform); + llvm::VersionTuple ignoredVersion; + + AvailabilityInference::updateBeforePlatformForFallback( + Attr, Ctx, platformString, ignoredVersion); + diagnose(AtLoc, diag::attr_has_no_effect_on_unavailable_decl, Attr, VD, platformString); diagnose(unavailableAttr->AtLoc, diag::availability_marked_unavailable, @@ -4607,6 +4622,11 @@ void AttributeChecker::checkBackDeployedAttrs( auto introVersion = availableAttr->Introduced.value(); StringRef introPlatformString = availableAttr->prettyPlatformString(); + AvailabilityInference::updateBeforePlatformForFallback( + Attr, Ctx, beforePlatformString, beforeVersion); + AvailabilityInference::updateIntroducedPlatformForFallback( + availableAttr, Ctx, introPlatformString, introVersion); + if (Attr->Version <= introVersion) { diagnose(AtLoc, diag::attr_has_no_effect_decl_not_available_before, Attr, VD, beforePlatformString, beforeVersion); diff --git a/lib/Sema/TypeCheckAvailability.cpp b/lib/Sema/TypeCheckAvailability.cpp index 1278e5495bdc7..74dd17fb4f95b 100644 --- a/lib/Sema/TypeCheckAvailability.cpp +++ b/lib/Sema/TypeCheckAvailability.cpp @@ -1212,7 +1212,7 @@ class TypeRefinementContextBuilder : private ASTWalker { // we want to chose the OS X spec unless there is an explicit // OSXApplicationExtension spec. if (isPlatformActive(VersionSpec->getPlatform(), Context.LangOpts, - forTargetVariant)) { + forTargetVariant, /* ForRuntimeQuery */ true)) { if (!BestSpec || inheritsAvailabilityFromPlatform(VersionSpec->getPlatform(), BestSpec->getPlatform())) { @@ -2674,6 +2674,11 @@ void TypeChecker::diagnoseIfDeprecated(SourceRange ReferenceRange, return; } + llvm::VersionTuple RemappedDeprecatedVersion; + if (AvailabilityInference::updateDeprecatedPlatformForFallback( + Attr, Context, Platform, RemappedDeprecatedVersion)) + DeprecatedVersion = RemappedDeprecatedVersion; + SmallString<32> newNameBuf; std::optional replacementDeclKind = describeRename(Context, Attr, /*decl*/ nullptr, newNameBuf); @@ -2743,6 +2748,11 @@ bool TypeChecker::diagnoseIfDeprecated(SourceLoc loc, if (attr->Deprecated) deprecatedVersion = attr->Deprecated.value(); + llvm::VersionTuple remappedDeprecatedVersion; + if (AvailabilityInference::updateDeprecatedPlatformForFallback( + attr, ctx, platform, remappedDeprecatedVersion)) + deprecatedVersion = remappedDeprecatedVersion; + if (attr->Message.empty()) { ctx.Diags.diagnose( loc, diag::conformance_availability_deprecated, @@ -3245,10 +3255,12 @@ bool swift::diagnoseExplicitUnavailability( // Skip the note emitted below. return true; } else { + auto unavailableDiagnosticPlatform = platform; + AvailabilityInference::updatePlatformStringForFallback(Attr, ctx, unavailableDiagnosticPlatform); EncodedDiagnosticMessage EncodedMessage(Attr->Message); diags .diagnose(Loc, diag::availability_decl_unavailable, D, platform.empty(), - platform, EncodedMessage.Message) + unavailableDiagnosticPlatform, EncodedMessage.Message) .highlight(R) .limitBehavior(limit); } diff --git a/lib/Sema/TypeCheckDeclObjC.cpp b/lib/Sema/TypeCheckDeclObjC.cpp index 7f7ad956793bd..f3af12a9a06bc 100644 --- a/lib/Sema/TypeCheckDeclObjC.cpp +++ b/lib/Sema/TypeCheckDeclObjC.cpp @@ -505,6 +505,8 @@ static VersionRange getMinOSVersionForClassStubs(const llvm::Triple &target) { return VersionRange::allGTE(llvm::VersionTuple(13, 0, 0)); if (target.isWatchOS()) return VersionRange::allGTE(llvm::VersionTuple(6, 0, 0)); + if (target.isXROS()) + return VersionRange::allGTE(llvm::VersionTuple(1, 0, 0)); return VersionRange::all(); } diff --git a/lib/Serialization/SerializedModuleLoader.cpp b/lib/Serialization/SerializedModuleLoader.cpp index 6f888e8243cb9..a44ee0f19e41a 100644 --- a/lib/Serialization/SerializedModuleLoader.cpp +++ b/lib/Serialization/SerializedModuleLoader.cpp @@ -845,6 +845,8 @@ getOSAndVersionForDiagnostics(const llvm::Triple &triple) { osName = swift::prettyPlatformString(PlatformKind::tvOS); } else if (triple.isiOS()) { osName = swift::prettyPlatformString(PlatformKind::iOS); + } else if (triple.isXROS()) { + osName = swift::prettyPlatformString(PlatformKind::visionOS); } else { assert(!triple.isOSDarwin() && "unknown Apple OS"); // Fallback to the LLVM triple name. This isn't great (it won't be diff --git a/lib/SymbolGraphGen/AvailabilityMixin.cpp b/lib/SymbolGraphGen/AvailabilityMixin.cpp index 03b6e963bbb95..01bec91ccd2aa 100644 --- a/lib/SymbolGraphGen/AvailabilityMixin.cpp +++ b/lib/SymbolGraphGen/AvailabilityMixin.cpp @@ -47,6 +47,8 @@ StringRef getDomain(const AvailableAttr &AvAttr) { return { "tvOS" }; case swift::PlatformKind::watchOS: return { "watchOS" }; + case swift::PlatformKind::visionOS: + return { "visionOS" }; case swift::PlatformKind::iOSApplicationExtension: return { "iOSAppExtension" }; case swift::PlatformKind::macCatalystApplicationExtension: @@ -57,6 +59,8 @@ StringRef getDomain(const AvailableAttr &AvAttr) { return { "tvOSAppExtension" }; case swift::PlatformKind::watchOSApplicationExtension: return { "watchOSAppExtension" }; + case swift::PlatformKind::visionOSApplicationExtension: + return { "visionOSAppExtension" }; case swift::PlatformKind::OpenBSD: return { "OpenBSD" }; case swift::PlatformKind::Windows: diff --git a/stdlib/cmake/modules/AddSwiftStdlib.cmake b/stdlib/cmake/modules/AddSwiftStdlib.cmake index ba6d9eb4547cd..d95ce397e7726 100644 --- a/stdlib/cmake/modules/AddSwiftStdlib.cmake +++ b/stdlib/cmake/modules/AddSwiftStdlib.cmake @@ -31,11 +31,13 @@ endfunction() # DEPLOYMENT_VERSION_IOS version # DEPLOYMENT_VERSION_TVOS version # DEPLOYMENT_VERSION_WATCHOS version +# DEPLOYMENT_VERSION_XROS version # # ) function(_add_target_variant_c_compile_link_flags) set(oneValueArgs SDK ARCH BUILD_TYPE RESULT_VAR_NAME ENABLE_LTO ANALYZE_CODE_COVERAGE DEPLOYMENT_VERSION_OSX DEPLOYMENT_VERSION_MACCATALYST DEPLOYMENT_VERSION_IOS DEPLOYMENT_VERSION_TVOS DEPLOYMENT_VERSION_WATCHOS + DEPLOYMENT_VERSION_XROS MACCATALYST_BUILD_FLAVOR ) cmake_parse_arguments(CFLAGS @@ -63,6 +65,8 @@ function(_add_target_variant_c_compile_link_flags) set(DEPLOYMENT_VERSION ${CFLAGS_DEPLOYMENT_VERSION_TVOS}) elseif("${CFLAGS_SDK}" STREQUAL "WATCHOS" OR "${CFLAGS_SDK}" STREQUAL "WATCHOS_SIMULATOR") set(DEPLOYMENT_VERSION ${CFLAGS_DEPLOYMENT_VERSION_WATCHOS}) + elseif("${CFLAGS_SDK}" STREQUAL "XROS" OR "${CFLAGS_SDK}" STREQUAL "XROS_SIMULATOR") + set(DEPLOYMENT_VERSION ${CFLAGS_DEPLOYMENT_VERSION_XROS}) endif() if("${DEPLOYMENT_VERSION}" STREQUAL "") @@ -154,6 +158,7 @@ endfunction() function(_add_target_variant_c_compile_flags) set(oneValueArgs SDK ARCH BUILD_TYPE ENABLE_ASSERTIONS ANALYZE_CODE_COVERAGE DEPLOYMENT_VERSION_OSX DEPLOYMENT_VERSION_MACCATALYST DEPLOYMENT_VERSION_IOS DEPLOYMENT_VERSION_TVOS DEPLOYMENT_VERSION_WATCHOS + DEPLOYMENT_VERSION_XROS RESULT_VAR_NAME ENABLE_LTO MACCATALYST_BUILD_FLAVOR) cmake_parse_arguments(CFLAGS @@ -189,6 +194,7 @@ function(_add_target_variant_c_compile_flags) DEPLOYMENT_VERSION_IOS "${CFLAGS_DEPLOYMENT_VERSION_IOS}" DEPLOYMENT_VERSION_TVOS "${CFLAGS_DEPLOYMENT_VERSION_TVOS}" DEPLOYMENT_VERSION_WATCHOS "${CFLAGS_DEPLOYMENT_VERSION_WATCHOS}" + DEPLOYMENT_VERSION_XROS "${CFLAGS_DEPLOYMENT_VERSION_XROS}" RESULT_VAR_NAME result MACCATALYST_BUILD_FLAVOR "${CFLAGS_MACCATALYST_BUILD_FLAVOR}") @@ -469,6 +475,7 @@ endfunction() function(_add_target_variant_link_flags) set(oneValueArgs SDK ARCH BUILD_TYPE ENABLE_ASSERTIONS ANALYZE_CODE_COVERAGE DEPLOYMENT_VERSION_OSX DEPLOYMENT_VERSION_MACCATALYST DEPLOYMENT_VERSION_IOS DEPLOYMENT_VERSION_TVOS DEPLOYMENT_VERSION_WATCHOS + DEPLOYMENT_VERSION_XROS RESULT_VAR_NAME ENABLE_LTO LTO_OBJECT_NAME LINK_LIBRARIES_VAR_NAME LIBRARY_SEARCH_DIRECTORIES_VAR_NAME MACCATALYST_BUILD_FLAVOR ) @@ -497,6 +504,7 @@ function(_add_target_variant_link_flags) DEPLOYMENT_VERSION_IOS "${LFLAGS_DEPLOYMENT_VERSION_IOS}" DEPLOYMENT_VERSION_TVOS "${LFLAGS_DEPLOYMENT_VERSION_TVOS}" DEPLOYMENT_VERSION_WATCHOS "${LFLAGS_DEPLOYMENT_VERSION_WATCHOS}" + DEPLOYMENT_VERSION_XROS "${LFLAGS_DEPLOYMENT_VERSION_XROS}" RESULT_VAR_NAME result MACCATALYST_BUILD_FLAVOR "${LFLAGS_MACCATALYST_BUILD_FLAVOR}") if("${LFLAGS_SDK}" STREQUAL "LINUX") @@ -783,6 +791,7 @@ function(add_swift_target_library_single target name) DEPLOYMENT_VERSION_OSX DEPLOYMENT_VERSION_TVOS DEPLOYMENT_VERSION_WATCHOS + DEPLOYMENT_VERSION_XROS INSTALL_IN_COMPONENT DARWIN_INSTALL_NAME_DIR SDK @@ -881,6 +890,7 @@ function(add_swift_target_library_single target name) if(SWIFT_EMBED_BITCODE_SECTION AND NOT SWIFTLIB_SINGLE_DONT_EMBED_BITCODE) if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "IOS" OR "${SWIFTLIB_SINGLE_SDK}" STREQUAL "TVOS" OR + "${SWIFTLIB_SINGLE_SDK}" STREQUAL "XROS" OR "${SWIFTLIB_SINGLE_SDK}" STREQUAL "WATCHOS") list(APPEND SWIFTLIB_SINGLE_C_COMPILE_FLAGS "-fembed-bitcode") set(embed_bitcode_arg EMBED_BITCODE) @@ -1403,6 +1413,7 @@ function(add_swift_target_library_single target name) DEPLOYMENT_VERSION_IOS "${SWIFTLIB_DEPLOYMENT_VERSION_IOS}" DEPLOYMENT_VERSION_TVOS "${SWIFTLIB_DEPLOYMENT_VERSION_TVOS}" DEPLOYMENT_VERSION_WATCHOS "${SWIFTLIB_DEPLOYMENT_VERSION_WATCHOS}" + DEPLOYMENT_VERSION_XROS "${SWIFTLIB_DEPLOYMENT_VERSION_XROS}" RESULT_VAR_NAME c_compile_flags MACCATALYST_BUILD_FLAVOR "${SWIFTLIB_SINGLE_MACCATALYST_BUILD_FLAVOR}" ) @@ -1425,6 +1436,7 @@ function(add_swift_target_library_single target name) DEPLOYMENT_VERSION_IOS "${SWIFTLIB_DEPLOYMENT_VERSION_IOS}" DEPLOYMENT_VERSION_TVOS "${SWIFTLIB_DEPLOYMENT_VERSION_TVOS}" DEPLOYMENT_VERSION_WATCHOS "${SWIFTLIB_DEPLOYMENT_VERSION_WATCHOS}" + DEPLOYMENT_VERSION_XROS "${SWIFTLIB_DEPLOYMENT_VERSION_XROS}" RESULT_VAR_NAME link_flags LINK_LIBRARIES_VAR_NAME link_libraries LIBRARY_SEARCH_DIRECTORIES_VAR_NAME library_search_directories @@ -1503,6 +1515,7 @@ function(add_swift_target_library_single target name) if(SWIFT_EMBED_BITCODE_SECTION AND NOT SWIFTLIB_SINGLE_DONT_EMBED_BITCODE) if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "IOS" OR "${SWIFTLIB_SINGLE_SDK}" STREQUAL "TVOS" OR + "${SWIFTLIB_SINGLE_SDK}" STREQUAL "XROS" OR "${SWIFTLIB_SINGLE_SDK}" STREQUAL "WATCHOS") # Please note that using a generator expression to fit # this in a single target_link_options does not work @@ -1659,6 +1672,7 @@ endfunction() # DEPLOYMENT_VERSION_IOS version # DEPLOYMENT_VERSION_TVOS version # DEPLOYMENT_VERSION_WATCHOS version +# DEPLOYMENT_VERSION_XROS version # MACCATALYST_BUILD_FLAVOR flavor # BACK_DEPLOYMENT_LIBRARY version # source1 [source2 source3 ...]) @@ -1701,6 +1715,9 @@ endfunction() # SWIFT_MODULE_DEPENDS_WATCHOS # Swift modules this library depends on when built for watchOS. # +# SWIFT_MODULE_DEPENDS_XROS +# Swift modules this library depends on when built for xrOS. +# # SWIFT_MODULE_DEPENDS_FREESTANDING # Swift modules this library depends on when built for Freestanding. # @@ -1777,6 +1794,9 @@ endfunction() # DEPLOYMENT_VERSION_WATCHOS # The minimum deployment version to build for if this is an WATCHOS library. # +# DEPLOYMENT_VERSION_XROS +# The minimum deployment version to build for if this is an XROS library. +# # INSTALL_WITH_SHARED # Install a static library target alongside shared libraries # @@ -1806,6 +1826,7 @@ function(add_swift_target_library name) DEPLOYMENT_VERSION_OSX DEPLOYMENT_VERSION_TVOS DEPLOYMENT_VERSION_WATCHOS + DEPLOYMENT_VERSION_XROS INSTALL_IN_COMPONENT INSTALL_BINARY_SWIFTMODULE DARWIN_INSTALL_NAME_DIR @@ -1838,6 +1859,7 @@ function(add_swift_target_library name) SWIFT_COMPILE_FLAGS_OSX SWIFT_COMPILE_FLAGS_TVOS SWIFT_COMPILE_FLAGS_WATCHOS + SWIFT_COMPILE_FLAGS_XROS SWIFT_COMPILE_FLAGS_LINUX SWIFT_MODULE_DEPENDS SWIFT_MODULE_DEPENDS_CYGWIN @@ -1851,6 +1873,7 @@ function(add_swift_target_library name) SWIFT_MODULE_DEPENDS_TVOS SWIFT_MODULE_DEPENDS_WASI SWIFT_MODULE_DEPENDS_WATCHOS + SWIFT_MODULE_DEPENDS_XROS SWIFT_MODULE_DEPENDS_WINDOWS SWIFT_MODULE_DEPENDS_FROM_SDK TARGET_SDKS @@ -2026,6 +2049,9 @@ function(add_swift_target_library name) elseif(sdk STREQUAL "WATCHOS" OR sdk STREQUAL "WATCHOS_SIMULATOR") list(APPEND swiftlib_module_depends_flattened ${SWIFTLIB_SWIFT_MODULE_DEPENDS_WATCHOS}) + elseif("${sdk}" STREQUAL "XROS" OR "${sdk}" STREQUAL "XROS_SIMULATOR") + list(APPEND swiftlib_module_depends_flattened + ${SWIFTLIB_SWIFT_MODULE_DEPENDS_XROS}) elseif(sdk STREQUAL "FREESTANDING") list(APPEND swiftlib_module_depends_flattened ${SWIFTLIB_SWIFT_MODULE_DEPENDS_FREESTANDING}) @@ -2077,6 +2103,9 @@ function(add_swift_target_library name) elseif(sdk STREQUAL "WATCHOS" OR sdk STREQUAL "WATCHOS_SIMULATOR") list(APPEND swiftlib_swift_compile_flags_all ${SWIFTLIB_SWIFT_COMPILE_FLAGS_WATCHOS}) + elseif("${sdk}" STREQUAL "XROS" OR "${sdk}" STREQUAL "XROS_SIMULATOR") + list(APPEND swiftlib_swift_compile_flags_all + ${SWIFTLIB_SWIFT_COMPILE_FLAGS_XROS}) elseif(sdk STREQUAL "LINUX") list(APPEND swiftlib_swift_compile_flags_all ${SWIFTLIB_SWIFT_COMPILE_FLAGS_LINUX}) @@ -2326,6 +2355,7 @@ function(add_swift_target_library name) DEPLOYMENT_VERSION_IOS "${SWIFTLIB_DEPLOYMENT_VERSION_IOS}" DEPLOYMENT_VERSION_TVOS "${SWIFTLIB_DEPLOYMENT_VERSION_TVOS}" DEPLOYMENT_VERSION_WATCHOS "${SWIFTLIB_DEPLOYMENT_VERSION_WATCHOS}" + DEPLOYMENT_VERSION_XROS "${SWIFTLIB_DEPLOYMENT_VERSION_XROS}" MACCATALYST_BUILD_FLAVOR "${maccatalyst_build_flavor}" ${back_deployment_library_option} ENABLE_LTO "${SWIFT_STDLIB_ENABLE_LTO}" diff --git a/stdlib/private/OSLog/CMakeLists.txt b/stdlib/private/OSLog/CMakeLists.txt index 8dce747672109..befc43e172b7c 100644 --- a/stdlib/private/OSLog/CMakeLists.txt +++ b/stdlib/private/OSLog/CMakeLists.txt @@ -29,6 +29,7 @@ add_swift_target_library(swiftOSLogTestHelper SWIFT_MODULE_DEPENDS_OSX ${swift_oslog_darwin_dependencies} SWIFT_MODULE_DEPENDS_TVOS ${swift_oslog_darwin_dependencies} SWIFT_MODULE_DEPENDS_WATCHOS ${swift_oslog_darwin_dependencies} + SWIFT_MODULE_DEPENDS_XROS ${swift_oslog_darwin_dependencies} SWIFT_MODULE_DEPENDS_MACCATALYST ${swift_oslog_darwin_dependencies} TARGET_SDKS ALL_APPLE_PLATFORMS SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} diff --git a/stdlib/private/StdlibUnittest/CMakeLists.txt b/stdlib/private/StdlibUnittest/CMakeLists.txt index 71e1a480fd869..711ee520376c0 100644 --- a/stdlib/private/StdlibUnittest/CMakeLists.txt +++ b/stdlib/private/StdlibUnittest/CMakeLists.txt @@ -59,6 +59,7 @@ add_swift_target_library(swiftStdlibUnittest ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} SWIFT_MODULE_DEPENDS_OSX ${swift_stdlib_unittest_darwin_dependencies} SWIFT_MODULE_DEPENDS_TVOS ${swift_stdlib_unittest_darwin_dependencies} SWIFT_MODULE_DEPENDS_WATCHOS ${swift_stdlib_unittest_darwin_dependencies} + SWIFT_MODULE_DEPENDS_XROS ${swift_stdlib_unittest_darwin_dependencies} SWIFT_MODULE_DEPENDS_MACCATALYST ${swift_stdlib_unittest_darwin_dependencies} SWIFT_MODULE_DEPENDS_FREESTANDING "${SWIFT_FREESTANDING_TEST_DEPENDENCIES}" SWIFT_MODULE_DEPENDS_LINUX Glibc diff --git a/stdlib/private/StdlibUnittest/StdlibUnittest.swift b/stdlib/private/StdlibUnittest/StdlibUnittest.swift index d73f63feda0e5..11e60e1dbad41 100644 --- a/stdlib/private/StdlibUnittest/StdlibUnittest.swift +++ b/stdlib/private/StdlibUnittest/StdlibUnittest.swift @@ -2205,9 +2205,11 @@ public enum OSVersion : CustomStringConvertible { case iOS(major: Int, minor: Int, bugFix: Int) case tvOS(major: Int, minor: Int, bugFix: Int) case watchOS(major: Int, minor: Int, bugFix: Int) + case visionOS(major: Int, minor: Int, bugFix: Int) case iOSSimulator case tvOSSimulator case watchOSSimulator + case visionOSSimulator case linux case freeBSD case openBSD @@ -2228,12 +2230,16 @@ public enum OSVersion : CustomStringConvertible { return "TVOS \(major).\(minor).\(bugFix)" case .watchOS(let major, let minor, let bugFix): return "watchOS \(major).\(minor).\(bugFix)" + case .visionOS(let major, let minor, let bugFix): + return "visionOS \(major).\(minor).\(bugFix)" case .iOSSimulator: return "iOSSimulator" case .tvOSSimulator: return "TVOSSimulator" case .watchOSSimulator: return "watchOSSimulator" + case .visionOSSimulator: + return "visionOSSimulator" case .linux: return "Linux" case .freeBSD: @@ -2282,6 +2288,8 @@ func _getOSVersion() -> OSVersion { return .tvOSSimulator #elseif os(watchOS) && targetEnvironment(simulator) return .watchOSSimulator +#elseif os(visionOS) && targetEnvironment(simulator) + return .visionOSSimulator #elseif os(Linux) return .linux #elseif os(FreeBSD) @@ -2311,6 +2319,8 @@ func _getOSVersion() -> OSVersion { return .tvOS(major: major, minor: minor, bugFix: bugFix) #elseif os(watchOS) return .watchOS(major: major, minor: minor, bugFix: bugFix) + #elseif os(visionOS) + return .visionOS(major: major, minor: minor, bugFix: bugFix) #else fatalError("could not determine OS version") #endif @@ -2373,6 +2383,16 @@ public enum TestRunPredicate : CustomStringConvertible { case watchOSSimulatorAny(/*reason:*/ String) + case visionOSAny(/*reason:*/ String) + case visionOSMajor(Int, reason: String) + case visionOSMajorRange(ClosedRange, reason: String) + case visionOSMinor(Int, Int, reason: String) + case visionOSMinorRange(Int, ClosedRange, reason: String) + case visionOSBugFix(Int, Int, Int, reason: String) + case visionOSBugFixRange(Int, Int, ClosedRange, reason: String) + + case visionOSSimulatorAny(/*reason:*/ String) + case linuxAny(reason: String) case freeBSDAny(reason: String) @@ -2467,6 +2487,24 @@ public enum TestRunPredicate : CustomStringConvertible { case .watchOSSimulatorAny(let reason): return "watchOSSimulatorAny(*, reason: \(reason))" + case .visionOSAny(let reason): + return "visionOS(*, reason: \(reason))" + case .visionOSMajor(let major, let reason): + return "visionOS(\(major).*, reason: \(reason))" + case .visionOSMajorRange(let range, let reason): + return "visionOS([\(range)], reason: \(reason))" + case .visionOSMinor(let major, let minor, let reason): + return "visionOS(\(major).\(minor), reason: \(reason))" + case .visionOSMinorRange(let major, let minorRange, let reason): + return "visionOS(\(major).[\(minorRange)], reason: \(reason))" + case .visionOSBugFix(let major, let minor, let bugFix, let reason): + return "visionOS(\(major).\(minor).\(bugFix), reason: \(reason))" + case .visionOSBugFixRange(let major, let minor, let bugFixRange, let reason): + return "visionOS(\(major).\(minor).[\(bugFixRange)], reason: \(reason))" + + case .visionOSSimulatorAny(let reason): + return "visionOSSimulatorAny(*, reason: \(reason))" + case .linuxAny(reason: let reason): return "linuxAny(*, reason: \(reason))" @@ -2745,6 +2783,70 @@ public enum TestRunPredicate : CustomStringConvertible { return false } + case .visionOSAny: + switch _getRunningOSVersion() { + case .visionOS: + return true + default: + return false + } + + case .visionOSMajor(let major, _): + switch _getRunningOSVersion() { + case .visionOS(major, _, _): + return true + default: + return false + } + + case .visionOSMajorRange(let range, _): + switch _getRunningOSVersion() { + case .visionOS(let major, _, _): + return range.contains(major) + default: + return false + } + + case .visionOSMinor(let major, let minor, _): + switch _getRunningOSVersion() { + case .visionOS(major, minor, _): + return true + default: + return false + } + + case .visionOSMinorRange(let major, let minorRange, _): + switch _getRunningOSVersion() { + case .visionOS(major, let runningMinor, _): + return minorRange.contains(runningMinor) + default: + return false + } + + case .visionOSBugFix(let major, let minor, let bugFix, _): + switch _getRunningOSVersion() { + case .visionOS(major, minor, bugFix): + return true + default: + return false + } + + case .visionOSBugFixRange(let major, let minor, let bugFixRange, _): + switch _getRunningOSVersion() { + case .visionOS(major, minor, let runningBugFix): + return bugFixRange.contains(runningBugFix) + default: + return false + } + + case .visionOSSimulatorAny: + switch _getRunningOSVersion() { + case .visionOSSimulator: + return true + default: + return false + } + case .linuxAny: switch _getRunningOSVersion() { case .linux: diff --git a/stdlib/private/StdlibUnittestFoundationExtras/StdlibUnittestFoundationExtras.swift b/stdlib/private/StdlibUnittestFoundationExtras/StdlibUnittestFoundationExtras.swift index f6f97598786dd..c90f6c8508a77 100644 --- a/stdlib/private/StdlibUnittestFoundationExtras/StdlibUnittestFoundationExtras.swift +++ b/stdlib/private/StdlibUnittestFoundationExtras/StdlibUnittestFoundationExtras.swift @@ -23,7 +23,7 @@ import StdlibUnittest public func autoreleasepoolIfUnoptimizedReturnAutoreleased( invoking body: () -> Void ) { -#if targetEnvironment(simulator) && arch(i386) && (os(iOS) || os(watchOS)) +#if targetEnvironment(simulator) && arch(i386) && (os(iOS) || os(watchOS) || os(visionOS)) autoreleasepool(invoking: body) #else body() diff --git a/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt b/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt index 5a1d12abe8eed..0e921de472932 100644 --- a/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt +++ b/stdlib/private/SwiftPrivateLibcExtras/CMakeLists.txt @@ -35,6 +35,7 @@ add_swift_target_library(swiftSwiftPrivateLibcExtras ${SWIFT_STDLIB_LIBRARY_BUIL SWIFT_MODULE_DEPENDS_IOS ${swift_private_libc_extras_darwin_depencencies} SWIFT_MODULE_DEPENDS_TVOS ${swift_private_libc_extras_darwin_depencencies} SWIFT_MODULE_DEPENDS_WATCHOS ${swift_private_libc_extras_darwin_depencencies} + SWIFT_MODULE_DEPENDS_XROS ${swift_private_libc_extras_darwin_depencencies} SWIFT_MODULE_DEPENDS_MACCATALYST ${swift_private_libc_extras_darwin_depencencies} SWIFT_MODULE_DEPENDS_FREESTANDING "${SWIFT_FREESTANDING_TEST_DEPENDENCIES}" SWIFT_MODULE_DEPENDS_LINUX Glibc diff --git a/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt b/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt index ced3246859d38..dd60a70551f02 100644 --- a/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt +++ b/stdlib/private/SwiftPrivateThreadExtras/CMakeLists.txt @@ -16,6 +16,7 @@ add_swift_target_library(swiftSwiftPrivateThreadExtras ${SWIFT_STDLIB_LIBRARY_BU SWIFT_MODULE_DEPENDS_OSX ${swift_private_thread_extras_darwin_depencencies} SWIFT_MODULE_DEPENDS_TVOS ${swift_private_thread_extras_darwin_depencencies} SWIFT_MODULE_DEPENDS_WATCHOS ${swift_private_thread_extras_darwin_depencencies} + SWIFT_MODULE_DEPENDS_XROS ${swift_private_thread_extras_darwin_depencencies} SWIFT_MODULE_DEPENDS_MACCATALYST ${swift_private_thread_extras_darwin_depencencies} SWIFT_MODULE_DEPENDS_FREESTANDING "${SWIFT_FREESTANDING_TEST_DEPENDENCIES}" SWIFT_MODULE_DEPENDS_LINUX Glibc diff --git a/stdlib/private/SwiftReflectionTest/CMakeLists.txt b/stdlib/private/SwiftReflectionTest/CMakeLists.txt index d751d84aeb10d..357b08b77b352 100644 --- a/stdlib/private/SwiftReflectionTest/CMakeLists.txt +++ b/stdlib/private/SwiftReflectionTest/CMakeLists.txt @@ -13,6 +13,7 @@ if (SWIFT_INCLUDE_TESTS AND SWIFT_BUILD_DYNAMIC_STDLIB) SWIFT_MODULE_DEPENDS_IOS ${swift_reflection_test_darwin_depencencies} SWIFT_MODULE_DEPENDS_TVOS ${swift_reflection_test_darwin_depencencies} SWIFT_MODULE_DEPENDS_WATCHOS ${swift_reflection_test_darwin_depencencies} + SWIFT_MODULE_DEPENDS_XROS ${swift_reflection_test_darwin_depencencies} SWIFT_MODULE_DEPENDS_LINUX Glibc SWIFT_MODULE_DEPENDS_FREEBSD Glibc SWIFT_MODULE_DEPENDS_OPENBSD Glibc diff --git a/stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift b/stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift index 3fc54debe1d49..44175a187da1b 100644 --- a/stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift +++ b/stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift @@ -28,7 +28,7 @@ let RequestDone = "d" let RequestPointerSize = "p" -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) import MachO import Darwin diff --git a/stdlib/public/Cxx/std/CMakeLists.txt b/stdlib/public/Cxx/std/CMakeLists.txt index 4da89471a1dce..85087204882ae 100644 --- a/stdlib/public/Cxx/std/CMakeLists.txt +++ b/stdlib/public/Cxx/std/CMakeLists.txt @@ -43,6 +43,7 @@ add_swift_target_library(swiftCxxStdlib STATIC NO_LINK_NAME IS_STDLIB IS_SWIFT_O SWIFT_MODULE_DEPENDS_OSX ${swift_cxxstdlib_darwin_dependencies} SWIFT_MODULE_DEPENDS_TVOS ${swift_cxxstdlib_darwin_dependencies} SWIFT_MODULE_DEPENDS_WATCHOS ${swift_cxxstdlib_darwin_dependencies} + SWIFT_MODULE_DEPENDS_XROS ${swift_cxxstdlib_darwin_dependencies} SWIFT_MODULE_DEPENDS_MACCATALYST ${swift_cxxstdlib_darwin_dependencies} SWIFT_COMPILE_FLAGS ${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS} ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} diff --git a/stdlib/public/Differentiation/CMakeLists.txt b/stdlib/public/Differentiation/CMakeLists.txt index f9c1199da9c11..1bb1c2c3e22f5 100644 --- a/stdlib/public/Differentiation/CMakeLists.txt +++ b/stdlib/public/Differentiation/CMakeLists.txt @@ -41,6 +41,7 @@ add_swift_target_library(swift_Differentiation ${SWIFT_STDLIB_LIBRARY_BUILD_TYPE SWIFT_MODULE_DEPENDS_IOS ${swiftDifferentiationDarwinDependencies} SWIFT_MODULE_DEPENDS_TVOS ${swiftDifferentiationDarwinDependencies} SWIFT_MODULE_DEPENDS_WATCHOS ${swiftDifferentiationDarwinDependencies} + SWIFT_MODULE_DEPENDS_XROS ${swiftDifferentiationDarwinDependencies} SWIFT_MODULE_DEPENDS_LINUX Glibc SWIFT_MODULE_DEPENDS_FREEBSD Glibc SWIFT_MODULE_DEPENDS_OPENBSD Glibc diff --git a/stdlib/public/Differentiation/TgmathDerivatives.swift.gyb b/stdlib/public/Differentiation/TgmathDerivatives.swift.gyb index 9428393c2b401..a517dade14502 100644 --- a/stdlib/public/Differentiation/TgmathDerivatives.swift.gyb +++ b/stdlib/public/Differentiation/TgmathDerivatives.swift.gyb @@ -14,7 +14,7 @@ import Swift -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) import Darwin.C.tgmath #elseif canImport(Musl) import Musl diff --git a/stdlib/public/Platform/MachError.swift b/stdlib/public/Platform/MachError.swift index d79fb7382a456..1dfecd66a5f1c 100644 --- a/stdlib/public/Platform/MachError.swift +++ b/stdlib/public/Platform/MachError.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && _runtime(_ObjC) +#if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)) && _runtime(_ObjC) /// Enumeration describing Mach error codes. @objc public enum MachErrorCode : Int32 { @@ -202,4 +202,4 @@ public enum MachErrorCode : Int32 { /// The requested property cannot be changed at this time. case policyStatic = 51 } -#endif // (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && _runtime(_ObjC) +#endif // (os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)) && _runtime(_ObjC) diff --git a/stdlib/public/Platform/POSIXError.swift b/stdlib/public/Platform/POSIXError.swift index 84777cb380436..8f1b488089bc0 100644 --- a/stdlib/public/Platform/POSIXError.swift +++ b/stdlib/public/Platform/POSIXError.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && _runtime(_ObjC) +#if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)) && _runtime(_ObjC) /// Enumeration describing POSIX error codes. @objc diff --git a/stdlib/public/Platform/Platform.swift b/stdlib/public/Platform/Platform.swift index 272b8e2c84850..a3e8f439fe44c 100644 --- a/stdlib/public/Platform/Platform.swift +++ b/stdlib/public/Platform/Platform.swift @@ -13,7 +13,7 @@ import SwiftShims import SwiftOverlayShims -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) //===----------------------------------------------------------------------===// // MacTypes.h //===----------------------------------------------------------------------===// @@ -102,7 +102,7 @@ public var errno : Int32 { // stdio.h //===----------------------------------------------------------------------===// -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(FreeBSD) || os(PS4) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) || os(FreeBSD) || os(PS4) public var stdin : UnsafeMutablePointer { get { return __stdinp @@ -250,7 +250,7 @@ public var S_IFBLK: mode_t { return mode_t(0o060000) } public var S_IFREG: mode_t { return mode_t(0o100000) } public var S_IFLNK: mode_t { return mode_t(0o120000) } public var S_IFSOCK: mode_t { return mode_t(0o140000) } -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) public var S_IFWHT: mode_t { return mode_t(0o160000) } #endif @@ -317,7 +317,7 @@ public func ioctl( // unistd.h //===----------------------------------------------------------------------===// -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) @available(*, unavailable, message: "Please use threads or posix_spawn*()") public func fork() -> Int32 { fatalError("unavailable function can't be called") @@ -333,7 +333,7 @@ public func vfork() -> Int32 { // signal.h //===----------------------------------------------------------------------===// -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) public var SIG_DFL: sig_t? { return nil } public var SIG_IGN: sig_t { return unsafeBitCast(1, to: sig_t.self) } public var SIG_ERR: sig_t { return unsafeBitCast(-1, to: sig_t.self) } @@ -397,7 +397,7 @@ public typealias Semaphore = UnsafeMutablePointer /// The value returned by `sem_open()` in the case of failure. public var SEM_FAILED: Semaphore? { -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) // The value is ABI. Value verified to be correct for OS X, iOS, watchOS, tvOS. return Semaphore(bitPattern: -1) #elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku) || os(WASI) @@ -430,7 +430,7 @@ public func sem_open( // time.h //===----------------------------------------------------------------------===// -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(Linux) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) || os(Linux) @available(SwiftStdlib 5.7, *) extension timespec { @@ -483,7 +483,7 @@ extension Duration { // Some platforms don't have `extern char** environ` imported from C. #if SWIFT_STDLIB_HAS_ENVIRON -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(FreeBSD) || os(OpenBSD) || os(PS4) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) || os(FreeBSD) || os(OpenBSD) || os(PS4) public var environ: UnsafeMutablePointer?> { return _swift_stdlib_getEnviron() } diff --git a/stdlib/public/Platform/TiocConstants.swift b/stdlib/public/Platform/TiocConstants.swift index 272f7e242e64d..9510315d19908 100644 --- a/stdlib/public/Platform/TiocConstants.swift +++ b/stdlib/public/Platform/TiocConstants.swift @@ -13,7 +13,7 @@ // Tty ioctl request constants, needed only on Darwin and FreeBSD. // Constants available on all platforms, also available on Linux. -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(FreeBSD) || os(Haiku) +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) || os(FreeBSD) || os(Haiku) /// Set exclusive use of tty. public var TIOCEXCL: UInt { return 0x2000740d } @@ -115,7 +115,7 @@ public var TIOCGLTC: UInt { return 0x40067474 } // Darwin only constants, also available on Linux. -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) /// Get termios struct. public var TIOCGETA: UInt { return 0x40487413 } diff --git a/stdlib/public/Platform/tgmath.swift.gyb b/stdlib/public/Platform/tgmath.swift.gyb index 29b011a4c51da..1680044d4d59f 100644 --- a/stdlib/public/Platform/tgmath.swift.gyb +++ b/stdlib/public/Platform/tgmath.swift.gyb @@ -234,7 +234,7 @@ public func ${ufunc}(_ x: ${T}) -> ${T} { % end -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) // Unary intrinsic functions // Note these have a corresponding LLVM intrinsic % for T, ufunc in TypedUnaryIntrinsicFunctions(): diff --git a/stdlib/public/core/AssertCommon.swift b/stdlib/public/core/AssertCommon.swift index e2f217b46e532..001756e78858b 100644 --- a/stdlib/public/core/AssertCommon.swift +++ b/stdlib/public/core/AssertCommon.swift @@ -74,7 +74,7 @@ func _isStdlibDebugChecksEnabled() -> Bool { internal func _fatalErrorFlags() -> UInt32 { // The current flags are: // (1 << 0): Report backtrace on fatal error -#if os(iOS) || os(tvOS) || os(watchOS) +#if os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) return 0 #else return _isDebugAssertConfiguration() ? 1 : 0 diff --git a/stdlib/public/core/Availability.swift b/stdlib/public/core/Availability.swift index eef9ec5cd2deb..43da1ff6dfff6 100644 --- a/stdlib/public/core/Availability.swift +++ b/stdlib/public/core/Availability.swift @@ -25,7 +25,7 @@ public func _stdlib_isOSVersionAtLeast( _ minor: Builtin.Word, _ patch: Builtin.Word ) -> Builtin.Int1 { -#if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && SWIFT_RUNTIME_OS_VERSIONING +#if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)) && SWIFT_RUNTIME_OS_VERSIONING if Int(major) == 9999 { return true._value } diff --git a/stdlib/public/core/CTypes.swift b/stdlib/public/core/CTypes.swift index f7e0592be83fe..b5c1cff68767e 100644 --- a/stdlib/public/core/CTypes.swift +++ b/stdlib/public/core/CTypes.swift @@ -69,7 +69,7 @@ public typealias CFloat = Float public typealias CDouble = Double /// The C 'long double' type. -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) // On Darwin, long double is Float80 on x86, and Double otherwise. #if arch(x86_64) || arch(i386) public typealias CLongDouble = Float80 @@ -273,7 +273,7 @@ extension UInt { } /// A wrapper around a C `va_list` pointer. -#if arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Windows)) +#if arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) || os(Windows)) @frozen public struct CVaListPointer { @usableFromInline // unsafe-performance diff --git a/stdlib/public/core/ErrorType.swift b/stdlib/public/core/ErrorType.swift index d48b87a2ad6ec..632e9da1b400c 100644 --- a/stdlib/public/core/ErrorType.swift +++ b/stdlib/public/core/ErrorType.swift @@ -195,7 +195,7 @@ func _willThrowTypedImpl(_ error: E) @_alwaysEmitIntoClient @_silgen_name("swift_willThrowTyped") public func _willThrowTyped(_ error: E) { - if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) { + if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *) { _willThrowTypedImpl(error) } } diff --git a/stdlib/public/core/VarArgs.swift b/stdlib/public/core/VarArgs.swift index 7dc05b341aa0c..c7b514c126599 100644 --- a/stdlib/public/core/VarArgs.swift +++ b/stdlib/public/core/VarArgs.swift @@ -102,7 +102,7 @@ internal let _countGPRegisters = 16 @usableFromInline internal let _registerSaveWords = _countGPRegisters -#elseif arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Windows)) +#elseif arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) || os(Windows)) // ARM Procedure Call Standard for aarch64. (IHI0055B) // The va_list type may refer to any parameter in a parameter list may be in one // of three memory locations depending on its type and position in the argument @@ -444,7 +444,7 @@ extension Float80: CVarArg, _CVarArgAligned { } #endif -#if (arch(x86_64) && !os(Windows)) || arch(s390x) || (arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Windows))) +#if (arch(x86_64) && !os(Windows)) || arch(s390x) || (arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) || os(Windows))) /// An object that can manage the lifetime of storage backing a /// `CVaListPointer`. diff --git a/stdlib/toolchain/Compatibility50/CMakeLists.txt b/stdlib/toolchain/Compatibility50/CMakeLists.txt index 7cc357cb03232..af8b8f2c686dd 100644 --- a/stdlib/toolchain/Compatibility50/CMakeLists.txt +++ b/stdlib/toolchain/Compatibility50/CMakeLists.txt @@ -20,6 +20,7 @@ add_swift_target_library("${library_name}" STATIC DEPLOYMENT_VERSION_IOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS} DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS} DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS} + DEPLOYMENT_VERSION_XROS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS} INSTALL_IN_COMPONENT compiler INSTALL_WITH_SHARED) diff --git a/stdlib/toolchain/Compatibility51/CMakeLists.txt b/stdlib/toolchain/Compatibility51/CMakeLists.txt index ce88f26470894..bca90850dc8da 100644 --- a/stdlib/toolchain/Compatibility51/CMakeLists.txt +++ b/stdlib/toolchain/Compatibility51/CMakeLists.txt @@ -20,6 +20,7 @@ add_swift_target_library("${library_name}" STATIC DEPLOYMENT_VERSION_IOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS} DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS} DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS} + DEPLOYMENT_VERSION_XROS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS} MACCATALYST_BUILD_FLAVOR "zippered" diff --git a/stdlib/toolchain/Compatibility56/CMakeLists.txt b/stdlib/toolchain/Compatibility56/CMakeLists.txt index 977d5f684d7e7..a1a55abd56c5d 100644 --- a/stdlib/toolchain/Compatibility56/CMakeLists.txt +++ b/stdlib/toolchain/Compatibility56/CMakeLists.txt @@ -29,6 +29,7 @@ add_swift_target_library("${library_name}" STATIC DEPLOYMENT_VERSION_IOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS} DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS} DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS} + DEPLOYMENT_VERSION_XROS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS} MACCATALYST_BUILD_FLAVOR "zippered" diff --git a/stdlib/toolchain/CompatibilityDynamicReplacements/CMakeLists.txt b/stdlib/toolchain/CompatibilityDynamicReplacements/CMakeLists.txt index 13aa1d744bc3c..ef1df81a9ab92 100644 --- a/stdlib/toolchain/CompatibilityDynamicReplacements/CMakeLists.txt +++ b/stdlib/toolchain/CompatibilityDynamicReplacements/CMakeLists.txt @@ -15,6 +15,7 @@ add_swift_target_library("${library_name}" STATIC DEPLOYMENT_VERSION_IOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS} DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS} DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS} + DEPLOYMENT_VERSION_XROS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS} INSTALL_IN_COMPONENT compiler INSTALL_WITH_SHARED) diff --git a/stdlib/toolchain/CompatibilityPacks/CMakeLists.txt b/stdlib/toolchain/CompatibilityPacks/CMakeLists.txt index 8e52618c59179..4b2657b7a5511 100644 --- a/stdlib/toolchain/CompatibilityPacks/CMakeLists.txt +++ b/stdlib/toolchain/CompatibilityPacks/CMakeLists.txt @@ -18,6 +18,7 @@ add_swift_target_library("${library_name}" STATIC DEPLOYMENT_VERSION_IOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS} DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS} DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS} + DEPLOYMENT_VERSION_XROS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS} MACCATALYST_BUILD_FLAVOR "zippered" diff --git a/stdlib/toolchain/CompatibilityThreading/CMakeLists.txt b/stdlib/toolchain/CompatibilityThreading/CMakeLists.txt index f2c94243cf41e..7bfd2ae1b130f 100644 --- a/stdlib/toolchain/CompatibilityThreading/CMakeLists.txt +++ b/stdlib/toolchain/CompatibilityThreading/CMakeLists.txt @@ -16,5 +16,6 @@ add_swift_target_library(swiftCompatibilityThreading OBJECT_LIBRARY DEPLOYMENT_VERSION_IOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS} DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS} DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS} + DEPLOYMENT_VERSION_XROS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS} MACCATALYST_BUILD_FLAVOR "zippered") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e1bce074e518e..cf7886047cf4e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -101,10 +101,12 @@ function(get_test_dependencies SDK result_var_name) if(("${SDK}" STREQUAL "IOS") OR ("${SDK}" STREQUAL "TVOS") OR ("${SDK}" STREQUAL "WATCHOS") OR + ("${SDK}" STREQUAL "XROS") OR ("${SDK}" STREQUAL "OSX") OR ("${SDK}" STREQUAL "IOS_SIMULATOR") OR ("${SDK}" STREQUAL "TVOS_SIMULATOR") OR ("${SDK}" STREQUAL "WATCHOS_SIMULATOR") OR + ("${SDK}" STREQUAL "XROS_SIMULATOR") OR ("${SDK}" STREQUAL "FREESTANDING") OR ("${SDK}" STREQUAL "LINUX") OR ("${SDK}" STREQUAL "CYGWIN") OR @@ -335,7 +337,7 @@ foreach(SDK ${SWIFT_SDKS}) set(command_upload_stdlib) set(command_upload_swift_reflection_test) - if("${SDK}" STREQUAL "IOS" OR "${SDK}" STREQUAL "TVOS" OR "${SDK}" STREQUAL "WATCHOS") + if("${SDK}" STREQUAL "IOS" OR "${SDK}" STREQUAL "TVOS" OR "${SDK}" STREQUAL "WATCHOS" OR "${SDK}" STREQUAL "XROS") # These are supported testing SDKs, but their implementation of # `command_upload_stdlib` is hidden. elseif("${SDK}" STREQUAL "ANDROID" AND NOT "${SWIFT_HOST_VARIANT}" STREQUAL "android") diff --git a/test/ClangImporter/availability_open_enums.swift b/test/ClangImporter/availability_open_enums.swift index 686e8a9c4b1d3..913dc033d1038 100644 --- a/test/ClangImporter/availability_open_enums.swift +++ b/test/ClangImporter/availability_open_enums.swift @@ -1,6 +1,7 @@ // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -I %S/Inputs/custom-modules -enable-nonfrozen-enum-exhaustivity-diagnostics %s // REQUIRES: objc_interop +// UNSUPPORTED: OS=xros import Foundation import AvailabilityExtras @@ -16,4 +17,4 @@ func exhaustiveSwitch(e: NSEnumAddedCasesIn2017) { case .existingCaseThree: return } -} \ No newline at end of file +} diff --git a/test/DebugInfo/mandatory-inlining-ownership.swift b/test/DebugInfo/mandatory-inlining-ownership.swift index 1b377fa4cd74d..5a99d9f0da7b1 100644 --- a/test/DebugInfo/mandatory-inlining-ownership.swift +++ b/test/DebugInfo/mandatory-inlining-ownership.swift @@ -6,7 +6,7 @@ // CHECK: sil_scope [[S0:[0-9]+]] { {{.*}} parent @$s4null3baryyF // CHECK: sil_scope [[S1:[0-9]+]] { loc "{{.*}}":18:3 parent [[S0]] } -// CHECK: sil_scope [[S2:[0-9]+]] { loc "{{.*}}":18:67 parent [[S1]] } +// CHECK: sil_scope [[S2:[0-9]+]] { loc "{{.*}}":18:82 parent [[S1]] } // CHECK: begin_borrow {{.*}} : $OSLog, loc {{.*}}, scope [[S2]] // CHECK: tuple (), loc {{.*}}, scope [[S2]] @@ -15,7 +15,7 @@ import os func bar() { - if #available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) { + if #available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, visionOS 9999, *) { foo(OSLog.default) } } diff --git a/test/IDE/complete_decl_attribute.swift b/test/IDE/complete_decl_attribute.swift index f6fb95a483d4e..5d656c4e4d5d0 100644 --- a/test/IDE/complete_decl_attribute.swift +++ b/test/IDE/complete_decl_attribute.swift @@ -69,10 +69,12 @@ actor MyGenericGlobalActor { // AVAILABILITY1-NEXT: Keyword/None: iOS[#Platform#]; name=iOS{{$}} // AVAILABILITY1-NEXT: Keyword/None: tvOS[#Platform#]; name=tvOS{{$}} // AVAILABILITY1-NEXT: Keyword/None: watchOS[#Platform#]; name=watchOS{{$}} +// AVAILABILITY1-NEXT: Keyword/None: visionOS[#Platform#]; name=visionOS{{$}} // AVAILABILITY1-NEXT: Keyword/None: macOS[#Platform#]; name=macOS{{$}} // AVAILABILITY1-NEXT: Keyword/None: iOSApplicationExtension[#Platform#]; name=iOSApplicationExtension{{$}} // AVAILABILITY1-NEXT: Keyword/None: tvOSApplicationExtension[#Platform#]; name=tvOSApplicationExtension{{$}} // AVAILABILITY1-NEXT: Keyword/None: watchOSApplicationExtension[#Platform#]; name=watchOSApplicationExtension{{$}} +// AVAILABILITY1-NEXT: Keyword/None: visionOSApplicationExtension[#Platform#]; name=visionOSApplicationExtension{{$}} // AVAILABILITY1-NEXT: Keyword/None: macOSApplicationExtension[#Platform#]; name=macOSApplicationExtension{{$}} // AVAILABILITY1-NEXT: Keyword/None: macCatalyst[#Platform#]; name=macCatalyst // AVAILABILITY1-NEXT: Keyword/None: macCatalystApplicationExtension[#Platform#]; name=macCatalystApplicationExtension diff --git a/test/IRGen/abitypes_objc.swift b/test/IRGen/abitypes_objc.swift index c626728a81513..3bf060dd3a650 100644 --- a/test/IRGen/abitypes_objc.swift +++ b/test/IRGen/abitypes_objc.swift @@ -20,6 +20,7 @@ import Foundation // arm64_32-watchos: [[ARM64_MYRECT:%.*]] = type { float, float, float, float } // arm64-watchos: [[ARM64_MYRECT:%.*]] = type { float, float, float, float } // arm64-macosx: [[ARM64_MYRECT:%.*]] = type { float, float, float, float } +// arm64-xros: [[ARM64_MYRECT:%.*]] = type { float, float, float, float } class Foo { // x86_64-macosx: define hidden swiftcc { float, float, float, float } @"$s8abitypes3FooC3bar{{[_0-9a-zA-Z]*}}F"(ptr swiftself %0) {{.*}} { @@ -48,6 +49,8 @@ class Foo { // arm64-watchos: define internal [[ARM64_MYRECT]] @"$s8abitypes3FooC3bar{{[_0-9a-zA-Z]*}}FTo"(ptr %0, ptr %1) {{[#0-9]*}} { // x86_64-watchos: define hidden swiftcc { float, float, float, float } @"$s8abitypes3FooC3bar{{[_0-9a-zA-Z]*}}F"(ptr swiftself %0) {{.*}} { // x86_64-watchos: define internal { <2 x float>, <2 x float> } @"$s8abitypes3FooC3bar{{[_0-9a-zA-Z]*}}FTo"(ptr %0, ptr %1) {{[#0-9]*}} { + // arm64-xros: define hidden swiftcc { float, float, float, float } @"$s8abitypes3FooC3bar{{[_0-9a-zA-Z]*}}F"(ptr swiftself %0) {{.*}} { + // arm64-xros: define internal [[ARM64_MYRECT]] @"$s8abitypes3FooC3bar{{[_0-9a-zA-Z]*}}FTo"(ptr %0, ptr %1) {{[#0-9]*}} { @objc dynamic func bar() -> MyRect { return MyRect(x: 1, y: 2, width: 3, height: 4) } diff --git a/test/IRGen/availability.swift b/test/IRGen/availability.swift index 029f8a3403137..49afdf00514b2 100644 --- a/test/IRGen/availability.swift +++ b/test/IRGen/availability.swift @@ -19,7 +19,7 @@ import Foundation // OPT: s10Foundation11MeasurementVySo17NSUnitTemperature public func dontHoist() { - if #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) { + if #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, visionOS 1.1, *) { let measurement = Measurement(value: Double(42), unit: .celsius) print("\(measurement)") } else { @@ -49,13 +49,13 @@ public func dontHoist() { // OPT-NOT: call {{.*}} @"$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF" // OPT: ret void public func multipleAvailabilityChecks() { - if #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) { + if #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, visionOS 1.1, *) { print("test one") } - if #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) { + if #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, visionOS 1.1, *) { print("test two") } - if #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) { + if #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, visionOS 1.1, *) { print("test three") } } diff --git a/test/IRGen/extended_existential_metadata_weak.swift b/test/IRGen/extended_existential_metadata_weak.swift index d293d98009916..7847c8e34911f 100644 --- a/test/IRGen/extended_existential_metadata_weak.swift +++ b/test/IRGen/extended_existential_metadata_weak.swift @@ -1,5 +1,6 @@ // RUN: %target-swift-frontend -emit-ir %s -target %target-swift-abi-5.5-triple | %FileCheck %s // REQUIRES: VENDOR=apple +// UNSUPPORTED: OS=xros public protocol P { associatedtype A @@ -10,4 +11,4 @@ public func f(_: T.Type) {} @available(SwiftStdlib 5.7, *) public func g(_: T.Type) { f((any P).self) } -// CHECK-LABEL: declare extern_weak ptr @swift_getExtendedExistentialTypeMetadata(ptr, ptr) \ No newline at end of file +// CHECK-LABEL: declare extern_weak ptr @swift_getExtendedExistentialTypeMetadata(ptr, ptr) diff --git a/test/IRGen/objc_globals.swift b/test/IRGen/objc_globals.swift index 39491efa715bc..8d0cbe921ae01 100644 --- a/test/IRGen/objc_globals.swift +++ b/test/IRGen/objc_globals.swift @@ -2,6 +2,7 @@ // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/abi %s -emit-ir | %FileCheck %s // // REQUIRES: objc_interop +// UNSUPPORTED: OS=xros import gadget import Foundation diff --git a/test/IRGen/objc_methods.swift b/test/IRGen/objc_methods.swift index fb7390eca901b..6b87f188ce1f0 100644 --- a/test/IRGen/objc_methods.swift +++ b/test/IRGen/objc_methods.swift @@ -54,6 +54,7 @@ class ObjcDestructible: NSObject { // CHECK-ios: [[FAIL_SIGNATURE:@.*]] = private unnamed_addr constant [12 x i8] c"B24@0:8^@16\00" // CHECK-tvos: [[FAIL_SIGNATURE:@.*]] = private unnamed_addr constant [12 x i8] c"B24@0:8^@16\00" // CHECK-watchos: [[FAIL_SIGNATURE:@.*]] = private unnamed_addr constant [12 x i8] c"B24@0:8^@16\00" +// CHECK-xros: [[FAIL_SIGNATURE:@.*]] = private unnamed_addr constant [12 x i8] c"B24@0:8^@16\00" // CHECK: @_INSTANCE_METHODS__TtC12objc_methods3Foo = internal constant { {{.*}}] } { // CHECK: i32 24, // CHECK: i32 10, @@ -82,6 +83,7 @@ class ObjcDestructible: NSObject { // CHECK: ptr [[FAIL_SIGNATURE]], // CHECK-macosx: ptr @"$s12objc_methods3FooC4failyyKFTo" // CHECK-ios: ptr @"$s12objc_methods3FooC4failyyKFTo" +// CHECK-xros: ptr @"$s12objc_methods3FooC4failyyKFTo" // CHECK: }] // CHECK: }, section "__DATA, {{.*}}", align 8 // CHECK: @_INSTANCE_METHODS__TtC12objc_methods16ObjcDestructible = internal constant { {{.*}}] } { diff --git a/test/IRGen/objc_type_encoding.swift b/test/IRGen/objc_type_encoding.swift index dcbc1dbc22a6a..5d7366c64b008 100644 --- a/test/IRGen/objc_type_encoding.swift +++ b/test/IRGen/objc_type_encoding.swift @@ -20,6 +20,7 @@ import gizmo // CHECK-ios: private unnamed_addr constant [8 x i8] c"#16@0:8\00" // CHECK-tvos: private unnamed_addr constant [8 x i8] c"#16@0:8\00" // CHECK-watchos: private unnamed_addr constant [8 x i8] c"#16@0:8\00" +// CHECK-xros: private unnamed_addr constant [8 x i8] c"#16@0:8\00" @objc class Methods { @objc func testSizedUnsignedTypes(_ a: UInt8, b: UInt16, c: UInt32, d: UInt64) {} @@ -27,18 +28,21 @@ import gizmo // CHECK-ios: private unnamed_addr constant [20 x i8] c"v36@0:8C16S20I24Q28\00" // CHECK-tvos: private unnamed_addr constant [20 x i8] c"v36@0:8C16S20I24Q28\00" // CHECK-watchos: private unnamed_addr constant [20 x i8] c"v36@0:8C16S20I24Q28\00" +// CHECK-xros: private unnamed_addr constant [20 x i8] c"v36@0:8C16S20I24Q28\00" @objc func testSizedFloats(_ a: Float32, b: Float64) {} // CHECK-macosx: private unnamed_addr constant [14 x i8] c"v28@0:8f16d20\00" // CHECK-ios: private unnamed_addr constant [14 x i8] c"v28@0:8f16d20\00" // CHECK-tvos: private unnamed_addr constant [14 x i8] c"v28@0:8f16d20\00" // CHECK-watchos: private unnamed_addr constant [14 x i8] c"v28@0:8f16d20\00" +// CHECK-xros: private unnamed_addr constant [14 x i8] c"v28@0:8f16d20\00" @objc func testParens(_ a: ((Int))) {} // CHECK-macosx: private unnamed_addr constant [11 x i8] c"v24@0:8q16\00" // CHECK-ios: private unnamed_addr constant [11 x i8] c"v24@0:8q16\00" // CHECK-tvos: private unnamed_addr constant [11 x i8] c"v24@0:8q16\00" // CHECK-watchos: private unnamed_addr constant [11 x i8] c"v24@0:8q16\00" +// CHECK-xros: private unnamed_addr constant [11 x i8] c"v24@0:8q16\00" @objc func testPrimitives(_ b: CBool, i: Int, f: Float, d: Double) -> OpaquePointer { fatalError() } @@ -46,6 +50,7 @@ import gizmo // CHECK-ios: private unnamed_addr constant [21 x i8] c"^v40@0:8B16q20f28d32\00" // CHECK-tvos: private unnamed_addr constant [21 x i8] c"^v40@0:8B16q20f28d32\00" // CHECK-watchos: private unnamed_addr constant [21 x i8] c"^v40@0:8B16q20f28d32\00" +// CHECK-xros: private unnamed_addr constant [21 x i8] c"^v40@0:8B16q20f28d32\00" @objc func testOptionalPrimitives() -> OpaquePointer? { return nil } @@ -53,36 +58,42 @@ import gizmo // CHECK-ios: private unnamed_addr constant [9 x i8] c"^v16@0:8\00" // CHECK-tvos: private unnamed_addr constant [9 x i8] c"^v16@0:8\00" // CHECK-watchos: private unnamed_addr constant [9 x i8] c"^v16@0:8\00" +// CHECK-xros: private unnamed_addr constant [9 x i8] c"^v16@0:8\00" @objc func testCSignedTypes(_ a: CSignedChar, b: CShort, c: CInt, d: CLong, e: CLongLong) {} // CHECK-macosx: private unnamed_addr constant [23 x i8] c"v44@0:8c16s20i24q28q36\00" // CHECK-ios: private unnamed_addr constant [23 x i8] c"v44@0:8c16s20i24q28q36\00" // CHECK-tvos: private unnamed_addr constant [23 x i8] c"v44@0:8c16s20i24q28q36\00" // CHECK-watchos: private unnamed_addr constant [23 x i8] c"v44@0:8c16s20i24q28q36\00" +// CHECK-xros: private unnamed_addr constant [23 x i8] c"v44@0:8c16s20i24q28q36\00" @objc func testCUnsignedTypes(_ a: CUnsignedChar, b: CUnsignedShort, c: CUnsignedInt, d: CUnsignedLong, e: CUnsignedLongLong) {} // CHECK-macosx: private unnamed_addr constant [23 x i8] c"v44@0:8C16S20I24Q28Q36\00" // CHECK-ios: private unnamed_addr constant [23 x i8] c"v44@0:8C16S20I24Q28Q36\00" // CHECK-tvos: private unnamed_addr constant [23 x i8] c"v44@0:8C16S20I24Q28Q36\00" // CHECK-watchos: private unnamed_addr constant [23 x i8] c"v44@0:8C16S20I24Q28Q36\00" +// CHECK-xros: private unnamed_addr constant [23 x i8] c"v44@0:8C16S20I24Q28Q36\00" @objc func testCChars(_ basic: CChar, wchar wide: CWideChar, char16: CChar16, char32: CChar32) {} // CHECK-macosx: private unnamed_addr constant [20 x i8] c"v32@0:8c16i20S24i28\00" // CHECK-ios: private unnamed_addr constant [20 x i8] c"v32@0:8c16i20S24i28\00" // CHECK-tvos: private unnamed_addr constant [20 x i8] c"v32@0:8c16i20S24i28\00" // CHECK-watchos: private unnamed_addr constant [20 x i8] c"v32@0:8c16i20S24i28\00" +// CHECK-xros: private unnamed_addr constant [20 x i8] c"v32@0:8c16i20S24i28\00" @objc func testCBool(_ a: CBool) {} // CHECK-macosx: private unnamed_addr constant [11 x i8] c"v20@0:8c16\00" // CHECK-ios: private unnamed_addr constant [11 x i8] c"v20@0:8B16\00" // CHECK-tvos: private unnamed_addr constant [11 x i8] c"v20@0:8B16\00" // CHECK-watchos: private unnamed_addr constant [11 x i8] c"v20@0:8B16\00" +// CHECK-xros: private unnamed_addr constant [11 x i8] c"v20@0:8B16\00" @objc func testSizedSignedTypes(_ a: Int8, b: Int16, c: Int32, d: Int64) {} // CHECK-macosx: private unnamed_addr constant [20 x i8] c"v36@0:8c16s20i24q28\00" // CHECK-ios: private unnamed_addr constant [20 x i8] c"v36@0:8c16s20i24q28\00" // CHECK-tvos: private unnamed_addr constant [20 x i8] c"v36@0:8c16s20i24q28\00" // CHECK-watchos: private unnamed_addr constant [20 x i8] c"v36@0:8c16s20i24q28\00" +// CHECK-xros: private unnamed_addr constant [20 x i8] c"v36@0:8c16s20i24q28\00" @objc class func getSelf() -> Methods.Type { return self } // These strings are required for another purpose and so are tested above. @@ -92,48 +103,56 @@ import gizmo // CHECK-ios: private unnamed_addr constant [8 x i8] c"@16@0:8\00" // CHECK-tvos: private unnamed_addr constant [8 x i8] c"@16@0:8\00" // CHECK-watchos: private unnamed_addr constant [8 x i8] c"@16@0:8\00" +// CHECK-xros: private unnamed_addr constant [8 x i8] c"@16@0:8\00" @objc func testId(_ s: AnyObject) -> AnyObject { return self } // CHECK-macosx: private unnamed_addr constant [11 x i8] c"@24@0:8@16\00" // CHECK-ios: private unnamed_addr constant [11 x i8] c"@24@0:8@16\00" // CHECK-tvos: private unnamed_addr constant [11 x i8] c"@24@0:8@16\00" // CHECK-watchos: private unnamed_addr constant [11 x i8] c"@24@0:8@16\00" +// CHECK-xros: private unnamed_addr constant [11 x i8] c"@24@0:8@16\00" @objc func comp1(_ a: P1 & P2, b: P1 & P2 & P3) -> P1 & P2 { return a } // CHECK-macosx: private unnamed_addr constant [14 x i8] c"@32@0:8@16@24\00" // CHECK-ios: private unnamed_addr constant [14 x i8] c"@32@0:8@16@24\00" // CHECK-tvos: private unnamed_addr constant [14 x i8] c"@32@0:8@16@24\00" // CHECK-watchos: private unnamed_addr constant [14 x i8] c"@32@0:8@16@24\00" +// CHECK-xros: private unnamed_addr constant [14 x i8] c"@32@0:8@16@24\00" @objc func returnsBool(_ b : Bool) -> Bool { return b } // CHECK-macosx: private unnamed_addr constant [11 x i8] c"c20@0:8c16\00" // CHECK-ios: private unnamed_addr constant [11 x i8] c"B20@0:8B16\00" // CHECK-tvos: private unnamed_addr constant [11 x i8] c"B20@0:8B16\00" // CHECK-watchos: private unnamed_addr constant [11 x i8] c"B20@0:8B16\00" +// CHECK-xros: private unnamed_addr constant [11 x i8] c"B20@0:8B16\00" @objc func comp1(_ a: Methods, b: Methods, c: Methods) -> Methods { return a } // CHECK-macosx: private unnamed_addr constant [17 x i8] c"@40@0:8@16@24@32\00" // CHECK-ios: private unnamed_addr constant [17 x i8] c"@40@0:8@16@24@32\00" // CHECK-tvos: private unnamed_addr constant [17 x i8] c"@40@0:8@16@24@32\00" // CHECK-watchos: private unnamed_addr constant [17 x i8] c"@40@0:8@16@24@32\00" +// CHECK-xros: private unnamed_addr constant [17 x i8] c"@40@0:8@16@24@32\00" @objc func passSelector(_ aSelector : Selector) {} // CHECK-macosx: private unnamed_addr constant [11 x i8] c"v24@0:8:16\00" // CHECK-ios: private unnamed_addr constant [11 x i8] c"v24@0:8:16\00" // CHECK-tvos: private unnamed_addr constant [11 x i8] c"v24@0:8:16\00" // CHECK-watchos: private unnamed_addr constant [11 x i8] c"v24@0:8:16\00" +// CHECK-xros: private unnamed_addr constant [11 x i8] c"v24@0:8:16\00" @objc func copyUnsafeMutablePointer(_ p: UnsafeMutablePointer) -> UnsafeMutablePointer { return p } // CHECK-macosx: private unnamed_addr constant [13 x i8] c"^i24@0:8^i16\00" // CHECK-ios: private unnamed_addr constant [13 x i8] c"^i24@0:8^i16\00" // CHECK-tvos: private unnamed_addr constant [13 x i8] c"^i24@0:8^i16\00" // CHECK-watchos: private unnamed_addr constant [13 x i8] c"^i24@0:8^i16\00" +// CHECK-xros: private unnamed_addr constant [13 x i8] c"^i24@0:8^i16\00" @objc func copyUnsafeMutablePointerInt(_ p: UnsafeMutablePointer) -> UnsafeMutablePointer { return p } // CHECK-macosx: private unnamed_addr constant [13 x i8] c"^q24@0:8^q16\00" // CHECK-ios: private unnamed_addr constant [13 x i8] c"^q24@0:8^q16\00" // CHECK-tvos: private unnamed_addr constant [13 x i8] c"^q24@0:8^q16\00" // CHECK-watchos: private unnamed_addr constant [13 x i8] c"^q24@0:8^q16\00" +// CHECK-xros: private unnamed_addr constant [13 x i8] c"^q24@0:8^q16\00" @objc func testArchetype(_ work: P3) { } @@ -141,6 +160,7 @@ import gizmo // CHECK-ios: private unnamed_addr constant [11 x i8] c"v24@0:8@16\00" // CHECK-tvos: private unnamed_addr constant [11 x i8] c"v24@0:8@16\00" // CHECK-watchos: private unnamed_addr constant [11 x i8] c"v24@0:8@16\00" +// CHECK-xros: private unnamed_addr constant [11 x i8] c"v24@0:8@16\00" @objc func foo(_ x: (Int) -> Int) -> Int { return 1 @@ -149,6 +169,7 @@ import gizmo // CHECK-ios: private unnamed_addr constant [12 x i8] c"q24@0:8@?16\00" // CHECK-tvos: private unnamed_addr constant [12 x i8] c"q24@0:8@?16\00" // CHECK-watchos: private unnamed_addr constant [12 x i8] c"q24@0:8@?16\00" +// CHECK-xros: private unnamed_addr constant [12 x i8] c"q24@0:8@?16\00" @objc func returnNSRadixedOptions() -> NSRadixedOptions { return .octal @@ -157,6 +178,7 @@ import gizmo // CHECK-ios: [[ENUMENCODING:@.*]] = private unnamed_addr constant [8 x i8] c"i16@0:8\00" // CHECK-tvos: [[ENUMENCODING:@.*]] = private unnamed_addr constant [8 x i8] c"i16@0:8\00" // CHECK-watchos: [[ENUMENCODING:@.*]] = private unnamed_addr constant [8 x i8] c"i16@0:8\00" +// CHECK-xros: [[ENUMENCODING:@.*]] = private unnamed_addr constant [8 x i8] c"i16@0:8\00" @objc func returnChoseNSRadixedOptions(_ choice: NSRadixedOptions) -> NSRadixedOptions { switch choice { @@ -168,10 +190,12 @@ import gizmo // CHECK-ios: private unnamed_addr constant [11 x i8] c"i20@0:8i16\00" // CHECK-tvos: private unnamed_addr constant [11 x i8] c"i20@0:8i16\00" // CHECK-watchos: private unnamed_addr constant [11 x i8] c"i20@0:8i16\00" +// CHECK-xros: private unnamed_addr constant [11 x i8] c"i20@0:8i16\00" @objc func getRawEnumInGizmo() -> RawEnumInGizmo { return InGizmoTwo } + // CHECK-macosx: { ptr @"\01L_selector_data(getRawEnumInGizmo)", // CHECK-macosx: ptr [[ENUMENCODING]] // CHECK-ios: { ptr @"\01L_selector_data(getRawEnumInGizmo)", @@ -180,6 +204,8 @@ import gizmo // CHECK-tvos: ptr [[ENUMENCODING]] // CHECK-watchos: { ptr @"\01L_selector_data(getRawEnumInGizmo)", // CHECK-watchos: ptr [[ENUMENCODING]] +// CHECK-xros: { ptr @"\01L_selector_data(getRawEnumInGizmo)", +// CHECK-xros: ptr [[ENUMENCODING]] } diff --git a/test/IRGen/temporary_allocation/codegen_very_large_allocation.swift b/test/IRGen/temporary_allocation/codegen_very_large_allocation.swift index 8a24a9952fe53..335355724ecce 100644 --- a/test/IRGen/temporary_allocation/codegen_very_large_allocation.swift +++ b/test/IRGen/temporary_allocation/codegen_very_large_allocation.swift @@ -2,6 +2,11 @@ // RUN: %target-swift-frontend -primary-file %s -O -emit-ir | %FileCheck %s --check-prefix=CHECK-LARGE-STACK-ALLOC -DWORD=i%target-ptrsize // RUN: %target-swift-frontend -primary-file %s -O -emit-ir | %FileCheck %s --check-prefix=CHECK-LARGE-HEAP-ALLOC -DWORD=i%target-ptrsize +// This test for conditionally checking the version with ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF +// xrOS is always succeeds the availability check so there is no need to call +// this function. +// UNSUPPORTED: OS=xros + @_silgen_name("blackHole") func blackHole(_ value: UnsafeMutableRawPointer?) -> Void diff --git a/test/Inputs/MockPlatformRemapSDKConfig/SDKSettings.json b/test/Inputs/MockPlatformRemapSDKConfig/SDKSettings.json new file mode 100644 index 0000000000000..acd8af4ae68c0 --- /dev/null +++ b/test/Inputs/MockPlatformRemapSDKConfig/SDKSettings.json @@ -0,0 +1,25 @@ +{ + "DisplayName": "visionOS 1.1", + "Version": "1.1", + "VersionMap": { + "xrOS_iOS": { + "1.0": "17.1", + "1.1": "17.4" + }, + "iOS_visionOS": { + "17.1": "1.0", + "17.4": "1.1" + }, + "iOS_xrOS": { + "17.1": "1.0", + "17.4": "1.1" + }, + "visionOS_iOS": { + "1.0": "17.1", + "1.1": "17.4" + } + }, + "DefaultDeploymentTarget": "1.1", + "MaximumDeploymentTarget": "1.1.99", + "CanonicalName": "xros1.1" +} diff --git a/test/Inputs/clang-importer-sdk/usr/include/Foundation.h b/test/Inputs/clang-importer-sdk/usr/include/Foundation.h index 25a405472946e..53499fd42cb1d 100644 --- a/test/Inputs/clang-importer-sdk/usr/include/Foundation.h +++ b/test/Inputs/clang-importer-sdk/usr/include/Foundation.h @@ -29,7 +29,8 @@ typedef struct _NSRange { extern NSUInteger NSRealMemoryAvailable(void) __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.8,message="" ))) __attribute__((availability(ios,introduced=2.0 ,deprecated=6.0,message="" ))); extern NSUInteger SomeCrazyAppExtensionForbiddenAPI(void) __attribute__((availability(macosx_app_extension,unavailable,message="Not available in App Extensions"))) - __attribute__((availability(ios_app_extension,unavailable,message="Not available in App Extensions"))); + __attribute__((availability(ios_app_extension,unavailable,message="Not available in App Extensions"))) + __attribute__((availability(xros_app_extension,unavailable,message="Not available in App Extensions"))); extern NSString *const globalStringAvailableOn10_51 __attribute__((availability(macosx,introduced=10.51))); extern NSString *const globalStringAvailableOn10_52 __attribute__((availability(macosx,introduced=10.52))); diff --git a/test/Interpreter/Inputs/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h b/test/Interpreter/Inputs/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h index 44676ddfe756c..d373b8ba75a56 100644 --- a/test/Interpreter/Inputs/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h +++ b/test/Interpreter/Inputs/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h @@ -1,8 +1,8 @@ #include -extern int UnavailableObjCGlobalVariable __attribute__((availability(macosx,introduced=1066.0))) __attribute__((availability(ios,introduced=1066.0))); +extern int UnavailableObjCGlobalVariable __attribute__((availability(macosx,introduced=1066.0))) __attribute__((availability(ios,introduced=1066.0))) __attribute__((availability(visionos,introduced=1066.0))); -__attribute__((availability(macosx,introduced=1066.0))) __attribute__((availability(ios,introduced=1066.0))) +__attribute__((availability(macosx,introduced=1066.0))) __attribute__((availability(ios,introduced=1066.0))) __attribute__((availability(visionos,introduced=1066.0))) @protocol UnavailableObjCProtocol - (void)someMethod; @end @@ -12,10 +12,10 @@ __attribute__((availability(macosx,introduced=1066.0))) __attribute__((availabi - (void)someMethod; @end -__attribute__((availability(macosx,introduced=1066.0))) __attribute__((availability(ios,introduced=1066.0))) +__attribute__((availability(macosx,introduced=1066.0))) __attribute__((availability(ios,introduced=1066.0))) __attribute__((availability(visionos,introduced=1066.0))) @interface UnavailableObjCClass : NSObject - (void)someMethod; @end -__attribute__((availability(macosx,introduced=1066.0))) __attribute__((availability(ios,introduced=1066.0))) +__attribute__((availability(macosx,introduced=1066.0))) __attribute__((availability(ios,introduced=1066.0)))__attribute__((availability(visionos,introduced=1066.0))) void someFunction(); diff --git a/test/Interpreter/Inputs/FakeUnavailableSwiftDylib.swift b/test/Interpreter/Inputs/FakeUnavailableSwiftDylib.swift index a5214503f8033..e2efee662576f 100644 --- a/test/Interpreter/Inputs/FakeUnavailableSwiftDylib.swift +++ b/test/Interpreter/Inputs/FakeUnavailableSwiftDylib.swift @@ -1,9 +1,9 @@ -@available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) +@available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) public protocol UnavailableSwiftProtocol { func someMethod() } -@available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) +@available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) public class UnavailableSwiftClass { func someMethod() {} } diff --git a/test/Interpreter/SDK/GLKit.swift b/test/Interpreter/SDK/GLKit.swift index 3e967e3bdf917..a689625fbbdb5 100644 --- a/test/Interpreter/SDK/GLKit.swift +++ b/test/Interpreter/SDK/GLKit.swift @@ -10,6 +10,7 @@ // GLKit is not available on watchOS. // UNSUPPORTED: OS=watchos +// UNSUPPORTED: OS=xros import GLKit diff --git a/test/Interpreter/SDK/GLKit_parse.swift b/test/Interpreter/SDK/GLKit_parse.swift index fa17b81abeaf1..d081ca600d361 100644 --- a/test/Interpreter/SDK/GLKit_parse.swift +++ b/test/Interpreter/SDK/GLKit_parse.swift @@ -4,6 +4,7 @@ // REQUIRES: objc_interop // UNSUPPORTED: OS=watchos // UNSUPPORTED: OS=tvos +// UNSUPPORTED: OS=xros import GLKit diff --git a/test/Interpreter/availability_weak_linking.swift b/test/Interpreter/availability_weak_linking.swift index d4b65d7e76389..edb1d14e081fd 100644 --- a/test/Interpreter/availability_weak_linking.swift +++ b/test/Interpreter/availability_weak_linking.swift @@ -34,7 +34,7 @@ import Foundation print("Running...") func useUnavailableObjCGlobal() { - if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) { + if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) { let g = UnavailableObjCGlobalVariable _blackHole(g) } @@ -53,7 +53,7 @@ func useClassConformingToUnavailableObjCProtocol() { let o = ClassConformingToUnavailableObjCProtocol() o.someMethod() - if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) { + if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) { let oAsUP: UnavailableObjCProtocol = o as UnavailableObjCProtocol oAsUP.someMethod() } @@ -76,7 +76,7 @@ func useClassThatWillBeExtendedToConformToUnavailableObjCProtocol() { let o = ClassThatWillBeExtendedToConformToUnavailableObjCProtocol() o.someMethod() - if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) { + if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) { let oAsUP: UnavailableObjCProtocol = o as UnavailableObjCProtocol oAsUP.someMethod() } @@ -116,13 +116,13 @@ func printClassMetadataViaGeneric() -> T { } func useUnavailableObjCClass() { - if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) { + if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) { let o = UnavailableObjCClass() o.someMethod() } for i in 0 ..< getInt(5) { - if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) { + if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) { let o: UnavailableObjCClass = printClassMetadataViaGeneric() _blackHole(o) } @@ -132,14 +132,14 @@ func useUnavailableObjCClass() { let someObject: AnyObject = _opaqueIdentity(SomeClass() as AnyObject) for i in 0 ..< getInt(5) { - if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) { + if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) { let isUnavailable = someObject is UnavailableObjCClass _blackHole(isUnavailable) } } for i in 0 ..< getInt(5) { - if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) { + if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) { let asUnavailable = someObject as? UnavailableObjCClass _blackHole(asUnavailable) } @@ -155,10 +155,10 @@ useUnavailableObjCClass() // Allow extending a weakly-linked class to conform to a protocol. protocol SomeSwiftProtocol { } -@available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) +@available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) extension UnavailableObjCClass : SomeSwiftProtocol { } -@available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) +@available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) extension UnavailableSwiftClass : SomeSwiftProtocol { } @@ -181,7 +181,7 @@ func useClassConformingToUnavailableSwiftProtocol() { let o = ClassConformingToUnavailableSwiftProtocol() o.someMethod() - if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) { + if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) { let oAsUP: UnavailableSwiftProtocol = o as UnavailableSwiftProtocol oAsUP.someMethod() } @@ -203,7 +203,7 @@ func useClassThatWillBeExtendedToConformToUnavailableSwiftProtocol() { let o = ClassThatWillBeExtendedToConformToUnavailableSwiftProtocol() o.someMethod() - if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, *) { + if #available(OSX 1066.0, iOS 1066.0, watchOS 1066.0, tvOS 1066.0, visionOS 1066.0, *) { let oAsUP: UnavailableSwiftProtocol = o as UnavailableSwiftProtocol oAsUP.someMethod() } diff --git a/test/Interpreter/builtin_bridge_object.swift b/test/Interpreter/builtin_bridge_object.swift index da7aac1cf1ca2..7756d5b7c3d54 100644 --- a/test/Interpreter/builtin_bridge_object.swift +++ b/test/Interpreter/builtin_bridge_object.swift @@ -3,6 +3,8 @@ // REQUIRES: executable_test // REQUIRES: objc_interop +// rdar://124700033 +// UNSUPPORTED: OS=xros // FIXME: rdar://problem/19648117 Needs splitting objc parts out diff --git a/test/Interpreter/llvm_link_time_opt.swift b/test/Interpreter/llvm_link_time_opt.swift index 389644db66e4f..7f60f66770109 100644 --- a/test/Interpreter/llvm_link_time_opt.swift +++ b/test/Interpreter/llvm_link_time_opt.swift @@ -3,6 +3,8 @@ // XFAIL: OS=linux-android, OS=linux-androideabi +// UNSUPPORTED: OS=xros + // For LTO, the linker dlopen()'s the libLTO library, which is a scenario that // ASan cannot work in ("Interceptors are not working, AddressSanitizer is // loaded too late"). diff --git a/test/Migrator/api-diff-data-dir.swift b/test/Migrator/api-diff-data-dir.swift index 3b2a259915025..ec2434c2d5ecc 100644 --- a/test/Migrator/api-diff-data-dir.swift +++ b/test/Migrator/api-diff-data-dir.swift @@ -1,4 +1,5 @@ // REQUIRES: objc_interop +// UNSUPPORTED: OS=xros // RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -api-diff-data-dir %S/Inputs/api-diff-data-dir -emit-migrated-file-path %t/api-diff-data-dir.swift.result -emit-remap-file-path %t/api-diff-data-dir.swift.remap -o /dev/null // RUN: %FileCheck %s -input-file %t/api-diff-data-dir.swift.result -match-full-lines -check-prefix=SWIFT4 diff --git a/test/Migrator/fixit_flatMap.swift b/test/Migrator/fixit_flatMap.swift index 8bb4fc8eb87b6..c4f4de58163b5 100644 --- a/test/Migrator/fixit_flatMap.swift +++ b/test/Migrator/fixit_flatMap.swift @@ -3,6 +3,7 @@ // RUN: diff -u %s.expected %t.result // REQUIRES: VENDOR=apple +// UNSUPPORTED: OS=xros func migrate(lseq: LazySequence, lcol: LazyCollection, seq: U, col: V, test: Bool) { _ = lseq.flatMap { test ? nil : $0 } diff --git a/test/Migrator/fixit_flatMap.swift.expected b/test/Migrator/fixit_flatMap.swift.expected index 40ad11d3e7389..ee69ce010467f 100644 --- a/test/Migrator/fixit_flatMap.swift.expected +++ b/test/Migrator/fixit_flatMap.swift.expected @@ -3,6 +3,7 @@ // RUN: diff -u %s.expected %t.result // REQUIRES: VENDOR=apple +// UNSUPPORTED: OS=xros func migrate(lseq: LazySequence, lcol: LazyCollection, seq: U, col: V, test: Bool) { _ = lseq.compactMap { test ? nil : $0 } diff --git a/test/Migrator/stdlib_rename.swift b/test/Migrator/stdlib_rename.swift index 6a39bb2b5ae45..e4d72b611fbcf 100644 --- a/test/Migrator/stdlib_rename.swift +++ b/test/Migrator/stdlib_rename.swift @@ -1,4 +1,5 @@ // REQUIRES: objc_interop +// UNSUPPORTED: OS=xros // RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -emit-migrated-file-path %t/stdlib_rename.swift.result -emit-remap-file-path %t/stdlib_rename.swift.remap -o /dev/null %api_diff_data_dir // RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result // RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -emit-migrated-file-path %t/stdlib_rename.swift.result -emit-remap-file-path %t/stdlib_rename.swift.remap -o /dev/null -swift-version 4.2 %api_diff_data_dir diff --git a/test/Migrator/stdlib_rename.swift.expected b/test/Migrator/stdlib_rename.swift.expected index 5174e069f1cff..e0f60e7f988b6 100644 --- a/test/Migrator/stdlib_rename.swift.expected +++ b/test/Migrator/stdlib_rename.swift.expected @@ -1,4 +1,5 @@ // REQUIRES: objc_interop +// UNSUPPORTED: OS=xros // RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -emit-migrated-file-path %t/stdlib_rename.swift.result -emit-remap-file-path %t/stdlib_rename.swift.remap -o /dev/null %api_diff_data_dir // RUN: diff -u %S/stdlib_rename.swift.expected %t/stdlib_rename.swift.result // RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -F %S/mock-sdk -emit-migrated-file-path %t/stdlib_rename.swift.result -emit-remap-file-path %t/stdlib_rename.swift.remap -o /dev/null -swift-version 4.2 %api_diff_data_dir diff --git a/test/ModuleInterface/actor_availability.swift b/test/ModuleInterface/actor_availability.swift index fccb5a376eaaa..c605ef71f6dca 100644 --- a/test/ModuleInterface/actor_availability.swift +++ b/test/ModuleInterface/actor_availability.swift @@ -80,7 +80,7 @@ extension Enum { // CHECK-PUBLIC: @available(macOS, unavailable) // CHECK-PUBLIC-NEXT: @available(iOS, unavailable) // CHECK-PUBLIC-NEXT: @available(watchOS, unavailable) -// CHECK-PUBLIC-NEXT: @available(tvOS, unavailable) +// CHECK-PUBLIC-NEXT: @available(tvOS, unavailable // CHECK-PUBLIC-NEXT: public struct SPIAvailableStruct // CHECK-PRIVATE: @_spi_available(macOS, introduced: 10.15.4) // CHECK-PRIVATE-NEXT: @_spi_available(iOS, introduced: 13.4) diff --git a/test/ModuleInterface/distributed-actor.swift b/test/ModuleInterface/distributed-actor.swift index 1af26faf298b9..7aef5a6f1ced0 100644 --- a/test/ModuleInterface/distributed-actor.swift +++ b/test/ModuleInterface/distributed-actor.swift @@ -67,7 +67,7 @@ public distributed actor DAG where ActorSystem: DistributedActorSys // CHECK: get // CHECK: } // CHECK: public init(actorSystem system: ActorSystem) -// CHECK: @available(iOS 9999, tvOS 9999, watchOS 9999, macOS 9999, *) +// CHECK: @available(iOS 9999, tvOS 9999, watchOS 9999, visionOS 9999, macOS 9999, *) // CHECK: @_semantics("defaultActor") nonisolated final public var unownedExecutor: _Concurrency.UnownedSerialExecutor { // CHECK: get // CHECK: } @@ -84,7 +84,7 @@ public distributed actor DAG where ActorSystem: DistributedActorSys // CHECK-NEXT:extension Library.DA : Swift.Decodable {} // CHECK-NOT: #if compiler(>=5.3) && $Actors -// CHECK: @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) +// CHECK: @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *) // CHECK-NEXT: extension Library.DAG : Distributed.DistributedActor {} //--- Client.swift diff --git a/test/Parse/ConditionalCompilation/basicParseErrors.swift b/test/Parse/ConditionalCompilation/basicParseErrors.swift index b1fd6e0237788..e5fe7972f514c 100644 --- a/test/Parse/ConditionalCompilation/basicParseErrors.swift +++ b/test/Parse/ConditionalCompilation/basicParseErrors.swift @@ -79,6 +79,12 @@ struct S { // expected-note@-3{{did you mean 'Android'?}} {{8-15=Android}} // expected-note@-4{{did you mean 'OSX'?}} {{8-15=OSX}} // expected-note@-5{{did you mean 'OpenBSD'?}} {{8-15=OpenBSD}} +// expected-note@-6{{did you mean 'xrOS'?}} {{8-15=xrOS}} +#endif + +#if os(bisionos) // expected-warning {{unknown operating system for build configuration 'os'}} +// expected-note@-1{{did you mean 'visionOS'?}} {{8-16=visionOS}} + #endif #if arch(leg) // expected-warning {{unknown architecture for build configuration 'arch'}} expected-note{{did you mean 'arm'?}} {{10-13=arm}} @@ -137,6 +143,7 @@ fn_k() // expected-warning@-4 {{unknown architecture for build configuration 'arch'}} // expected-note@-5 {{did you mean 'arm'?}} {{26-29=arm}} // expected-note@-6 {{did you mean 'i386'?}} {{26-29=i386}} +// expected-note@-7 {{did you mean 'visionOS'?}} {{8-16=visionOS}} func undefinedFunc() // ignored. #endif undefinedFunc() // expected-error {{cannot find 'undefinedFunc' in scope}} diff --git a/test/PrintAsObjC/resilient-ancestry.swift b/test/PrintAsObjC/resilient-ancestry.swift index ca877beeff5e8..2025177bdd6b3 100644 --- a/test/PrintAsObjC/resilient-ancestry.swift +++ b/test/PrintAsObjC/resilient-ancestry.swift @@ -12,6 +12,7 @@ // REQUIRES: objc_interop // UNSUPPORTED: OS=iosmac +// UNSUPPORTED: OS=xros // See also resilient-ancestry.swift, for the stable ABI deployment target test. diff --git a/test/Reflection/conformance_descriptors.swift b/test/Reflection/conformance_descriptors.swift index 02d601c9f7164..b2d6901522aa9 100644 --- a/test/Reflection/conformance_descriptors.swift +++ b/test/Reflection/conformance_descriptors.swift @@ -1,5 +1,8 @@ // UNSUPPORTED: OS=windows-msvc - +// +// LC_DYLD_CHAINED_FIXUPS decode not currently supported (default on visionOS) +// UNSUPPORTED: OS=xros +// // Temporarily disable on AArch64 Linux (rdar://88451721) // UNSUPPORTED: OS=linux-gnu && CPU=aarch64 diff --git a/test/Reflection/typeref_decoding.swift b/test/Reflection/typeref_decoding.swift index 1b8fa31b87635..b1bc12da5ec82 100644 --- a/test/Reflection/typeref_decoding.swift +++ b/test/Reflection/typeref_decoding.swift @@ -1,5 +1,8 @@ // REQUIRES: no_asan - +// +// LC_DYLD_CHAINED_FIXUPS decode not currently supported (default on visionOS) +// UNSUPPORTED: OS=xros +// // rdar://100805115 // UNSUPPORTED: CPU=arm64e diff --git a/test/Reflection/typeref_decoding_imported.swift b/test/Reflection/typeref_decoding_imported.swift index fd0b2527dc8a1..d877e3015d70d 100644 --- a/test/Reflection/typeref_decoding_imported.swift +++ b/test/Reflection/typeref_decoding_imported.swift @@ -1,5 +1,8 @@ // XFAIL: OS=windows-msvc - +// +// LC_DYLD_CHAINED_FIXUPS decode not currently supported (default on visionOS) +// UNSUPPORTED: OS=xros +// // https://github.com/apple/swift/issues/55339 // XFAIL: OS=openbsd diff --git a/test/Reflection/typeref_lowering.swift b/test/Reflection/typeref_lowering.swift index 03df741b3d8e3..4d53be234c945 100644 --- a/test/Reflection/typeref_lowering.swift +++ b/test/Reflection/typeref_lowering.swift @@ -1,4 +1,8 @@ // REQUIRES: no_asan +// +// LC_DYLD_CHAINED_FIXUPS decode not currently supported (default on visionOS) +// UNSUPPORTED: OS=xros +// // XFAIL: OS=windows-msvc // RUN: %empty-directory(%t) diff --git a/test/Runtime/protocol_conformance_collision.swift b/test/Runtime/protocol_conformance_collision.swift index 391cc9669b83c..b74c8a804f206 100644 --- a/test/Runtime/protocol_conformance_collision.swift +++ b/test/Runtime/protocol_conformance_collision.swift @@ -13,6 +13,7 @@ // UNSUPPORTED: DARWIN_SIMULATOR=ios // UNSUPPORTED: DARWIN_SIMULATOR=tvos // UNSUPPORTED: DARWIN_SIMULATOR=watchos +// UNSUPPORTED: DARWIN_SIMULATOR=xros // UNSUPPORTED: use_os_stdlib // UNSUPPORTED: back_deployment_runtime diff --git a/test/SILGen/Inputs/mock-visionos-sdk/SDKSettings.json b/test/SILGen/Inputs/mock-visionos-sdk/SDKSettings.json new file mode 100644 index 0000000000000..92ce99f0fd99e --- /dev/null +++ b/test/SILGen/Inputs/mock-visionos-sdk/SDKSettings.json @@ -0,0 +1,56 @@ +{ + "CanonicalName": "xros1.0", + "DefaultDeploymentTarget": "1.0", + "DefaultProperties": {}, + "DisplayName": "visionOS 1.0", + "IsBaseSDK": "YES", + "MaximumDeploymentTarget": "1.0.99", + "MinimalDisplayName": "1.0", + "SupportedTargets": { + "xros": { + "Archs": [ + "arm64e", + "arm64" + ], + "BuildVersionPlatformID": "11", + "ClangRuntimeLibraryPlatformName": "xros", + "DefaultDeploymentTarget": "1.0", + "DeploymentTargetSettingName": "XROS_DEPLOYMENT_TARGET", + "DeviceFamilies": [ + { + "DisplayName": "Apple Vision", + "Identifier": "7" + } + ], + "LLVMTargetTripleEnvironment": "", + "LLVMTargetTripleSys": "xros", + "LLVMTargetTripleVendor": "apple", + "MaximumDeploymentTarget": "1.0.99", + "MinimumDeploymentTarget": "1.0", + "PlatformFamilyDisplayName": "visionOS", + "PlatformFamilyName": "xrOS", + "RecommendedDeploymentTarget": "1.0", + "SwiftConcurrencyMinimumDeploymentTarget": "1.0", + "SwiftOSRuntimeMinimumDeploymentTarget": "1.0", + "SystemPrefix": "", + "ValidDeploymentTargets": [ + "1.0" + ] + } + }, + "Version": "1.0", + "VersionMap": { + "iOS_visionOS": { + "17.0": "1.0" + }, + "iOS_xrOS": { + "17.0": "1.0" + }, + "visionOS_iOS": { + "1.0": "17.0" + }, + "xrOS_iOS": { + "1.0": "17.0" + } + } +} diff --git a/test/SILGen/unavailable_decl_optimization_visionos.swift b/test/SILGen/unavailable_decl_optimization_visionos.swift new file mode 100644 index 0000000000000..68a6b201d1a45 --- /dev/null +++ b/test/SILGen/unavailable_decl_optimization_visionos.swift @@ -0,0 +1,68 @@ +// RUN: %target-swift-emit-silgen -module-name Test -parse-as-library %s -verify -target arm64-apple-xros1.0 | %FileCheck %s --check-prefixes=CHECK +// RUN: %target-swift-emit-silgen -module-name Test -parse-as-library %s -verify -unavailable-decl-optimization=none -target arm64-apple-xros1.0 | %FileCheck %s --check-prefixes=CHECK + +// REQUIRES: OS=xros + +public struct S {} + +// CHECK-LABEL: sil{{.*}}@$s4Test19visionOSUnavailableAA1SVyF +// CHECK-NOT: ss31_diagnoseUnavailableCodeReacheds5NeverOyF +// CHECK: } // end sil function '$s4Test19visionOSUnavailableAA1SVyF' +@available(visionOS, unavailable) +public func visionOSUnavailable() -> S { + return S() +} + +// CHECK-LABEL: sil{{.*}}@$s4Test14iOSUnavailableAA1SVyF +// CHECK-NOT: ss31_diagnoseUnavailableCodeReacheds5NeverOyF +// CHECK: } // end sil function '$s4Test14iOSUnavailableAA1SVyF' +@available(iOS, unavailable) +public func iOSUnavailable() -> S { + return S() +} + +// CHECK-LABEL: sil{{.*}}@$s4Test16macOSUnavailableAA1SVyF +// CHECK-NOT: ss31_diagnoseUnavailableCodeReacheds5NeverOyF +// CHECK: } // end sil function '$s4Test16macOSUnavailableAA1SVyF' +@available(macOS, unavailable) +public func macOSUnavailable() -> S { + return S() +} + +// CHECK-LABEL: sil{{.*}}@$s4Test31iOSUnavailableVisionOSAvailableAA1SVyF +// CHECK-NOT: ss31_diagnoseUnavailableCodeReacheds5NeverOyF +// CHECK: } // end sil function '$s4Test31iOSUnavailableVisionOSAvailableAA1SVyF' +@available(iOS, unavailable) +@available(visionOS, introduced: 1.0) +public func iOSUnavailableVisionOSAvailable() -> S { + return S() +} + +// CHECK-LABEL: sil{{.*}}@$s4Test25iOSAndVisionOSUnavailableAA1SVyF +// CHECK-NOT: ss31_diagnoseUnavailableCodeReacheds5NeverOyF +// CHECK: } // end sil function '$s4Test25iOSAndVisionOSUnavailableAA1SVyF' +@available(iOS, unavailable) +@available(visionOS, unavailable) +public func iOSAndVisionOSUnavailable() -> S { + // FIXME: This function should be optimized (rdar://116742214) + return S() +} + +@available(visionOS, unavailable) +public struct UnavailableOnVisionOS { + // CHECK-LABEL: sil{{.*}}@$s4Test21UnavailableOnVisionOSV14noAvailabilityAA1SVyF + // CHECK-NOT: ss31_diagnoseUnavailableCodeReacheds5NeverOyF + // CHECK: } // end sil function '$s4Test21UnavailableOnVisionOSV14noAvailabilityAA1SVyF' + public func noAvailability() -> S { + return S() + } + + // CHECK-LABEL: sil{{.*}}@$s4Test21UnavailableOnVisionOSV022iOSUnavailableInheritsdF0AA1SVyF + // CHECK-NOT: ss31_diagnoseUnavailableCodeReacheds5NeverOyF + // CHECK: } // end sil function '$s4Test21UnavailableOnVisionOSV022iOSUnavailableInheritsdF0AA1SVyF' + @available(iOS, unavailable) + public func iOSUnavailableInheritsVisionOSUnavailable() -> S { + // FIXME: This function should be optimized (rdar://116742214) + return S() + } +} diff --git a/test/SILGen/visionos_available_rawvalue_enum.swift b/test/SILGen/visionos_available_rawvalue_enum.swift new file mode 100644 index 0000000000000..8cb9c16b49ec0 --- /dev/null +++ b/test/SILGen/visionos_available_rawvalue_enum.swift @@ -0,0 +1,19 @@ +// Mock SDK will contain an appropriate SDKSettings and a loadable stdlib +// RUN: %empty-directory(%t/mock-sdk) +// RUN: %empty-directory(%t/mock-sdk/usr/lib/swift) +// RUN: cp -r %test-resource-dir/xros/Swift.swiftmodule %t/mock-sdk/usr/lib/swift/Swift.swiftmodule +// RUN: cp %S/Inputs/mock-visionos-sdk/SDKSettings.json %t/mock-sdk/SDKSettings.json +// RUN: %swift -emit-sil -parse-as-library %s -target arm64-apple-xros1.0 -sdk %t/mock-sdk -I %t/mock-sdk/usr/lib/swift/ -verify +// RUN: %swift -emit-silgen -parse-as-library %s -target arm64-apple-xros1.0 -sdk %t/mock-sdk -I %t/mock-sdk/usr/lib/swift/ -o %t/ios_available_rawvalue_enum_on_visionos.sil +// RUN: %FileCheck %s < %t/ios_available_rawvalue_enum_on_visionos.sil + +// REQUIRES: OS=xros + +// CHECK-LABEL: // Metasyntactics.init(rawValue:) +// Ensure that OS version check is generated for the current platform +// CHECK: function_ref @$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF +public enum Metasyntactics: String, RawRepresentable { + case foo + @available(visionOS 1.1, *) + case bar +} diff --git a/test/Sema/availability_refinement_contexts_target_min_inlining.swift b/test/Sema/availability_refinement_contexts_target_min_inlining.swift index 4674f0bb65144..61a990b949c9e 100644 --- a/test/Sema/availability_refinement_contexts_target_min_inlining.swift +++ b/test/Sema/availability_refinement_contexts_target_min_inlining.swift @@ -10,9 +10,11 @@ // CHECK-ios: {{^}}(root versions=[8.0,+Inf) // CHECK-tvos: {{^}}(root versions=[9.0,+Inf) // CHECK-watchos: {{^}}(root versions=[2.0,+Inf) +// CHECK-xros: {{^}}(root versions=[1.0,+Inf) // CHECK-macosx-NEXT: {{^}} (decl_implicit versions=[10.15,+Inf) decl=foo() // CHECK-ios-NEXT: {{^}} (decl_implicit versions=[13,+Inf) decl=foo() // CHECK-tvos-NEXT: {{^}} (decl_implicit versions=[13,+Inf) decl=foo() // CHECK-watchos-NEXT: {{^}} (decl_implicit versions=[6,+Inf) decl=foo() + func foo() {} diff --git a/test/SourceKit/InterfaceGen/gen_vision_availability.swift b/test/SourceKit/InterfaceGen/gen_vision_availability.swift new file mode 100644 index 0000000000000..fc994f96265e1 --- /dev/null +++ b/test/SourceKit/InterfaceGen/gen_vision_availability.swift @@ -0,0 +1,39 @@ +// REQUIRES: concurrency + +// RUN: %empty-directory(%t) + +// RUN: %sourcekitd-test -req=interface-gen %s -- %s -target %target-triple -module-name MyModule | %FileCheck %s --check-prefix=SWIFTSOURCE + +// RUN: %target-swift-frontend -emit-module -module-name MyModule -o %t/MyModule.swiftmodule %s +// RUN: %sourcekitd-test -req=interface-gen -module MyModule -- -target %target-triple -I %t | %FileCheck %s --check-prefix=SWIFTMODULE +// RUN: %sourcekitd-test -req=doc-info -module MyModule -- -target %target-triple -I %t | %FileCheck %s --check-prefix=DOCINFO + +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, visionOS 1.0, *) +public struct SomeStruct {} + +public struct TestStruct { + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, visionOS 1.0, *) + public func availableMethod() {} +} + +// SWIFTSOURCE: @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, visionOS 1.0, *) +// SWIFTSOURCE: public struct SomeStruct { +// SWIFTSOURCE: } +// SWIFTSOURCE: public struct TestStruct { +// SWIFTSOURCE: @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, visionOS 1.0, *) +// SWIFTSOURCE: public func availableMethod() +// SWIFTSOURCE: } + +// SWIFTMODULE: @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, visionOS 1.0, *) +// SWIFTMODULE: public struct SomeStruct { +// SWIFTMODULE: } +// SWIFTMODULE: public struct TestStruct { +// SWIFTMODULE: @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, visionOS 1.0, *) +// SWIFTMODULE: public func availableMethod() +// SWIFTMODULE: } + +// DOCINFO: struct SomeStruct { +// DOCINFO: } +// DOCINFO: struct TestStruct { +// DOCINFO: func availableMethod() +// DOCINFO: } diff --git a/test/TBD/multimodule-implied-objc.swift b/test/TBD/multimodule-implied-objc.swift index 55404539acab8..6e2321cd94b74 100644 --- a/test/TBD/multimodule-implied-objc.swift +++ b/test/TBD/multimodule-implied-objc.swift @@ -1,4 +1,5 @@ // REQUIRES: VENDOR=apple +// XFAIL: OS=xros // RUN: %empty-directory(%t) // RUN: %empty-directory(%t/cache) // RUN: split-file %s %t diff --git a/test/attr/attr_ibaction_ios.swift b/test/attr/attr_ibaction_ios.swift index 47546317e5655..392b502730e4c 100644 --- a/test/attr/attr_ibaction_ios.swift +++ b/test/attr/attr_ibaction_ios.swift @@ -8,22 +8,25 @@ class IBActionWrapperTy { // CHECK-macosx: attr_ibaction_ios.swift:[[@LINE-2]]:18: error: @IBAction methods must have 1 argument // CHECK-tvos-NOT: attr_ibaction_ios.swift:[[@LINE-3]] // CHECK-watchos-NOT: attr_ibaction_ios.swift:[[@LINE-4]] + // CHECK-xros-NOT: attr_ibaction_ios.swift:[[@LINE-5]] @IBAction func unary(_: AnyObject) {} // CHECK-ios-NOT: attr_ibaction_ios.swift:[[@LINE-1]] // CHECK-macosx-NOT: attr_ibaction_ios.swift:[[@LINE-2]] // CHECK-tvos-NOT: attr_ibaction_ios.swift:[[@LINE-3]] // CHECK-watchos-NOT: attr_ibaction_ios.swift:[[@LINE-4]] + // CHECK-xros-NOT: attr_ibaction_ios.swift:[[@LINE-5]] @IBAction func binary(_: AnyObject, _: AnyObject) {} // CHECK-ios-NOT: attr_ibaction_ios.swift:[[@LINE-1]] // CHECK-macosx: attr_ibaction_ios.swift:[[@LINE-2]]:18: error: @IBAction methods must have 1 argument // CHECK-tvos-NOT: attr_ibaction_ios.swift:[[@LINE-3]] // CHECK-watchos-NOT: attr_ibaction_ios.swift:[[@LINE-4]] + // CHECK-xros-NOT: attr_ibaction_ios.swift:[[@LINE-5]] @IBAction func ternary(_: AnyObject, _: AnyObject, _: AnyObject) {} // CHECK-ios: attr_ibaction_ios.swift:[[@LINE-1]]:18: error: @IBAction methods must have at most 2 arguments // CHECK-macosx: attr_ibaction_ios.swift:[[@LINE-2]]:18: error: @IBAction methods must have 1 argument // CHECK-tvos: attr_ibaction_ios.swift:[[@LINE-3]]:18: error: @IBAction methods must have at most 2 arguments // CHECK-watchos: attr_ibaction_ios.swift:[[@LINE-4]]:18: error: @IBAction methods must have at most 2 arguments -} + // CHECK-xros: attr_ibaction_ios.swift:[[@LINE-5]]:18: error: @IBAction methods must have at most 2 arguments diff --git a/test/attr/attr_objc_resilience.swift b/test/attr/attr_objc_resilience.swift index 0afd4cefa6acd..e69b0322b9a81 100644 --- a/test/attr/attr_objc_resilience.swift +++ b/test/attr/attr_objc_resilience.swift @@ -4,6 +4,7 @@ // RUN: %target-swift-frontend -typecheck -verify %s -I %t // REQUIRES: objc_interop +// UNSUPPORTED: OS=xros import Foundation import resilient_objc_class diff --git a/test/lit.cfg b/test/lit.cfg index 59781fc96d28c..f2f2f391f40be 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -111,6 +111,9 @@ def get_simulator_command(run_os, run_cpu): return "simctl spawn --standalone 'Apple Watch Series 2 - 42mm'" else: return "simctl spawn --standalone 'Apple Watch Series 9 (45mm)'" + elif run_os == 'xros': + lit_config.note("xrOS Simulator Is Not Supported Yet - Tests Will Fail") + return "simctl spawn --standalone 'Apple Vision Pro'" else: lit_config.fatal("Unknown simulator OS %r" % run_os) @@ -542,6 +545,7 @@ config.sil_test_options = os.environ.get('SIL_TEST_OPTIONS', '') config.clang_module_cache_path = make_path(config.swift_test_results_dir, "clang-module-cache") shutil.rmtree(config.clang_module_cache_path, ignore_errors=True) mcp_opt = "-module-cache-path %s" % shell_quote(config.clang_module_cache_path) +platform_remap_mock_sdk_config = "%s" % make_path(config.test_source_root, 'Inputs', 'MockPlatformRemapSDKConfig/') clang_mcp_opt = "-fmodules-cache-path=%r" % config.clang_module_cache_path lit_config.note("Using Clang module cache: " + config.clang_module_cache_path) lit_config.note("Using test results dir: " + config.swift_test_results_dir) @@ -925,7 +929,8 @@ if run_vendor == 'apple': 'ios': '12.1', 'maccatalyst': '12.1', 'tvos': '12.1', - 'watchos': '5.1' + 'watchos': '5.1', + 'xros': '1.0' } pre_stable_version = PRE_STABLE_VERSION.get(run_os, '') @@ -936,7 +941,8 @@ if run_vendor == 'apple': 'ios': '12.2', 'maccatalyst': '12.2', 'tvos': '12.2', - 'watchos': '5.2' + 'watchos': '5.2', + 'xros': '1.0' } stable_version = STABLE_VERSION.get(run_os, '') config.stable_abi_triple = '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os, @@ -947,7 +953,8 @@ if run_vendor == 'apple': 'ios': '13', 'maccatalyst': '13', 'tvos': '13', - 'watchos': '6' + 'watchos': '6', + 'xros': '1.0' } next_stable_version = NEXT_STABLE_VERSION.get(run_os, '') config.next_stable_abi_triple = '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os, @@ -993,7 +1000,8 @@ target_os_abi = run_os target_os_is_maccatalyst = "FALSE" target_mandates_stable_abi = "FALSE" if (run_cpu in ('arm64e',) or \ - (run_os == 'watchos' and run_cpu == 'x86_64')): + (run_os == 'watchos' and run_cpu == 'x86_64') or \ + (run_os == 'xros')): target_mandates_stable_abi = "TRUE" config.available_features.add('swift_only_stable_abi') if run_os in ('maccatalyst',): @@ -1300,6 +1308,11 @@ if run_vendor == 'apple': lit_config.note("Testing watchOS simulator " + config.variant_triple) xcrun_sdk_name = "watchsimulator" target_future_version = "99.99.0" + elif run_os == 'xros': + config.available_features.add('DARWIN_SIMULATOR=xros') + lit_config.note("Testing xrOS simulator " + config.variant_triple) + xcrun_sdk_name = "xrsimulator" + target_future_version = "99.99.0" else: config.available_features.add('DARWIN_SIMULATOR=tvos') lit_config.note("Testing AppleTV simulator " + config.variant_triple) @@ -1415,14 +1428,23 @@ if run_vendor == 'apple': maccatalyst_extra_frameworks = "" if run_os == 'maccatalyst': maccatalyst_extra_frameworks = "-F {}/System/iOSSupport/System/Library/Frameworks".format(config.variant_sdk) + + swift_frontend_platform_remap_config = "" + swiftc_platform_remap_config = "" + if run_os == 'xros': + swift_frontend_platform_remap_config = "-platform-availability-inheritance-map-path %s" % platform_remap_mock_sdk_config + swiftc_platform_remap_config = "-Xfrontend -platform-availability-inheritance-map-path -Xfrontend %s" % platform_remap_mock_sdk_config + config.target_swift_frontend = ( - "%s %s -sdk %r %s %s %s" % + "%s %s -sdk %r %s %s %s %s" % (config.swift_frontend, target_options, config.variant_sdk, maccatalyst_extra_frameworks, - config.swift_test_options, config.swift_frontend_test_options)) + config.swift_test_options, config.swift_frontend_test_options, + swift_frontend_platform_remap_config)) subst_target_swift_frontend_mock_sdk = ( - "%s %s -sdk %r %s %s" % + "%s %s -sdk %r %s %s %s" % (config.swift_frontend, target_options_for_mock_sdk, config.variant_sdk, - config.swift_test_options, config.swift_frontend_test_options)) + config.swift_test_options, config.swift_frontend_test_options, + swift_frontend_platform_remap_config)) config.target_swift_modulewrap = ( '%s -modulewrap -target %s' % (config.swiftc, config.variant_triple)) @@ -1459,8 +1481,8 @@ if run_vendor == 'apple': ("%s %s -toolchain-stdlib-rpath %s " + # This ensures LC_LOAD_DYLIB rewrite will succeed in %target-codesign (rdar://7885126): "-Xlinker -headerpad_max_install_names " + - "-Xlinker -rpath -Xlinker /usr/lib/swift %s ")% - (xcrun_prefix, config.swiftc, target_options, config.swift_driver_test_options)) + "-Xlinker -rpath -Xlinker /usr/lib/swift %s %s ")% + (xcrun_prefix, config.swiftc, target_options, config.swift_driver_test_options, swiftc_platform_remap_config)) config.target_stdlib_swiftc_driver = config.target_swiftc_driver config.target_clang = ( "%s %s %s" % @@ -1481,7 +1503,8 @@ if run_vendor == 'apple': 'ios': '14.0', 'maccatalyst': '14.0', 'tvos': '14.0', - 'watchos': '7.0' + 'watchos': '7.0', + 'xros': '1.0' } sdk_2020_version = SDK_2020_VERSION.get(run_os, '') SDK_2021_VERSION = { @@ -1489,17 +1512,20 @@ if run_vendor == 'apple': 'ios': '15.0', 'maccatalyst': '15.0', 'tvos': '15.0', - 'watchos': '8.0' + 'watchos': '8.0', + 'xros': '1.0' } sdk_2021_version = SDK_2021_VERSION.get(run_os, '') linker_os = { 'iphoneos': 'ios', 'appletvos': 'tvos', 'watchos': 'watchos', + 'xros': 'xros', 'iphonesimulator': 'ios-simulator', 'watchsimulator': 'watchos-simulator', 'appletvsimulator': 'tvos-simulator', - 'macosx': 'macos' + 'macosx': 'macos', + 'xrsimulator': 'xros-simulator' }.get(config.target_sdk_name, run_os) config.target_link_sdk_2020_version = ( @@ -2168,9 +2194,11 @@ config.compiler_rt_platform = { 'iphoneos': 'ios', 'appletvos': 'tvos', 'watchos': 'watchos', + 'xros': 'xros', 'iphonesimulator': 'iossim', 'watchsimulator': 'watchossim', 'appletvsimulator': 'tvossim', + 'xrsimulator': 'xrossim', 'macosx': 'osx' }.get(config.target_sdk_name, run_cpu) diff --git a/test/stdlib/BridgeEquatableToObjC.swift b/test/stdlib/BridgeEquatableToObjC.swift index 6fafbed6c5059..02b1f5088b4d0 100644 --- a/test/stdlib/BridgeEquatableToObjC.swift +++ b/test/stdlib/BridgeEquatableToObjC.swift @@ -32,7 +32,7 @@ BridgeEquatableToObjC.test("Bridge equatable struct") { let objcResult = objcA.isEqual(objcB) expectEqual(swiftResult, true) -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) // Apple platforms use old semantics for now... expectEqual(objcResult, false) #else diff --git a/test/stdlib/Runtime.swift.gyb b/test/stdlib/Runtime.swift.gyb index 330119f9b642f..c4f872f1961e7 100644 --- a/test/stdlib/Runtime.swift.gyb +++ b/test/stdlib/Runtime.swift.gyb @@ -377,7 +377,7 @@ Runtime.test("demangleName") { expectEqual("Foobar", _stdlib_demangleName("$s13__lldb_expr_46FoobarCD")) } -if #available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) { +if #available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, visionOS 1.0, *) { Runtime.test("demangleTruncate") { // Swift.Int requires 10 bytes to be fully demangled. let buffer = UnsafeMutableBufferPointer.allocate(capacity: 10) diff --git a/test/stdlib/SwiftObjectNSObject.swift b/test/stdlib/SwiftObjectNSObject.swift index 8f7c65f570541..841160d3eeaa5 100644 --- a/test/stdlib/SwiftObjectNSObject.swift +++ b/test/stdlib/SwiftObjectNSObject.swift @@ -91,7 +91,7 @@ func TestSwiftObjectNSObjectAssertNoErrors() // Verify that Obj-C isEqual: provides same answer as Swift == func TestEquatableEquals(_ e1: T, _ e2: T) { if e1 == e2 { -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) // Legacy behavior: Equatable Swift does not imply == in ObjC TestSwiftObjectNSObjectNotEquals(e1, e2) #else @@ -109,7 +109,7 @@ func TestNonEquatableEquals(_ e1: AnyObject, _ e2: AnyObject) { // Verify that Obj-C hashValue matches Swift hashValue for Hashable types func TestHashable(_ h: H) { -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) // Legacy behavior: Hash value is identity in ObjC TestSwiftObjectNSObjectDefaultHashValue(h) #else @@ -121,7 +121,7 @@ func TestHashable(_ h: H) // Test Obj-C hashValue for Swift types that are Equatable but not Hashable func TestEquatableHash(_ e: AnyObject) { -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) // Legacy behavior: Equatable in Swift => ObjC hashes with identity TestSwiftObjectNSObjectDefaultHashValue(e) fakeEquatableWarning(e) diff --git a/test/stdlib/SwiftValueNSObject.swift b/test/stdlib/SwiftValueNSObject.swift index 6fd50b198eaa9..8d04961756dca 100644 --- a/test/stdlib/SwiftValueNSObject.swift +++ b/test/stdlib/SwiftValueNSObject.swift @@ -90,7 +90,7 @@ func TestHashableEquals(_ e1: T, _ e2: T) { // This has not always been true for Equatable value types func TestEquatableEquals(_ e1: T, _ e2: T) { if e1 == e2 { -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS) // Legacy: Swift Equatable is not used in ObjC TestSwiftValueNSObjectNotEquals(e1 as AnyObject, e2 as AnyObject) #else @@ -114,7 +114,7 @@ func TestHashable(_ h: T) // Test Obj-C hashValue for Swift types that are Equatable but not Hashable func TestEquatableHash(_ e: T) { -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) // Legacy behavior used the pointer value, which is // incompatible with user-defined equality. TestSwiftValueNSObjectDefaultHashValue(e as AnyObject) diff --git a/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp b/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp index a90b4439b3d8f..6d342fe3e5fdd 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp @@ -715,6 +715,9 @@ static void reportAttributes(ASTContext &Ctx, PlatformUID = PlatformWatchOS; break; case PlatformKind::iOSApplicationExtension: PlatformUID = PlatformIOSAppExt; break; + case PlatformKind::visionOS: + // FIXME: Formal platform support in SourceKit is needed. + PlatformUID = UIdent(); break; case PlatformKind::macCatalystApplicationExtension: PlatformUID = PlatformMacCatalystAppExt; break; case PlatformKind::macOSApplicationExtension: @@ -723,6 +726,9 @@ static void reportAttributes(ASTContext &Ctx, PlatformUID = PlatformtvOSAppExt; break; case PlatformKind::watchOSApplicationExtension: PlatformUID = PlatformWatchOSAppExt; break; + case PlatformKind::visionOSApplicationExtension: + // FIXME: Formal platform support in SourceKit is needed. + PlatformUID = UIdent(); break; case PlatformKind::OpenBSD: PlatformUID = PlatformOpenBSD; break; case PlatformKind::Windows: diff --git a/utils/availability-macros.def b/utils/availability-macros.def index 4754b750ca03d..828314c02ed01 100644 --- a/utils/availability-macros.def +++ b/utils/availability-macros.def @@ -34,8 +34,8 @@ SwiftStdlib 5.6:macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4 SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0 SwiftStdlib 5.8:macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4 SwiftStdlib 5.9:macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0 -SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4 -SwiftStdlib 6.0:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999 +SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.1 +SwiftStdlib 6.0:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999 # TODO: Also update ASTContext::getSwift510Availability when needed # TODO: Also update ASTContext::getSwift60Availability when needed diff --git a/utils/build-presets.ini b/utils/build-presets.ini index 808404c02f12b..e522ce98990f6 100644 --- a/utils/build-presets.ini +++ b/utils/build-presets.ini @@ -73,6 +73,8 @@ skip-build-tvos skip-test-tvos skip-build-watchos skip-test-watchos +skip-build-xros +skip-test-xros stdlib-deployment-targets=macosx-x86_64 swift-primary-variant-sdk=OSX swift-primary-variant-arch=x86_64 @@ -167,6 +169,7 @@ mixin-preset= skip-test-ios-host skip-test-tvos-host skip-test-watchos-host +skip-test-xros-host [preset: buildbot,tools=RA,stdlib=DA,test=non_executable] @@ -179,6 +182,7 @@ skip-test-osx skip-test-ios-simulator skip-test-tvos-simulator skip-test-watchos-simulator +skip-test-xros-simulator [preset: buildbot,tools=RA,stdlib=RD] mixin-preset= @@ -189,6 +193,7 @@ mixin-preset= skip-test-ios-host skip-test-tvos-host skip-test-watchos-host +skip-test-xros-host [preset: buildbot,tools=RA,stdlib=RD,test=non_executable] mixin-preset= @@ -200,6 +205,7 @@ skip-test-osx skip-test-ios-simulator skip-test-tvos-simulator skip-test-watchos-simulator +skip-test-xros-simulator [preset: buildbot,tools=R,stdlib=RD] mixin-preset= @@ -210,6 +216,7 @@ mixin-preset= skip-test-ios-host skip-test-tvos-host skip-test-watchos-host +skip-test-xros-host check-incremental-compilation [preset: buildbot,tools=R,stdlib=RD,test=non_executable] @@ -222,6 +229,7 @@ skip-test-osx skip-test-ios-simulator skip-test-tvos-simulator skip-test-watchos-simulator +skip-test-xros-simulator [preset: buildbot,tools=RA,stdlib=RDA] mixin-preset= @@ -232,6 +240,7 @@ mixin-preset= skip-test-ios-host skip-test-tvos-host skip-test-watchos-host +skip-test-xros-host [preset: buildbot,tools=RA,stdlib=RDA,test=non_executable] mixin-preset= @@ -243,6 +252,7 @@ skip-test-osx skip-test-ios-simulator skip-test-tvos-simulator skip-test-watchos-simulator +skip-test-xros-simulator [preset: buildbot,tools=RA,stdlib=RDA,long_test] mixin-preset= @@ -266,6 +276,7 @@ lto skip-test-ios-host skip-test-tvos-host skip-test-watchos-host +skip-test-xros-host [preset: buildbot,tools=RDA-flto,stdlib=RDA] mixin-preset= @@ -278,6 +289,7 @@ lto skip-test-ios-host skip-test-tvos-host skip-test-watchos-host +skip-test-xros-host # This is a mixin preset which builds and smoke-tests lldb. [preset: lldb-smoketest,tools=RA] @@ -379,6 +391,7 @@ skip-test-playgroundsupport skip-test-ios skip-test-tvos skip-test-watchos +skip-test-xros install-llvm install-swift @@ -448,6 +461,10 @@ skip-test-tvos skip-build-watchos skip-test-watchos +# FIXME: Swift/ASan does not support xros yet. +skip-build-xros +skip-test-xros + enable-asan [preset: buildbot_incremental_tsan,tools=RDA,stdlib=RDA] @@ -468,6 +485,8 @@ skip-build-tvos skip-test-tvos skip-build-watchos skip-test-watchos +skip-build-xros +skip-test-xros [preset: buildbot_incremental_asan_ubsan,tools=RDA,stdlib=RDA] mixin-preset=buildbot_incremental_base_all_platforms @@ -496,6 +515,10 @@ skip-test-tvos skip-build-watchos skip-test-watchos +# FIXME: Swift/ASan does not support xros yet. +skip-build-xros +skip-test-xros + enable-asan enable-ubsan @@ -522,6 +545,8 @@ skip-build-tvos skip-test-tvos skip-build-watchos skip-test-watchos +skip-build-xros +skip-test-xros stdlib-deployment-targets=macosx-x86_64 swift-primary-variant-sdk=OSX swift-primary-variant-arch=x86_64 @@ -557,6 +582,10 @@ skip-test-tvos skip-build-watchos skip-test-watchos +# FIXME: Swift/ASan does not support xros yet. +skip-build-xros +skip-test-xros + enable-asan swift-stdlib-build-type=RelWithDebInfo @@ -610,6 +639,8 @@ skip-build-tvos skip-test-tvos skip-build-watchos skip-test-watchos +skip-build-xros +skip-test-xros stdlib-deployment-targets=macosx-x86_64 swift-primary-variant-sdk=OSX swift-primary-variant-arch=x86_64 @@ -1261,6 +1292,7 @@ mixin-preset=mixin_buildbot_install_components_with_clang ios tvos watchos +xros lldb llbuild @@ -1557,6 +1589,7 @@ build-subdir=buildbot_incremental # Skip watchOS and tvOS skip-build-watchos skip-build-tvos +skip-build-xros # Build Release without debug info, because it is faster to build. release @@ -1651,6 +1684,7 @@ sil-verify-all-macos-only # faster. skip-test-ios-host skip-test-watchos-host +skip-test-xros-host # Skip LLBuild test until GitHub issue is fixed: # https://github.com/apple/swift-llbuild/issues/894 @@ -1663,6 +1697,7 @@ llvm-include-tests # Skip downstream project tests skip-test-watchos +skip-test-xros skip-test-swiftsyntax skip-test-indexstore-db skip-test-sourcekit-lsp @@ -2078,6 +2113,8 @@ skip-build-tvos skip-test-tvos skip-build-watchos skip-test-watchos +skip-build-xros +skip-test-xros swift-sdks=IOS swift-primary-variant-sdk=IOS swift-primary-variant-arch=arm64 @@ -2116,6 +2153,8 @@ skip-build-osx skip-test-osx skip-build-watchos skip-test-watchos +skip-build-xros +skip-test-xros skip-build-ios skip-test-ios swift-sdks=TVOS @@ -2167,6 +2206,7 @@ lit-args=-v skip-test-ios skip-test-tvos skip-test-watchos +skip-test-xros skip-reconfigure [preset: mixin_buildbot_incremental,test=iOS,type=simulator] @@ -2178,6 +2218,7 @@ lit-args=-v skip-test-osx skip-test-tvos skip-test-watchos +skip-test-xros skip-reconfigure [preset: mixin_buildbot_incremental,test=tvOS,type=simulator] @@ -2187,6 +2228,7 @@ lit-args=-v skip-test-osx skip-test-watchos +skip-test-xros skip-test-ios skip-reconfigure @@ -2418,6 +2460,7 @@ validation-test skip-test-ios skip-test-tvos skip-test-watchos +skip-test-xros skip-build-benchmark verbose-build lit-args=-v diff --git a/utils/build-script b/utils/build-script index e4cbfb5594de8..529865512f780 100755 --- a/utils/build-script +++ b/utils/build-script @@ -96,7 +96,8 @@ def initialize_runtime_environment(): 'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET', 'TVOS_DEPLOYMENT_TARGET', - 'WATCHOS_DEPLOYMENT_TARGET']: + 'WATCHOS_DEPLOYMENT_TARGET', + 'XROS_DEPLOYMENT_TARGET']: os.environ.pop(v, None) # Provide a default NINJA_STATUS to format ninja output. @@ -296,6 +297,12 @@ def default_stdlib_deployment_targets(args): .AppleWatchSimulator.targets) if args.build_watchos and args.build_watchos_device: targets.extend(StdlibDeploymentTarget.AppleWatch.targets) + if StdlibDeploymentTarget.XROSSimulator and \ + args.build_xros and args.build_xros_simulator: + targets.extend(StdlibDeploymentTarget.XROSSimulator.targets) + if StdlibDeploymentTarget.XROS and \ + args.build_xros and args.build_xros_device: + targets.extend(StdlibDeploymentTarget.XROS.targets) return targets else: # All other machines only configure their host stdlib by default. diff --git a/utils/build-script-impl b/utils/build-script-impl index f4dbb8391c850..55954d26ab32d 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -99,6 +99,7 @@ KNOWN_SETTINGS=( darwin-deployment-version-osx "10.13" "minimum deployment target version for OS X" darwin-deployment-version-tvos "11.0" "minimum deployment target version for tvOS" darwin-deployment-version-watchos "4.0" "minimum deployment target version for watchOS" + darwin-deployment-version-xros "1.0" "minimum deployment target version for xrOS" darwin-install-extract-symbols "" "whether to extract symbols with dsymutil during installations" darwin-install-extract-symbols-use-just-built-dsymutil "1" "whether we should extract symbols using the just built dsymutil" darwin-symroot-path-filters "" "space-separated list of path patterns to consider for symbol generation" @@ -500,6 +501,9 @@ function verify_host_is_supported() { | watchsimulator-arm64 \ | watchos-armv7k \ | watchos-arm64_32 \ + | xrsimulator-arm64 \ + | xros-arm64 \ + | xros-arm64e \ | wasi-wasm32 \ | android-armv7 \ | android-aarch64 \ @@ -587,7 +591,9 @@ function set_build_options_for_host() { appletvos-* | \ appletvsimulator-* | \ watchos-* | \ - watchsimulator-*) + watchsimulator-* | \ + xros-* | \ + xrsimulator-*) swift_cmake_options+=( -DPython3_EXECUTABLE="$(xcrun -f python3)" ) @@ -710,6 +716,27 @@ function set_build_options_for_host() { SWIFT_HOST_VARIANT_SDK="WATCHOS" cmake_osx_deployment_target="" ;; + xrsimulator-arm64) + SWIFT_HOST_TRIPLE="arm64-apple-xros${DARWIN_DEPLOYMENT_VERSION_XROS}-simulator" + llvm_target_arch="AArch64" + + SWIFT_HOST_VARIANT_SDK="XROS_SIMULATOR" + cmake_osx_deployment_target="" + ;; + xros-arm64) + SWIFT_HOST_TRIPLE="arm64-apple-xros${DARWIN_DEPLOYMENT_VERSION_XROS}" + llvm_target_arch="AArch64" + + SWIFT_HOST_VARIANT_SDK="XROS" + cmake_osx_deployment_target="" + ;; + xros-arm64e) + SWIFT_HOST_TRIPLE="arm64e-apple-xros${DARWIN_DEPLOYMENT_VERSION_XROS}" + llvm_target_arch="AArch64" + + SWIFT_HOST_VARIANT_SDK="XROS" + cmake_osx_deployment_target="" + ;; esac if [[ "${DARWIN_SDK_DEPLOYMENT_TARGETS}" != "" ]]; then @@ -735,6 +762,7 @@ function set_build_options_for_host() { -DCMAKE_OSX_SYSROOT:PATH="${cmake_os_sysroot}" -DCOMPILER_RT_ENABLE_IOS:BOOL=FALSE -DCOMPILER_RT_ENABLE_WATCHOS:BOOL=FALSE + -DCOMPILER_RT_ENABLE_XROS:BOOL=FALSE -DCOMPILER_RT_ENABLE_TVOS:BOOL=FALSE -DLLVM_ENABLE_MODULES:BOOL="$(true_false ${LLVM_ENABLE_MODULES})" -DCMAKE_OSX_ARCHITECTURES="${architecture}" @@ -767,6 +795,7 @@ function set_build_options_for_host() { -DSWIFT_DARWIN_DEPLOYMENT_VERSION_IOS="${DARWIN_DEPLOYMENT_VERSION_IOS}" -DSWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS="${DARWIN_DEPLOYMENT_VERSION_TVOS}" -DSWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS="${DARWIN_DEPLOYMENT_VERSION_WATCHOS}" + -DSWIFT_DARWIN_DEPLOYMENT_VERSION_XROS="${DARWIN_DEPLOYMENT_VERSION_XROS}" -DCMAKE_OSX_SYSROOT:PATH="${cmake_os_sysroot}" # This is needed to make sure to avoid using the wrong architecture # in the compiler checks CMake performs @@ -1366,6 +1395,12 @@ function common_cross_c_flags() { watchos-*) echo -n " -arch ${arch} -target ${arch}-apple-watchos${DARWIN_DEPLOYMENT_VERSION_WATCHOS}" ;; + xrsimulator-*) + echo -n " -arch ${arch} -target ${arch}-apple-xros${DARWIN_DEPLOYMENT_VERSION_XROS}-simulator" + ;; + xros-*) + echo -n " -arch ${arch} -target ${arch}-apple-xros${DARWIN_DEPLOYMENT_VERSION_XROS}" + ;; esac local build_type=$2 diff --git a/utils/build-tooling-libs b/utils/build-tooling-libs index 0163d76830859..b2cd7453cd165 100755 --- a/utils/build-tooling-libs +++ b/utils/build-tooling-libs @@ -156,6 +156,29 @@ class Builder(object): ] llvm_c_flags += " -target " + host_triple + elif self.host == "xrsimulator": + deployment_version = "1.0" + host_triple = "%s-apple-xros%s-simulator" % ( + self.arch, + deployment_version, + ) + host_sdk = "XROS_SIMULATOR" + cmake_args += [ + "-DCMAKE_OSX_DEPLOYMENT_TARGET=" + deployment_version, + "-DSWIFT_DARWIN_DEPLOYMENT_VERSION_XROS=" + deployment_version, + ] + llvm_c_flags += " -target " + host_triple + + elif self.host == "xros": + deployment_version = "1.0" + host_triple = "%s-apple-xros%s" % (self.arch, deployment_version) + host_sdk = "XROS" + cmake_args += [ + "-DCMAKE_OSX_DEPLOYMENT_TARGET=" + deployment_version, + "-DSWIFT_DARWIN_DEPLOYMENT_VERSION_XROS=" + deployment_version, + ] + llvm_c_flags += " -target " + host_triple + assert host_triple assert host_sdk cmake_args += [ diff --git a/utils/build_swift/build_swift/defaults.py b/utils/build_swift/build_swift/defaults.py index 0fc8cd90873ab..41ed3725e3db8 100644 --- a/utils/build_swift/build_swift/defaults.py +++ b/utils/build_swift/build_swift/defaults.py @@ -31,6 +31,7 @@ 'DARWIN_DEPLOYMENT_VERSION_IOS', 'DARWIN_DEPLOYMENT_VERSION_TVOS', 'DARWIN_DEPLOYMENT_VERSION_WATCHOS', + 'DARWIN_DEPLOYMENT_VERSION_XROS', 'UNIX_INSTALL_PREFIX', 'DARWIN_INSTALL_PREFIX', 'LLVM_MAX_PARALLEL_LTO_LINK_JOBS', @@ -55,6 +56,7 @@ DARWIN_DEPLOYMENT_VERSION_IOS = '11.0' DARWIN_DEPLOYMENT_VERSION_TVOS = '11.0' DARWIN_DEPLOYMENT_VERSION_WATCHOS = '4.0' +DARWIN_DEPLOYMENT_VERSION_XROS = '1.0' UNIX_INSTALL_PREFIX = '/usr' DARWIN_INSTALL_PREFIX = ('/Applications/Xcode.app/Contents/Developer/' diff --git a/utils/build_swift/build_swift/driver_arguments.py b/utils/build_swift/build_swift/driver_arguments.py index 68774fb159f25..37d82d8a48a6d 100644 --- a/utils/build_swift/build_swift/driver_arguments.py +++ b/utils/build_swift/build_swift/driver_arguments.py @@ -143,6 +143,10 @@ def _apply_default_arguments(args): raise ValueError('error: --watchos-all is unavailable in open-source ' 'Swift.\nUse --watchos to skip watchOS device tests.') + if args.xros_all: + raise ValueError('error: --xros-all is unavailable in open-source ' + 'Swift.\nUse --xros to skip xrOS device tests.') + # --skip-{ios,tvos,watchos} or --skip-build-{ios,tvos,watchos} are # merely shorthands for --skip-build-{**os}-{device,simulator} if not args.ios or not args.build_ios: @@ -157,6 +161,10 @@ def _apply_default_arguments(args): args.build_watchos_device = False args.build_watchos_simulator = False + if not args.xros or not args.build_xros: + args.build_xros_device = False + args.build_xros_simulator = False + if not args.android or not args.build_android: args.build_android = False @@ -199,6 +207,7 @@ def _apply_default_arguments(args): args.test_ios = False args.test_tvos = False args.test_watchos = False + args.test_xros = False args.test_android = False args.test_cmark = False args.test_swiftpm = False @@ -230,6 +239,11 @@ def _apply_default_arguments(args): if not args.test_watchos: args.test_watchos_host = False args.test_watchos_simulator = False + # --skip-test-xros is merely a shorthand for host and simulator + # --tests. + if not args.test_xros: + args.test_xros_host = False + args.test_xros_simulator = False # --skip-build-{ios,tvos,watchos}-{device,simulator} implies # --skip-test-{ios,tvos,watchos}-{host,simulator} @@ -248,6 +262,11 @@ def _apply_default_arguments(args): if not args.build_watchos_simulator: args.test_watchos_simulator = False + if not args.build_xros_device: + args.test_xros_host = False + if not args.build_xros_simulator: + args.test_xros_simulator = False + if not args.build_android: # If building natively on an Android host, allow running the test suite # without the NDK config. @@ -263,6 +282,7 @@ def _apply_default_arguments(args): args.test_ios_host = False args.test_tvos_host = False args.test_watchos_host = False + args.test_xros_host = False args.test_android_host = False @@ -345,6 +365,15 @@ def create_argument_parser(): option('--skip-watchos', store_false('watchos'), help='set to skip everything watchOS-related') + option('--xros', toggle_true, + help='also build for xrOS, but disallow tests that require an ' + 'xrOS device') + option('--xros-all', toggle_true('xros_all'), + help='also build for Apple xrOS, and allow all Apple xrOS ' + 'tests') + option('--skip-xros', store_false('xros'), + help='set to skip everything xrOS-related') + option('--maccatalyst', toggle_true, help='Enable building Swift with macCatalyst support') @@ -497,6 +526,10 @@ def create_argument_parser(): default=defaults.DARWIN_DEPLOYMENT_VERSION_WATCHOS, metavar='MAJOR.MINOR', help='minimum deployment target version for watchOS') + option('--darwin-deployment-version-xros', store, + default=defaults.DARWIN_DEPLOYMENT_VERSION_XROS, + metavar='MAJOR.MINOR', + help='minimum deployment target version for xrOS') option('--extra-cmake-options', append, type=argparse.ShellSplitType(), @@ -1155,6 +1188,16 @@ def create_argument_parser(): help='skip building Swift stdlibs for watchOS simulator ' '(i.e. build devices only)') + option('--skip-build-xros', toggle_false('build_xros'), + help='skip building Swift stdlibs for xrOS') + option('--skip-build-xros-device', toggle_false('build_xros_device'), + help='skip building Swift stdlibs for xrOS devices ' + '(i.e. build simulators only)') + option('--skip-build-xros-simulator', + toggle_false('build_xros_simulator'), + help='skip building Swift stdlibs for xrOS simulator ' + '(i.e. build devices only)') + option('--skip-build-android', toggle_false('build_android'), help='skip building Swift stdlibs for Android') @@ -1216,6 +1259,17 @@ def create_argument_parser(): help='skip testing watchOS device targets on the host machine (the ' 'watch itself)') + option('--skip-test-xros', + toggle_false('test_xros'), + help='skip testing all xrOS targets. Equivalent to specifying both ' + '--skip-test-xros-simulator and --skip-test-xros-host') + option('--skip-test-xros-simulator', + toggle_false('test_xros_simulator'), + help='skip testing xrOS simulator targets') + option('--skip-test-xros-host', + toggle_false('test_xros_host'), + help='skip testing xrOS device targets on the host machine') + option('--skip-test-android', toggle_false('test_android'), help='skip testing all Android targets.') diff --git a/utils/build_swift/tests/expected_options.py b/utils/build_swift/tests/expected_options.py index 24236d6eea6b2..b29f52c2b77e0 100644 --- a/utils/build_swift/tests/expected_options.py +++ b/utils/build_swift/tests/expected_options.py @@ -128,6 +128,9 @@ 'build_watchos': True, 'build_watchos_device': False, 'build_watchos_simulator': False, + 'build_xros': True, + 'build_xros_device': False, + 'build_xros_simulator': False, 'build_xctest': False, 'build_wasmstdlib': False, 'build_wasmkit': False, @@ -156,6 +159,8 @@ defaults.DARWIN_DEPLOYMENT_VERSION_TVOS, 'darwin_deployment_version_watchos': defaults.DARWIN_DEPLOYMENT_VERSION_WATCHOS, + 'darwin_deployment_version_xros': + defaults.DARWIN_DEPLOYMENT_VERSION_XROS, 'darwin_symroot_path_filters': [], 'darwin_xcrun_toolchain': None, 'distcc': False, @@ -289,6 +294,9 @@ 'test_watchos': False, 'test_watchos_host': False, 'test_watchos_simulator': False, + 'test_xros': False, + 'test_xros_host': False, + 'test_xros_simulator': False, 'test_playgroundsupport': True, 'test_cmark': False, 'test_swiftpm': False, @@ -307,6 +315,8 @@ 'verbose_build': False, 'watchos': False, 'watchos_all': False, + 'xros': False, + 'xros_all': False, 'llvm_install_components': defaults.llvm_install_components(), 'clean_install_destdir': False, } @@ -519,6 +529,7 @@ class BuildScriptImplOption(_BaseOption): SetOption('--skip-ios', dest='ios', value=False), SetOption('--skip-tvos', dest='tvos', value=False), SetOption('--skip-watchos', dest='watchos', value=False), + SetOption('--skip-xros', dest='xros', value=False), SetOption('--skip-test-early-swift-driver', dest='test_early_swift_driver', value=False), @@ -654,6 +665,7 @@ class BuildScriptImplOption(_BaseOption): EnableOption('--validation-test'), EnableOption('--verbose-build'), EnableOption('--watchos'), + EnableOption('--xros'), EnableOption('--xctest', dest='build_xctest'), EnableOption('--swift-disable-dead-stripping'), EnableOption('--clean-early-swift-driver', dest='clean_early_swift_driver'), @@ -683,6 +695,9 @@ class BuildScriptImplOption(_BaseOption): dest='build_watchos_device'), DisableOption('--skip-build-watchos-simulator', dest='build_watchos_simulator'), + DisableOption('--skip-build-xros', dest='build_xros'), + DisableOption('--skip-build-xros-device', dest='build_xros_device'), + DisableOption('--skip-build-xros-simulator', dest='build_xros_simulator'), DisableOption('--skip-clean-libdispatch', dest='clean_libdispatch'), DisableOption('--skip-clean-foundation', dest='clean_foundation'), DisableOption('--skip-clean-xctest', dest='clean_xctest'), @@ -748,6 +763,10 @@ class BuildScriptImplOption(_BaseOption): StrOption('--darwin-deployment-version-osx'), StrOption('--darwin-deployment-version-tvos'), StrOption('--darwin-deployment-version-watchos'), + StrOption('--darwin-deployment-version-xros'), + DisableOption('--skip-test-xros-host', dest='test_xros_host'), + DisableOption('--skip-test-xros', dest='test_xros'), + DisableOption('--skip-test-xros-simulator', dest='test_xros_simulator'), StrOption('--darwin-xcrun-toolchain'), StrOption('--host-target'), StrOption('--lit-args'), @@ -836,6 +855,7 @@ class BuildScriptImplOption(_BaseOption): IgnoreOption('--ios-all'), IgnoreOption('--tvos-all'), IgnoreOption('--watchos-all'), + IgnoreOption('--xros-all'), StrOption('--llvm-install-components'), ] diff --git a/utils/swift_build_support/swift_build_support/build_script_invocation.py b/utils/swift_build_support/swift_build_support/build_script_invocation.py index dc86c97f7dc0c..d61731aa4a281 100644 --- a/utils/swift_build_support/swift_build_support/build_script_invocation.py +++ b/utils/swift_build_support/swift_build_support/build_script_invocation.py @@ -103,6 +103,8 @@ def convert_to_impl_arguments(self): args.darwin_deployment_version_tvos), "--darwin-deployment-version-watchos=%s" % ( args.darwin_deployment_version_watchos), + "--darwin-deployment-version-xros=%s" % ( + args.darwin_deployment_version_xros), "--cmake", toolchain.cmake, "--llvm-build-type", args.llvm_build_variant, "--swift-build-type", args.swift_build_variant, diff --git a/utils/swift_build_support/swift_build_support/host_specific_configuration.py b/utils/swift_build_support/swift_build_support/host_specific_configuration.py index 55f742cb95e89..cbb5b22e52b0c 100644 --- a/utils/swift_build_support/swift_build_support/host_specific_configuration.py +++ b/utils/swift_build_support/swift_build_support/host_specific_configuration.py @@ -250,6 +250,13 @@ def __platforms_to_skip_build(self, args, stage_dependent_args): if not stage_dependent_args.build_watchos_simulator: platforms_to_skip_build.add( StdlibDeploymentTarget.AppleWatchSimulator) + if StdlibDeploymentTarget.XROS and \ + not stage_dependent_args.build_xros_device: + platforms_to_skip_build.add(StdlibDeploymentTarget.XROS) + if StdlibDeploymentTarget.XROSSimulator and \ + not stage_dependent_args.build_xros_simulator: + platforms_to_skip_build.add( + StdlibDeploymentTarget.XROSSimulator) if not stage_dependent_args.build_android: platforms_to_skip_build.add(StdlibDeploymentTarget.Android) if not args.build_wasm: @@ -293,6 +300,18 @@ def __platforms_to_skip_test(self, args, stage_dependent_args): if not stage_dependent_args.test_watchos_simulator: platforms_to_skip_test.add( StdlibDeploymentTarget.AppleWatchSimulator) + if StdlibDeploymentTarget.XROS and \ + not stage_dependent_args.test_xros_host and \ + not args.only_non_executable_test: + platforms_to_skip_test.add(StdlibDeploymentTarget.XROS) + elif StdlibDeploymentTarget.XROS and not args.only_non_executable_test: + raise ArgumentError(None, + "error: xrOS device tests are not " + + "supported in open-source Swift.") + if StdlibDeploymentTarget.XROSSimulator and \ + not stage_dependent_args.test_xros_simulator: + platforms_to_skip_test.add( + StdlibDeploymentTarget.XROSSimulator) if not stage_dependent_args.test_android: platforms_to_skip_test.add(StdlibDeploymentTarget.Android) @@ -310,6 +329,9 @@ def __platforms_archs_to_skip_test(self, args, stage_dependent_args, host_target StdlibDeploymentTarget.AppleTVSimulator.arm64) platforms_archs_to_skip_test.add( StdlibDeploymentTarget.AppleWatchSimulator.arm64) + if StdlibDeploymentTarget.XROSSimulator is not None: + platforms_archs_to_skip_test.add( + StdlibDeploymentTarget.XROSSimulator.arm64) if host_target == StdlibDeploymentTarget.OSX.arm64.name: platforms_archs_to_skip_test.add( StdlibDeploymentTarget.iOSSimulator.x86_64) @@ -335,4 +357,8 @@ def __platforms_to_skip_test_host(self, args, stage_dependent_args): if not stage_dependent_args.test_watchos_host and \ not args.only_non_executable_test: platforms_to_skip_test_host.add(StdlibDeploymentTarget.AppleWatch) + if StdlibDeploymentTarget.XROS and \ + not stage_dependent_args.test_xros_host and \ + not args.only_non_executable_test: + platforms_to_skip_test_host.add(StdlibDeploymentTarget.XROS) return platforms_to_skip_test_host diff --git a/utils/swift_build_support/swift_build_support/products/cmake_product.py b/utils/swift_build_support/swift_build_support/products/cmake_product.py index 568e9069a8056..de148ec8c76e6 100644 --- a/utils/swift_build_support/swift_build_support/products/cmake_product.py +++ b/utils/swift_build_support/swift_build_support/products/cmake_product.py @@ -201,7 +201,9 @@ def host_cmake_options(self, host_target): elif host_target.startswith('macosx') or \ host_target.startswith('iphone') or \ host_target.startswith('appletv') or \ - host_target.startswith('watch'): + host_target.startswith('watch') or \ + host_target.startswith('xros-') or \ + host_target.startswith('xrsimulator-'): swift_cmake_options.define('Python3_EXECUTABLE', self.toolchain.find_tool('python3')) @@ -329,6 +331,27 @@ def host_cmake_options(self, host_target): swift_host_variant_sdk = 'WATCHOS' cmake_osx_deployment_target = None + elif host_target == 'xrsimulator-arm64': + swift_host_triple = 'arm64-apple-xros{}-simulator'.format( + self.args.darwin_deployment_version_xros) + llvm_target_arch = 'AARCH64' + swift_host_variant_sdk = 'XROS_SIMULATOR' + cmake_osx_deployment_target = None + + elif host_target == 'xros-arm64': + swift_host_triple = 'arm64-apple-xros{}'.format( + self.args.darwin_deployment_version_xros) + llvm_target_arch = 'AARCH64' + swift_host_variant_sdk = 'XROS' + cmake_osx_deployment_target = None + + elif host_target == 'xros-arm64e': + swift_host_triple = 'arm64e-apple-xros{}'.format( + self.args.darwin_deployment_version_xros) + llvm_target_arch = 'AARCH64' + swift_host_variant_sdk = 'XROS' + cmake_osx_deployment_target = None + darwin_sdk_deployment_targets = os.environ.get( 'DARWIN_SDK_DEPLOYMENT_TARGETS') if darwin_sdk_deployment_targets: diff --git a/utils/swift_build_support/swift_build_support/products/product.py b/utils/swift_build_support/swift_build_support/products/product.py index 927263f52d9a6..ababc351f95ee 100644 --- a/utils/swift_build_support/swift_build_support/products/product.py +++ b/utils/swift_build_support/swift_build_support/products/product.py @@ -288,6 +288,9 @@ def target_for_platform(self, platform, arch, include_version=True): target = '{}-apple-watchos{}'.format( arch, self.args.darwin_deployment_version_watchos if include_version else "") + elif platform in ['xrsimulator', 'xros']: + target = '{}-apple-xros{}'.format( + arch, self.args.darwin_deployment_version_xros) return target def generate_darwin_toolchain_file(self, platform, arch): diff --git a/utils/swift_build_support/swift_build_support/targets.py b/utils/swift_build_support/swift_build_support/targets.py index 588ba88161d84..4124989e9bc48 100644 --- a/utils/swift_build_support/swift_build_support/targets.py +++ b/utils/swift_build_support/swift_build_support/targets.py @@ -258,6 +258,14 @@ class StdlibDeploymentTarget(object): sdk_name="WATCHOS_SIMULATOR", is_simulator=True) + XROS = DarwinPlatform("xros", archs=["arm64", "arm64e"], + sdk_name="XROS") + + XROSSimulator = DarwinPlatform("xrsimulator", + archs=["arm64"], + sdk_name="XROS_SIMULATOR", + is_simulator=True) + # A platform that's not tied to any particular OS, and it meant to be used # to build the stdlib as standalone and/or statically linked. Freestanding = Platform("freestanding", archs=[ @@ -298,6 +306,7 @@ class StdlibDeploymentTarget(object): iOS, iOSSimulator, AppleTV, AppleTVSimulator, AppleWatch, AppleWatchSimulator, + XROS, XROSSimulator, Freestanding, Linux, FreeBSD, @@ -321,6 +330,8 @@ class StdlibDeploymentTarget(object): 'TVOS_SIMULATOR': AppleTVSimulator.targets, 'WATCHOS': AppleWatch.targets, 'WATCHOS_SIMULATOR': AppleWatchSimulator.targets, + 'XROS': XROS.targets, + 'XROS_SIMULATOR': XROSSimulator.targets, } @staticmethod diff --git a/validation-test/BuildSystem/skip_clean_corelibs.test b/validation-test/BuildSystem/skip_clean_corelibs.test index 173f3f829f944..8814648cd3628 100644 --- a/validation-test/BuildSystem/skip_clean_corelibs.test +++ b/validation-test/BuildSystem/skip_clean_corelibs.test @@ -3,7 +3,8 @@ # UNSUPPORTED: OS=ios # UNSUPPORTED: OS=tvos # UNSUPPORTED: OS=watchos - +# UNSUPPORTED: OS=xros +# # RUN: %empty-directory(%t) # RUN: mkdir -p %t # RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --xctest --cmake %cmake 2>&1 | %FileCheck --check-prefix=CLEAN-CORELIBS-CHECK %s diff --git a/validation-test/stdlib/ArrayTrapsObjC.swift b/validation-test/stdlib/ArrayTrapsObjC.swift index 0bbf644ffe019..8b1f28c440761 100644 --- a/validation-test/stdlib/ArrayTrapsObjC.swift +++ b/validation-test/stdlib/ArrayTrapsObjC.swift @@ -7,6 +7,9 @@ // Temporarily disable for backdeployment (rdar://89821303) // UNSUPPORTED: use_os_stdlib +// rdar://121343746 +// UNSUPPORTED: OS=xros + import StdlibUnittest import Foundation