Skip to content

Commit f04aaa2

Browse files
authored
Merge pull request swiftlang#73062 from artemcm/60UpstreamVisionOS
[6.0 🍒] Introduce VisionOS Platform
2 parents 753a361 + 0b64745 commit f04aaa2

File tree

130 files changed

+1334
-101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+1334
-101
lines changed

CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ set(SWIFT_DARWIN_EMBEDDED_VARIANTS "^(iphoneos|iphonesimulator|appletvos|appletv
119119
# if("${SWIFT_HOST_VARIANT_SDK}" IN_LIST SWIFT_DARWIN_PLATFORMS)
120120
# ...
121121
# endif()
122-
set(SWIFT_DARWIN_PLATFORMS "IOS" "IOS_SIMULATOR" "TVOS" "TVOS_SIMULATOR" "WATCHOS" "WATCHOS_SIMULATOR" "OSX")
122+
set(SWIFT_DARWIN_PLATFORMS "IOS" "IOS_SIMULATOR" "TVOS" "TVOS_SIMULATOR" "WATCHOS" "WATCHOS_SIMULATOR" "OSX" "XROS" "XROS_SIMULATOR")
123123

124124
set(SWIFT_APPLE_PLATFORMS ${SWIFT_DARWIN_PLATFORMS})
125125
if(SWIFT_FREESTANDING_FLAVOR STREQUAL "apple")
@@ -542,6 +542,9 @@ set(SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS "11.0" CACHE STRING
542542
set(SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS "4.0" CACHE STRING
543543
"Minimum deployment target version for watchOS")
544544

545+
set(SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS "1.0" CACHE STRING
546+
"Minimum deployment target version for xrOS")
547+
545548
#
546549
# Compatibility library deployment versions
547550
#
@@ -550,6 +553,7 @@ set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX "10.9")
550553
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS "7.0")
551554
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS "9.0")
552555
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS "2.0")
556+
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS "1.0")
553557
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_MACCATALYST "13.1")
554558

555559
#
@@ -595,7 +599,7 @@ option(SWIFT_REPORT_STATISTICS
595599
FALSE)
596600

597601
# Only Darwin platforms enable ObjC interop by default.
598-
if("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
602+
if("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*|XROS*)")
599603
set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default TRUE)
600604
else()
601605
set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default FALSE)
@@ -1139,7 +1143,7 @@ elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WASI")
11391143
set(SWIFT_PRIMARY_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
11401144
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}")
11411145

1142-
elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
1146+
elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*|XROS*)")
11431147

11441148
set(SWIFT_HOST_VARIANT "macosx" CACHE STRING
11451149
"Deployment OS for Swift host tools (the compiler) [macosx, iphoneos].")

cmake/modules/DarwinSDKs.cmake

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64;arm64")
1515
set(SUPPORTED_WATCHOS_ARCHS "armv7k;arm64_32")
1616
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;x86_64;arm64")
1717
set(SUPPORTED_OSX_ARCHS "x86_64;arm64")
18+
set(SUPPORTED_XROS_ARCHS "arm64;arm64e")
19+
set(SUPPORTED_XROS_SIMULATOR_ARCHS "arm64")
1820

1921
is_sdk_requested(OSX swift_build_osx)
2022
if(swift_build_osx)
@@ -50,7 +52,8 @@ if(swift_build_freestanding AND (SWIFT_FREESTANDING_FLAVOR STREQUAL "apple"))
5052
endif()
5153

5254
# Compatible cross-compile SDKS for Darwin OSes: IOS, IOS_SIMULATOR, TVOS,
53-
# TVOS_SIMULATOR, WATCHOS, WATCHOS_SIMULATOR (archs hardcoded below).
55+
# TVOS_SIMULATOR, WATCHOS, WATCHOS_SIMULATOR, XROS, XROS_SIMULATOR
56+
# (archs hardcoded below).
5457

