peachsim 0.1.2767 → 0.1.2769

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +2 -2
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +351 -77
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-RDD3HI5C.mjs → acorn-GNB3RJH7.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-BY3E6CUM.mjs → chunk-3WG4L5YK.mjs} +372 -106
  28. package/dist-lib/esm-chunks/{chunk-YX56RZ26.mjs → chunk-3ZKE33FC.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-555YCJDH.mjs → chunk-4GHACZYW.mjs} +5 -5
  30. package/dist-lib/esm-chunks/{chunk-CBAMX2H3.mjs → chunk-4IJOKKT2.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-GKHSLOW6.mjs → chunk-53WFZATQ.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-H4KLP3QO.mjs → chunk-57JPQBQL.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-PDMYH4NT.mjs → chunk-ALLMPTWQ.mjs} +2 -2
  34. package/dist-lib/esm-chunks/{chunk-UGTY5DQQ.mjs → chunk-BFLH7V77.mjs} +6 -6
  35. package/dist-lib/esm-chunks/{chunk-LO5KFOI3.mjs → chunk-BP7TLKZD.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-WJKKLL2J.mjs → chunk-ETXC2XBY.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-C6YNOAXM.mjs → chunk-GHJPVQ3A.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-D6JZSVL7.mjs → chunk-L2U2IEHU.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-7G6WGJWR.mjs → chunk-MBLYJ74N.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-P2KN5U5O.mjs → chunk-MGIODRG3.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-XPSICY6F.mjs → chunk-OG5C2CN2.mjs} +3 -3
  42. package/dist-lib/esm-chunks/{chunk-4W67A7NE.mjs → chunk-OPIPPBGX.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-DFK4ZVNM.mjs → chunk-TI42U3CD.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-H5C5TZNB.mjs → chunk-TJNFADI5.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-OYMWLKPN.mjs → chunk-TTVQWJGW.mjs} +4 -4
  46. package/dist-lib/esm-chunks/{chunk-7VSU2AV7.mjs → chunk-VF3CWZTM.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-AC2RBU5N.mjs → chunk-WWANYYJG.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-EJWUFWN3.mjs → chunk-XX7VUACB.mjs} +26 -13
  49. package/dist-lib/esm-chunks/{chunk-BSN5R62H.mjs → chunk-ZGNNVEWM.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-3WJRW63F.mjs → chunk-ZLYAJ4CU.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{metro-layout-parser-7POGDD5P.mjs → metro-layout-parser-LT2DPN6F.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-ULD72CI5.mjs → swift-package-prebuilt-ZFFWBI33.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-VXSTLD57.mjs → swift-sdk-app-module-UZ6BZSES.mjs} +22 -17
  54. package/dist-lib/esm-chunks/{swift-sdk-image-KDJATRA6.mjs → swift-sdk-image-J2DE3SBW.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-KNBUALWN.mjs → swift-sdk-image-producer-C4U4EQRW.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +351 -77
  57. package/dist-lib/expo-swift-metadata.cjs +1 -1
  58. package/dist-lib/expo-swift-metadata.mjs +7 -7
  59. package/dist-lib/home-paths.cjs +1 -1
  60. package/dist-lib/host/bridge-host.cjs +351 -77
  61. package/dist-lib/host/fetch-proxy-handler.cjs +24 -20
  62. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  63. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  64. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  65. package/dist-lib/host/websocket-proxy.cjs +1 -1
  66. package/dist-lib/index.cjs +1 -1
  67. package/dist-lib/kotlin-host.cjs +1 -1
  68. package/dist-lib/menu.cjs +1 -1
  69. package/dist-lib/menu.mjs +3 -3
  70. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  71. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  72. package/dist-lib/metro-production-bundle.cjs +1 -1
  73. package/dist-lib/metro-production-bundle.mjs +4 -4
  74. package/dist-lib/native-app-identity-project.cjs +1 -1
  75. package/dist-lib/native-app-identity-project.mjs +15 -15
  76. package/dist-lib/native-app-identity.cjs +1 -1
  77. package/dist-lib/native-app-identity.mjs +6 -6
  78. package/dist-lib/native-firebase-metadata.cjs +1 -1
  79. package/dist-lib/native-firebase-metadata.mjs +3 -3
  80. package/dist-lib/pdfium-raster.cjs +1 -1
  81. package/dist-lib/pdfium-raster.mjs +2 -2
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +3 -3
  84. package/dist-lib/profiles.cjs +1 -1
  85. package/dist-lib/public-brand.cjs +1 -1
  86. package/dist-lib/public-origins-lib-esm.json +85 -85
  87. package/dist-lib/public-origins-lib.json +64 -64
  88. package/dist-lib/react-native-host-modules.cjs +1 -1
  89. package/dist-lib/react-native-host-modules.mjs +2 -2
  90. package/dist-lib/reap-browser.cjs +1 -1
  91. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  92. package/dist-lib/sdk.cjs +1 -1
  93. package/dist-lib/sdk.mjs +8 -8
  94. package/dist-lib/skills.cjs +351 -77
  95. package/dist-lib/swift-compile.cjs +331 -57
  96. package/dist-lib/swift-compile.mjs +12 -12
  97. package/dist-lib/swift-package.cjs +1 -1
  98. package/dist-lib/swift-package.mjs +3 -3
  99. package/dist-lib/swift-submit.cjs +1 -1
  100. package/dist-lib/swift-submit.mjs +6 -6
  101. package/dist-lib/swift-svg-raster.cjs +1 -1
  102. package/dist-lib/swift-svg-raster.mjs +2 -2
  103. package/dist-lib/swift-toolchain.cjs +1 -1
  104. package/dist-lib/swift.cjs +1 -1
  105. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  106. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  108. package/dist-lib/vendor/acorn.cjs +1 -1
  109. package/dist-lib/vendor/magic-string.cjs +1 -1
  110. package/dist-lib/vendor/stream-json.cjs +1 -1
  111. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  112. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase.cjs +1 -1
  116. package/dist-lib/vendor/terser.cjs +1 -1
  117. package/dist-lib/vendor/valibot.cjs +1 -1
  118. package/dist-lib/vendor/ws.cjs +1 -1
  119. package/dist-lib/vendor/zod.cjs +1 -1
  120. package/dist-lib/worklet-executable.cjs +1 -1
  121. package/dist-lib/worklet-executable.mjs +3 -3
  122. package/dist-types/packages/peach-engine/src/render-worker/aux-pointer-native.d.ts +4 -0
  123. package/dist-types/packages/peach-engine/src/render-worker/auxPointerContract.d.ts +4 -0
  124. package/package.json +1 -1
  125. package/src/case-insensitive-header-overlay.ts +9 -1
  126. package/src/native-static-libraries.ts +16 -16
  127. package/src/swift-compile.ts +158 -42
  128. package/src/swift-distribution-mirror.ts +273 -10
  129. package/src/swift-objc-prebuilt.ts +10 -1
  130. package/src/swift-objc-standin.ts +6 -1
  131. package/src/swift-sdk-app-module.ts +10 -3
  132. package/src/swift-sdk-surface.ts +5 -1
@@ -50,7 +50,11 @@ import {
50
50
  } from './swift-distribution-contract'
51
51
  import {
52
52
  SWIFT_DISTRIBUTION_MIRROR,
53
+ SWIFT_SDK_MIRROR,
54
+ SWIFT_SDK_MIRROR_ID,
53
55
  syncSwiftDistributionMirror,
56
+ syncSwiftSdkMirror,
57
+ type SwiftMirrorSdk,
54
58
  } from './swift-distribution-mirror'
55
59
  import { foundationCategoryObjects } from './swift-foundation'
56
60
  import { compileGuestLink } from './swift-guest-compile'
@@ -136,6 +140,7 @@ import {
136
140
  cActiveCode,
137
141
  clangInterfaceHeader,
138
142
  clearLinkedModuleDigests,
143
+ clearSwiftSdkPathsCache,
139
144
  CORE_FOUNDATION_OVERLAY_GLOBALS,
140
145
  emptyMacroEnvironment,
141
146
  FOUNDATION_IMPLICIT_MODULES,
@@ -2280,6 +2285,7 @@ export function syncSwiftTree(
2280
2285
  // must not remove them.
2281
2286
  entry.name === CLANG_DISTRIBUTION_MODULES ||
2282
2287
  entry.name === SWIFT_DISTRIBUTION_MIRROR ||
2288
+ entry.name === SWIFT_SDK_MIRROR ||
2283
2289
  entry.name === SWIFT_LINK_STAMP ||
2284
2290
  entry.name === SWIFT_BUILD_ROOT_SHAPE)
2285
2291
  )
@@ -3369,6 +3375,7 @@ export function writeSwiftProject(
3369
3375
  prebuilt?: SwiftFrameworkProducts,
3370
3376
  allowHeaderCompiler = false,
3371
3377
  objcPrebuiltStage?: SwiftObjCPrebuiltStage | false,
3378
+ compileSdk?: Pick<SwiftMirrorSdk, 'id' | 'options'>,
3372
3379
  ): SwiftProjectPreparation & {
3373
3380
  generatedOwners: Map<string, string>
3374
3381
  targetToolset: boolean
@@ -3540,6 +3547,8 @@ export function writeSwiftProject(
3540
3547
  checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot))
3541
3548
  return checkedToolchain
3542
3549
  }
3550
+ const resolvedSdkPaths = (toolchainBin: string) =>
3551
+ swiftSdkPaths(moduleRoot, toolchainBin, compileSdk?.options, compileSdk?.id)
3543
3552
  const targetStagedFiles = new Map<string, Map<string, string | Buffer | undefined>>()
3544
3553
  const stageTargetFile = (
3545
3554
  target: string,
@@ -3713,16 +3722,35 @@ export function writeSwiftProject(
3713
3722
  files.set(destination, contents)
3714
3723
  }
3715
3724
  }
3725
+ // ensure active staged binary-tree headers in this input exist on disk before
3726
+ // building the case-insensitive overlay, so stale trees from prior runs are excluded.
3727
+ const binaryTreePrefix = `${SWIFT_BINARY_TREES_DIR}/`
3728
+ const binaryTreeSegment = `/${SWIFT_BINARY_TREES_DIR}/`
3729
+ const isBinaryTreeFile = (file: string) =>
3730
+ file.startsWith(binaryTreePrefix) || file.includes(binaryTreeSegment)
3731
+ const stageBinaryTreeFile = (file: string, contents: string | Buffer) => {
3732
+ const destination = path.join(layout.root, file)
3733
+ if (files.has(destination)) return
3734
+ writeBuildFile(destination, contents)
3735
+ alreadySynced.set(destination, contents)
3736
+ files.set(destination, contents)
3737
+ }
3738
+ for (const [file, contents] of Object.entries(input.files))
3739
+ if (isBinaryTreeFile(file)) stageBinaryTreeFile(file, contents)
3740
+ for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
3741
+ if (isBinaryTreeFile(file) && !file.endsWith('.swift'))
3742
+ stageBinaryTreeFile(file, Buffer.from(bytes, 'base64'))
3743
+ for (const [file, bytes] of Object.entries(input.projectFiles ?? {}))
3744
+ if (isBinaryTreeFile(file)) stageBinaryTreeFile(file, Buffer.from(bytes, 'base64'))
3716
3745
  // xcode's header maps and product header overlay, naming the headers
3717
3746
  // written above, bound into every clang command of their target.
3718
3747
  const fromInputRoot = (file: string) =>
3719
3748
  file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`)
3720
3749
  ? path.join(layout.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1))
3721
3750
  : file
3722
- // a warm root also holds what earlier builds emitted into it; this input's
3723
- // headers and the staged binary trees are the same on every run.
3751
+ // a warm root also holds what earlier builds emitted into it; admit only this
3752
+ // input's files under the root so stale binary trees never churn the overlay.
3724
3753
  const inRoot = `${layout.root}${path.sep}`
3725
- const binaryTree = `${path.sep}${SWIFT_BINARY_TREES_DIR}${path.sep}`
3726
3754
  const headerSearch = writeXcodeHeaderSearch(
3727
3755
  path.join(layout.root, '.build', 'peach-xcode-headers'),
3728
3756
  nativeTargets.map((settings) => {
@@ -3784,7 +3812,7 @@ export function writeSwiftProject(
3784
3812
  path.join(layout.root, file),
3785
3813
  ]),
3786
3814
  ),
3787
- (file) => !file.startsWith(inRoot) || files.has(file) || file.includes(binaryTree),
3815
+ (file) => !file.startsWith(inRoot) || files.has(file),
3788
3816
  )
3789
3817
  // declarations are imported before swift can emit the header that native
3790
3818
  // implementations consume. give those implementations a downstream target.
@@ -3973,7 +4001,7 @@ export function writeSwiftProject(
3973
4001
  ]
3974
4002
  })()
3975
4003
  const sdkInclude = path.join(
3976
- swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
4004
+ resolvedSdkPaths(toolchainBin).sysroot,
3977
4005
  'darwin/usr/include',
3978
4006
  )
3979
4007
  const dependencyModuleMaps = clangImportModuleMapFlags(
@@ -4914,7 +4942,11 @@ export function writeSwiftProject(
4914
4942
  )
4915
4943
  if (nativeFlags) {
4916
4944
  const toolchainBin = nativeToolchain()
4917
- const headers = path.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, 'darwin')
4945
+ const headers = path.join(resolvedSdkPaths(toolchainBin).sysroot, 'darwin')
4946
+ const sdkOverlayDirectory =
4947
+ compileSdk?.id === SWIFT_SDK_MIRROR_ID
4948
+ ? path.join(layout.root, SWIFT_SDK_MIRROR)
4949
+ : undefined
4918
4950
  const dependencies = swiftTargetDependencies(input.files, targets)
4919
4951
  const reachesNative = (name: string, seen = new Set<string>()): boolean => {
4920
4952
  if (native.has(name)) return true
@@ -4937,7 +4969,12 @@ export function writeSwiftProject(
4937
4969
  ': missing or unsupported declared iOS deployment target ' +
4938
4970
  JSON.stringify(version),
4939
4971
  )
4940
- const sdkIntake = objcSdkIntakeFlags(headers, toolchainBin, minimum)
4972
+ const sdkIntake = objcSdkIntakeFlags(
4973
+ headers,
4974
+ toolchainBin,
4975
+ minimum,
4976
+ sdkOverlayDirectory,
4977
+ )
4941
4978
  const sdkOverlay = sdkIntake.indexOf('-ivfsoverlay')
4942
4979
  if (sdkOverlay >= 0) generatedOverlays.add(sdkIntake[sdkOverlay + 1]!)
4943
4980
  const intake = [
@@ -5225,7 +5262,7 @@ export function writeSwiftProject(
5225
5262
  deferDarwinOverlay:
5226
5263
  native.size > 0 &&
5227
5264
  toolsetOrdersLibcxxBeforeDarwinOverlay(
5228
- swiftSdkPaths(moduleRoot, nativeToolchain()).cFlags,
5265
+ resolvedSdkPaths(nativeToolchain()).cFlags,
5229
5266
  ),
5230
5267
  ...(reachesFrameworks
5231
5268
  ? {
@@ -5278,7 +5315,7 @@ export function writeSwiftProject(
5278
5315
  ? [
5279
5316
  '-fmodule-map-file=' +
5280
5317
  path.join(
5281
- swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
5318
+ resolvedSdkPaths(nativeToolchain()).sysroot,
5282
5319
  'darwin/wasm/include/module.modulemap',
5283
5320
  ),
5284
5321
  ]
@@ -5297,7 +5334,7 @@ export function writeSwiftProject(
5297
5334
  ? swiftObjCPrebuiltCompiler(
5298
5335
  clang,
5299
5336
  layout.root,
5300
- swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
5337
+ resolvedSdkPaths(nativeToolchain()).sysroot,
5301
5338
  distribution.id,
5302
5339
  [...native.keys()],
5303
5340
  objcPrebuiltStage,
@@ -5572,14 +5609,69 @@ export function writeSwiftProject(
5572
5609
  return name
5573
5610
  }
5574
5611
  // normalize a dependency header before its consumers, while swiftpm schedules
5575
- // independent producers together within the admitted job budget.
5576
- const headerBuilds = headerCompiler
5577
- ? [
5612
+ // independent producers together within the admitted job budget. chunk large
5613
+ // producer graphs in topological level order so llbuild commits build.db and
5614
+ // product checkpoints every few minutes instead of rolling back on timeout.
5615
+ const producerUnitCount = new Map<string, number>()
5616
+ for (const target of targets) {
5617
+ if (!producerSet.has(target.name)) continue
5618
+ producerUnitCount.set(
5619
+ target.name,
5620
+ Math.max(
5621
+ 1,
5622
+ targetEntries(target).filter(([file]) => file.endsWith('.swift')).length,
5623
+ ),
5624
+ )
5625
+ }
5626
+ const MAX_HEADER_STAGE_TARGETS = 100
5627
+ const MAX_HEADER_STAGE_UNITS = 400
5628
+ const chunkHeaderProducers = (
5629
+ producers: readonly string[],
5630
+ ): { target: string; producers: string[] }[] => {
5631
+ const levelOrdered = [...producers].sort(
5632
+ (left, right) => depths.get(left)! - depths.get(right)!,
5633
+ )
5634
+ const totalUnits = levelOrdered.reduce(
5635
+ (sum, name) => sum + (producerUnitCount.get(name) ?? 1),
5636
+ 0,
5637
+ )
5638
+ if (
5639
+ levelOrdered.length <= 1 ||
5640
+ (levelOrdered.length <= MAX_HEADER_STAGE_TARGETS &&
5641
+ totalUnits <= MAX_HEADER_STAGE_UNITS)
5642
+ ) {
5643
+ return [
5578
5644
  {
5579
- target: buildProduct(SWIFT_HEADER_PRODUCTS_TARGET, orderedProducers),
5580
- producers: orderedProducers,
5645
+ target: buildProduct(SWIFT_HEADER_PRODUCTS_TARGET, levelOrdered),
5646
+ producers: levelOrdered,
5581
5647
  },
5582
5648
  ]
5649
+ }
5650
+ const chunks: string[][] = []
5651
+ let current: string[] = []
5652
+ let units = 0
5653
+ for (const name of levelOrdered) {
5654
+ const size = producerUnitCount.get(name) ?? 1
5655
+ if (
5656
+ current.length > 0 &&
5657
+ (current.length >= MAX_HEADER_STAGE_TARGETS ||
5658
+ units + size > MAX_HEADER_STAGE_UNITS)
5659
+ ) {
5660
+ chunks.push(current)
5661
+ current = []
5662
+ units = 0
5663
+ }
5664
+ current.push(name)
5665
+ units += size
5666
+ }
5667
+ if (current.length > 0) chunks.push(current)
5668
+ return chunks.map((members, index) => ({
5669
+ target: buildProduct(`${SWIFT_HEADER_PRODUCTS_TARGET}${index + 1}`, members),
5670
+ producers: members,
5671
+ }))
5672
+ }
5673
+ const headerBuilds = headerCompiler
5674
+ ? chunkHeaderProducers(orderedProducers)
5583
5675
  : [...stages]
5584
5676
  .sort(([left], [right]) => left - right)
5585
5677
  .map(([level, producers]) => ({
@@ -7616,6 +7708,15 @@ async function compileSwiftProjectOnce(
7616
7708
  // memoized per toolchain, so only a process's first build waits on it,
7617
7709
  // and that one reads and gzips it while swift builds
7618
7710
  const sdk = swiftModuleSdk(frameworkRoot).wasmSdkId
7711
+ const compileSdk: SwiftMirrorSdk = mirrorDistribution
7712
+ ? syncSwiftSdkMirror(root, frameworkRoot, options.toolchainBin, sdk)
7713
+ : {
7714
+ id: sdk,
7715
+ options: swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
7716
+ toolsetChanged: false,
7717
+ }
7718
+ if (mirrorDistribution && compileSdk.toolsetChanged)
7719
+ clearSwiftSdkPathsCache(path.join(root, SWIFT_SDK_MIRROR))
7619
7720
  const icu = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk)
7620
7721
  let prebuilt: SwiftFrameworkProducts | undefined
7621
7722
  if (!distribution) {
@@ -7655,6 +7756,7 @@ async function compileSwiftProjectOnce(
7655
7756
  compileFrameworkRoot,
7656
7757
  macroPlugins,
7657
7758
  sdk,
7759
+ compileSdk,
7658
7760
  icu,
7659
7761
  prebuilt,
7660
7762
  readHold,
@@ -7677,7 +7779,7 @@ async function compileSwiftProjectOnce(
7677
7779
  frameworkRoot,
7678
7780
  compileFrameworkRoot,
7679
7781
  macroPlugins,
7680
- sdk,
7782
+ compileSdk,
7681
7783
  icu,
7682
7784
  prebuilt,
7683
7785
  } = frameworks
@@ -7697,15 +7799,19 @@ async function compileSwiftProjectOnce(
7697
7799
  retireStaleSwiftLink(
7698
7800
  root,
7699
7801
  swiftLinkStamp({
7700
- frameworkKey: `${options.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
7802
+ frameworkKey: mirrorDistribution
7803
+ ? `${options.release}\0mirror`
7804
+ : `${options.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
7701
7805
  packageHostMacros,
7702
7806
  }),
7703
7807
  swiftLinkStamp({
7704
- // a distribution's objects reach only the deferred link, and
7705
- // the root's mirror keeps its compile inputs at fixed paths
7706
- frameworkKey: distribution
7707
- ? `${options.release}\0${distribution.wasmSdkChecksum}`
7708
- : frameworkKey,
7808
+ // mirrored distributions and their WASI SDK mirror invalidate
7809
+ // dependents per changed file instead of wiping every Clang object.
7810
+ frameworkKey: mirrorDistribution
7811
+ ? `${options.release}\0mirror`
7812
+ : distribution
7813
+ ? `${options.release}\0${distribution.wasmSdkChecksum}`
7814
+ : frameworkKey,
7709
7815
  prebuilt,
7710
7816
  packageHostMacros,
7711
7817
  }),
@@ -7724,6 +7830,7 @@ async function compileSwiftProjectOnce(
7724
7830
  ? false
7725
7831
  : (options.objcPrebuiltStage ??
7726
7832
  (options.intermediates ? false : undefined)),
7833
+ compileSdk,
7727
7834
  )
7728
7835
  // the framework objects link as inputs, so the product name its
7729
7836
  // modules autolink has no archive to load
@@ -7828,6 +7935,9 @@ async function compileSwiftProjectOnce(
7828
7935
  !input.optimize &&
7829
7936
  !input.unoptimized
7830
7937
  const perFile = input.unoptimized || incrementalPreview
7938
+ const reproducibleFrameworkRoot = mirrorDistribution
7939
+ ? frameworkRoot
7940
+ : compileFrameworkRoot
7831
7941
  const buildArgs = [
7832
7942
  'build',
7833
7943
  ...(projectProcess?.cacheOptions ?? swiftPackageCacheOptions()),
@@ -7837,10 +7947,10 @@ async function compileSwiftProjectOnce(
7837
7947
  String(jobs),
7838
7948
  '--package-path',
7839
7949
  root,
7840
- ...swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
7950
+ ...compileSdk.options,
7841
7951
  ...swiftObjCSelectorOptions(frameworkRoot),
7842
7952
  '--swift-sdk',
7843
- sdk,
7953
+ compileSdk.id,
7844
7954
  ...(preparation.targetToolset
7845
7955
  ? ['--toolset', path.join(root, '.peach-target-toolset.json')]
7846
7956
  : []),
@@ -7883,7 +7993,7 @@ async function compileSwiftProjectOnce(
7883
7993
  ]),
7884
7994
  ...swiftReproducibleBuildFlags([
7885
7995
  [path.dirname(options.toolchainBin), 'toolchain'],
7886
- [compileFrameworkRoot, 'framework'],
7996
+ [reproducibleFrameworkRoot, 'framework'],
7887
7997
  [root, 'build'],
7888
7998
  ...forwarders,
7889
7999
  ]).flatMap((flag, index, flags) => {
@@ -7893,8 +8003,8 @@ async function compileSwiftProjectOnce(
7893
8003
  let mapped = flag
7894
8004
  for (const [dir, target] of [
7895
8005
  [root, '/peach/build'],
7896
- [compileFrameworkRoot, '/peach/framework'],
7897
- [realpathSync(compileFrameworkRoot), '/peach/framework'],
8006
+ [reproducibleFrameworkRoot, '/peach/framework'],
8007
+ [realpathSync(reproducibleFrameworkRoot), '/peach/framework'],
7898
8008
  [toolchainDir, '/peach/toolchain'],
7899
8009
  [realpathSync(toolchainDir), '/peach/toolchain'],
7900
8010
  ] as const) {
@@ -7934,8 +8044,14 @@ async function compileSwiftProjectOnce(
7934
8044
  string,
7935
8045
  { file: string; header: string; module: boolean } | null
7936
8046
  >()
8047
+ const compileSdkPaths = swiftSdkPaths(
8048
+ frameworkRoot,
8049
+ options.toolchainBin,
8050
+ compileSdk.options,
8051
+ compileSdk.id,
8052
+ )
7937
8053
  const sdkFrameworks = path.join(
7938
- swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
8054
+ compileSdkPaths.darwin,
7939
8055
  'System/Library/Frameworks',
7940
8056
  )
7941
8057
  const generatedInterface = (source: string) =>
@@ -8180,16 +8296,18 @@ async function compileSwiftProjectOnce(
8180
8296
  options.toolchainBin,
8181
8297
  recipe,
8182
8298
  new Map(
8183
- preparation.headerBuilds[0]!.producers.map((producer) => {
8184
- const paths = headerPaths(producer)
8185
- return [
8186
- swiftTargetModuleName(producer),
8187
- {
8188
- header: paths.original,
8189
- publish: () => publishHeader(paths),
8190
- },
8191
- ]
8192
- }),
8299
+ preparation.headerBuilds
8300
+ .flatMap((stage) => stage.producers)
8301
+ .map((producer) => {
8302
+ const paths = headerPaths(producer)
8303
+ return [
8304
+ swiftTargetModuleName(producer),
8305
+ {
8306
+ header: paths.original,
8307
+ publish: () => publishHeader(paths),
8308
+ },
8309
+ ]
8310
+ }),
8193
8311
  ),
8194
8312
  runApp,
8195
8313
  )
@@ -8290,7 +8408,7 @@ async function compileSwiftProjectOnce(
8290
8408
  swiftCompiler: preparation.headerCompiler
8291
8409
  ? path.join(root, SWIFT_HEADER_COMPILER_WRAPPER)
8292
8410
  : (compiler.SWIFT_EXEC ?? path.join(options.toolchainBin, 'swiftc')),
8293
- sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
8411
+ sysroot: compileSdkPaths.sysroot,
8294
8412
  sdk: swiftModuleSdk(frameworkRoot),
8295
8413
  sdkImage,
8296
8414
  compilerDigest: compilerSourceDigest,
@@ -8320,9 +8438,7 @@ async function compileSwiftProjectOnce(
8320
8438
  project: options.project && {
8321
8439
  ...options.project,
8322
8440
  env: { ...options.project.env, ...projectProcess?.env },
8323
- sdkRoot: path.dirname(
8324
- swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
8325
- ),
8441
+ sdkRoot: path.dirname(compileSdkPaths.sysroot),
8326
8442
  linked: output,
8327
8443
  },
8328
8444
  })