peachsim 0.1.2224 → 0.1.2228

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 (171) hide show
  1. package/cli/bridge-flow-runner.ts +56 -3
  2. package/cli/commands/control.ts +27 -1
  3. package/cli/commands/flow.ts +26 -0
  4. package/cli/commands/package.ts +9 -2
  5. package/cli/drivers/playwright.ts +1 -0
  6. package/cli/drivers/types.ts +3 -0
  7. package/cli/internal-child.ts +4 -2
  8. package/dist-lib/agent-daemon-client.cjs +1 -1
  9. package/dist-lib/agent-events.cjs +1 -1
  10. package/dist-lib/attached-projects.cjs +1 -1
  11. package/dist-lib/auth/shared-session.cjs +1 -1
  12. package/dist-lib/backend-origin.cjs +1 -1
  13. package/dist-lib/beta.cjs +1 -1
  14. package/dist-lib/beta.mjs +1 -1
  15. package/dist-lib/bridge-constants.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.mjs +1 -1
  18. package/dist-lib/bridge-contract.cjs +1 -1
  19. package/dist-lib/bridge-contract.mjs +1 -1
  20. package/dist-lib/bundle-channel.cjs +931 -455
  21. package/dist-lib/capture-contract.cjs +1 -1
  22. package/dist-lib/capture-contract.mjs +1 -1
  23. package/dist-lib/cloud-contract.cjs +1 -1
  24. package/dist-lib/cloud-contract.mjs +1 -1
  25. package/dist-lib/cloud-test-args.cjs +1 -1
  26. package/dist-lib/cloud-test-args.mjs +1 -1
  27. package/dist-lib/cloud.cjs +1 -1
  28. package/dist-lib/cloud.mjs +1 -1
  29. package/dist-lib/config.cjs +1 -1
  30. package/dist-lib/config.mjs +1 -1
  31. package/dist-lib/detox/index.cjs +2 -2
  32. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  33. package/dist-lib/expo-swift-bundle.cjs +867 -391
  34. package/dist-lib/expo-swift-metadata.cjs +1 -1
  35. package/dist-lib/expo-swift-metadata.mjs +1 -1
  36. package/dist-lib/home-paths.cjs +1 -1
  37. package/dist-lib/host/bridge-host.cjs +926 -450
  38. package/dist-lib/host/fetch-proxy-handler.cjs +55 -12
  39. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  40. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  41. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  42. package/dist-lib/host/websocket-proxy.cjs +1 -1
  43. package/dist-lib/index.cjs +60 -16
  44. package/dist-lib/jump-to-source-babel.cjs +1 -1
  45. package/dist-lib/jump-to-source-native.cjs +1 -1
  46. package/dist-lib/kotlin-host.cjs +1 -1
  47. package/dist-lib/menu.cjs +1 -1
  48. package/dist-lib/menu.mjs +1 -1
  49. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  50. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  51. package/dist-lib/metro-production-bundle.cjs +11 -4
  52. package/dist-lib/metro-production-bundle.mjs +10 -4
  53. package/dist-lib/metro.cjs +60 -16
  54. package/dist-lib/native-app-identity-project.cjs +53 -9
  55. package/dist-lib/native-app-identity-project.mjs +84 -37
  56. package/dist-lib/native-app-identity.cjs +1 -1
  57. package/dist-lib/native-app-identity.mjs +1 -1
  58. package/dist-lib/native-firebase-metadata.cjs +1 -1
  59. package/dist-lib/native-firebase-metadata.mjs +1 -1
  60. package/dist-lib/pdfium-raster.cjs +1 -1
  61. package/dist-lib/pdfium-raster.mjs +1 -1
  62. package/dist-lib/plist.cjs +1 -1
  63. package/dist-lib/plist.mjs +1 -1
  64. package/dist-lib/profiles.cjs +1 -1
  65. package/dist-lib/public-brand.cjs +1 -1
  66. package/dist-lib/public-origins-lib-esm.json +26 -24
  67. package/dist-lib/public-origins-lib.json +66 -54
  68. package/dist-lib/react-native-host-modules.cjs +1 -1
  69. package/dist-lib/react-native-host-modules.mjs +1 -1
  70. package/dist-lib/reap-browser.cjs +1 -1
  71. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  72. package/dist-lib/sdk.cjs +1 -1
  73. package/dist-lib/sdk.mjs +1 -1
  74. package/dist-lib/skills.cjs +1049 -512
  75. package/dist-lib/swift-compile.cjs +557 -121
  76. package/dist-lib/swift-compile.mjs +693 -258
  77. package/dist-lib/swift-package.cjs +1 -1
  78. package/dist-lib/swift-package.mjs +1 -1
  79. package/dist-lib/swift-submit.cjs +1 -1
  80. package/dist-lib/swift-submit.mjs +1 -1
  81. package/dist-lib/swift-toolchain.cjs +38 -2
  82. package/dist-lib/swift.cjs +1 -1
  83. package/dist-lib/vite-swift.cjs +1726 -1209
  84. package/dist-lib/vite.cjs +55 -12
  85. package/dist-lib/worklet-executable.cjs +1 -1
  86. package/dist-lib/worklet-executable.mjs +1 -1
  87. package/dist-types/packages/peach-engine/src/bundle-parse-receipt.d.ts +17 -0
  88. package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +2 -1
  89. package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +2 -2
  90. package/dist-types/packages/peach-engine/src/engine/native-layout.d.ts +1 -0
  91. package/dist-types/packages/peach-engine/src/engine/native-paragraph.d.ts +4 -0
  92. package/dist-types/packages/peach-engine/src/engine/node.d.ts +2 -0
  93. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -1
  94. package/dist-types/packages/peach-engine/src/engine/types.d.ts +7 -0
  95. package/dist-types/packages/peach-engine/src/engine/yoga-layout.d.ts +2 -0
  96. package/dist-types/packages/peach-engine/src/metro-fingerprint.d.ts +3 -2
  97. package/dist-types/packages/peach-engine/src/preview/preview-room-contract.d.ts +6 -0
  98. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +1 -0
  99. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +15 -3
  100. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +0 -5
  101. package/dist-types/packages/peach-kit/src/capabilities.d.ts +2 -0
  102. package/dist-types/packages/peach-kit/src/internal.d.ts +1 -1
  103. package/dist-types/packages/peach-kit/src/ios-tint.d.ts +2 -0
  104. package/kotlin/sdk.tar.gz +0 -0
  105. package/package.json +1 -1
  106. package/runtime-companion.json +1 -1
  107. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCGTypes.h +0 -6
  108. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSCharacterSet.h +1 -1
  109. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSURL.h +1 -1
  110. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIControl.h +0 -26
  111. package/sdk/ios/System/Library/Frameworks/UIKitTypes.framework/Headers/UIKitTypes.h +27 -0
  112. package/sdk/ios/usr/include/AvailabilityInternal.h +2 -2
  113. package/sdk/ios/usr/include/ObjectiveC.apinotes +380 -7
  114. package/sdk/ios/usr/include/peach/pthread.h +1 -7
  115. package/sdk/ios/wasm/include/TargetConditionals.h +2 -3
  116. package/sdk/ios/wasm/include/__struct_timeval.h +15 -0
  117. package/sdk/ios/wasm/include/__typedef_suseconds_t.h +9 -0
  118. package/sdk/ios/wasm/include/limits.h +1 -1
  119. package/sdk/ios/wasm/include/machine/_types.h +1 -1
  120. package/sdk/ios/wasm/include/machine/limits.h +1 -1
  121. package/sdk/ios/wasm/include/machine/param.h +2 -2
  122. package/sdk/ios/wasm/include/math.h +13 -0
  123. package/sdk/ios/wasm/include/pthread.h +1 -13
  124. package/sdk/ios/wasm/include/sys/resource.h +3 -0
  125. package/sdk/ios/wasm/include/sys/socket.h +0 -10
  126. package/sdk/ios/wasm/include/sys/stat.h +5 -2
  127. package/sdk/ios/wasm/include/sys/time.h +16 -3
  128. package/sdk/ios/wasm/include/sys/types.h +4 -1
  129. package/sdk/ios/wasm/include/time.h +2 -0
  130. package/sdk/ios/wasm/storage-include/TargetConditionals.h +2 -3
  131. package/sdk/native-hashes.json +14 -14
  132. package/src/metro-production-bundle.ts +15 -2
  133. package/src/native-slices.ts +3 -2
  134. package/src/native-static-libraries.ts +23 -23
  135. package/src/native-swift-slices.ts +2 -2
  136. package/src/nitro-adapter.lock.json +288 -288
  137. package/src/nitro-compiler-digest.ts +0 -1
  138. package/src/nitro-dependencies.ts +8 -9
  139. package/src/nitro-superset.lock.json +4 -4
  140. package/src/react-native-core-build.ts +2 -2
  141. package/src/swift-compile.ts +209 -47
  142. package/src/swift-compiler-digest.ts +2 -0
  143. package/src/swift-cxx-standin.ts +1 -1
  144. package/src/swift-darwin-records.ts +4 -4
  145. package/src/swift-distribution-contract.ts +2 -2
  146. package/src/swift-distribution.lock.json +13 -12
  147. package/src/swift-guest-compile.ts +6 -5
  148. package/src/swift-guest-image-ledger.ts +5 -5
  149. package/src/swift-guest-link.ts +1 -1
  150. package/src/swift-guest-linked-spans.ts +7 -4
  151. package/src/swift-guest-manifest.ts +2 -2
  152. package/src/swift-guest-source-inputs.ts +16 -5
  153. package/src/swift-host.ts +10 -5
  154. package/src/swift-icu.ts +1 -1
  155. package/src/swift-objc-compile.ts +9 -4
  156. package/src/swift-objc-standin.ts +1 -4
  157. package/src/swift-package-manifest.ts +5 -1
  158. package/src/swift-packages.ts +2 -2
  159. package/src/swift-shared-sdk.ts +1 -1
  160. package/src/swift-standin-emit.ts +3 -16
  161. package/src/swift-standins.ts +119 -87
  162. package/src/swift-toolchain.ts +37 -1
  163. package/src/swift-uniform-type-constants.ts +1 -1
  164. package/src/swift-wasm-prune.ts +17 -12
  165. package/src/swiftGuestImageContract.ts +4 -4
  166. package/src/swiftNativePinContract.ts +1 -1
  167. package/src/swiftRuntimeProductContract.ts +1 -1
  168. package/src/turbo-runtime.lock.json +28 -28
  169. package/src/wasm-narrow-boundary.ts +296 -0
  170. package/src/wasm-optimize.ts +59 -14
  171. package/src/xcode-project.ts +6 -4