5558
is_sdk_requested(IOS swift_build_ios)
5659
if(swift_build_ios)
@@ -120,3 +123,28 @@ if(swift_build_watchos_simulator)
120123
configure_target_variant(WATCHOS_SIMULATOR-RA "watchOS Release+Asserts" WATCHOS_SIMULATOR RA "Release+Asserts")
121124
configure_target_variant(WATCHOS_SIMULATOR-R "watchOS Release" WATCHOS_SIMULATOR R "Release")
122125
endif()
126+
127+
is_sdk_requested(XROS swift_build_xros)
128+
if(swift_build_xros)
129+
configure_sdk_darwin(
130+
XROS "xrOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}"
131+
xros xros xros "${SUPPORTED_XROS_ARCHS}")
132+
configure_target_variant(XROS-DA "xrOS Debug+Asserts" XROS DA "Debug+Asserts")
133+
configure_target_variant(XROS-RA "xrOS Release+Asserts" XROS RA "Release+Asserts")
134+
configure_target_variant(XROS-R "xrOS Release" XROS R "Release")
135+
endif()
136+
137+
is_sdk_requested(XROS_SIMULATOR swift_build_xros_simulator)
138+
if(swift_build_xros_simulator)
139+
configure_sdk_darwin(
140+
XROS_SIMULATOR "xrOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}"
141+
xrsimulator xros xros-simulator
142+
"${SUPPORTED_XROS_SIMULATOR_ARCHS}")
143+
144+
configure_target_variant(
145+
XROS_SIMULATOR-DA "xrOS Simulator Debug+Asserts" XROS_SIMULATOR DA "Debug+Asserts")
146+
configure_target_variant(
147+
XROS_SIMULATOR-RA "xrOS Simulator Release+Asserts" XROS_SIMULATOR RA "Release+Asserts")
148+
configure_target_variant(
149+
XROS_SIMULATOR-R "xrOS Simulator Release" XROS_SIMULATOR R "Release")
150+
endif()

cmake/modules/StandaloneOverlay.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ set(CMAKE_INSTALL_PREFIX
100100

101101

102102
set(SWIFT_DARWIN_PLATFORMS
103-
OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR)
103+
OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR XROS XROS_SIMULATOR)
104104

105105
# Flags used to indicate we are building a standalone overlay.
106106
# FIXME: We should cut this down to a single flag.

include/swift/AST/ASTContext.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "swift/Basic/BlockList.h"
3535
#include "swift/SymbolGraphGen/SymbolGraphOptions.h"
3636
#include "clang/AST/DeclTemplate.h"
37+
#include "clang/Basic/DarwinSDKInfo.h"
3738
#include "llvm/ADT/ArrayRef.h"
3839
#include "llvm/ADT/DenseMap.h"
3940
#include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -948,6 +949,12 @@ class ASTContext final {
948949
return getMultiPayloadEnumTagSinglePayloadAvailability();
949950
}
950951

952+
/// Test support utility for loading a platform remap file
953+
/// in case an SDK is not specified to the compilation.
954+
const clang::DarwinSDKInfo::RelatedTargetVersionMapping *
955+
getAuxiliaryDarwinPlatformRemapInfo(
956+
clang::DarwinSDKInfo::OSEnvPair Kind) const;
957+
951958
//===--------------------------------------------------------------------===//
952959
// Diagnostics Helper functions
953960
//===--------------------------------------------------------------------===//
@@ -1511,6 +1518,9 @@ class ASTContext final {
15111518
/// Provide context-level uniquing for SIL lowered type layouts and boxes.
15121519
friend SILLayout;
15131520
friend SILBoxType;
1521+
1522+
public:
1523+
clang::DarwinSDKInfo *getDarwinSDKInfo() const;
15141524
};
15151525

15161526
} // end namespace swift

