@@ -1573,6 +1573,32 @@ extension Triple {
15731573// MARK: - Darwin Versions
15741574
15751575extension Triple {
1576+ // Version 26 alignment helper. Each Apple OS jumped to version 26, so the
1577+ // last pre-jump release canonicalizes to 26; versions in the unshipped gap
1578+ // below 26 are left unchanged. Only `_iOSVersion` consumes this.
1579+
1580+ /// Canonicalize the last pre-26 release to the year-aligned version 26.
1581+ /// Gap versions (between the pre-jump release and 26) pass through unchanged.
1582+ static func _canonicalVersion( _ version: Version , for os: OS ) -> Version {
1583+ func isExactly( _ major: Int ) -> Bool {
1584+ version. major == major && version. minor == 0 && version. micro == 0
1585+ }
1586+ switch os {
1587+ case . macosx:
1588+ if version. major == 10 && version. minor == 16 { return Version ( 11 , 0 , 0 ) }
1589+ if isExactly ( 16 ) { return Version ( 26 , 0 , 0 ) }
1590+ case . ios, . tvos:
1591+ if isExactly ( 19 ) { return Version ( 26 , 0 , 0 ) }
1592+ case . visionos:
1593+ if isExactly ( 3 ) { return Version ( 26 , 0 , 0 ) }
1594+ case . watchos:
1595+ if isExactly ( 12 ) { return Version ( 26 , 0 , 0 ) }
1596+ default :
1597+ break
1598+ }
1599+ return version
1600+ }
1601+
15761602 /// Parse the version number as with getOSVersion and then
15771603 /// translate generic "darwin" versions to the corresponding OS X versions.
15781604 /// This may also be called with IOS triples but the OS X version number is
@@ -1601,11 +1627,16 @@ extension Triple {
16011627 version. micro = 0
16021628 version. minor = version. major - 4
16031629 version. major = 10
1604- } else {
1630+ } else if version . major < 25 {
16051631 version. micro = 0
16061632 version. minor = 0
1607- // darwin20+ corresponds to macOS 11+ .
1633+ // darwin20-24 corresponds to macOS 11-15 .
16081634 version. major = version. major - 9
1635+ } else if version. major == 25 || version. major == 26 {
1636+ version. micro = 0
1637+ version. minor = 0
1638+ // darwin25-26 corresponds to macOS 26-27.
1639+ version. major = version. major + 1
16091640 }
16101641
16111642 case . macosx:
@@ -1644,19 +1675,29 @@ extension Triple {
16441675 // toolchain that wants to know the iOS version number even when targeting
16451676 // OS X.
16461677 return Version ( 5 , 0 , 0 )
1647- case . ios:
1678+ case . ios, . tvos :
16481679 var version = self . osVersion
16491680 // Default to 5.0 (or 7.0 for arm64).
16501681 if version. major == 0 {
16511682 version. major = arch == . aarch64 ? 7 : 5
16521683 }
1653- return version
1654- case . tvos:
1655- return osVersion
1684+ // iOS & tvOS 19 correspond to iOS 26.
1685+ if version. major == 19 {
1686+ return Version ( 26 , 0 , 0 )
1687+ }
1688+ return Triple . _canonicalVersion ( version, for: . ios)
16561689 case . visionos:
1657- return Version ( 15 , 0 , 0 )
1690+ let version = self . osVersion
1691+ // xrOS 1/2 are aligned with iOS 17/18.
1692+ if version. major < 3 {
1693+ return Version ( version. major + 16 , version. minor, version. micro)
1694+ }
1695+ // visionOS 3 corresponds to iOS 26.
1696+ return Triple . _canonicalVersion ( version, for: . visionos)
16581697 case . watchos:
1659- fatalError ( " conflicting triple info " )
1698+ let version = self . osVersion
1699+ // watchOS 12 corresponds to iOS 26.
1700+ return Triple . _canonicalVersion ( version, for: . watchos)
16601701 default :
16611702 fatalError ( " unexpected OS for Darwin triple " )
16621703 }
0 commit comments