@@ -6,6 +6,7 @@ import {
6
6
  } from 'node:child_process'
7
7
  import { createHash, randomUUID } from 'node:crypto'
8
8
  import {
9
+ chmodSync,
9
10
  copyFileSync,
10
11
  cpSync,
11
12
  existsSync,
@@ -48,6 +49,7 @@ import {
48
49
  } from './swift-distribution-contract'
49
50
  import { foundationCategoryObjects } from './swift-foundation'
50
51
  import { compileGuestLink } from './swift-guest-compile'
52
+ import { CLANG_TARGET_MODULE_WRAPPER } from './swift-guest-source-inputs'
51
53
  import {
52
54
  brotliCompressQ11,
53
55
  brotliCompressQ4,
@@ -140,7 +142,7 @@ import {
140
142
  SWIFT_FRAMEWORK_PRODUCT_FILE,
141
143
  swiftFrameworkProductSchema,
142
144
  } from './swiftRuntimeProductContract'
143
- import { KEEP_WASM_NAMES, optimizeWasm, WASM_OPTIMIZE_IDENTITY } from './wasm-optimize'
145
+ import { KEEP_WASM_NAMES, lowerWasm, WASM_LOWER_IDENTITY } from './wasm-optimize'
144
146
  import { writeBuildFile } from './write-build-file'
145
147
  import { writeXcodeHeaderSearch } from './xcode-header-search'
146
148
  import type { SwiftImageUpload } from './swift-submit'
@@ -263,7 +265,7 @@ async function runCompiler(
263
265
  }
264
266
  }
265
267
 
266
- export const WASM_TRIPLE = 'wasm32-unknown-wasip1'
268
+ export const WASM_TRIPLE = 'wasm64-unknown-wasip1'
267
269
 
268
270
  // swiftpm's step counter, echoed while a build runs; its diagnostics print
269
271
  // once, with the failure.
@@ -435,6 +437,26 @@ const clangInterfaceHeader = (header: string): string =>
435
437
  .replace(/\b_TtC10Foundation\d+(NS\w+)\b/g, '$1')
436
438
  .replace(/\b__attribute__\(\(objc_subclassing_restricted\)\)\s*/g, '')
437
439
 
440
+ export function swiftHeaderWithSuperclassImports(
441
+ header: string,
442
+ interfaceFor: (name: string) => { file: string; header: string } | null,
443
+ ): string {
444
+ const superclasses = new Set(
445
+ [...header.matchAll(/@interface\s+\w+\s*:\s*(\w+)/g)].map((match) => match[1]!),
446
+ )
447
+ return header.replace(/^@import (\w+);$/gm, (statement, name: string) => {
448
+ const dependency = interfaceFor(name)
449
+ if (
450
+ !dependency ||
451
+ ![...swiftInterfaceDeclarations(dependency.header)].some((name) =>
452
+ superclasses.has(name),
453
+ )
454
+ )
455
+ return statement
456
+ return `${statement}\n#import ${JSON.stringify(dependency.file)}`
457
+ })
458
+ }
459
+
438
460
  /** the Objective-C protocols and classes a generated interface header defines. */
439
461
  export const swiftInterfaceDeclarations = (header: string): Set<string> =>
440
462
  new Set([
@@ -906,7 +928,7 @@ export function swiftOptionalFramework(name: string): boolean {
906
928
  // an import may carry attributes (`@_exported`, `@preconcurrency`) and a
907
929
  // declaration kind (`import struct Nuke.ImageRequest`).
908
930
  const SWIFT_IMPORT =
909
- /^\s*(?:@\w+(?:\([^)]*\))?\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/
931
+ /^\s*(?:@\w+(?:\([^)]*\))?\s+|(?:public|package|internal|fileprivate|private)\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/
910
932
 
911
933
  // three-valued (kleene) logic shared by the swift and c condition
912
934
  // evaluators: an undecided operand only decides when the other forces the
@@ -933,7 +955,7 @@ const kleeneOr = (
933
955
  : undefined
934
956
 
935
957
  // a compilation condition as the wasm compile sees it after the source
936
- // rewrite below: `os(iOS)` and `os(WASI)` hold, other platforms do not,
958
+ // rewrite below: `os(iOS)` holds, other platforms (WASI too) do not,
937
959
  // `canImport` holds for an available module. what the scan cannot know
938
960
  // (custom flags, swift versions, features) is undefined, three-valued
939
961
  // through `!`, `&&` and `||`.
@@ -956,10 +978,11 @@ function swiftCondition(
956
978
  const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? '')
957
979
  if (!call) return undefined
958
980
  const [, name, argument] = call
959
- if (name === 'os') return argument === 'iOS' || argument === 'WASI'
960
- if (name === 'canImport') return available?.has(argument!)
981
+ if (name === 'os') return argument === 'iOS'
982
+ if (name === 'canImport')
983
+ return argument !== 'FoundationNetworking' && available?.has(argument!)
961
984
  if (name === 'targetEnvironment') return argument === 'simulator'
962
- if (name === 'arch') return argument === 'wasm32'
985
+ if (name === 'arch') return argument === 'wasm64'
963
986
  return undefined
964
987
  }
965
988
  const both = (): boolean | undefined => {
@@ -1103,7 +1126,7 @@ export function swiftSdkPaths(
1103
1126
  ...options,
1104
1127
  '--show-configuration',
1105
1128
  sdk,
1106
- 'wasm32-unknown-wasip1',
1129
+ 'wasm64-unknown-wasip1',
1107
1130
  ],
1108
1131
  { encoding: 'utf8', env: swiftEnvironment(), stdio: ['ignore', 'pipe', 'pipe'] },
1109
1132
  )
@@ -1636,6 +1659,19 @@ export const FOUNDATION_IMPLICIT_MODULES = [
1636
1659
  'PeachFoundationCombine',
1637
1660
  'Darwin',
1638
1661
  ]
1662
+ // darwin's Foundation is one module, so `@preconcurrency import Foundation`
1663
+ // (or of UIKit or SwiftUI, which re-export it) relaxes Sendable checking for
1664
+ // everything it exports. Peach splits that surface across ObjectiveC and the
1665
+ // implicit modules, and swift credits a type's import attributes to a direct
1666
+ // import of its own module before the first re-exporting import, which is
1667
+ // always an implicit one. naming each split module under the same attribute
1668
+ // gives the darwin result; the guard keeps host-built macro sources intact.
1669
+ const PRECONCURRENCY_FOUNDATION_IMPORT =
1670
+ /^[ \t]*@preconcurrency[ \t]+(?:(?:public|package|internal|fileprivate|private)[ \t]+)?import[ \t]+(?:Foundation|UIKit|SwiftUI)[ \t]*(?:\/\/.*)?$/m
1671
+ export function withPreconcurrencyFoundationModules(source: string): string {
1672
+ if (!PRECONCURRENCY_FOUNDATION_IMPORT.test(source)) return source
1673
+ return `${source}${source.endsWith('\n') ? '' : '\n'}#if canImport(PeachObjC)\n${['ObjectiveC', ...FOUNDATION_IMPLICIT_MODULES].map((module) => `@preconcurrency import ${module}\n`).join('')}#endif\n`
1674
+ }
1639
1675
  const FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
1640
1676
  (module) => `, "-Xfrontend", "-import-module", "-Xfrontend", "${module}"`,
1641
1677
  ).join('')
@@ -1689,7 +1725,8 @@ export function swiftArtifactHash(
1689
1725
  if (input.oneModule) hash.update('one-module\n')
1690
1726
  if (KEEP_WASM_NAMES) hash.update('names\n')
1691
1727
  hash.update(swiftModuleDigest(moduleRoot))
1692
- if (input.optimize) hash.update(`optimize\n${WASM_OPTIMIZE_IDENTITY}\n`)
1728
+ hash.update(`lower\n${WASM_LOWER_IDENTITY}\n`)
1729
+ if (input.optimize) hash.update('optimize\n')
1693
1730
  for (const file of Object.keys(input.files).sort()) {
1694
1731
  hash.update(createHash('sha256').update(file).digest())
1695
1732
  hash.update(createHash('sha256').update(input.files[file]).digest())
@@ -1855,6 +1892,10 @@ function toolsetOrdersLibcxxBeforeDarwinOverlay(options: readonly string[]): boo
1855
1892
  return libcxx >= 0 && overlay > libcxx
1856
1893
  }
1857
1894
 
1895
+ // the iOS minimum swiftpm gives a package that declares no iOS platform
1896
+ // (swift-package-manager PackageModel Platform.iOS oldestSupportedVersion).
1897
+ const SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET = '12.0'
1898
+
1858
1899
  export function emitSwiftPackageManifest(args: {
1859
1900
  /** the build root holding the linker each executable links with. */
1860
1901
  root: string
@@ -2230,7 +2271,8 @@ export function emitSwiftPackageManifest(args: {
2230
2271
  ? `, "-emit-objc-header-path", ${JSON.stringify(path.join(args.headerDirectory, `${target.name}-Swift${args.nativeHeaderDeclarations?.[target.name] ? '.original' : ''}.h`))}`
2231
2272
  : ''
2232
2273
  const clangMode = target.cxxInterop ? '' : ', "-Xcc", "-fno-cxx-modules"'
2233
- const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ''}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${upstream}]`)})]`
2274
+ const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`
2275
+ const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ''}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`
2234
2276
  const deps = [
2235
2277
  ...new Set([
2236
2278
  ...(target.dependencies ?? []).flatMap((dependency) =>
@@ -2500,12 +2542,16 @@ export function syncSwiftTree(base: string, files: Map<string, string | Buffer>)
2500
2542
  // every iOS branch of the app would compile out. peach is the iOS simulator,
2501
2543
  // so `targetEnvironment(simulator)` holds too. a condition line names iOS
2502
2544
  // as `true` padded to the same length, so diagnostics keep their columns;
2503
- // os(WASI) still holds for code written for wasm. only `#if` and `#elseif`
2504
- // lines that begin in code change: a line inside a string literal or a block
2505
- // comment is content. the artifact hash stays over the original text.
2545
+ // `os(WASI)` is `false` the same way, as on iOS, so a package takes the
2546
+ // branch its iOS app runs. only `#if` and `#elseif` lines that begin in code
2547
+ // change: a line inside a string literal or a block comment is content. the
2548
+ // artifact hash stays over the original text.
2506
2549
  // objective-c syntax is compiled unchanged by the native importer.
2507
2550
  const DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/
2508
2551
  const OS_IOS = /\b(?:os\(\s*iOS\s*\)|targetEnvironment\(\s*simulator\s*\))/g
2552
+ // iOS has no FoundationNetworking module; Peach's is imported implicitly
2553
+ // and gated packages must take their Apple branch
2554
+ const NOT_ON_IOS = /\b(?:os\(\s*WASI\s*\)|canImport\(\s*FoundationNetworking\s*\))/g
2509
2555
  // uikit makes app and scene delegates from their class through the objc
2510
2556
  // runtime; here their protocols require init(), which a non-final class
2511
2557
  // meets only with a required one. a class declaring one of them that is
@@ -2532,19 +2578,17 @@ function compiledSwiftSources(
2532
2578
  )
2533
2579
  })
2534
2580
  const manifest = /(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file)
2535
- return [
2536
- file,
2537
- manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file))
2538
- ? source
2539
- : swiftSourceAsIOS(
2540
- source,
2541
- overlayFrameworks,
2542
- owner?.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) &&
2543
- !owner.defines.includes('SWIFT_PACKAGE')
2544
- ? false
2545
- : undefined,
2546
- ),
2547
- ]
2581
+ if (manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)))
2582
+ return [file, source]
2583
+ const ios = swiftSourceAsIOS(
2584
+ source,
2585
+ overlayFrameworks,
2586
+ owner?.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) &&
2587
+ !owner.defines.includes('SWIFT_PACKAGE')
2588
+ ? false
2589
+ : undefined,
2590
+ )
2591
+ return [file, withPreconcurrencyFoundationModules(ios)]
2548
2592
  }),