include/swift/AST/Availability.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
namespace swift {
2626
class ASTContext;
2727
class AvailableAttr;
28+
class BackDeployedAttr;
2829
class Decl;
2930

3031
/// A lattice of version ranges of the form [x.y.z, +Inf).
@@ -380,6 +381,39 @@ class AvailabilityInference {
380381

381382
static AvailabilityContext
382383
annotatedAvailableRangeForAttr(const SpecializeAttr *attr, ASTContext &ctx);
384+
385+
/// For the attribute's introduction version, update the platform and version
386+
/// values to the re-mapped platform's, if using a fallback platform.
387+
/// Returns `true` if a remap occured.
388+
static bool updateIntroducedPlatformForFallback(
389+
const AvailableAttr *attr, const ASTContext &Ctx,
390+
llvm::StringRef &Platform, llvm::VersionTuple &PlatformVer);
391+
392+
/// For the attribute's deprecation version, update the platform and version
393+
/// values to the re-mapped platform's, if using a fallback platform.
394+
/// Returns `true` if a remap occured.
395+
static bool updateDeprecatedPlatformForFallback(
396+
const AvailableAttr *attr, const ASTContext &Ctx,
397+
llvm::StringRef &Platform, llvm::VersionTuple &PlatformVer);
398+
399+
/// For the attribute's obsoletion version, update the platform and version
400+
/// values to the re-mapped platform's, if using a fallback platform.
401+
/// Returns `true` if a remap occured.
402+
static bool updateObsoletedPlatformForFallback(
403+
const AvailableAttr *attr, const ASTContext &Ctx,
404+
llvm::StringRef &Platform, llvm::VersionTuple &PlatformVer);
405+
406+
static void updatePlatformStringForFallback(
407+
const AvailableAttr *attr, const ASTContext &Ctx,
408+
llvm::StringRef &Platform);
409+
410+
/// For the attribute's before version, update the platform and version
411+
/// values to the re-mapped platform's, if using a fallback platform.
412+
/// Returns `true` if a remap occured.
413+
static bool updateBeforePlatformForFallback(const BackDeployedAttr *attr,
414+
const ASTContext &Ctx,
415+
llvm::StringRef &Platform,
416+
llvm::VersionTuple &PlatformVer);
383417
};
384418

385419
/// Given a declaration upon which an availability attribute would appear in

include/swift/AST/PlatformKind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ inline bool isApplicationExtensionPlatform(PlatformKind Platform) {
7878
/// triple will be used rather than the target to determine whether the
7979
/// platform is active.
8080
bool isPlatformActive(PlatformKind Platform, const LangOptions &LangOpts,
81-
bool ForTargetVariant = false);
81+
bool ForTargetVariant = false, bool ForRuntimeQuery = false);
8282

8383
/// Returns the target platform for the given language options.
8484
PlatformKind targetPlatform(const LangOptions &LangOpts);

include/swift/AST/PlatformKinds.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
AVAILABILITY_PLATFORM(iOS, "iOS")
2626
AVAILABILITY_PLATFORM(tvOS, "tvOS")
2727
AVAILABILITY_PLATFORM(watchOS, "watchOS")
28+
AVAILABILITY_PLATFORM(visionOS, "visionOS")
2829
AVAILABILITY_PLATFORM(macOS, "macOS")
2930
AVAILABILITY_PLATFORM(iOSApplicationExtension, "application extensions for iOS")
3031
AVAILABILITY_PLATFORM(tvOSApplicationExtension, "application extensions for tvOS")
3132
AVAILABILITY_PLATFORM(watchOSApplicationExtension, "application extensions for watchOS")
33+
AVAILABILITY_PLATFORM(visionOSApplicationExtension, "application extensions for visionOS")
3234
AVAILABILITY_PLATFORM(macOSApplicationExtension, "application extensions for macOS")
3335
AVAILABILITY_PLATFORM(macCatalyst, "Mac Catalyst")
3436
AVAILABILITY_PLATFORM(macCatalystApplicationExtension, "application extensions for Mac Catalyst")

include/swift/AST/RuntimeVersions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ RUNTIME_VERSION(
135135
PLATFORM(macOS, (14, 4, 0))
136136
PLATFORM(iOS, (17, 4, 0))
137137
PLATFORM(watchOS, (10, 4, 0))
138+
PLATFORM(xrOS, (1, 0, 0))
138139
)
139140

140141
RUNTIME_VERSION(

include/swift/AST/SearchPathOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ class SearchPathOptions {
500500
/// A file containing a list of protocols whose conformances require const value extraction.
501501
std::string ConstGatherProtocolListFilePath;
502502

503+
/// Path to the file that defines platform mapping for availability
504+
/// version inheritance.
505+
std::optional<std::string> PlatformAvailabilityInheritanceMapPath;
506+
503507
/// Debug path mappings to apply to serialized search paths. These are
504508
/// specified in LLDB from the target.source-map entries.
505509
PathRemapper SearchPathRemapper;

include/swift/Basic/LangOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ namespace swift {
635635
return Target.getiOSVersion();
636636
} else if (Target.isWatchOS()) {
637637
return Target.getOSVersion();
638+
} else if (Target.isXROS()) {
639+
return Target.getOSVersion();
638640
}
639641
return llvm::VersionTuple(/*Major=*/0, /*Minor=*/0, /*Subminor=*/0);
640642
}

0 commit comments

Comments
 (0)