2549
2593
  )
2550
2594
  }
@@ -3251,21 +3295,26 @@ export function foundationOwnerOf(name: string): string | undefined {
3251
3295
  return undefined
3252
3296
  }
3253
3297
 
3254
- export function swiftSourceAsIOS(
3298
+ // dependency sources take the same platform branches as app sources
3299
+ function swiftPackageSourceAsIOS(source: string): string {
3300
+ return swiftConditionsAsIOS(source, swiftCodeScan(source).lineStarts)
3301
+ }
3302
+
3303
+ function swiftConditionsAsIOS(
3255
3304
  source: string,
3256
- overlayFrameworks: () => ReadonlySet<string>,
3305
+ lineStarts: ReadonlySet<number>,
3257
3306
  swiftPackage?: boolean,
3258
3307
  ): string {
3259
- const { lineStarts, tokens } = swiftCodeScan(source)
3260
3308
  let offset = 0
3261
- // equal width, so every token offset still holds
3262
- const conditioned = source
3309
+ return source
3263
3310
  .split('\n')
3264
3311
  .map((line) => {
3265
3312
  const start = offset
3266
3313
  offset += line.length + 1
3267
3314
  if (!lineStarts.has(start) || !DIRECTIVE.test(line)) return line
3268
- const platform = line.replace(OS_IOS, (match) => 'true'.padEnd(match.length))
3315
+ const platform = line
3316
+ .replace(OS_IOS, (match) => 'true'.padEnd(match.length))
3317
+ .replace(NOT_ON_IOS, (match) => 'false'.padEnd(match.length))
3269
3318
  // SwiftPM is the backend for Xcode targets, whose original conditions
3270
3319
  // do not include its automatically injected SWIFT_PACKAGE definition.
3271
3320
  return swiftPackage === false
@@ -3273,6 +3322,16 @@ export function swiftSourceAsIOS(
3273
3322
  : platform
3274
3323
  })
3275
3324
  .join('\n')
3325
+ }
3326
+
3327
+ export function swiftSourceAsIOS(
3328
+ source: string,
3329
+ overlayFrameworks: () => ReadonlySet<string>,
3330
+ swiftPackage?: boolean,
3331
+ ): string {
3332
+ const { lineStarts, tokens } = swiftCodeScan(source)
3333
+ // equal width, so every token offset still holds
3334
+ const conditioned = swiftConditionsAsIOS(source, lineStarts, swiftPackage)
3276
3335
  let out = ''
3277
3336
  let copied = 0
3278
3337
  const sceneLifecycleBodies = new Set<number>()
@@ -3859,7 +3918,7 @@ function stripCCode(source: string): string {
3859
3918
  return code
3860
3919
  }
3861
3920
 
3862
- // whether the unit's code under wasm32 takes its own return address, which
3921
+ // whether the unit's wasm code takes its own return address, which
3863
3922
  // the WebAssembly backend rejects ("hasn't implemented __builtin_return_address"):
3864
3923
  // native machine code the target has no lowering for, like assembly. branches
3865
3924
  // the native architecture macros guard are not wasm code.
@@ -3867,7 +3926,7 @@ const wasmMacroEnvironment: SwiftCMacroEnvironment = {
3867
3926
  ...emptyMacroEnvironment,
3868
3927
  defines: new Map([
3869
3928
  ['__wasm__', '1'],
3870
- ['__wasm32__', '1'],
3929
+ ['__wasm64__', '1'],
3871
3930
  ['__wasi__', '1'],
3872
3931
  ]),
3873
3932
  }
@@ -5883,8 +5942,17 @@ export function writeSwiftProject(
5883
5942
  }) + moduleFiles,
5884
5943
  )
5885
5944
  }
5886
- for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
5887
- files.set(path.join(layout.root, file), Buffer.from(bytes, 'base64'))
5945
+ for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
5946
+ const contents = Buffer.from(bytes, 'base64')
5947
+ files.set(
5948
+ path.join(layout.root, file),
5949
+ file.endsWith('.swift') && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file)
5950
+ ? withPreconcurrencyFoundationModules(
5951
+ swiftPackageSourceAsIOS(contents.toString('utf8')),
5952
+ )
5953
+ : contents,
5954
+ )
5955
+ }
5888
5956
  for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
5889
5957
  const destination = path.join(layout.root, file)
5890
5958
  if (files.has(destination)) continue
@@ -5904,15 +5972,43 @@ export function writeSwiftProject(
5904
5972
  ]
5905
5973
  : []),
5906
5974
  ]
5975
+ // swiftpm compiles a package's C and Objective-C targets with -fmodules
5976
+ // and -fmodule-name=<target> only on darwin triples, so `@import UIKit`
5977
+ // in an iOS package compiles natively and fails on wasm. the toolset
5978
+ // passes -fmodules; this names the target from the <target>.build
5979
+ // directory swiftpm writes its objects to, so a target's own headers stay
5980
+ // textual as on darwin.
5981
+ const clangWrapper = path.join(layout.root, CLANG_TARGET_MODULE_WRAPPER)
5982
+ files.set(
5983
+ clangWrapper,
5984
+ [
5985
+ '#!/bin/sh',
5986
+ 'name=',
5987
+ 'prev=',
5988
+ 'for arg in "$@"; do',
5989
+ ' if [ "$prev" = -o ]; then name=${arg%/*}; name=${name##*/}; fi',
5990
+ ' prev=$arg',
5991
+ 'done',
5992
+ 'case $name in',
5993
+ ` *.build) exec '${path.join(nativeToolchain(), 'clang')}' "-fmodule-name=\${name%.build}" "$@" ;;`,
5994
+ ` *) exec '${path.join(nativeToolchain(), 'clang')}' "$@" ;;`,
5995
+ 'esac',
5996
+ '',
5997
+ ].join('\n'),
5998
+ )
5907
5999
  files.set(
5908
6000
  path.join(layout.root, '.peach-target-toolset.json'),
5909
6001
  JSON.stringify({
5910
6002
  schemaVersion: '1.0',
6003
+ cCompiler: {
6004
+ extraCLIOptions: [
6005
+ ...nativeToolsetFlags,
6006
+ '-fmodules',
6007
+ `-fmodules-cache-path=${path.join(layout.root, '.build', 'ModuleCache')}`,
6008
+ ],
6009
+ },
5911
6010
  ...(nativeToolsetFlags.length > 0
5912
- ? {
5913
- cCompiler: { extraCLIOptions: nativeToolsetFlags },
5914
- cxxCompiler: { extraCLIOptions: nativeToolsetFlags },
5915
- }
6011
+ ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } }
5916
6012
  : {}),
5917
6013
  swiftCompiler: {
5918
6014
  extraCLIOptions: [
@@ -6004,6 +6100,8 @@ export function writeSwiftProject(
6004
6100
  '// dependency targets emit their native compatibility headers.\n',
6005
6101
  )
6006
6102
  syncSwiftTree(layout.root, files)
6103
+ const clangWrapper = path.join(layout.root, CLANG_TARGET_MODULE_WRAPPER)
6104
+ if (files.has(clangWrapper)) chmodSync(clangWrapper, 0o755)
6007
6105
  // header-consuming units have moved downstream. only the emitted target
6008
6106
  // graph describes which producer builds already emit another header.
6009
6107
  const dependencies = new Map(
@@ -6619,6 +6717,9 @@ async function buildFrameworkProducts(
6619
6717
  'release',
6620
6718
  '-Xswiftc',
6621
6719
  '-Osize',
6720
+ // the release link strips all debug info, so none is generated
6721
+ '-Xswiftc',
6722
+ '-gnone',
6622
6723
  '-Xswiftc',
6623
6724
  '-num-threads',
6624
6725
  '-Xswiftc',
@@ -7262,14 +7363,18 @@ function compileSwiftProjectOnce(
7262
7363
  const projectProcess = options.project
7263
7364
  ? prepareSwiftProjectProcess(root, options.project)
7264
7365
  : undefined
7366
+ // the native build system takes its C compiler from CC, never a toolset
7367
+ const compiler: Record<string, string> = preparation.targetToolset
7368
+ ? { CC: path.join(root, CLANG_TARGET_MODULE_WRAPPER) }
7369
+ : {}
7265
7370
  const appOptions = projectProcess
7266
7371
  ? {
7267
7372
  ...buildOptions,
7268
7373
  uid: projectProcess.uid,
7269
7374
  gid: projectProcess.gid,
7270
- confined: projectProcess.env,
7375
+ confined: { ...projectProcess.env, ...compiler },
7271
7376
  }
7272
- : buildOptions
7377
+ : { ...buildOptions, env: { ...buildOptions.env, ...compiler } }
7273
7378
  const unprepared = preparation.targetFailures.map(
7274
7379
  (failure) => `error: target ${failure}`,
7275
7380
  )
@@ -7306,6 +7411,9 @@ function compileSwiftProjectOnce(
7306
7411
  : []),
7307
7412
  '-c',
7308
7413
  'release',
7414
+ // the link strips debug info, so none is generated (as for the framework)
7415
+ '-Xswiftc',
7416
+ '-gnone',
7309
7417
  '-Xswiftc',
7310
7418
  '-num-threads',
7311
7419
  '-Xswiftc',
@@ -7349,6 +7457,58 @@ function compileSwiftProjectOnce(
7349
7457
  if (existsSync(linked) && statSync(linked).size <= 8)
7350
7458
  rmSync(linked, { force: true })
7351
7459
  report('compiling and linking Swift modules')
7460
+ const frameworkInterfaces = new Map<
7461
+ string,
7462
+ { file: string; header: string } | null
7463
+ >()
7464
+ const frameworkInterface = (
7465
+ name: string,
7466
+ ): { file: string; header: string } | null => {
7467
+ if (frameworkInterfaces.has(name)) return frameworkInterfaces.get(name)!
7468
+ const source = distribution
7469
+ ? path.join(frameworkRoot, 'modules', `${name}-Swift.h`)
7470
+ : path.join(
7471
+ prebuilt!.modules,
7472
+ '..',
7473
+ `${name}.build/include/${name}-Swift.h`,
7474
+ )
7475
+ if (!existsSync(source)) {
7476
+ frameworkInterfaces.set(name, null)
7477
+ return null
7478
+ }
7479
+ const headers = path.join(
7480
+ swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
7481
+ `System/Library/Frameworks/${name}.framework/Headers`,
7482
+ )
7483
+ const declared = new Set<string>()
7484
+ if (existsSync(headers))
7485
+ for (const file of readdirSync(headers, {
7486
+ recursive: true,
7487
+ encoding: 'utf8',
7488
+ }))
7489
+ if (file.endsWith('.h'))
7490
+ for (const name of swiftInterfaceDeclarations(
7491
+ readFileSync(path.join(headers, file), 'utf8'),
7492
+ ))
7493
+ declared.add(name)
7494
+ const header = withoutSwiftDeclarations(
7495
+ clangInterfaceHeader(readFileSync(source, 'utf8')),
7496
+ declared,
7497
+ `#import <${name}/${name}.h>`,
7498
+ )
7499
+ const value = {
7500
+ file: path.join(root, '.build/peach-framework-objc', `${name}-Swift.h`),
7501
+ header,
7502
+ }
7503
+ frameworkInterfaces.set(name, value)
7504
+ writeBuildFile(
7505
+ value.file,
7506
+ (existsSync(path.join(headers, `${name}.h`))
7507
+ ? `#import <${name}/${name}.h>\n`
7508
+ : '') + swiftHeaderWithSuperclassImports(header, frameworkInterface),
7509
+ )
7510
+ return value
7511
+ }
7352
7512
  try {
7353
7513
  // clang consumes the real emitted headers after swift finishes.
7354
7514
  // swiftpm's transitive swift module maps are not C declarations:
@@ -7387,7 +7547,10 @@ function compileSwiftProjectOnce(
7387
7547
  writeBuildFile(
7388
7548
  emitted,
7389
7549
  withoutSwiftDeclarations(
7390
- clangInterfaceHeader(readFileSync(original, 'utf8')),
7550
+ swiftHeaderWithSuperclassImports(
7551
+ clangInterfaceHeader(readFileSync(original, 'utf8')),
7552
+ frameworkInterface,
7553
+ ),
7391
7554
  new Set(preparation.nativeHeaderDeclarations[producer]),
7392
7555
  `#import <${producer}/${producer}.h>`,
7393
7556
  ),
@@ -7522,16 +7685,15 @@ function compileSwiftProjectOnce(
7522
7685
  output,
7523
7686
  optimized,
7524
7687
  })
7525
- else if (input.optimize) await optimizeWasm(output, optimized)
7526
- const executable = input.optimize ? optimized : output
7688
+ else await lowerWasm(output, optimized, { optimize: input.optimize === true })
7527
7689
  await runCompiler(
7528
7690
  path.join(options.toolchainBin, 'llvm-objcopy'),
7529
- ['--remove-section=.swift1_autolink_entries', executable],
7691
+ ['--remove-section=.swift1_autolink_entries', optimized],
7530
7692
  buildOptions,
7531
7693
  )
7532
7694
  const artifact = {
7533
7695
  hash,
7534
- bytes: readFileSync(executable),
7696
+ bytes: readFileSync(optimized),
7535
7697
  icu: await icu,
7536
7698
  }
7537
7699
  if (artifact.bytes.length <= 8)
@@ -21,6 +21,8 @@ export const SWIFT_DIGEST_SOURCES = [
21
21
  'process-table.ts',
22
22
  'swift-link-roots.ts',
23
23
  'swift-wasm-prune.ts',
24
+ 'wasm-optimize.ts',
25
+ 'wasm-narrow-boundary.ts',
24
26
  'swift-guest-image-ledger.ts',
25
27
  'swift-guest-archive.ts',
26
28
  'swift-guest-link-plan.ts',
@@ -120,7 +120,7 @@ export async function emitCxxStandin(input: CxxInputs): Promise<{
120
120
  )
121
121
  const flags = [
122
122
  '-target',
123
- 'wasm32-unknown-wasip1',
123
+ 'wasm64-unknown-wasip1',
124
124
  '--sysroot',
125
125
  input.sysroot,
126
126
  ...WASI_EMULATION_FLAGS,
@@ -1,6 +1,6 @@
1
1
  // the darwin record providers (packages/sootsim-swift/Sources/DarwinRecords)
2
- // compiled for wasm32. they answer darwin's calls over the installed libc, so
3
- // they compile in its view, with the records' shared sdk tree. the wasm sdk
2
+ // compiled for wasm64. they answer darwin's calls over the installed libc,
3
+ // sysctl uses the client records; libc adapters retain the installed view. the sdk
4
4
  // ships them as libDarwinRecords.a for its own clients; a distribution and a
5
5
  // source checkout compile them from the same source as their Darwin module and
6
6
  // link them ahead of that archive (specs/peach/swift/darwin-libc-providers.md).
@@ -51,7 +51,7 @@ export function compileDarwinRecords(args: {
51
51
  execFileSync(
52
52
  path.join(args.bin, 'clang'),
53
53
  [
54
- '--target=wasm32-unknown-wasip1',
54
+ '--target=wasm64-unknown-wasip1',
55
55
  `--sysroot=${args.sysroot}`,
56
56
  '-Oz',
57
57
  '-g0',
@@ -64,7 +64,7 @@ export function compileDarwinRecords(args: {
64
64
  `-ffile-prefix-map=${records}${path.sep}=DarwinRecords/`,
65
65
  // apple's headers select on the ios identity original units compile
66
66
  // with, and TargetConditionals.h refuses a compiler without it
67
- ...(file.endsWith('.m')
67
+ ...(file === 'sysctl.c' || file.endsWith('.m')
68
68
  ? objcSdkIntakeFlags(args.darwin, args.bin, args.minimum)
69
69
  : [
70
70
  ...swiftObjCPlatformFlags(args.bin, args.minimum),
@@ -26,7 +26,7 @@ export function swiftDistributionHost(
26
26
  return SWIFT_DISTRIBUTION_HOSTS.find((candidate) => candidate === host) ?? null
27
27
  }
28
28
 
29
- /** the host-independent half: wasm32 modules and their objects. */
29
+ /** the host-independent half: wasm64 modules and their objects. */
30
30
  export interface SwiftDistributionWasm extends SwiftWasmSdk {
31
31
  /** the digest of the module sources it was built from (swiftModuleDigest). */
32
32
  id: string
@@ -34,7 +34,7 @@ export interface SwiftDistributionWasm extends SwiftWasmSdk {
34
34
  release: string
35
35
  /** the importable Swift modules under modules/. */
36
36
  modules: string[]
37
- /** the modules' wasm32 objects, relative to the root, in link order. */
37
+ /** the modules' wasm64 objects, relative to the root, in link order. */
38
38
  objects: string[]
39
39
  /** linker flags the objects autolink. */
40
40
  link: string[]
@@ -1,10 +1,10 @@
1
1
  {
2
- "id": "e7ae8fdb51086f73",
3
- "release": "swift-6.4.0-RELEASE-custom-11345d60dca47496",
4
- "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-19471d4b",
5
- "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-19471d4b.artifactbundle.tar.gz",
6
- "wasmSdkChecksum": "764c16e7e34156bf90d6c3372a2b77b98b9d8c3470235520d0f9619f90f33456",
7
- "source": "dbcdd2998c7a523cb5136f3731f6850cfe0bd154",
2
+ "id": "c7825880e72c77d4",
3
+ "release": "swift-6.4.0-RELEASE-custom-fb42d2535739dfd2",
4
+ "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-b577231e",
5
+ "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-b577231e.artifactbundle.tar.gz",
6
+ "wasmSdkChecksum": "9a8f0c694ada318ede49413cd72395e34a7fbb1b9a227b31eff8b05371ffb9aa",
7
+ "source": "071342e8371d62d839b1acf0b4462235ed263eae",
8
8
  "targets": [
9
9
  "ImagePlayground",
10
10
  "QuickLookThumbnailing",
@@ -216,6 +216,7 @@
216
216
  "deviceModel": ["string"],
217
217
  "systemName": ["string"],
218
218
  "systemVersion": ["string"],
219
+ "gameCenterPlayerIDs": ["array"],
219
220
  "screenMetrics": ["array"],
220
221
  "reservedRegions": ["array"],
221
222
  "colorScheme": ["string:light", "string:dark"],
@@ -244,16 +245,16 @@
244
245
  },
245
246
  "hosts": {
246
247
  "darwin-arm64": {
247
- "sha256": "8680805789e5212d83e374bea9e4af3e3c7a86011e8ebf4921e76a8eba092761",
248
- "size": 103496854
248
+ "sha256": "f932303a90b0119e4500f2569ed6b6c519430d7fddad998d8555d92493d0f30a",
249
+ "size": 104821966
249
250
  },
250
251
  "linux-x64": {
251
- "sha256": "9d82820dfdbc857d5127c489b9c704c9e9336fe8b010256cd5b1d24ba956f454",
252
- "size": 106214710
252
+ "sha256": "aed1395ab7cc4c464b2e32fa21096b85f343a9001cdb72e714444f54a5b6f91a",
253
+ "size": 107541215
253
254
  },
254
255
  "linux-arm64": {
255
- "sha256": "a8e5084e14867ca9245428e51cb9435bc5b34505914fa5855950951d01b6b990",
256
- "size": 105708986
256
+ "sha256": "c45ecac4feab55969b26bbf910258f49c1301552e9c523dd76a14dc7b221266e",
257
+ "size": 107034390
257
258
  }
258
259
  }
259
260
  }
@@ -32,7 +32,7 @@ import {
32
32
  planGuestSourceLink,
33
33
  } from './swift-guest-source-plan'
34
34
  import { frameworkRuntimeProductId } from './swift-runtime-products'
35
- import { optimizeWasm } from './wasm-optimize'
35
+ import { lowerWasm } from './wasm-optimize'
36
36
  import type { SwiftSourceLinkGraph } from './swiftContract'
37
37
  import type { SwiftGuestImageManifest } from './swiftGuestImageContract'
38
38
 
@@ -84,7 +84,7 @@ export async function compileGuestLink(options: {
84
84
  }
85
85
  const buildVersion = imageBuildVersion(entry.buildVersion)
86
86
  const clangOptions = [
87
- '--target=wasm32-unknown-wasip1',
87
+ '--target=wasm64-unknown-wasip1',
88
88
  `--sysroot=${options.sysroot}`,
89
89
  `-I${path.join(options.moduleRoot, 'include')}`,
90
90
  ]
@@ -437,9 +437,10 @@ export async function compileGuestLink(options: {
437
437
  },
438
438
  })
439
439
  if (!reserved || !projectionObject) throw new Error('guest projection was not reserved')
440
- await optimizeWasm(options.output, options.optimized, [
441
- 'duplicate-function-elimination',
442
- ])
440
+ await lowerWasm(options.output, options.optimized, {
441
+ optimize: true,
442
+ skipPasses: ['duplicate-function-elimination'],
443
+ })
443
444
  const map = readFileSync(result.mapPath, 'utf8')
444
445
  // no linked code reads the image records, so the link dropped them and
445
446
  // there is nothing to fill.
@@ -59,7 +59,7 @@ function readNumber(bytes: Uint8Array, position: number): [number, number] {
59
59
  let value = 0
60
60
  let shift = 0
61
61
  for (;;) {
62
- if (position >= bytes.length || shift > 28) throw new Error('invalid wasm integer')
62
+ if (position >= bytes.length || shift > 63) throw new Error('invalid wasm integer')
63
63
  const byte = bytes[position++]!
64
64
  value += (byte & 127) * 2 ** shift
65
65
  if (!(byte & 128)) return [value, position]
@@ -195,12 +195,12 @@ function rewriteObject(
195
195
  if (referenceType !== 0x70 && referenceType !== 0x6f)
196
196
  throw new Error('unsupported table type')
197
197
  const flags = number()
198
- if (flags & ~3) throw new Error('unsupported table limits')
198
+ if (flags & ~7) throw new Error('unsupported table limits')
199
199
  number()
200
200
  if (flags & 1) number()
201
201
  } else if (kind === 2) {
202
202
  const flags = number()
203
- if (flags & ~3) throw new Error('unsupported memory limits')
203
+ if (flags & ~7) throw new Error('unsupported memory limits')
204
204
  number()
205
205
  if (flags & 1) number()
206
206
  } else if (kind === 3) offset += 2
@@ -215,7 +215,7 @@ function rewriteObject(
215
215
  if (module === 'env' && names.has(name)) usedSymbols.add(name)
216
216
  if (isDlsym || isDlerror) {
217
217
  const type = types[functionType]
218
- const expected = isDlsym ? '127,127:127' : ':127'
218
+ const expected = isDlsym ? '126,126:126' : ':126'
219
219
  if (
220
220
  !type ||
221
221
  `${type.parameters.join(',')}:${type.results.join(',')}` !== expected
@@ -598,7 +598,7 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
598
598
  })
599
599
  .join('')
600
600
  const ir = [
601
- 'target triple = "wasm32-unknown-wasip1"',
601
+ 'target triple = "wasm64-unknown-wasip1"',
602
602
  `@.names = private constant [${nameSize} x i8] c"${nameContents}"`,
603
603
  ]
604
604
  for (const definition of exported.values()) {