peachsim 0.1.2596 → 0.1.2597

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 (138) 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 +969 -423
  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-WGTQK4JN.mjs → acorn-55PXV665.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-IGMABYTC.mjs → chunk-3DRJIOHV.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-BNXCKF2B.mjs → chunk-42RIRPTB.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-WPX7HLFR.mjs → chunk-56YYEI6C.mjs} +7 -6
  30. package/dist-lib/esm-chunks/{chunk-FDMS7FWE.mjs → chunk-7ECUAVIA.mjs} +2 -2
  31. package/dist-lib/esm-chunks/{chunk-4PMXT2UO.mjs → chunk-7J65FNXI.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-SYCOZ2CT.mjs → chunk-AJHFCIEU.mjs} +4 -4
  33. package/dist-lib/esm-chunks/{chunk-4MMPS5YL.mjs → chunk-CKUEWEY4.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-QEGUUPRI.mjs → chunk-DCL2ZEGA.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-4UUWP6NP.mjs → chunk-GECWNEHA.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-5NZPSLS4.mjs → chunk-GRGNTIO7.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-ZVBBDMPW.mjs → chunk-GZD5CTG7.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-ISZE675P.mjs → chunk-HATXI62T.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-TILPABC4.mjs → chunk-INA4S3MF.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-3C2YVQZH.mjs → chunk-IPN35TGX.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-SPKD6UYK.mjs → chunk-LH524OUR.mjs} +3 -3
  42. package/dist-lib/esm-chunks/{chunk-DY6PUVXF.mjs → chunk-MMHNSEZY.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-BAEOHCN5.mjs → chunk-NWLCTKBM.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-HZPXGVY4.mjs → chunk-O5FDNHDG.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-TNZG7SFG.mjs → chunk-ROFBHGEA.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-UCIOSXXU.mjs → chunk-V6SI2XY7.mjs} +963 -490
  47. package/dist-lib/esm-chunks/{chunk-C3C5OJG4.mjs → chunk-VN7BXTMG.mjs} +5 -5
  48. package/dist-lib/esm-chunks/{chunk-LZF4BVEY.mjs → chunk-Y4XMEBRN.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{metro-layout-parser-QNM3HYV7.mjs → metro-layout-parser-5FUYCP6P.mjs} +3 -3
  50. package/dist-lib/esm-chunks/{swift-package-prebuilt-BXXQB7Q2.mjs → swift-package-prebuilt-W3VMDYHC.mjs} +10 -10
  51. package/dist-lib/esm-chunks/{swift-sdk-app-module-FKL3X2ZC.mjs → swift-sdk-app-module-ZHGBY6T7.mjs} +126 -56
  52. package/dist-lib/esm-chunks/{swift-sdk-image-CCVWDFHB.mjs → swift-sdk-image-2PC4PKHZ.mjs} +14 -14
  53. package/dist-lib/esm-chunks/{swift-sdk-image-producer-OTMZVBDN.mjs → swift-sdk-image-producer-WDN6BXQL.mjs} +4 -4
  54. package/dist-lib/expo-swift-bundle.cjs +968 -422
  55. package/dist-lib/expo-swift-metadata.cjs +1 -1
  56. package/dist-lib/expo-swift-metadata.mjs +7 -7
  57. package/dist-lib/home-paths.cjs +1 -1
  58. package/dist-lib/host/bridge-host.cjs +969 -423
  59. package/dist-lib/host/fetch-proxy-handler.cjs +36 -6
  60. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  61. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  62. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  63. package/dist-lib/host/websocket-proxy.cjs +1 -1
  64. package/dist-lib/index.cjs +1 -1
  65. package/dist-lib/kotlin-host.cjs +1 -1
  66. package/dist-lib/menu.cjs +1 -1
  67. package/dist-lib/menu.mjs +3 -3
  68. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  69. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  70. package/dist-lib/metro-production-bundle.cjs +1 -1
  71. package/dist-lib/metro-production-bundle.mjs +4 -4
  72. package/dist-lib/native-app-identity-project.cjs +34 -4
  73. package/dist-lib/native-app-identity-project.mjs +16 -16
  74. package/dist-lib/native-app-identity.cjs +1 -1
  75. package/dist-lib/native-app-identity.mjs +6 -6
  76. package/dist-lib/native-firebase-metadata.cjs +1 -1
  77. package/dist-lib/native-firebase-metadata.mjs +3 -3
  78. package/dist-lib/pdfium-raster.cjs +1 -1
  79. package/dist-lib/pdfium-raster.mjs +2 -2
  80. package/dist-lib/plist.cjs +1 -1
  81. package/dist-lib/plist.mjs +3 -3
  82. package/dist-lib/profiles.cjs +1 -1
  83. package/dist-lib/public-brand.cjs +1 -1
  84. package/dist-lib/public-origins-lib-esm.json +81 -81
  85. package/dist-lib/public-origins-lib.json +69 -69
  86. package/dist-lib/react-native-host-modules.cjs +1 -1
  87. package/dist-lib/react-native-host-modules.mjs +2 -2
  88. package/dist-lib/reap-browser.cjs +1 -1
  89. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  90. package/dist-lib/sdk.cjs +1 -1
  91. package/dist-lib/sdk.mjs +8 -8
  92. package/dist-lib/skills.cjs +970 -424
  93. package/dist-lib/swift-compile.cjs +966 -420
  94. package/dist-lib/swift-compile.mjs +10 -10
  95. package/dist-lib/swift-package.cjs +1 -1
  96. package/dist-lib/swift-package.mjs +3 -3
  97. package/dist-lib/swift-submit.cjs +1 -1
  98. package/dist-lib/swift-submit.mjs +6 -6
  99. package/dist-lib/swift-svg-raster.cjs +1 -1
  100. package/dist-lib/swift-svg-raster.mjs +2 -2
  101. package/dist-lib/swift-toolchain.cjs +1 -1
  102. package/dist-lib/swift.cjs +1 -1
  103. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  104. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  105. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  106. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  107. package/dist-lib/vendor/acorn.cjs +1 -1
  108. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  109. package/dist-lib/vendor/ignore.cjs +1 -1
  110. package/dist-lib/vendor/magic-string.cjs +1 -1
  111. package/dist-lib/vendor/plist.cjs +1 -1
  112. package/dist-lib/vendor/smol-toml.cjs +1 -1
  113. package/dist-lib/vendor/stream-json.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  117. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  118. package/dist-lib/vendor/sucrase.cjs +1 -1
  119. package/dist-lib/vendor/terser.cjs +1 -1
  120. package/dist-lib/vendor/valibot.cjs +1 -1
  121. package/dist-lib/vendor/ws.cjs +1 -1
  122. package/dist-lib/vendor/zod.cjs +1 -1
  123. package/dist-lib/worklet-executable.cjs +1 -1
  124. package/dist-lib/worklet-executable.mjs +3 -3
  125. package/dist-types/packages/peach-engine/src/render-worker/nativeAnimMirrorContract.d.ts +0 -2
  126. package/package.json +1 -1
  127. package/src/swift-compile.ts +421 -175
  128. package/src/swift-guest-compile.ts +16 -0
  129. package/src/swift-guest-image-ledger.ts +65 -14
  130. package/src/swift-guest-link.ts +21 -0
  131. package/src/swift-guest-manifest.ts +27 -5
  132. package/src/swift-guest-source-inputs.ts +119 -14
  133. package/src/swift-sdk-app-module.ts +128 -55
  134. package/src/swift-sdk-image-wasm.ts +76 -39
  135. package/src/swift-sdk-image.ts +2 -1
  136. package/src/swift-wasm-prune.ts +282 -222
  137. package/src/wasm-optimize.ts +1 -1
  138. package/src/write-build-file.ts +9 -8
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2596 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2597 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -5712,13 +5712,13 @@ var init_swift_standin_digest = __esm({
5712
5712
  STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
5713
5713
  SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
5714
5714
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
5715
- STANDIN_SOURCE_DIGEST = true ? "1c18ee984fb850e9cae4edbd880543482bce4e531c8c17dab14608646edfe47d" : standinSourceDigest();
5715
+ STANDIN_SOURCE_DIGEST = true ? "803880cad876e27e4e621723b8eae85b3c486a882db0f0f745babaf80c070680" : standinSourceDigest();
5716
5716
  }
5717
5717
  });
5718
5718
 
5719
5719
  // src/expo-native-compiler-digest.ts
5720
5720
  function expoNativeCompilerDigestValue() {
5721
- return true ? "56c5386e790e97ea00592b0a6a272d29e6c69ed548741daedd6e7ce9c3bcfca1" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
5721
+ return true ? "4e04e854647f1a1e167543007b405e6d43a936b2b02d7be227ac14a5bcb224f9" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
5722
5722
  }
5723
5723
  var import_node_crypto11;
5724
5724
  var init_expo_native_compiler_digest = __esm({
@@ -12848,8 +12848,14 @@ var init_podspec_ruby_stdlib = __esm({
12848
12848
 
12849
12849
  // src/write-build-file.ts
12850
12850
  function writeBuildFile(file, contents2) {
12851
- if ((0, import_node_fs33.existsSync)(file) && (typeof contents2 === "string" ? (0, import_node_fs33.readFileSync)(file, "utf8") === contents2 : (0, import_node_fs33.readFileSync)(file).equals(contents2)))
12852
- return;
12851
+ const stat2 = (0, import_node_fs33.statSync)(file, { throwIfNoEntry: false });
12852
+ if (stat2?.isFile()) {
12853
+ if (typeof contents2 === "string") {
12854
+ if ((0, import_node_fs33.readFileSync)(file, "utf8") === contents2) return;
12855
+ } else if (stat2.size === contents2.length && (0, import_node_fs33.readFileSync)(file).equals(contents2)) {
12856
+ return;
12857
+ }
12858
+ }
12853
12859
  (0, import_node_fs33.mkdirSync)(import_node_path31.default.dirname(file), { recursive: true });
12854
12860
  (0, import_node_fs33.writeFileSync)(file, contents2);
12855
12861
  }
@@ -37571,7 +37577,11 @@ function relocationEdges(bytes, segmentAddress) {
37571
37577
  const sections = wasmSections(bytes);
37572
37578
  const linking = sections.find((s) => s.name === "linking");
37573
37579
  if (!linking) throw new Error("relocation link has no linking section");
37574
- const symbols = [];
37580
+ let symKind = new Uint8Array(0);
37581
+ let symFlags = new Uint32Array(0);
37582
+ let symSegment = new Int32Array(0);
37583
+ let symOffset = new Int32Array(0);
37584
+ let symIndex = new Int32Array(0);
37575
37585
  const segmentNames = [];
37576
37586
  {
37577
37587
  const r = wasmReader(bytes, linking.start);
@@ -37579,27 +37589,31 @@ function relocationEdges(bytes, segmentAddress) {
37579
37589
  while (r.at < linking.end) {
37580
37590
  const type = r.byte();
37581
37591
  const end = r.u() + r.at;
37582
- if (type === 8)
37583
- for (let n = r.u(); n > 0; n--) {
37592
+ if (type === 8) {
37593
+ const count = r.u();
37594
+ symKind = new Uint8Array(count);
37595
+ symFlags = new Uint32Array(count);
37596
+ symSegment = new Int32Array(count).fill(-1);
37597
+ symOffset = new Int32Array(count);
37598
+ symIndex = new Int32Array(count).fill(-1);
37599
+ for (let i = 0; i < count; i++) {
37584
37600
  const kind = r.byte();
37585
37601
  const flags = r.u();
37586
- let segment2 = -1;
37587
- let offset = 0;
37588
- let index = -1;
37602
+ symKind[i] = kind;
37603
+ symFlags[i] = flags;
37589
37604
  if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
37590
- index = r.u();
37591
- if (!(flags & 16) || flags & 64) r.name();
37605
+ symIndex[i] = r.u();
37606
+ if (!(flags & 16) || flags & 64) r.skip(r.u());
37592
37607
  } else if (kind === 1) {
37593
- r.name();
37608
+ r.skip(r.u());
37594
37609
  if (!(flags & 16)) {
37595
- segment2 = r.u();
37596
- offset = r.u();
37610
+ symSegment[i] = r.u();
37611
+ symOffset[i] = r.u();
37597
37612
  r.u();
37598
37613
  }
37599
37614
  } else if (kind === 3) r.u();
37600
- symbols.push({ kind, flags, segment: segment2, offset, index });
37601
37615
  }
37602
- else if (type === 5)
37616
+ } else if (type === 5)
37603
37617
  for (let n = r.u(); n > 0; n--) {
37604
37618
  segmentNames.push(r.name());
37605
37619
  r.u();
@@ -37638,37 +37652,66 @@ function relocationEdges(bytes, segmentAddress) {
37638
37652
  const importedFunctions = readModule(bytes).importedFuncs;
37639
37653
  const data = [];
37640
37654
  const dataFunctions = [];
37641
- const code = bodyStarts.map(() => []);
37642
- const calls = bodyStarts.map(() => []);
37655
+ const bodyCount = bodyStarts.length;
37656
+ const code = Array.from({ length: bodyCount }, () => []);
37657
+ const calls = Array.from({ length: bodyCount }, () => []);
37643
37658
  for (const s of sections) {
37644
37659
  if (!s.name?.startsWith("reloc.")) continue;
37645
- const r = wasmReader(bytes, s.start);
37646
- const target = r.u();
37660
+ let cur = s.start;
37661
+ const readU = () => {
37662
+ const b0 = bytes[cur++];
37663
+ if (b0 < 128) return b0;
37664
+ let value = b0 & 127;
37665
+ let shift = 7;
37666
+ for (; ; ) {
37667
+ const byte = bytes[cur++];
37668
+ value += (byte & 127) * 2 ** shift;
37669
+ if (byte < 128) return value;
37670
+ shift += 7;
37671
+ }
37672
+ };
37673
+ const readS = () => {
37674
+ const b0 = bytes[cur++];
37675
+ if (b0 < 128) return b0 & 64 ? b0 - 128 : b0;
37676
+ let value = b0 & 127;
37677
+ let shift = 7;
37678
+ let byte = b0;
37679
+ while (byte >= 128) {
37680
+ byte = bytes[cur++];
37681
+ value += (byte & 127) * 2 ** shift;
37682
+ shift += 7;
37683
+ }
37684
+ if (byte & 64) value -= 2 ** shift;
37685
+ return value;
37686
+ };
37687
+ const target = readU();
37647
37688
  if (target !== dataIndex && target !== codeIndex) continue;
37648
37689
  let segment2 = 0;
37649
37690
  let body = 0;
37650
- for (let n = r.u(); n > 0; n--) {
37651
- const type = r.byte();
37652
- const offset = r.u();
37653
- const index = r.u();
37654
- const addend = ADDEND_RELOCATIONS.has(type) ? Number(r.s()) : 0;
37655
- const functionRelocation = FUNCTION_RELOCATIONS.has(type);
37656
- const memoryRelocation = MEMORY_RELOCATIONS.has(type);
37691
+ const isData = target === dataIndex;
37692
+ for (let n = readU(); n > 0; n--) {
37693
+ const type = bytes[cur++];
37694
+ const offset = readU();
37695
+ const index = readU();
37696
+ const bit = type < 32 ? 1 << type : 0;
37697
+ const addend = (ADDEND_RELOC_MASK & bit) !== 0 ? readS() : 0;
37698
+ const functionRelocation = (FUNCTION_RELOC_MASK & bit) !== 0;
37699
+ const memoryRelocation = (MEMORY_RELOC_MASK & bit) !== 0;
37657
37700
  if (!functionRelocation && !memoryRelocation) continue;
37658
- const symbol2 = symbols[index];
37659
- const functionReference = functionRelocation && symbol2.kind === 0;
37660
- if (symbol2.flags & 16) continue;
37661
- if (!functionReference && (!memoryRelocation || symbol2.kind !== 1 || symbol2.segment < 0))
37701
+ if (symFlags[index] & 16) continue;
37702
+ const kind = symKind[index];
37703
+ const functionReference = functionRelocation && kind === 0;
37704
+ if (!functionReference && (!memoryRelocation || kind !== 1 || symSegment[index] < 0))
37662
37705
  continue;
37663
- const to = functionReference ? symbol2.index - importedFunctions : addresses[symbol2.segment] + symbol2.offset + addend;
37664
- if (functionReference && (to < 0 || to >= bodyStarts.length)) continue;
37665
- if (target === dataIndex) {
37706
+ const to = functionReference ? symIndex[index] - importedFunctions : addresses[symSegment[index]] + symOffset[index] + addend;
37707
+ if (functionReference && (to < 0 || to >= bodyCount)) continue;
37708
+ if (isData) {
37666
37709
  while (payloads[segment2].end <= offset) segment2++;
37667
37710
  const payload = payloads[segment2];
37668
37711
  const edges = functionReference ? dataFunctions : data;
37669
37712
  edges.push(payload.address + offset - payload.start, to);
37670
37713
  } else {
37671
- while (body + 1 < bodyStarts.length && bodyStarts[body + 1] <= offset) body++;
37714
+ while (body + 1 < bodyCount && bodyStarts[body + 1] <= offset) body++;
37672
37715
  const edges = functionReference ? calls : code;
37673
37716
  edges[body].push(to);
37674
37717
  }
@@ -37724,7 +37767,7 @@ function unslottedFunctions(bytes) {
37724
37767
  const slotted = new Set([...m.slots.keys()].filter((index) => index >= m.importedFuncs));
37725
37768
  return m.bodies.length - slotted.size;
37726
37769
  }
37727
- var uleb, sleb, encodedName, section, PROCESS_EXPORTS, SWIFT_SDK_CONSTRUCTOR_LIMIT, FUNCTION_RELOCATIONS, MEMORY_RELOCATIONS, ADDEND_RELOCATIONS;
37770
+ var uleb, sleb, encodedName, section, PROCESS_EXPORTS, SWIFT_SDK_CONSTRUCTOR_LIMIT, FUNCTION_RELOCATIONS, MEMORY_RELOCATIONS, ADDEND_RELOCATIONS, FUNCTION_RELOC_MASK, MEMORY_RELOC_MASK, ADDEND_RELOC_MASK;
37728
37771
  var init_swift_sdk_image_wasm = __esm({
37729
37772
  "src/swift-sdk-image-wasm.ts"() {
37730
37773
  "use strict";
@@ -37794,6 +37837,12 @@ var init_swift_sdk_image_wasm = __esm({
37794
37837
  25,
37795
37838
  27
37796
37839
  ]);
37840
+ FUNCTION_RELOC_MASK = 0;
37841
+ for (const type of FUNCTION_RELOCATIONS) FUNCTION_RELOC_MASK |= 1 << type;
37842
+ MEMORY_RELOC_MASK = 0;
37843
+ for (const type of MEMORY_RELOCATIONS) MEMORY_RELOC_MASK |= 1 << type;
37844
+ ADDEND_RELOC_MASK = 0;
37845
+ for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK |= 1 << type;
37797
37846
  }
37798
37847
  });
37799
37848
 
@@ -37961,7 +38010,8 @@ function isRootSegName(name3) {
37961
38010
  return false;
37962
38011
  }
37963
38012
  function decodeRelocations(buf, sections) {
37964
- const count = sections.reduce((sum, section2) => sum + section2.count, 0);
38013
+ let count = 0;
38014
+ for (let s = 0; s < sections.length; s++) count += sections[s].count;
37965
38015
  const start = new Uint32Array(count);
37966
38016
  const end = new Uint32Array(count);
37967
38017
  const ro = new Int32Array(count);
@@ -37970,29 +38020,59 @@ function decodeRelocations(buf, sections) {
37970
38020
  const spans = [];
37971
38021
  let i = 0;
37972
38022
  let length = 0;
37973
- for (const section2 of sections) {
37974
- let cur = section2.at;
37975
- for (let k = 0; k < section2.count; k++, i++) {
37976
- start[i] = length + cur - section2.at;
38023
+ for (let s = 0; s < sections.length; s++) {
38024
+ const section2 = sections[s];
38025
+ const baseAt = section2.at;
38026
+ const sectionCount = section2.count;
38027
+ let cur = baseAt;
38028
+ for (let k = 0; k < sectionCount; k++, i++) {
38029
+ start[i] = length + cur - baseAt;
37977
38030
  const rType = buf[cur++];
37978
- const [offset, c2] = readULEB2(buf, cur);
37979
- const [symbol2, c3] = readULEB2(buf, c2);
37980
- cur = c3;
37981
- if (ADDEND_RELOCATIONS.has(rType)) {
37982
- const [value, c4] = readSLEB(buf, cur);
38031
+ let offset = buf[cur++];
38032
+ if (offset >= 128) {
38033
+ offset &= 127;
38034
+ let shift = 7;
38035
+ while (true) {
38036
+ const byte = buf[cur++];
38037
+ offset |= (byte & 127) << shift;
38038
+ if (byte < 128) break;
38039
+ shift += 7;
38040
+ }
38041
+ }
38042
+ let symbol2 = buf[cur++];
38043
+ if (symbol2 >= 128) {
38044
+ symbol2 &= 127;
38045
+ let shift = 7;
38046
+ while (true) {
38047
+ const byte = buf[cur++];
38048
+ symbol2 |= (byte & 127) << shift;
38049
+ if (byte < 128) break;
38050
+ shift += 7;
38051
+ }
38052
+ }
38053
+ if (rType < 32 && (ADDEND_RELOC_MASK2 & 1 << rType) !== 0) {
38054
+ let byte = buf[cur++];
38055
+ let value = byte & 127;
38056
+ let shift = 7;
38057
+ while (byte >= 128) {
38058
+ byte = buf[cur++];
38059
+ value |= (byte & 127) << shift;
38060
+ shift += 7;
38061
+ }
38062
+ if (shift < 32 && (byte & 64) !== 0) value |= ~0 << shift;
37983
38063
  addend[i] = value;
37984
- cur = c4;
37985
38064
  }
37986
38065
  ro[i] = offset;
37987
38066
  rs[i] = symbol2;
37988
- end[i] = length + cur - section2.at;
38067
+ end[i] = length + cur - baseAt;
37989
38068
  }
37990
- spans.push([section2.at, cur]);
37991
- length += cur - section2.at;
38069
+ spans.push([baseAt, cur]);
38070
+ length += cur - baseAt;
37992
38071
  }
37993
38072
  const bytes = new Uint8Array(length);
37994
38073
  let at = 0;
37995
- for (const [from, to] of spans) {
38074
+ for (let s = 0; s < spans.length; s++) {
38075
+ const [from, to] = spans[s];
37996
38076
  bytes.set(buf.subarray(from, to), at);
37997
38077
  at += to - from;
37998
38078
  }
@@ -38157,6 +38237,27 @@ function patchSwiftrtObject(src) {
38157
38237
  function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
38158
38238
  const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
38159
38239
  let pos = 8;
38240
+ let cur = 8;
38241
+ const readU = () => {
38242
+ const b0 = buf[cur++];
38243
+ if (b0 < 128) return b0;
38244
+ let res = b0 & 127;
38245
+ let shift = 7;
38246
+ while (true) {
38247
+ const byte = buf[cur++];
38248
+ res |= (byte & 127) << shift;
38249
+ if (byte < 128) return res;
38250
+ shift += 7;
38251
+ }
38252
+ };
38253
+ const skipU = () => {
38254
+ while (buf[cur++] >= 128) {
38255
+ }
38256
+ };
38257
+ const skipS = () => {
38258
+ while (buf[cur++] >= 128) {
38259
+ }
38260
+ };
38160
38261
  let numImportFuncs = 0;
38161
38262
  let importsDlsym = false;
38162
38263
  const importFuncNames = [];
@@ -38185,150 +38286,122 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
38185
38286
  const dataRelocSections = [];
38186
38287
  while (pos < buf.length) {
38187
38288
  const id = buf[pos++];
38188
- const [sz, p] = readULEB2(buf, pos);
38289
+ cur = pos;
38290
+ const sz = readU();
38291
+ const p = cur;
38189
38292
  const end = p + sz;
38190
38293
  if (id === 2) {
38191
- let [cnt, cp] = readULEB2(buf, p);
38294
+ const cnt = readU();
38192
38295
  for (let i = 0; i < cnt; i++) {
38193
- const [mLen, m2] = readULEB2(buf, cp);
38194
- const mName = rawBuf.toString("utf8", m2, m2 + mLen);
38195
- cp = m2 + mLen;
38196
- const [fLen, f2] = readULEB2(buf, cp);
38197
- const fName = rawBuf.toString("utf8", f2, f2 + fLen);
38198
- cp = f2 + fLen;
38199
- const kind = buf[cp++];
38296
+ const mLen = readU();
38297
+ const mName = rawBuf.toString("utf8", cur, cur + mLen);
38298
+ cur += mLen;
38299
+ const fLen = readU();
38300
+ const fName = rawBuf.toString("utf8", cur, cur + fLen);
38301
+ cur += fLen;
38302
+ const kind = buf[cur++];
38200
38303
  if (kind === 0) {
38201
- const [, c2] = readULEB2(buf, cp);
38202
- cp = c2;
38304
+ skipU();
38203
38305
  importFuncNames.push(fName);
38204
38306
  importFuncModules.push(mName);
38205
38307
  if (mName === "env" && fName === "dlsym") importsDlsym = true;
38206
38308
  numImportFuncs++;
38207
38309
  } else if (kind === 1) {
38208
- cp++;
38209
- const [fl, c2] = readULEB2(buf, cp);
38210
- cp = c2;
38211
- const [, c3] = readULEB2(buf, cp);
38212
- cp = c3;
38213
- if (fl & 1) {
38214
- const [, c4] = readULEB2(buf, cp);
38215
- cp = c4;
38216
- }
38310
+ cur++;
38311
+ const fl = readU();
38312
+ skipU();
38313
+ if (fl & 1) skipU();
38217
38314
  importTableNames.push(fName);
38218
38315
  } else if (kind === 2) {
38219
- const [fl, c2] = readULEB2(buf, cp);
38220
- cp = c2;
38221
- const [, c3] = readULEB2(buf, cp);
38222
- cp = c3;
38223
- if (fl & 1) {
38224
- const [, c4] = readULEB2(buf, cp);
38225
- cp = c4;
38226
- }
38316
+ const fl = readU();
38317
+ skipU();
38318
+ if (fl & 1) skipU();
38227
38319
  } else if (kind === 3) {
38228
- cp += 2;
38320
+ cur += 2;
38229
38321
  importGlobalNames.push(fName);
38230
38322
  } else if (kind === 4) {
38231
- cp++;
38232
- const [, c2] = readULEB2(buf, cp);
38233
- cp = c2;
38323
+ cur++;
38324
+ skipU();
38234
38325
  importEventNames.push(fName);
38235
38326
  }
38236
38327
  }
38237
38328
  } else if (id === 10) {
38238
38329
  codeStart = p;
38239
- let [cnt, cp] = readULEB2(buf, p);
38330
+ const cnt = readU();
38240
38331
  for (let i = 0; i < cnt; i++) {
38241
- const st = cp - codeStart;
38242
- const [bLen, b2] = readULEB2(buf, cp);
38243
- cp = b2 + bLen;
38332
+ const st = cur - codeStart;
38333
+ const bLen = readU();
38334
+ cur += bLen;
38244
38335
  fStarts.push(st);
38245
- fEnds.push(cp - codeStart);
38336
+ fEnds.push(cur - codeStart);
38246
38337
  }
38247
38338
  } else if (id === 11) {
38248
38339
  dataStart = p;
38249
- let [cnt, cp] = readULEB2(buf, p);
38340
+ const cnt = readU();
38250
38341
  for (let i = 0; i < cnt; i++) {
38251
- const st = cp - dataStart;
38252
- const [mode, m2] = readULEB2(buf, cp);
38253
- cp = m2;
38254
- if (mode === 2) {
38255
- const [, m3] = readULEB2(buf, cp);
38256
- cp = m3;
38257
- }
38342
+ const st = cur - dataStart;
38343
+ const mode = readU();
38344
+ if (mode === 2) skipU();
38258
38345
  if (mode === 0 || mode === 2) {
38259
- const op = buf[cp++];
38260
- if (op === 65 || op === 66) {
38261
- const [, m4] = readSLEB(buf, cp);
38262
- cp = m4;
38263
- } else if (op === 35) {
38264
- const [, m4] = readULEB2(buf, cp);
38265
- cp = m4;
38266
- }
38267
- cp++;
38346
+ const op = buf[cur++];
38347
+ if (op === 65 || op === 66) skipS();
38348
+ else if (op === 35) skipU();
38349
+ cur++;
38268
38350
  }
38269
- const [dLen, d2] = readULEB2(buf, cp);
38270
- sPayloadStarts.push(d2 - dataStart);
38271
- cp = d2 + dLen;
38351
+ const dLen = readU();
38352
+ sPayloadStarts.push(cur - dataStart);
38353
+ cur += dLen;
38272
38354
  sStarts.push(st);
38273
- sEnds.push(cp - dataStart);
38355
+ sEnds.push(cur - dataStart);
38274
38356
  }
38275
38357
  } else if (id === 0) {
38276
- const [nLen, np] = readULEB2(buf, p);
38277
- const name3 = rawBuf.toString("utf8", np, np + nLen);
38278
- const cp = np + nLen;
38358
+ const nLen = readU();
38359
+ const name3 = rawBuf.toString("utf8", cur, cur + nLen);
38360
+ cur += nLen;
38279
38361
  if (name3 === "linking") {
38280
- let [, lp] = readULEB2(buf, cp);
38281
- while (lp < end) {
38282
- const subId = buf[lp++];
38283
- const [subLen, sp] = readULEB2(buf, lp);
38284
- const subEnd = sp + subLen;
38362
+ skipU();
38363
+ while (cur < end) {
38364
+ const subId = buf[cur++];
38365
+ const subLen = readU();
38366
+ const subEnd = cur + subLen;
38285
38367
  if (subId === 5) {
38286
- const [cnt, p2] = readULEB2(buf, sp);
38287
- let cur = p2;
38368
+ const cnt = readU();
38288
38369
  for (let i = 0; i < cnt; i++) {
38289
- const [sLen, s2] = readULEB2(buf, cur);
38290
- segNames.push(rawBuf.toString("utf8", s2, s2 + sLen));
38291
- cur = s2 + sLen;
38292
- const [, s3] = readULEB2(buf, cur);
38293
- const [fl, s4] = readULEB2(buf, s3);
38294
- segFlags.push(fl);
38295
- cur = s4;
38370
+ const sLen = readU();
38371
+ segNames.push(rawBuf.toString("utf8", cur, cur + sLen));
38372
+ cur += sLen;
38373
+ skipU();
38374
+ segFlags.push(readU());
38296
38375
  }
38297
38376
  } else if (subId === 6) {
38298
- const [cnt, p2] = readULEB2(buf, sp);
38299
- let cur = p2;
38377
+ const cnt = readU();
38300
38378
  for (let i = 0; i < cnt; i++) {
38301
- const [, s2] = readULEB2(buf, cur);
38302
- const [symIdx, s3] = readULEB2(buf, s2);
38303
- initFuncs.push(symIdx);
38304
- cur = s3;
38379
+ skipU();
38380
+ initFuncs.push(readU());
38305
38381
  }
38306
38382
  } else if (subId === 8) {
38307
- const [cnt, p2] = readULEB2(buf, sp);
38383
+ const cnt = readU();
38308
38384
  symKind = new Uint8Array(cnt);
38309
38385
  symFlags = new Uint32Array(cnt);
38310
38386
  symElemIdx = new Int32Array(cnt).fill(-1);
38311
- symOff = new Int32Array(cnt).fill(0);
38312
- symSz = new Int32Array(cnt).fill(0);
38313
- let cur = p2;
38387
+ symOff = new Int32Array(cnt);
38388
+ symSz = new Int32Array(cnt);
38314
38389
  for (let i = 0; i < cnt; i++) {
38315
38390
  const kind = buf[cur++];
38316
38391
  if (symbolFlagOffsets) symbolFlagOffsets[i] = cur;
38317
- const [fl, c2] = readULEB2(buf, cur);
38318
- cur = c2;
38392
+ const fl = readU();
38319
38393
  symKind[i] = kind;
38320
38394
  symFlags[i] = fl;
38321
38395
  const isUndef = (fl & 16) !== 0;
38322
38396
  const isExplicitName = (fl & 64) !== 0;
38323
38397
  if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
38324
- const [el, c3] = readULEB2(buf, cur);
38325
- cur = c3;
38398
+ const el = readU();
38326
38399
  if (!isUndef && kind === 0) symElemIdx[i] = el;
38327
38400
  let sName = "";
38328
38401
  if (!isUndef || isExplicitName) {
38329
- const [sLen, c4] = readULEB2(buf, cur);
38330
- sName = rawBuf.toString("utf8", c4, c4 + sLen);
38331
- cur = c4 + sLen;
38402
+ const sLen = readU();
38403
+ sName = rawBuf.toString("utf8", cur, cur + sLen);
38404
+ cur += sLen;
38332
38405
  } else if (kind === 0) {
38333
38406
  sName = importFuncNames[el] ?? "";
38334
38407
  } else if (kind === 2) {
@@ -38342,33 +38415,28 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
38342
38415
  hostImportNames.add(sName);
38343
38416
  symNames.push(sName);
38344
38417
  } else if (kind === 1) {
38345
- const [sLen, c3] = readULEB2(buf, cur);
38346
- const sName = rawBuf.toString("utf8", c3, c3 + sLen);
38347
- cur = c3 + sLen;
38418
+ const sLen = readU();
38419
+ const sName = rawBuf.toString("utf8", cur, cur + sLen);
38420
+ cur += sLen;
38348
38421
  if (!isUndef) {
38349
- const [segIdx, c4] = readULEB2(buf, cur);
38350
- const [sOff, c5] = readULEB2(buf, c4);
38351
- const [sSz, c6] = readULEB2(buf, c5);
38352
- cur = c6;
38353
- symElemIdx[i] = segIdx;
38354
- symOff[i] = sOff;
38355
- symSz[i] = sSz;
38422
+ symElemIdx[i] = readU();
38423
+ symOff[i] = readU();
38424
+ symSz[i] = readU();
38356
38425
  }
38357
38426
  symNames.push(sName);
38358
38427
  } else if (kind === 3) {
38359
- const [, c3] = readULEB2(buf, cur);
38360
- cur = c3;
38428
+ skipU();
38361
38429
  symNames.push("");
38362
38430
  }
38363
38431
  }
38364
38432
  }
38365
- lp = subEnd;
38433
+ cur = subEnd;
38366
38434
  }
38367
38435
  } else if (name3 === "reloc.CODE" || name3 === "reloc.DATA") {
38368
- const [, r1] = readULEB2(buf, cp);
38369
- const [count, at] = readULEB2(buf, r1);
38436
+ skipU();
38437
+ const count = readU();
38370
38438
  (name3 === "reloc.DATA" ? dataRelocSections : codeRelocSections).push({
38371
- at,
38439
+ at: cur,
38372
38440
  count
38373
38441
  });
38374
38442
  }
@@ -38421,40 +38489,63 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
38421
38489
  segTopSyms.set(segIdx, dedupTop);
38422
38490
  }
38423
38491
  }
38424
- const funcRelocs = Array.from({ length: fEnds.length }, () => []);
38425
- const rawCode = decodeRelocations(buf, fEnds.length > 0 ? codeRelocSections : []);
38492
+ const funcCount = fEnds.length;
38493
+ const funcRelocs = Array.from({ length: funcCount }, () => []);
38494
+ const rawCode = decodeRelocations(buf, funcCount > 0 ? codeRelocSections : []);
38426
38495
  const codeRelocs = { ...rawCode, funcIdx: new Uint32Array(rawCode.count) };
38496
+ let fCursor = 0;
38497
+ let prevCodeRo = -1;
38427
38498
  for (let i = 0; i < codeRelocs.count; i++) {
38428
38499
  const ro = codeRelocs.ro[i];
38429
- let lo = 0;
38430
- let hi = fEnds.length - 1;
38431
- while (lo < hi) {
38432
- const mid = lo + hi >> 1;
38433
- if (fEnds[mid] <= ro) lo = mid + 1;
38434
- else hi = mid;
38500
+ let lo;
38501
+ if (ro >= prevCodeRo) {
38502
+ while (fCursor < funcCount - 1 && fEnds[fCursor] <= ro) fCursor++;
38503
+ lo = fCursor;
38504
+ } else {
38505
+ lo = 0;
38506
+ let hi = funcCount - 1;
38507
+ while (lo < hi) {
38508
+ const mid = lo + hi >> 1;
38509
+ if (fEnds[mid] <= ro) lo = mid + 1;
38510
+ else hi = mid;
38511
+ }
38512
+ fCursor = lo;
38435
38513
  }
38514
+ prevCodeRo = ro;
38436
38515
  if (codeRelocs.bytes[codeRelocs.start[i]] !== 6)
38437
38516
  funcRelocs[lo].push(codeRelocs.rs[i]);
38438
38517
  codeRelocs.funcIdx[i] = lo;
38439
38518
  }
38440
- const segRelocs = Array.from({ length: segNames.length }, () => []);
38519
+ const segCount = segNames.length;
38520
+ const segRelocs = Array.from({ length: segCount }, () => []);
38441
38521
  const symDataRelocs = /* @__PURE__ */ new Map();
38442
38522
  const rawData = decodeRelocations(buf, sEnds.length > 0 ? dataRelocSections : []);
38443
38523
  const dataSegIdx = new Uint32Array(rawData.count);
38444
38524
  const dataOffInSeg = new Int32Array(rawData.count);
38445
38525
  const dataOwnerSymIdx = new Int32Array(rawData.count);
38446
38526
  let kept = 0;
38527
+ let sCursor = 0;
38528
+ let prevDataRo = -1;
38529
+ const sEndLast = sEnds.length - 1;
38447
38530
  for (let i = 0; i < rawData.count; i++) {
38448
38531
  const ro = rawData.ro[i];
38449
38532
  const rs = rawData.rs[i];
38450
- let lo = 0;
38451
- let hi = sEnds.length - 1;
38452
- while (lo < hi) {
38453
- const mid = lo + hi >> 1;
38454
- if (sEnds[mid] <= ro) lo = mid + 1;
38455
- else hi = mid;
38533
+ let lo;
38534
+ if (ro >= prevDataRo) {
38535
+ while (sCursor < sEndLast && sEnds[sCursor] <= ro) sCursor++;
38536
+ lo = sCursor;
38537
+ } else {
38538
+ lo = 0;
38539
+ let hi = sEndLast;
38540
+ while (lo < hi) {
38541
+ const mid = lo + hi >> 1;
38542
+ if (sEnds[mid] <= ro) lo = mid + 1;
38543
+ else hi = mid;
38544
+ }
38545
+ sCursor = lo;
38456
38546
  }
38457
- if (lo >= segRelocs.length) continue;
38547
+ prevDataRo = ro;
38548
+ if (lo >= segCount) continue;
38458
38549
  const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
38459
38550
  let ownerSymIdx = -1;
38460
38551
  const topList = segTopSyms.get(lo);
@@ -38601,74 +38692,78 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
38601
38692
  const conformanceProtocols = /* @__PURE__ */ new Map();
38602
38693
  const objcCategoryTargets = [];
38603
38694
  if (isDist) {
38604
- const relocAt = /* @__PURE__ */ new Map();
38605
- for (let i = 0; i < dataRelocs.count; i++) {
38606
- relocAt.set(`${dataRelocs.segIdx[i]}:${dataRelocs.offInSeg[i]}`, {
38607
- rs: dataRelocs.rs[i],
38608
- addend: dataRelocs.addend[i]
38609
- });
38610
- }
38611
38695
  const confSegs = /* @__PURE__ */ new Set();
38612
38696
  let hasCatsSeg = false;
38613
38697
  for (let i = 0; i < segNames.length; i++) {
38614
38698
  if (segNames[i] === "swift5_protocol_conformances") confSegs.add(i);
38615
38699
  else if (segNames[i] === "__objc_cats") hasCatsSeg = true;
38616
38700
  }
38617
- if (confSegs.size > 0) {
38618
- const segOffToMpSym = /* @__PURE__ */ new Map();
38619
- for (let i = 0; i < symKind.length; i++) {
38620
- if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
38621
- segOffToMpSym.set(`${symElemIdx[i]}:${symOff[i]}`, symNames[i]);
38622
- }
38623
- }
38624
- const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
38701
+ if (confSegs.size > 0 || hasCatsSeg) {
38702
+ const relocKey = (seg, off) => seg * 4294967296 + (off >>> 0);
38703
+ const relocAt = /* @__PURE__ */ new Map();
38625
38704
  for (let i = 0; i < dataRelocs.count; i++) {
38626
- if (!confSegs.has(dataRelocs.segIdx[i])) continue;
38627
- const mcIdx = dataRelocs.rs[i];
38628
- if (symKind[mcIdx] !== 1 || (symFlags[mcIdx] & 16) !== 0 || symElemIdx[mcIdx] < 0) {
38629
- continue;
38705
+ relocAt.set(relocKey(dataRelocs.segIdx[i], dataRelocs.offInSeg[i]), i);
38706
+ }
38707
+ if (confSegs.size > 0) {
38708
+ const segOffToMpSym = /* @__PURE__ */ new Map();
38709
+ for (let i = 0; i < symKind.length; i++) {
38710
+ if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
38711
+ segOffToMpSym.set(relocKey(symElemIdx[i], symOff[i]), symNames[i]);
38712
+ }
38630
38713
  }
38631
- const mcSeg = symElemIdx[mcIdx];
38632
- const mcOff = symOff[mcIdx];
38633
- const pr = relocAt.get(`${mcSeg}:${mcOff}`);
38634
- let mp = "";
38635
- if (pr) {
38636
- const raw2 = symNames[pr.rs];
38637
- const stripped2 = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
38638
- if (stripped2.startsWith("$s") && stripped2.endsWith("Mp")) {
38639
- mp = stripped2;
38640
- } else if (symKind[pr.rs] === 3 || stripped2 === "") {
38641
- mp = segOffToMpSym.get(`${mcSeg}:${pr.addend}`) ?? "";
38714
+ const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
38715
+ for (let i = 0; i < dataRelocs.count; i++) {
38716
+ if (!confSegs.has(dataRelocs.segIdx[i])) continue;
38717
+ const mcIdx = dataRelocs.rs[i];
38718
+ if (symKind[mcIdx] !== 1 || (symFlags[mcIdx] & 16) !== 0 || symElemIdx[mcIdx] < 0) {
38719
+ continue;
38642
38720
  }
38643
- } else {
38644
- const fileOff = dataStart + sPayloadStarts[mcSeg] + mcOff;
38645
- if (fileOff + 4 <= buf.length) {
38646
- const delta = dv.getInt32(fileOff, true);
38647
- mp = segOffToMpSym.get(`${mcSeg}:${mcOff + delta}`) ?? segOffToMpSym.get(`${mcSeg}:${mcOff + (delta & ~1)}`) ?? "";
38721
+ const mcSeg = symElemIdx[mcIdx];
38722
+ const mcOff = symOff[mcIdx];
38723
+ const prIdx = relocAt.get(relocKey(mcSeg, mcOff));
38724
+ let mp = "";
38725
+ if (prIdx !== void 0) {
38726
+ const prRs = dataRelocs.rs[prIdx];
38727
+ const raw2 = symNames[prRs];
38728
+ const stripped2 = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
38729
+ if (stripped2.startsWith("$s") && stripped2.endsWith("Mp")) {
38730
+ mp = stripped2;
38731
+ } else if (symKind[prRs] === 3 || stripped2 === "") {
38732
+ mp = segOffToMpSym.get(relocKey(mcSeg, dataRelocs.addend[prIdx])) ?? "";
38733
+ }
38734
+ } else {
38735
+ const fileOff = dataStart + sPayloadStarts[mcSeg] + mcOff;
38736
+ if (fileOff + 4 <= buf.length) {
38737
+ const delta = dv.getInt32(fileOff, true);
38738
+ mp = segOffToMpSym.get(relocKey(mcSeg, mcOff + delta)) ?? segOffToMpSym.get(relocKey(mcSeg, mcOff + (delta & ~1))) ?? "";
38739
+ }
38648
38740
  }
38741
+ if (mp) conformanceProtocols.set(mcIdx, mp);
38649
38742
  }
38650
- if (mp) conformanceProtocols.set(mcIdx, mp);
38651
38743
  }
38652
- }
38653
- if (hasCatsSeg) {
38654
- const seenClasses = /* @__PURE__ */ new Set();
38655
- for (let i = 0; i < symKind.length; i++) {
38656
- if (symKind[i] !== 1 || (symFlags[i] & 16) !== 0 || symElemIdx[i] < 0 || segNames[symElemIdx[i]] !== "__objc_cats" || !symNames[i].startsWith(".objc_category_")) {
38657
- continue;
38658
- }
38659
- const cSeg = symElemIdx[i];
38660
- const cOff = symOff[i];
38661
- const cr = relocAt.get(`${cSeg}:${cOff + 8}`);
38662
- if (cr && symKind[cr.rs] === 1 && (symFlags[cr.rs] & 16) === 0 && symElemIdx[cr.rs] >= 0) {
38663
- const tSeg = symElemIdx[cr.rs];
38664
- const strOff = dataStart + sPayloadStarts[tSeg] + symOff[cr.rs] + cr.addend;
38665
- let sEnd = strOff;
38666
- while (sEnd < buf.length && buf[sEnd] !== 0) sEnd++;
38667
- if (sEnd > strOff) {
38668
- const clsName = Buffer.from(buf.subarray(strOff, sEnd)).toString("utf8");
38669
- if (!seenClasses.has(clsName)) {
38670
- seenClasses.add(clsName);
38671
- objcCategoryTargets.push(clsName);
38744
+ if (hasCatsSeg) {
38745
+ const seenClasses = /* @__PURE__ */ new Set();
38746
+ for (let i = 0; i < symKind.length; i++) {
38747
+ if (symKind[i] !== 1 || (symFlags[i] & 16) !== 0 || symElemIdx[i] < 0 || segNames[symElemIdx[i]] !== "__objc_cats" || !symNames[i].startsWith(".objc_category_")) {
38748
+ continue;
38749
+ }
38750
+ const cSeg = symElemIdx[i];
38751
+ const cOff = symOff[i];
38752
+ const crIdx = relocAt.get(relocKey(cSeg, cOff + 8));
38753
+ if (crIdx !== void 0) {
38754
+ const crRs = dataRelocs.rs[crIdx];
38755
+ if (symKind[crRs] === 1 && (symFlags[crRs] & 16) === 0 && symElemIdx[crRs] >= 0) {
38756
+ const tSeg = symElemIdx[crRs];
38757
+ const strOff = dataStart + sPayloadStarts[tSeg] + symOff[crRs] + dataRelocs.addend[crIdx];
38758
+ let sEnd = strOff;
38759
+ while (sEnd < buf.length && buf[sEnd] !== 0) sEnd++;
38760
+ if (sEnd > strOff) {
38761
+ const clsName = rawBuf.toString("utf8", strOff, sEnd);
38762
+ if (!seenClasses.has(clsName)) {
38763
+ seenClasses.add(clsName);
38764
+ objcCategoryTargets.push(clsName);
38765
+ }
38766
+ }
38672
38767
  }
38673
38768
  }
38674
38769
  }
@@ -39881,7 +39976,9 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
39881
39976
  return true;
39882
39977
  };
39883
39978
  const writePrunedObject = (obj, outFile) => {
39884
- const buf = new Uint8Array(import_node_fs56.default.readFileSync(obj.file));
39979
+ const cached4 = objectBytes.get(obj);
39980
+ const buf = cached4 ? new Uint8Array(cached4) : new Uint8Array(import_node_fs56.default.readFileSync(obj.file));
39981
+ const rawBuf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
39885
39982
  const inputSha256 = link ? (0, import_node_crypto29.createHash)("sha256").update(buf).digest("hex") : "";
39886
39983
  const fLive = liveFuncs.get(obj);
39887
39984
  const sLive = liveSegs.get(obj);
@@ -39973,7 +40070,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
39973
40070
  const end = p + sz;
39974
40071
  if (id === 0) {
39975
40072
  const [nLen, np] = readULEB2(buf, p);
39976
- const name3 = Buffer.from(buf.subarray(np, np + nLen)).toString("utf8");
40073
+ const name3 = rawBuf.toString("utf8", np, np + nLen);
39977
40074
  const cp = np + nLen;
39978
40075
  if (name3 === "linking") {
39979
40076
  const [, lpStart] = readULEB2(buf, cp);
@@ -40235,7 +40332,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
40235
40332
  );
40236
40333
  import_node_fs56.default.rmSync(rspPath, { force: true });
40237
40334
  }
40238
- var import_node_child_process25, import_node_crypto29, import_node_fs56, import_node_path57, v3, WIDE_DATA_RELOCS, ROOT_SEG_PREFIXES, RECORD_SEGS, PARTITIONED_SEGS, PRUNED_SDK_ARCHIVES, OMIT_SDK_LIB_FLAGS, NEUTRALIZED_SWIFTRT_SECTIONS, relocationBytes, parsedObjectCache, PARSED_ROOTS, SWIFTUI_WRAPPER_HOST_PROTOCOLS, SWIFT_PRUNED_LINK_MAP, SWIFT_PRUNED_LINK_RESPONSE;
40335
+ var import_node_child_process25, import_node_crypto29, import_node_fs56, import_node_path57, v3, WIDE_DATA_RELOCS, ROOT_SEG_PREFIXES, RECORD_SEGS, PARTITIONED_SEGS, PRUNED_SDK_ARCHIVES, OMIT_SDK_LIB_FLAGS, NEUTRALIZED_SWIFTRT_SECTIONS, ADDEND_RELOC_MASK2, relocationBytes, parsedObjectCache, PARSED_ROOTS, SWIFTUI_WRAPPER_HOST_PROTOCOLS, SWIFT_PRUNED_LINK_MAP, SWIFT_PRUNED_LINK_RESPONSE;
40239
40336
  var init_swift_wasm_prune = __esm({
40240
40337
  "src/swift-wasm-prune.ts"() {
40241
40338
  "use strict";
@@ -40315,6 +40412,8 @@ var init_swift_wasm_prune = __esm({
40315
40412
  "swift5_reflstr",
40316
40413
  "swift5_typeref"
40317
40414
  ]);
40415
+ ADDEND_RELOC_MASK2 = 0;
40416
+ for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK2 |= 1 << type;
40318
40417
  relocationBytes = (relocs, i) => relocs.bytes.subarray(relocs.start[i], relocs.end[i]);
40319
40418
  parsedObjectCache = /* @__PURE__ */ new Map();
40320
40419
  PARSED_ROOTS = 2;
@@ -40939,7 +41038,7 @@ function llvmType(value) {
40939
41038
  function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options2 = {}) {
40940
41039
  if (!isWasmMagic(bytes)) throw new Error("expected wasm object");
40941
41040
  const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
40942
- const { sdkLookupOnly, sdkProduct } = options2;
41041
+ const { sdkLookupOnly, sdkProduct, collectRewrittenSymbols } = options2;
40943
41042
  const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
40944
41043
  const rewrite = binding !== void 0;
40945
41044
  const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
@@ -40948,6 +41047,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
40948
41047
  const definitions = [];
40949
41048
  const functionImports = /* @__PURE__ */ new Map();
40950
41049
  const functionImportNames = [];
41050
+ const tableImportNames = [];
41051
+ const globalImportNames = [];
41052
+ const eventImportNames = [];
40951
41053
  const functionSymbols = [];
40952
41054
  const addressTaken = /* @__PURE__ */ new Set();
40953
41055
  let usesDlsym = false;
@@ -41069,12 +41171,18 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
41069
41171
  if (isDlsym) usesDlsym = true;
41070
41172
  if (isDlerror) usesDlerror = true;
41071
41173
  if (importWriter && binding) {
41174
+ const rewrittenName = isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3;
41072
41175
  importWriter.string(module2);
41073
- importWriter.string(
41074
- isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3
41075
- );
41176
+ importWriter.string(rewrittenName);
41076
41177
  importWriter.byte(kind);
41077
41178
  importWriter.bytes(bytes, typeStart, offset);
41179
+ if (collectRewrittenSymbols) {
41180
+ if (kind === 0)
41181
+ functionImportNames[functionImportNames.length - 1] = rewrittenName;
41182
+ else if (kind === 1) tableImportNames.push(rewrittenName);
41183
+ else if (kind === 3) globalImportNames.push(rewrittenName);
41184
+ else if (kind === 4) eventImportNames.push(rewrittenName);
41185
+ }
41078
41186
  }
41079
41187
  }
41080
41188
  if (offset !== end) throw new Error("invalid wasm import section");
@@ -41157,13 +41265,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
41157
41265
  if (!rewrite && flags & 16 && symbolKind === 1 && alias)
41158
41266
  usedSymbols.add(name3);
41159
41267
  if (entryWriter && binding) {
41268
+ let rewrittenSym = name3;
41269
+ let addedCanonical;
41160
41270
  if ((name3 === "dlsym" && usesDlsym || name3 === "dlerror" && usesDlerror) && flags & 16 && flags & 64 && symbolKind === 0) {
41271
+ rewrittenSym = name3 === "dlsym" ? callerAlias : dlerrorAlias;
41161
41272
  entryWriter.bytes(bytes, begin, nameStart);
41162
- entryWriter.string(name3 === "dlsym" ? callerAlias : dlerrorAlias);
41273
+ entryWriter.string(rewrittenSym);
41163
41274
  entryWriter.bytes(bytes, nameEnd, offset);
41164
41275
  } else if (flags & 16 && name3 !== "dlsym" && name3 !== "dlerror" && binding(name3) !== void 0) {
41276
+ rewrittenSym = binding(name3);
41165
41277
  entryWriter.bytes(bytes, begin, nameStart);
41166
- entryWriter.string(binding(name3));
41278
+ entryWriter.string(rewrittenSym);
41167
41279
  entryWriter.bytes(bytes, nameEnd, offset);
41168
41280
  } else if (alias && !(flags & 16) && (flags & 3) !== 2) {
41169
41281
  if (symbolKind !== 0 && symbolKind !== 1)
@@ -41177,7 +41289,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
41177
41289
  extraWriter.string(alias);
41178
41290
  extraWriter.bytes(bytes, nameEnd, offset);
41179
41291
  added++;
41292
+ addedCanonical = alias;
41180
41293
  } else {
41294
+ rewrittenSym = alias;
41181
41295
  entryWriter.bytes(bytes, begin, nameStart);
41182
41296
  entryWriter.string(alias);
41183
41297
  entryWriter.bytes(bytes, nameEnd, offset);
@@ -41185,6 +41299,16 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
41185
41299
  } else {
41186
41300
  entryWriter.bytes(bytes, begin, offset);
41187
41301
  }
41302
+ if (collectRewrittenSymbols) {
41303
+ if (flags & 16) {
41304
+ const resolved = flags & 64 || symbolKind === 1 ? rewrittenSym : symbolKind === 0 ? functionImportNames[index] ?? "" : symbolKind === 2 ? globalImportNames[index] ?? "" : symbolKind === 4 ? eventImportNames[index] ?? "" : symbolKind === 5 ? tableImportNames[index] ?? "" : "";
41305
+ if (resolved) collectRewrittenSymbols.referenced.add(resolved);
41306
+ } else if ((flags & 3) !== 2) {
41307
+ if (rewrittenSym) collectRewrittenSymbols.defined.add(rewrittenSym);
41308
+ if (addedCanonical)
41309
+ collectRewrittenSymbols.defined.add(addedCanonical);
41310
+ }
41311
+ }
41188
41312
  } else if (alias && !(flags & 16) && (flags & 3) !== 2) {
41189
41313
  if (symbolKind !== 0 && symbolKind !== 1)
41190
41314
  throw new Error(`unsupported symbol ${name3}`);
@@ -41548,6 +41672,7 @@ function createGuestImageLedger(input) {
41548
41672
  sdkGlobalBindings.set(name3, first.alias);
41549
41673
  }
41550
41674
  }
41675
+ const appSymbols = input.registerAppTables ? { referenced: /* @__PURE__ */ new Set(), defined: /* @__PURE__ */ new Set() } : void 0;
41551
41676
  const objects = units.map(({ image, object: object9, aliases, functionImports }) => {
41552
41677
  const shared = sharedLookupByImage.get(image);
41553
41678
  const own2 = startup.get(object9.path);
@@ -41582,7 +41707,10 @@ function createGuestImageLedger(input) {
41582
41707
  binding,
41583
41708
  object9.instrumentDynamicLookups,
41584
41709
  preserveCanonical,
41585
- { sdkProduct: object9.sdkProduct }
41710
+ {
41711
+ sdkProduct: object9.sdkProduct,
41712
+ collectRewrittenSymbols: object9.sdkProduct === void 0 ? appSymbols : void 0
41713
+ }
41586
41714
  ).bytes
41587
41715
  };
41588
41716
  });
@@ -41703,7 +41831,9 @@ function createGuestImageLedger(input) {
41703
41831
  llvmIR: render2(false, lazy),
41704
41832
  lazyFunctions: lazy,
41705
41833
  appLLVMIR: appLazy && render2(true, appLazy),
41706
- appLazyFunctions: appLazy
41834
+ appLazyFunctions: appLazy,
41835
+ appReferencedSymbols: appSymbols?.referenced,
41836
+ appDefinedSymbols: appSymbols?.defined
41707
41837
  };
41708
41838
  }
41709
41839
  function guestLazyFunctionRuntime(count) {
@@ -42597,6 +42727,26 @@ function selectedGuestManifestInputs(plan, selection, identities, readSelected)
42597
42727
  }
42598
42728
  return images;
42599
42729
  }
42730
+ function framedLinkOptions(options2) {
42731
+ const cached4 = framedLinkOptionsCache.get(options2);
42732
+ if (cached4) return cached4;
42733
+ const parts2 = new Array(options2.length * 2 + 2);
42734
+ const count = Buffer.from(String(options2.length), "utf8");
42735
+ const countSize = Buffer.allocUnsafe(8);
42736
+ countSize.writeBigUInt64BE(BigInt(count.byteLength));
42737
+ parts2[0] = countSize;
42738
+ parts2[1] = count;
42739
+ for (let i = 0; i < options2.length; i++) {
42740
+ const encoded = Buffer.from(options2[i], "utf8");
42741
+ const size2 = Buffer.allocUnsafe(8);
42742
+ size2.writeBigUInt64BE(BigInt(encoded.byteLength));
42743
+ parts2[i * 2 + 2] = size2;
42744
+ parts2[i * 2 + 3] = encoded;
42745
+ }
42746
+ const framed = Buffer.concat(parts2);
42747
+ framedLinkOptionsCache.set(options2, framed);
42748
+ return framed;
42749
+ }
42600
42750
  function createGuestImageManifest(image) {
42601
42751
  const target = {
42602
42752
  triple: SWIFT_WASM_TRIPLE,
@@ -42606,10 +42756,10 @@ function createGuestImageManifest(image) {
42606
42756
  cpuSubtype: 0
42607
42757
  };
42608
42758
  const digest3 = (0, import_node_crypto33.createHash)("sha256");
42759
+ const sizeBuf = Buffer.allocUnsafe(8);
42609
42760
  const add = (bytes) => {
42610
- const size2 = Buffer.alloc(8);
42611
- size2.writeBigUInt64BE(BigInt(bytes.byteLength));
42612
- digest3.update(size2);
42761
+ sizeBuf.writeBigUInt64BE(BigInt(bytes.byteLength));
42762
+ digest3.update(sizeBuf);
42613
42763
  digest3.update(bytes);
42614
42764
  };
42615
42765
  const text7 = (value) => add(Buffer.from(value, "utf8"));
@@ -42626,8 +42776,7 @@ function createGuestImageManifest(image) {
42626
42776
  `${version2.platform}:${version2.minimum.major}:${version2.minimum.minor}:${version2.minimum.patch}`
42627
42777
  );
42628
42778
  text7(`${version2.sdk.major}:${version2.sdk.minor}:${version2.sdk.patch}`);
42629
- text7(String(image.linkOptions.length));
42630
- for (const option of image.linkOptions) text7(option);
42779
+ digest3.update(framedLinkOptions(image.linkOptions));
42631
42780
  text7(String(image.inputs.length));
42632
42781
  for (const input of image.inputs) {
42633
42782
  text7(input.identity);
@@ -42648,7 +42797,7 @@ function createGuestImageManifest(image) {
42648
42797
  regions: image.regions
42649
42798
  };
42650
42799
  }
42651
- var import_node_crypto33, import_node_fs58;
42800
+ var import_node_crypto33, import_node_fs58, framedLinkOptionsCache;
42652
42801
  var init_swift_guest_manifest = __esm({
42653
42802
  "src/swift-guest-manifest.ts"() {
42654
42803
  "use strict";
@@ -42657,6 +42806,7 @@ var init_swift_guest_manifest = __esm({
42657
42806
  init_swift_guest_link_plan();
42658
42807
  init_swift_wasm_prune();
42659
42808
  init_swiftTargetContract();
42809
+ framedLinkOptionsCache = /* @__PURE__ */ new WeakMap();
42660
42810
  }
42661
42811
  });
42662
42812
 
@@ -43959,7 +44109,7 @@ var init_wasm_optimize = __esm({
43959
44109
  ];
43960
44110
  BINARYEN_VERSION = binaryen_lock_default.version;
43961
44111
  runBinaryen = (0, import_node_util5.promisify)(import_node_child_process27.execFile);
43962
- WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} shared-stack-check-v2 native-image-v1 table-reserve-v2 ${NATIVE_TABLE_ABI} unoptimized-names`;
44112
+ WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} fused-pipeline-v1 narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} shared-stack-check-v2 native-image-v1 table-reserve-v2 ${NATIVE_TABLE_ABI} unoptimized-names`;
43963
44113
  BINARYEN_RELEASES = new Map(Object.entries(binaryen_lock_default.platforms));
43964
44114
  }
43965
44115
  });
@@ -44404,6 +44554,7 @@ function linkGuestImages(options2) {
44404
44554
  const ledgerObjects = new Map(ledger.objects.map((item) => [item.path, item]));
44405
44555
  const appObjects = /* @__PURE__ */ new Map();
44406
44556
  const sdkObjects = /* @__PURE__ */ new Map();
44557
+ const finalArchives = /* @__PURE__ */ new Map();
44407
44558
  for (const [index, artifact] of plan.artifacts.entries()) {
44408
44559
  const prefix = `${artifact.path}(`;
44409
44560
  if (artifact.kind === "object") {
@@ -44457,6 +44608,10 @@ function linkGuestImages(options2) {
44457
44608
  const response = import_node_path61.default.join(memberDir, "members.rsp");
44458
44609
  import_node_fs61.default.writeFileSync(response, inputs2.map((input) => JSON.stringify(input)).join(" "));
44459
44610
  (0, import_node_child_process28.execFileSync)(llvmAr, ["rcs", output, `@${response}`], { stdio: "pipe" });
44611
+ finalArchives.set(
44612
+ output,
44613
+ members2.map((member) => ({ name: member.name, bytes: new Uint8Array(0) }))
44614
+ );
44460
44615
  replacements.set(artifact.path, output);
44461
44616
  }
44462
44617
  const compileLedger = (name3, source) => {
@@ -44588,7 +44743,8 @@ function linkGuestImages(options2) {
44588
44743
  remapGuestLinkPlan(plan, replacements),
44589
44744
  finalArgs,
44590
44745
  import_node_fs61.default.readFileSync(finalWhy, "utf8"),
44591
- finalTrace
44746
+ finalTrace,
44747
+ finalArchives
44592
44748
  );
44593
44749
  const original = new Map([...replacements].map(([before2, after2]) => [after2, before2]));
44594
44750
  const key2 = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
@@ -44621,12 +44777,25 @@ ${changed2.join("\n")}`
44621
44777
  ])
44622
44778
  );
44623
44779
  appObjects.set(appLedgerObject, options2.ledgerDataImage);
44780
+ let appReferencedSymbols;
44781
+ let appDefinedSymbols;
44782
+ if (ledger.appReferencedSymbols && ledger.appDefinedSymbols) {
44783
+ const referenced = new Set(ledger.appReferencedSymbols);
44784
+ const defined = new Set(ledger.appDefinedSymbols);
44785
+ const ledgerSyms = guestWasmSymbols(import_node_fs61.default.readFileSync(appLedgerObject));
44786
+ for (const name3 of ledgerSyms.undefined) referenced.add(name3);
44787
+ for (const name3 of ledgerSyms.defined) defined.add(name3);
44788
+ appReferencedSymbols = referenced;
44789
+ appDefinedSymbols = defined;
44790
+ }
44624
44791
  options2.onSplitInputs({
44625
44792
  appObjects,
44626
44793
  appSections,
44627
44794
  sdkObjects,
44628
44795
  lazyFunctions: ledger.appLazyFunctions ?? [],
44629
- dyldSymbols: ledger.dyldSymbols
44796
+ dyldSymbols: ledger.dyldSymbols,
44797
+ appReferencedSymbols,
44798
+ appDefinedSymbols
44630
44799
  });
44631
44800
  }
44632
44801
  return selected;
@@ -45609,6 +45778,93 @@ function sourceGuestInputIdentities(graph, buildDirectory, objects) {
45609
45778
  }
45610
45779
  return identities;
45611
45780
  }
45781
+ function wasmAutolinkEntries(bytes, out) {
45782
+ if (bytes.length < 8) return false;
45783
+ if (bytes[0] === 33 && bytes[1] === 60 && bytes[2] === 97 && bytes[3] === 114 && bytes[4] === 99 && bytes[5] === 104 && bytes[6] === 62 && bytes[7] === 10) {
45784
+ for (const member of readArMembers(bytes)) {
45785
+ if (!wasmAutolinkEntries(member.bytes, out)) return false;
45786
+ }
45787
+ return true;
45788
+ }
45789
+ if (bytes[0] !== 0 || bytes[1] !== 97 || bytes[2] !== 115 || bytes[3] !== 109)
45790
+ return false;
45791
+ const raw2 = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
45792
+ let pos = 8;
45793
+ const len = bytes.length;
45794
+ while (pos < len) {
45795
+ const id = bytes[pos++];
45796
+ let sz = bytes[pos++];
45797
+ if (sz >= 128) {
45798
+ sz &= 127;
45799
+ let shift = 7;
45800
+ while (true) {
45801
+ const b = bytes[pos++];
45802
+ sz |= (b & 127) << shift;
45803
+ if (b < 128) break;
45804
+ shift += 7;
45805
+ }
45806
+ }
45807
+ const end = pos + sz;
45808
+ if (id === 0) {
45809
+ let nLen = bytes[pos++];
45810
+ if (nLen >= 128) {
45811
+ nLen &= 127;
45812
+ let shift = 7;
45813
+ while (true) {
45814
+ const b = bytes[pos++];
45815
+ nLen |= (b & 127) << shift;
45816
+ if (b < 128) break;
45817
+ shift += 7;
45818
+ }
45819
+ }
45820
+ if (nLen === 24 && raw2.toString("ascii", pos, pos + 24) === ".swift1_autolink_entries") {
45821
+ const payload = raw2.toString("utf8", pos + 24, end);
45822
+ for (const entry of payload.split("\0")) {
45823
+ const trimmed = entry.trim();
45824
+ if (trimmed.length > 0) out.push(trimmed);
45825
+ }
45826
+ }
45827
+ }
45828
+ pos = end;
45829
+ }
45830
+ return true;
45831
+ }
45832
+ function readAutolinkFlags(objects, toolchainBin, responsePath) {
45833
+ if (!objects.length) return [];
45834
+ const rawFlags = [];
45835
+ for (const file of objects) {
45836
+ if (!wasmAutolinkEntries((0, import_node_fs62.readFileSync)(file), rawFlags)) {
45837
+ (0, import_node_fs62.writeFileSync)(
45838
+ responsePath,
45839
+ objects.map((entry) => JSON.stringify(entry)).join("\n") + "\n"
45840
+ );
45841
+ return (0, import_node_child_process29.execFileSync)(
45842
+ import_node_path62.default.join(toolchainBin, "swift-autolink-extract"),
45843
+ [`@${responsePath}`, "-o", "-"],
45844
+ { encoding: "utf8" }
45845
+ ).split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
45846
+ }
45847
+ }
45848
+ const seen = /* @__PURE__ */ new Set();
45849
+ const flags = [];
45850
+ for (let i = 0; i < rawFlags.length; i++) {
45851
+ const flag = rawFlags[i];
45852
+ if ((flag === "-framework" || flag === "-weak_framework" || flag === "-l" || flag === "--library") && i + 1 < rawFlags.length) {
45853
+ const value = rawFlags[++i];
45854
+ const key2 = `${flag}\0${value}`;
45855
+ if (!seen.has(key2)) {
45856
+ seen.add(key2);
45857
+ flags.push(flag, value);
45858
+ }
45859
+ continue;
45860
+ }
45861
+ if (!seen.has(flag)) {
45862
+ seen.add(flag);
45863
+ flags.push(flag);
45864
+ }
45865
+ }
45866
+ return flags;
45867
+ }
45612
45868
  function sourceGuestRuntimeLinks(options2) {
45613
45869
  const aliases = /* @__PURE__ */ new Map();
45614
45870
  const artifacts = /* @__PURE__ */ new Map();
@@ -45696,15 +45952,7 @@ function sourceGuestRuntimeLinks(options2) {
45696
45952
  for (const image of options2.images) {
45697
45953
  if (result.has(image.id)) throw new Error(`duplicate source image ${image.id}`);
45698
45954
  const response = import_node_path62.default.join(options2.directory, `image-${image.id}-autolink.rsp`);
45699
- (0, import_node_fs62.writeFileSync)(
45700
- response,
45701
- image.objects.map((file) => JSON.stringify(file)).join("\n") + "\n"
45702
- );
45703
- const autolink = image.objects.length ? (0, import_node_child_process29.execFileSync)(
45704
- import_node_path62.default.join(options2.toolchainBin, "swift-autolink-extract"),
45705
- [`@${response}`, "-o", "-"],
45706
- { encoding: "utf8" }
45707
- ).split("\n").map((line) => line.trim()).filter((line) => line.length > 0) : [];
45955
+ const autolink = readAutolinkFlags(image.objects, options2.toolchainBin, response);
45708
45956
  const links = [];
45709
45957
  const requests = [];
45710
45958
  const optionGroups = [
@@ -45804,6 +46052,7 @@ var init_swift_guest_source_inputs = __esm({
45804
46052
  init_forked_script_contract();
45805
46053
  init_swift_guest_source_plan();
45806
46054
  init_swift_runtime_products();
46055
+ init_swift_wasm_prune();
45807
46056
  CLANG_TARGET_MODULE_WRAPPER = ".peach-clang";
45808
46057
  PARALLEL_REPLAY = `
45809
46058
  const { spawn } = require('node:child_process')
@@ -49330,9 +49579,10 @@ function sdkHostExports(appRoot) {
49330
49579
  if (!(byte & 128)) return value;
49331
49580
  }
49332
49581
  };
49582
+ const raw2 = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
49333
49583
  for (let n = u(); n > 0; n--) {
49334
49584
  const length = u();
49335
- names.push(Buffer.from(bytes.subarray(at, at + length)).toString());
49585
+ names.push(raw2.toString("utf8", at, at + length));
49336
49586
  at += length + 1;
49337
49587
  u();
49338
49588
  }
@@ -49876,56 +50126,109 @@ function swiftAppModuleInputs(tokens2, buildRoot, sdkLibraries) {
49876
50126
  }
49877
50127
  return inputs2;
49878
50128
  }
49879
- async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project2, readInput) {
50129
+ function llvmQuoted(value) {
50130
+ const bytes = Buffer.from(value, "utf8");
50131
+ let out = '"';
50132
+ for (let i = 0; i < bytes.length; i++) {
50133
+ const b = bytes[i];
50134
+ if (b >= 32 && b <= 126 && b !== 34 && b !== 92) out += String.fromCharCode(b);
50135
+ else out += `\\${b.toString(16).toUpperCase().padStart(2, "0")}`;
50136
+ }
50137
+ return out + '"';
50138
+ }
50139
+ async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project2, readInput, precomputedSymbols) {
49880
50140
  const { signatures, tls } = sdk2.sdkInterface;
49881
- const directories = inputs2.filter((input) => input.startsWith("-L")).map((input) => input.slice(2));
49882
- const referenced = /* @__PURE__ */ new Set();
49883
- const defined = /* @__PURE__ */ new Set();
49884
- const scan3 = (bytes) => {
49885
- const symbols = guestWasmSymbols(bytes);
49886
- for (const name3 of symbols.undefined) referenced.add(name3);
49887
- for (const name3 of symbols.defined) defined.add(name3);
50141
+ let referenced;
50142
+ let defined;
50143
+ if (precomputedSymbols) {
50144
+ referenced = precomputedSymbols.referenced;
50145
+ defined = precomputedSymbols.defined;
50146
+ } else {
50147
+ const directories = inputs2.filter((input) => input.startsWith("-L")).map((input) => input.slice(2));
50148
+ const refSet = /* @__PURE__ */ new Set();
50149
+ const defSet = /* @__PURE__ */ new Set();
50150
+ const scan3 = (bytes) => {
50151
+ const symbols = guestWasmSymbols(bytes);
50152
+ for (const name3 of symbols.undefined) refSet.add(name3);
50153
+ for (const name3 of symbols.defined) defSet.add(name3);
50154
+ };
50155
+ for (const input of inputs2) {
50156
+ const file = input.startsWith("-l") ? directories.map((directory2) => import_node_path71.default.join(directory2, `lib${input.slice(2)}.a`)).find((candidate) => (0, import_node_fs71.existsSync)(candidate)) : input.startsWith("-") ? void 0 : input;
50157
+ if (!file) continue;
50158
+ const bytes = readInput(file);
50159
+ if (file.endsWith(".a"))
50160
+ for (const member of readArMembers(bytes)) scan3(member.bytes);
50161
+ else scan3(bytes);
50162
+ }
50163
+ referenced = refSet;
50164
+ defined = defSet;
50165
+ }
50166
+ const irType = {
50167
+ i: "i32",
50168
+ j: "i64",
50169
+ f: "float",
50170
+ d: "double"
50171
+ };
50172
+ const type = (kinds) => {
50173
+ const out = new Array(kinds.length);
50174
+ for (let i = 0; i < kinds.length; i++) {
50175
+ const kind = kinds[i];
50176
+ const name3 = irType[kind];
50177
+ if (!name3) throw new Error(`sdk signature kind ${kind}`);
50178
+ out[i] = name3;
50179
+ }
50180
+ return out;
49888
50181
  };
49889
- for (const input of inputs2) {
49890
- const file = input.startsWith("-l") ? directories.map((directory2) => import_node_path71.default.join(directory2, `lib${input.slice(2)}.a`)).find((candidate) => (0, import_node_fs71.existsSync)(candidate)) : input.startsWith("-") ? void 0 : input;
49891
- if (!file) continue;
49892
- const bytes = readInput(file);
49893
- if (file.endsWith(".a")) for (const member of readArMembers(bytes)) scan3(member.bytes);
49894
- else scan3(bytes);
49895
- }
49896
- const c = { i: "int", j: "long long", f: "float", d: "double" };
49897
- const type = (kinds) => [...kinds].map((kind) => {
49898
- const name3 = c[kind];
49899
- if (!name3) throw new Error(`sdk signature kind ${kind}`);
49900
- return name3;
49901
- });
49902
- const literal4 = (name3) => JSON.stringify(name3);
49903
- const lines = [];
49904
- if (signatures.__objc_send_load_messages === ":")
50182
+ const lines = [`target triple = "${SWIFT_WASM_TRIPLE}"`];
50183
+ const attrs = [];
50184
+ const addImportAttr = (name3) => {
50185
+ const id = attrs.length;
50186
+ attrs.push(
50187
+ `attributes #${id} = { "wasm-import-module"="env" "wasm-import-name"=${llvmQuoted(name3)} }`
50188
+ );
50189
+ return id;
50190
+ };
50191
+ if (signatures.__objc_send_load_messages === ":") {
50192
+ const attr = addImportAttr("__objc_send_load_messages");
49905
50193
  lines.push(
49906
- '__attribute__((import_module("env"), import_name("__objc_send_load_messages"))) void sdk_send_load_messages(void);',
49907
- "__attribute__((constructor)) static void send_app_load_messages(void) { sdk_send_load_messages(); }"
50194
+ "@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @send_app_load_messages, ptr null }]",
50195
+ `declare void @sdk_send_load_messages() #${attr}`,
50196
+ "define internal void @send_app_load_messages() {",
50197
+ " tail call void @sdk_send_load_messages()",
50198
+ " ret void",
50199
+ "}"
49908
50200
  );
50201
+ }
49909
50202
  const forwarders = /* @__PURE__ */ new Set();
49910
50203
  let index = 0;
49911
50204
  for (const name3 of referenced) {
49912
50205
  const signature2 = signatures[name3];
49913
50206
  if (signature2 === void 0 || defined.has(name3)) continue;
49914
- const [params = "", results = ""] = signature2.split(":");
50207
+ const colon = signature2.indexOf(":");
50208
+ const params = colon < 0 ? signature2 : signature2.slice(0, colon);
50209
+ const results = colon < 0 ? "" : signature2.slice(colon + 1);
49915
50210
  if (results.length > 1) throw new Error(`sdk function ${name3} returns several values`);
49916
50211
  const result = results ? type(results)[0] : "void";
49917
- const declared = type(params).map((kind, at) => `${kind} a${at}`).join(", ") || "void";
49918
- const passed = type(params).map((_, at) => `a${at}`).join(", ");
50212
+ const paramTypes = type(params);
50213
+ const declParams = paramTypes.join(", ");
50214
+ const defParams = paramTypes.map((kind, at) => `${kind} %a${at}`).join(", ");
50215
+ const callArgs = paramTypes.map((kind, at) => `${kind} %a${at}`).join(", ");
50216
+ const attr = addImportAttr(name3);
50217
+ const quoted2 = llvmQuoted(name3);
49919
50218
  lines.push(
49920
- `__attribute__((import_module("env"), import_name(${literal4(name3)}))) ${result} i${index}(${declared});`,
49921
- `__attribute__((weak)) ${result} f${index}(${declared}) __asm__(${literal4(name3)});`,
49922
- `${result} f${index}(${declared}) { ${result === "void" ? "" : "return "}i${index}(${passed}); }`
50219
+ `declare ${result} @i${index}(${declParams}) #${attr}`,
50220
+ `define weak hidden ${result} @${quoted2}(${defParams}) {`,
50221
+ result === "void" ? ` tail call void @i${index}(${callArgs})
50222
+ ret void` : ` %r = tail call ${result} @i${index}(${callArgs})
50223
+ ret ${result} %r`,
50224
+ "}"
49923
50225
  );
49924
50226
  forwarders.add(name3);
49925
50227
  index++;
49926
50228
  }
49927
50229
  const errno = tls.errno;
49928
50230
  let declaredErrno = false;
50231
+ const usedHelpers = [];
49929
50232
  for (const name3 of referenced) {
49930
50233
  const offset = tls[name3];
49931
50234
  if (offset === void 0 || defined.has(name3)) continue;
@@ -49933,28 +50236,44 @@ async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project
49933
50236
  throw new Error("the sdk image has no errno to find its thread block by");
49934
50237
  if (!declaredErrno) {
49935
50238
  declaredErrno = true;
50239
+ const attr = addImportAttr("__errno_location");
49936
50240
  lines.push(
49937
- `__attribute__((import_module("env"), import_name("__errno_location"))) char *__peach_errno(void);`
50241
+ `declare ptr @__peach_errno() #${attr}`,
50242
+ "declare ptr @llvm.wasm.tls.base()"
49938
50243
  );
49939
50244
  }
50245
+ const helper = `@${llvmQuoted(SDK_TLS_HELPER + name3)}`;
50246
+ const delta = `@${llvmQuoted(SDK_TLS_DELTA + name3)}`;
50247
+ usedHelpers.push(`ptr ${helper}`);
49940
50248
  lines.push(
49941
- `__attribute__((weak)) _Thread_local char t${index} __asm__(${literal4(name3)});`,
49942
- `__attribute__((used)) long long h${index}(void) __asm__(${literal4(SDK_TLS_HELPER + name3)});`,
49943
- `extern char d${index} __asm__(${literal4(SDK_TLS_DELTA + name3)});`,
49944
- `long long h${index}(void) { return (long long)__peach_errno() + (long long)&d${index} - (long long)__builtin_wasm_tls_base(); }`
50249
+ `@${llvmQuoted(name3)} = weak hidden thread_local global i8 0, align 1`,
50250
+ `${delta} = external global i8, align 1`,
50251
+ `define hidden i64 ${helper}() {`,
50252
+ " %e = tail call ptr @__peach_errno()",
50253
+ " %ei = ptrtoint ptr %e to i64",
50254
+ ` %di = ptrtoint ptr ${delta} to i64`,
50255
+ " %s = add i64 %ei, %di",
50256
+ " %b = tail call ptr @llvm.wasm.tls.base()",
50257
+ " %bi = ptrtoint ptr %b to i64",
50258
+ " %r = sub i64 %s, %bi",
50259
+ " ret i64 %r",
50260
+ "}"
49945
50261
  );
49946
50262
  index++;
49947
50263
  }
49948
- const source = `${output.slice(0, -2)}.c`;
49949
- (0, import_node_fs71.writeFileSync)(source, lines.join("\n") + "\n");
50264
+ if (usedHelpers.length > 0) {
50265
+ lines.push(
50266
+ `@llvm.used = appending global [${usedHelpers.length} x ptr] [${usedHelpers.join(", ")}], section "llvm.metadata"`
50267
+ );
50268
+ }
50269
+ const source = `${output.slice(0, -2)}.ll`;
50270
+ (0, import_node_fs71.writeFileSync)(source, [...lines, ...attrs].join("\n") + "\n");
49950
50271
  await run5(
49951
50272
  import_node_path71.default.join(toolchainBin, "clang"),
49952
50273
  [
49953
50274
  `--target=${SWIFT_WASM_TRIPLE}`,
49954
- "-O2",
49955
50275
  "-matomics",
49956
50276
  "-mbulk-memory",
49957
- "-ffreestanding",
49958
50277
  "-c",
49959
50278
  source,
49960
50279
  "-o",
@@ -49973,7 +50292,8 @@ async function linkSwiftAppModule(options2) {
49973
50292
  toolchainBin,
49974
50293
  forwarders,
49975
50294
  options2.project,
49976
- options2.readInput ?? import_node_fs71.readFileSync
50295
+ options2.readInput ?? import_node_fs71.readFileSync,
50296
+ options2.precomputedSymbols
49977
50297
  );
49978
50298
  const lazy = options2.lazyFunctions ?? [];
49979
50299
  const lazyExports = import_node_path71.default.join(work, "lazy-exports.rsp");
@@ -51717,6 +52037,15 @@ async function compileGuestLink(options2) {
51717
52037
  { stdio: "pipe" }
51718
52038
  );
51719
52039
  }
52040
+ let precomputedSymbols;
52041
+ if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
52042
+ const referenced = new Set(splitInputs.appReferencedSymbols);
52043
+ const defined = new Set(splitInputs.appDefinedSymbols);
52044
+ const projSyms = guestWasmSymbols((0, import_node_fs72.readFileSync)(projectionObject));
52045
+ for (const name3 of projSyms.undefined) referenced.add(name3);
52046
+ for (const name3 of projSyms.defined) defined.add(name3);
52047
+ precomputedSymbols = { referenced, defined };
52048
+ }
51720
52049
  for (; ; ) {
51721
52050
  const link = await linkSwiftAppModule2({
51722
52051
  objects: [...owners.keys()],
@@ -51728,6 +52057,7 @@ async function compileGuestLink(options2) {
51728
52057
  optimize: options2.optimize,
51729
52058
  layoutMap,
51730
52059
  project: project2,
52060
+ precomputedSymbols,
51731
52061
  loweringCache: project2 ? void 0 : {
51732
52062
  file: import_node_path72.default.join(
51733
52063
  options2.buildDirectory,
@@ -51852,6 +52182,7 @@ var init_swift_guest_compile = __esm({
51852
52182
  init_swift_runtime_products();
51853
52183
  init_swift_sdk_guest_lookups();
51854
52184
  init_swift_toolchain();
52185
+ init_swift_wasm_prune();
51855
52186
  init_swiftTargetContract();
51856
52187
  init_wasm_optimize();
51857
52188
  }
@@ -53303,7 +53634,25 @@ function swiftBuildJobs() {
53303
53634
  return Math.min(cores, memoryJobs);
53304
53635
  }
53305
53636
  function swiftCompilerJobs() {
53306
- return Math.min(16, swiftBuildJobs(), Math.max(1, Math.floor(import_node_os16.default.totalmem() / 2 ** 31)));
53637
+ return Math.min(32, swiftBuildJobs(), Math.max(1, Math.floor(import_node_os16.default.totalmem() / 2 ** 31)));
53638
+ }
53639
+ function swiftCompilerBaseEnv(toolchainBin, sourceEnv, includePeachHome = false) {
53640
+ const env = {};
53641
+ for (const key2 of SWIFT_COMPILER_ENV_KEYS) {
53642
+ const value = sourceEnv[key2];
53643
+ if (value !== void 0) env[key2] = value;
53644
+ }
53645
+ if (includePeachHome && sourceEnv.PEACH_HOME !== void 0)
53646
+ env.PEACH_HOME = sourceEnv.PEACH_HOME;
53647
+ if (process.platform === "linux") {
53648
+ env.LD_LIBRARY_PATH = [
53649
+ import_node_path81.default.resolve(toolchainBin, "../lib/swift/linux"),
53650
+ import_node_path81.default.resolve(toolchainBin, "../lib/swift/host"),
53651
+ sourceEnv.LD_LIBRARY_PATH
53652
+ ].filter(Boolean).join(":");
53653
+ }
53654
+ env.PEACH_DEFER_WASM_LINK = "1";
53655
+ return env;
53307
53656
  }
53308
53657
  function assertSwiftBuildCores() {
53309
53658
  const admitted = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
@@ -54492,10 +54841,22 @@ function emitSwiftPackageManifest(args) {
54492
54841
  const available2 = distribution.objects.filter(
54493
54842
  (object9) => !isProvider(object9) && !replacedObjects.has(object9)
54494
54843
  );
54844
+ const targetNamesWithDash = targets.filter((target) => target.name.includes("-")).map((target) => `lib/${target.name}-`);
54845
+ const targetNameSet = new Set(targets.map((target) => target.name));
54846
+ const optionalSet = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...GAME_FAMILY, "PeachBox2D"]);
54847
+ const isTargetObject = (object9) => {
54848
+ const dash = object9.indexOf("-", 4);
54849
+ if (dash > 4 && targetNameSet.has(object9.slice(4, dash))) return true;
54850
+ return targetNamesWithDash.some((prefix) => object9.startsWith(prefix));
54851
+ };
54852
+ const isUnreachedOptional = (object9) => {
54853
+ const dash = object9.indexOf("-", 4);
54854
+ if (dash <= 4) return false;
54855
+ const name3 = object9.slice(4, dash);
54856
+ return optionalSet.has(name3) && !reachedFrameworks.has(name3);
54857
+ };
54495
54858
  const objects = available2.filter(
54496
- (object9) => !targets.some((target) => object9.startsWith(`lib/${target.name}-`)) && [...OPTIONAL_FRAMEWORKS, ...GAME_FAMILY, "PeachBox2D"].every(
54497
- (name3) => !object9.startsWith(`lib/${name3}-`) || reachedFrameworks.has(name3)
54498
- )
54859
+ (object9) => !isTargetObject(object9) && !isUnreachedOptional(object9)
54499
54860
  );
54500
54861
  const quoted2 = (object9) => `"${import_node_path81.default.join(moduleRoot, object9).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
54501
54862
  const categoryObjects = new Set(
@@ -54576,18 +54937,53 @@ function emitSwiftPackageManifest(args) {
54576
54937
  args.files.set(file, content);
54577
54938
  return JSON.stringify([`@${file}`]);
54578
54939
  };
54579
- const frameworkDirectories = (name3, seen = /* @__PURE__ */ new Set()) => (siblings.get(name3) ?? []).flatMap((dependency) => {
54580
- if (seen.has(dependency)) return [];
54581
- seen.add(dependency);
54582
- const owner = args.targets.find((other) => other.name === dependency);
54940
+ const targetByName = new Map(targets.map((target) => [target.name, target]));
54941
+ const ownFrameworkDir = /* @__PURE__ */ new Map();
54942
+ for (const target of targets) {
54583
54943
  const framework = /^(.*)\/[^/]+\.framework\/Modules$/.exec(
54584
- owner?.publicHeadersPath ?? ""
54944
+ target.publicHeadersPath ?? ""
54585
54945
  );
54586
- return [
54587
- ...owner && framework ? [import_node_path81.default.posix.join(args.root, owner.path, framework[1])] : [],
54588
- ...frameworkDirectories(dependency, seen)
54589
- ];
54590
- });
54946
+ if (framework)
54947
+ ownFrameworkDir.set(
54948
+ target.name,
54949
+ import_node_path81.default.posix.join(args.root, target.path, framework[1])
54950
+ );
54951
+ }
54952
+ const frameworkDirectoriesCache = /* @__PURE__ */ new Map();
54953
+ const frameworkDirectories = (name3) => {
54954
+ if (ownFrameworkDir.size === 0) return [];
54955
+ const cached4 = frameworkDirectoriesCache.get(name3);
54956
+ if (cached4) return cached4;
54957
+ const dirs = [];
54958
+ const seen = /* @__PURE__ */ new Set();
54959
+ const visit3 = (current2) => {
54960
+ for (const dependency of siblings.get(current2) ?? []) {
54961
+ if (seen.has(dependency)) continue;
54962
+ seen.add(dependency);
54963
+ const dir = ownFrameworkDir.get(dependency);
54964
+ if (dir) dirs.push(dir);
54965
+ visit3(dependency);
54966
+ }
54967
+ };
54968
+ visit3(name3);
54969
+ frameworkDirectoriesCache.set(name3, dirs);
54970
+ return dirs;
54971
+ };
54972
+ const targetSwiftXccFlags = /* @__PURE__ */ new Map();
54973
+ for (const target of targets) {
54974
+ const flags = target.swiftFlags;
54975
+ if (!flags || flags.length === 0) continue;
54976
+ const xcc = [];
54977
+ for (let index = 1; index < flags.length; index++) {
54978
+ if (flags[index - 1] === "-Xcc")
54979
+ xcc.push(flags[index].replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root));
54980
+ }
54981
+ if (xcc.length > 0) targetSwiftXccFlags.set(target.name, xcc);
54982
+ }
54983
+ const binaryImports = args.binaryModules ? `, "-I", ${JSON.stringify(args.binaryModules)}` : "";
54984
+ const sharedImports = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
54985
+ providedModulesPath(args.root, distributionModules, args.moduleExcludes)
54986
+ )}${distributionClangModuleOptions(args.root, distributionModules).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map2) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map2}`)}`).join("")}` : "");
54591
54987
  const frameworkSearchFlags = (target, tool) => frameworkDirectories(target?.name ?? "").map((directory2) => ({
54592
54988
  tool,
54593
54989
  flags: ["-F", directory2]
@@ -54636,10 +55032,7 @@ function emitSwiftPackageManifest(args) {
54636
55032
  const upstream = (target.swiftFlags ?? []).map(
54637
55033
  (flag) => `, ${JSON.stringify(flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root))}`
54638
55034
  ).join("");
54639
- const binaryImports = args.binaryModules ? `, "-I", ${JSON.stringify(args.binaryModules)}` : "";
54640
- const imports2 = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
54641
- providedModulesPath(args.root, distributionModules, args.moduleExcludes)
54642
- )}${distributionClangModuleOptions(args.root, distributionModules).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map2) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map2}`)}`).join("")}` : "");
55035
+ const imports2 = sharedImports;
54643
55036
  const nativeFlags = [
54644
55037
  ...args.nativeFlags?.get(target.name) ?? [],
54645
55038
  ...args.nativeHeaderFlags ?? []
@@ -54663,12 +55056,7 @@ function emitSwiftPackageManifest(args) {
54663
55056
  return map2 ? ["-fmodule-map-file=" + map2] : [];
54664
55057
  }),
54665
55058
  ...[...importContext].flatMap((name3) => args.native?.get(name3)?.importFlags ?? []),
54666
- ...[...importContext].flatMap((name3) => {
54667
- const flags = targets.find((target2) => target2.name === name3)?.swiftFlags ?? [];
54668
- return flags.flatMap(
54669
- (flag, index) => flags[index - 1] === "-Xcc" ? [flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root)] : []
54670
- );
54671
- })
55059
+ ...[...importContext].flatMap((name3) => targetSwiftXccFlags.get(name3) ?? [])
54672
55060
  ];
54673
55061
  const nativeImportFlags = [
54674
55062
  ...frameworkDirectories(target.name).flatMap((directory2) => ["-F", directory2]),
@@ -54683,9 +55071,7 @@ function emitSwiftPackageManifest(args) {
54683
55071
  ...native?.swiftFlags ?? [],
54684
55072
  ...args.objcImplementationModules?.has(target.name) ? ["-enable-experimental-feature", "ObjCImplementation"] : []
54685
55073
  ].map((flag) => `, ${JSON.stringify(flag)}`).join("");
54686
- const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
54687
- (value) => value.late?.producers.includes(target.name)
54688
- )) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path81.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
55074
+ const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || lateProducers.has(target.name)) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path81.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
54689
55075
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
54690
55076
  const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
54691
55077
  const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports2}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`;
@@ -54718,9 +55104,7 @@ function emitSwiftPackageManifest(args) {
54718
55104
  (dependency) => clang && // textual native headers can include one another without imposing
54719
55105
  // an object build order. the executable already links every native
54720
55106
  // target; only generated Swift headers require producer ordering.
54721
- (args.native?.get(dependency)?.clang || [...args.native?.values() ?? []].some(
54722
- (value) => value.late?.producers.includes(dependency)
54723
- )) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targets.some((candidate) => candidate.name === dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
55107
+ (args.native?.get(dependency)?.clang || lateProducers.has(dependency)) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targetNames.has(dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
54724
55108
  ),
54725
55109
  // a swift importer still needs the producers its clang dependencies
54726
55110
  // reached upstream, whose edges the clang targets above dropped.
@@ -54807,7 +55191,7 @@ function emitSwiftPackageManifest(args) {
54807
55191
  ...args.nativeFlags?.get(name3) ?? [],
54808
55192
  ...args.nativeHeaderFlags ?? []
54809
55193
  ];
54810
- const owner = targets.find((target) => target.name === name3);
55194
+ const owner = targetByName.get(name3);
54811
55195
  const context = /* @__PURE__ */ new Set();
54812
55196
  const visit3 = (dependency) => {
54813
55197
  if (context.has(dependency)) return;
@@ -54883,10 +55267,16 @@ ${declaration.replace(/,$/, "")}
54883
55267
  ""
54884
55268
  ].join("\n");
54885
55269
  }
54886
- function syncSwiftTree(base2, files2) {
55270
+ function syncSwiftTree(base2, files2, alreadySynced) {
54887
55271
  (0, import_node_fs79.mkdirSync)(base2, { recursive: true });
54888
- const kept = /* @__PURE__ */ new Set();
54889
- for (const file of files2.keys()) if ((0, import_node_fs79.existsSync)(file)) kept.add((0, import_node_fs79.statSync)(file).ino);
55272
+ let kept;
55273
+ if (process.platform !== "linux") {
55274
+ kept = /* @__PURE__ */ new Set();
55275
+ for (const file of files2.keys()) {
55276
+ const stat2 = (0, import_node_fs79.statSync)(file, { throwIfNoEntry: false });
55277
+ if (stat2) kept.add(stat2.ino);
55278
+ }
55279
+ }
54890
55280
  const walk4 = (dir) => {
54891
55281
  for (const entry of (0, import_node_fs79.readdirSync)(dir, { withFileTypes: true })) {
54892
55282
  const full = import_node_path81.default.join(dir, entry.name);
@@ -54895,12 +55285,13 @@ function syncSwiftTree(base2, files2) {
54895
55285
  entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP))
54896
55286
  continue;
54897
55287
  if (entry.isDirectory()) walk4(full);
54898
- else if (!files2.has(full) && !kept.has((0, import_node_fs79.lstatSync)(full).ino))
55288
+ else if (!files2.has(full) && (!kept || !kept.has((0, import_node_fs79.lstatSync)(full).ino)))
54899
55289
  (0, import_node_fs79.rmSync)(full, { force: true });
54900
55290
  }
54901
55291
  };
54902
55292
  walk4(base2);
54903
55293
  for (const [full, contents2] of files2) {
55294
+ if (alreadySynced?.get(full) === contents2) continue;
54904
55295
  writeBuildFile(full, contents2);
54905
55296
  }
54906
55297
  }
@@ -55008,25 +55399,59 @@ function swiftWasmCallGuards(source, unavailable2) {
55008
55399
  out = out.slice(0, at) + replacement + out.slice(at + width);
55009
55400
  return out;
55010
55401
  }
55402
+ function matchesPathPrefixSet(file, set2) {
55403
+ if (set2.has(file)) return true;
55404
+ for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
55405
+ if (set2.has(file.slice(0, slash))) return true;
55406
+ }
55407
+ return false;
55408
+ }
55409
+ function indexTargetsByDirectory(targets) {
55410
+ const byDir = /* @__PURE__ */ new Map();
55411
+ for (const target of targets) {
55412
+ const key2 = target.path === "." ? "" : target.path.replace(/\/+$/, "");
55413
+ let list2 = byDir.get(key2);
55414
+ if (!list2) byDir.set(key2, list2 = []);
55415
+ list2.push(target);
55416
+ }
55417
+ return byDir;
55418
+ }
55419
+ function findTargetForFile(file, byDir, predicate) {
55420
+ for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
55421
+ const candidates = byDir.get(file.slice(0, slash));
55422
+ if (!candidates) continue;
55423
+ const relative6 = file.slice(slash + 1);
55424
+ for (const target of candidates) if (predicate(target, relative6)) return target;
55425
+ }
55426
+ const rootCandidates = byDir.get("");
55427
+ if (rootCandidates) {
55428
+ for (const target of rootCandidates) if (predicate(target, file)) return target;
55429
+ }
55430
+ return void 0;
55431
+ }
55011
55432
  function compiledSwiftSources(files2, targets, overlayFrameworks, headers, nativeSourceGlue = false) {
55012
55433
  const ordered = [...targets].sort((a, b) => b.path.length - a.path.length);
55013
- const owners = new Map(
55014
- Object.entries(files2).filter(([file]) => file.endsWith(".swift")).map(([file, source]) => {
55015
- const owner = ordered.find((target) => {
55016
- const prefix = target.path === "." ? "" : target.path + "/";
55017
- if (!file.startsWith(prefix)) return false;
55018
- const relative6 = file.slice(prefix.length);
55019
- return !target.exclude?.some(
55020
- (excluded) => relative6 === excluded || relative6.startsWith(excluded + "/")
55021
- );
55022
- });
55023
- return [file, { source, owner }];
55024
- })
55025
- );
55434
+ const byDir = indexTargetsByDirectory(ordered);
55435
+ const excludeSets = /* @__PURE__ */ new Map();
55436
+ for (const target of ordered) {
55437
+ if (target.exclude?.length) excludeSets.set(target.name, new Set(target.exclude));
55438
+ }
55439
+ const owners = /* @__PURE__ */ new Map();
55440
+ for (const [file, source] of Object.entries(files2)) {
55441
+ if (!file.endsWith(".swift")) continue;
55442
+ const owner = findTargetForFile(file, byDir, (target, relative6) => {
55443
+ const excluded = excludeSets.get(target.name);
55444
+ return !excluded || !matchesPathPrefixSet(relative6, excluded);
55445
+ });
55446
+ owners.set(file, { source, owner });
55447
+ }
55026
55448
  const swiftSources = /* @__PURE__ */ new Map();
55027
- for (const { source, owner } of owners.values())
55028
- if (owner)
55029
- swiftSources.set(owner.name, [...swiftSources.get(owner.name) ?? [], source]);
55449
+ for (const { source, owner } of owners.values()) {
55450
+ if (!owner) continue;
55451
+ let list2 = swiftSources.get(owner.name);
55452
+ if (!list2) swiftSources.set(owner.name, list2 = []);
55453
+ list2.push(source);
55454
+ }
55030
55455
  const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
55031
55456
  return new Map(
55032
55457
  [...owners].map(([file, { source, owner }]) => {
@@ -55815,18 +56240,46 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
55815
56240
  const bySourcePath = [...targets].sort(
55816
56241
  (left, right) => right.path.length - left.path.length
55817
56242
  );
56243
+ const targetsByDir = indexTargetsByDirectory(bySourcePath);
56244
+ const targetByName = new Map(targets.map((target) => [target.name, target]));
56245
+ const nativeTargets2 = input.nativeTargets ?? [];
56246
+ const nativeTargetByName = new Map(nativeTargets2.map((target) => [target.name, target]));
56247
+ const nativeTargetIndex = new Map(
56248
+ nativeTargets2.map((target, index) => [target.name, index])
56249
+ );
56250
+ const resourceTargetByName = new Map(
56251
+ resourceTargets.map((target) => [target.name, target])
56252
+ );
56253
+ const targetSourceSets = /* @__PURE__ */ new Map();
56254
+ const targetExcludeFullSets = /* @__PURE__ */ new Map();
56255
+ const targetExcludeExactSets = /* @__PURE__ */ new Map();
56256
+ for (const target of targets) {
56257
+ const prefix = target.path === "." ? "" : `${target.path}/`;
56258
+ if (target.sources !== void 0) {
56259
+ targetSourceSets.set(
56260
+ target.name,
56261
+ new Set(target.sources.map((source) => import_node_path81.default.posix.join(prefix, source)))
56262
+ );
56263
+ }
56264
+ if (target.exclude?.length) {
56265
+ targetExcludeFullSets.set(
56266
+ target.name,
56267
+ new Set(target.exclude.map((excluded) => `${prefix}${excluded}`))
56268
+ );
56269
+ targetExcludeExactSets.set(
56270
+ target.name,
56271
+ new Set(target.exclude.map((name3) => import_node_path81.default.posix.join(target.path, name3)))
56272
+ );
56273
+ }
56274
+ }
55818
56275
  const swiftTargets = /* @__PURE__ */ new Set();
55819
56276
  for (const file of Object.keys(input.files)) {
55820
56277
  if (!file.endsWith(".swift")) continue;
55821
- const target = bySourcePath.find(
55822
- (candidate) => (candidate.path === "." || file.startsWith(`${candidate.path}/`)) && (candidate.sources === void 0 || candidate.sources.some((source) => {
55823
- const selected = import_node_path81.default.posix.join(candidate.path, source);
55824
- return file === selected || file.startsWith(`${selected}/`);
55825
- }))
55826
- );
55827
- const excluded = target?.exclude?.some(
55828
- (name3) => file === import_node_path81.default.posix.join(target.path, name3)
55829
- );
56278
+ const target = findTargetForFile(file, targetsByDir, (candidate) => {
56279
+ const selected = targetSourceSets.get(candidate.name);
56280
+ return !selected || matchesPathPrefixSet(file, selected);
56281
+ });
56282
+ const excluded = target && targetExcludeExactSets.get(target.name)?.has(file);
55830
56283
  if (target && !excluded) swiftTargets.add(target.name);
55831
56284
  }
55832
56285
  const importedModules = /* @__PURE__ */ new Set();
@@ -55864,7 +56317,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
55864
56317
  checkedToolchain = swiftToolchain(pin2.release, swiftModuleSdk(moduleRoot));
55865
56318
  return checkedToolchain;
55866
56319
  };
55867
- const deploymentTarget = (name3) => input.nativeTargets?.find((value) => value.name === name3)?.deploymentTarget ?? targets.find((value) => value.name === name3)?.iosDeploymentTarget ?? null;
56320
+ const deploymentTarget = (name3) => nativeTargetByName.get(name3)?.deploymentTarget ?? targetByName.get(name3)?.iosDeploymentTarget ?? null;
55868
56321
  const targetStagedFiles = /* @__PURE__ */ new Map();
55869
56322
  const stageTargetFile = (target, file, contents2, options2) => {
55870
56323
  const relative6 = import_node_path81.default.relative(layout2.root, file).split(import_node_path81.default.sep).join(import_node_path81.default.posix.sep);
@@ -55876,18 +56329,41 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
55876
56329
  targetStagedFiles.set(target, staged);
55877
56330
  files2.set(file, contents2);
55878
56331
  };
56332
+ const entriesByPrefix = /* @__PURE__ */ new Map();
56333
+ for (const target of targets) {
56334
+ const prefix = target.path === "." ? "" : `${target.path}/`;
56335
+ if (!entriesByPrefix.has(prefix)) entriesByPrefix.set(prefix, []);
56336
+ }
56337
+ for (const entry of Object.entries(input.files)) {
56338
+ const [file] = entry;
56339
+ entriesByPrefix.get("")?.push(entry);
56340
+ for (let end = file.indexOf("/"); end !== -1; end = file.indexOf("/", end + 1)) {
56341
+ entriesByPrefix.get(file.slice(0, end + 1))?.push(entry);
56342
+ }
56343
+ }
56344
+ const targetEntriesCache = /* @__PURE__ */ new Map();
55879
56345
  const targetEntries = (target) => {
56346
+ const cached4 = targetEntriesCache.get(target.name);
56347
+ if (cached4) return cached4;
55880
56348
  const prefix = target.path === "." ? "" : `${target.path}/`;
55881
- return Object.entries(input.files).filter(
55882
- ([file]) => file.startsWith(prefix) && (target.sources === void 0 || !(file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) || target.sources.some((source) => {
55883
- const selected = import_node_path81.default.posix.join(prefix, source);
55884
- return file === selected || file.startsWith(`${selected}/`);
55885
- })) && !target.exclude?.some(
55886
- (excluded) => file === `${prefix}${excluded}` || file.startsWith(`${prefix}${excluded}/`)
55887
- ) && !targets.some(
55888
- (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
55889
- )
55890
- );
56349
+ const selectedSources = targetSourceSets.get(target.name);
56350
+ const excludedPaths = targetExcludeFullSets.get(target.name);
56351
+ const nestedPrefixes = [];
56352
+ for (const candidate of targets) {
56353
+ if (candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix))
56354
+ nestedPrefixes.push(`${candidate.path}/`);
56355
+ }
56356
+ const matched = (entriesByPrefix.get(prefix) ?? []).filter(([file]) => {
56357
+ if (selectedSources !== void 0 && (file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) && !matchesPathPrefixSet(file, selectedSources))
56358
+ return false;
56359
+ if (excludedPaths !== void 0 && matchesPathPrefixSet(file, excludedPaths))
56360
+ return false;
56361
+ if (nestedPrefixes.length > 0 && nestedPrefixes.some((p) => file.startsWith(p)))
56362
+ return false;
56363
+ return true;
56364
+ });
56365
+ targetEntriesCache.set(target.name, matched);
56366
+ return matched;
55891
56367
  };
55892
56368
  const failTargetPreparation = (target, message) => {
55893
56369
  const prefix = target.path === "." ? "" : `${target.path}/`;
@@ -55932,19 +56408,21 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
55932
56408
  return value;
55933
56409
  };
55934
56410
  const podHeaders = /* @__PURE__ */ new Map();
55935
- for (const settings of input.nativeTargets ?? [])
56411
+ for (const settings of nativeTargets2)
55936
56412
  for (const file of settings.headers) {
55937
56413
  const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
55938
56414
  file
55939
56415
  )?.[1];
55940
- if (owner)
55941
- podHeaders.set(import_node_path81.default.basename(file), [
55942
- ...podHeaders.get(import_node_path81.default.basename(file)) ?? [],
55943
- { owner, content: input.files[file] }
55944
- ]);
56416
+ if (owner) {
56417
+ const base2 = import_node_path81.default.basename(file);
56418
+ let list2 = podHeaders.get(base2);
56419
+ if (!list2) podHeaders.set(base2, list2 = []);
56420
+ list2.push({ owner, content: input.files[file] });
56421
+ }
55945
56422
  }
55946
56423
  const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(import_node_path81.default.basename(file))?.find((header) => header.content === content)?.owner;
55947
- for (const settings of input.nativeTargets ?? []) {
56424
+ const alreadySynced = /* @__PURE__ */ new Map();
56425
+ for (const settings of nativeTargets2) {
55948
56426
  for (const file of settings.headers) {
55949
56427
  const destination = import_node_path81.default.join(layout2.root, file);
55950
56428
  if (files2.has(destination)) continue;
@@ -55961,10 +56439,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
55961
56439
  `#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`
55962
56440
  ) : rawContents;
55963
56441
  writeBuildFile(destination, contents2);
56442
+ alreadySynced.set(destination, contents2);
55964
56443
  files2.set(destination, contents2);
55965
56444
  }
55966
56445
  }
55967
- const nativeTargets2 = input.nativeTargets ?? [];
55968
56446
  const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? import_node_path81.default.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
55969
56447
  const inRoot = `${layout2.root}${import_node_path81.default.sep}`;
55970
56448
  const binaryTree = `${import_node_path81.default.sep}${SWIFT_BINARY_TREES_DIR}${import_node_path81.default.sep}`;
@@ -56029,12 +56507,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
56029
56507
  const prefix = target.path === "." ? "" : `${target.path}/`;
56030
56508
  const entries2 = targetEntries(target);
56031
56509
  const units = entries2.filter(([file]) => isSwiftNativeTranslationUnit(file));
56032
- if (units.length === 0 && !(entries2.some(([file]) => file.endsWith(".swift")) && input.nativeTargets?.some(
56033
- (settings2) => settings2.name === target.name && (settings2.publicHeaders.length > 0 || settings2.bridgingHeader !== null)
56034
- )))
56510
+ const settings = nativeTargetByName.get(target.name);
56511
+ if (units.length === 0 && !(entries2.some(([file]) => file.endsWith(".swift")) && settings !== void 0 && (settings.publicHeaders.length > 0 || settings.bridgingHeader !== null)))
56035
56512
  continue;
56036
56513
  const includes = `${prefix}include/`;
56037
- const settings = input.nativeTargets?.find((value) => value.name === target.name);
56038
56514
  const searchRoots = [
56039
56515
  ...settings?.userHeaderSearchPaths ?? [],
56040
56516
  ...settings?.headerSearchPaths ?? [],
@@ -56065,7 +56541,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
56065
56541
  ...searchRoots.map((root) => import_node_path81.default.posix.join(root, include))
56066
56542
  ].find((candidate) => input.files[candidate] !== void 0);
56067
56543
  if (local) {
56068
- reverse.set(local, [...reverse.get(local) ?? [], file]);
56544
+ let parents = reverse.get(local);
56545
+ if (!parents) reverse.set(local, parents = []);
56546
+ parents.push(file);
56069
56547
  if (xcodeTarget && !seenHeaders.has(local)) {
56070
56548
  seenHeaders.add(local);
56071
56549
  searchEntries.push([local, input.files[local]]);
@@ -56111,9 +56589,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
56111
56589
  const stageFlags = (flags2, sdkInclude2) => flags2.map(
56112
56590
  (flag) => flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout2.root).replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude2)
56113
56591
  );
56592
+ const settingsHeaderFlags = headerSearch.flags[nativeTargetIndex.get(settings.name)];
56114
56593
  const originalFlags = [
56115
56594
  ...settings.flags,
56116
- ...headerSearch.flags[nativeTargets2.indexOf(settings)],
56595
+ ...settingsHeaderFlags,
56117
56596
  ...search,
56118
56597
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
56119
56598
  "-F",
@@ -56124,7 +56603,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
56124
56603
  ];
56125
56604
  const importOriginalFlags = settings.flattensPublicHeaders ? [
56126
56605
  ...settings.importerFlags,
56127
- ...headerSearch.flags[nativeTargets2.indexOf(settings)],
56606
+ ...settingsHeaderFlags,
56128
56607
  ...search,
56129
56608
  ...settings.frameworkSearchPaths.flatMap((dir) => [
56130
56609
  "-F",
@@ -56149,7 +56628,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
56149
56628
  }
56150
56629
  return [
56151
56630
  ...kept,
56152
- ...headerSearch.flags[nativeTargets2.indexOf(settings)],
56631
+ ...settingsHeaderFlags,
56153
56632
  ...search,
56154
56633
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
56155
56634
  "-F",
@@ -56178,7 +56657,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
56178
56657
  const bundleName = entries2.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
56179
56658
  target: target.name,
56180
56659
  path: target.path,
56181
- resources: resourceTargets.find((candidate) => candidate.name === target.name)?.resources ?? false,
56660
+ resources: resourceTargetByName.get(target.name)?.resources ?? false,
56182
56661
  usesBundleMacro: entries2.some(
56183
56662
  ([file, contents2]) => (isSwiftNativeTranslationUnit(file) || /\.(?:h|hpp|hh|hxx)$/.test(file)) && /\bSWIFTPM_MODULE_BUNDLE\b/.test(contents2)
56184
56663
  ),
@@ -56331,10 +56810,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
56331
56810
  .../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
56332
56811
  ...stageFlags(
56333
56812
  [...objcCxx ? settings.cxxFlags : [], ...fileFlags],
56334
- import_node_path81.default.join(
56335
- swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
56336
- "darwin/usr/include"
56337
- )
56813
+ sdkInclude
56338
56814
  )
56339
56815
  ];
56340
56816
  const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
@@ -56374,13 +56850,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
56374
56850
  ...flags,
56375
56851
  ...prefixHeader,
56376
56852
  ...accessorFlags,
56377
- ...stageFlags(
56378
- cxx ? settings.cxxFlags : [],
56379
- import_node_path81.default.join(
56380
- swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
56381
- "darwin/usr/include"
56382
- )
56383
- ),
56853
+ ...stageFlags(cxx ? settings.cxxFlags : [], sdkInclude),
56384
56854
  ...perFile,
56385
56855
  ...moduleFlag
56386
56856
  ]
@@ -56635,7 +57105,9 @@ module ${moduleName2}.Swift {
56635
57105
  }
56636
57106
  ` : swiftObjCModuleMap(
56637
57107
  moduleName2,
56638
- (input.nativeTargets?.find((target) => target.name === name3)?.publicHeaders ?? []).map((header) => import_node_path81.default.join(layout2.root, header)),
57108
+ (nativeTargetByName.get(name3)?.publicHeaders ?? []).map(
57109
+ (header) => import_node_path81.default.join(layout2.root, header)
57110
+ ),
56639
57111
  submoduleImports2.get(moduleName2),
56640
57112
  import_node_path81.default.join(headerDirectory, name3 + "-Swift.h")
56641
57113
  )
@@ -57185,6 +57657,7 @@ ${entry}`);
57185
57657
  files2.set(destination, Buffer.from(bytes, "base64"));
57186
57658
  }
57187
57659
  const targetToolset = nativeToolset || native.size > 0;
57660
+ let usesObjcPrebuilt = false;
57188
57661
  if (targetToolset) {
57189
57662
  const nativeToolsetFlags = [
57190
57663
  ...headerAliasFlags,
@@ -57205,6 +57678,7 @@ ${entry}`);
57205
57678
  [...native.keys()],
57206
57679
  objcPrebuiltStage
57207
57680
  ) : [];
57681
+ usesObjcPrebuilt = prebuiltCompiler.length > 0;
57208
57682
  files2.set(
57209
57683
  clangWrapper2,
57210
57684
  [
@@ -57513,17 +57987,39 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
57513
57987
  (name3) => !nativePrerequisiteSet.has(name3)
57514
57988
  );
57515
57989
  const nativeTargetUnitCount = /* @__PURE__ */ new Map();
57990
+ const nativeTargetSources = /* @__PURE__ */ new Map();
57516
57991
  for (const target of manifestTargets)
57517
- if (target.sources?.length)
57992
+ if (target.sources?.length) {
57518
57993
  nativeTargetUnitCount.set(target.name, target.sources.length);
57994
+ nativeTargetSources.set(target.name, target.sources);
57995
+ }
57519
57996
  for (const [name3, plan] of native) {
57520
- if (!plan.mixed && plan.sources.length > 0)
57521
- nativeTargetUnitCount.set(name3, plan.clang?.sources.length ?? plan.sources.length);
57522
- for (const group of plan.groups ?? [])
57997
+ if (!plan.mixed && plan.sources.length > 0) {
57998
+ const sources = plan.clang?.sources ?? plan.sources;
57999
+ nativeTargetUnitCount.set(name3, sources.length);
58000
+ nativeTargetSources.set(name3, sources);
58001
+ }
58002
+ for (const group of plan.groups ?? []) {
57523
58003
  nativeTargetUnitCount.set(group.name, group.sources.length);
57524
- if (plan.late && !plan.groups?.length)
58004
+ nativeTargetSources.set(group.name, group.sources);
58005
+ }
58006
+ if (plan.late && !plan.groups?.length) {
57525
58007
  nativeTargetUnitCount.set(plan.late.name, plan.sources.length);
58008
+ nativeTargetSources.set(plan.late.name, plan.lateSources);
58009
+ }
57526
58010
  }
58011
+ const nativeStageObjects = /* @__PURE__ */ new Map();
58012
+ const recordStageObjects = (stageTarget, members2) => {
58013
+ const objects = [];
58014
+ for (const member of members2) {
58015
+ const sources = nativeTargetSources.get(member);
58016
+ if (!sources || sources.length === 0) return stageTarget;
58017
+ for (const source of sources)
58018
+ objects.push(import_node_path81.default.join(`${member}.build`, `${source}.o`));
58019
+ }
58020
+ nativeStageObjects.set(stageTarget, objects);
58021
+ return stageTarget;
58022
+ };
57527
58023
  const MAX_NATIVE_STAGE_UNITS = 250;
57528
58024
  const chunkNativeStageTargets = (prefix, names) => {
57529
58025
  if (names.length === 0) return [];
@@ -57532,7 +58028,7 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
57532
58028
  0
57533
58029
  );
57534
58030
  if (names.length === 1 || total <= MAX_NATIVE_STAGE_UNITS)
57535
- return [buildProduct(prefix, names)];
58031
+ return [recordStageObjects(buildProduct(prefix, names), names)];
57536
58032
  const chunks = [];
57537
58033
  let current2 = [];
57538
58034
  let count = 0;
@@ -57547,7 +58043,9 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
57547
58043
  count += size2;
57548
58044
  }
57549
58045
  if (current2.length > 0) chunks.push(current2);
57550
- return chunks.map((members2, index) => buildProduct(`${prefix}${index + 1}`, members2));
58046
+ return chunks.map(
58047
+ (members2, index) => recordStageObjects(buildProduct(`${prefix}${index + 1}`, members2), members2)
58048
+ );
57551
58049
  };
57552
58050
  const nativePrerequisiteStageTargets = chunkNativeStageTargets(
57553
58051
  "PeachHeaderNativePrereqs",
@@ -57558,7 +58056,7 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
57558
58056
  remainingNativeBuildTargets
57559
58057
  );
57560
58058
  files2.set(manifestPath, manifest);
57561
- syncSwiftTree(layout2.root, files2);
58059
+ syncSwiftTree(layout2.root, files2, alreadySynced);
57562
58060
  if (layout2.multi)
57563
58061
  for (const target of targets)
57564
58062
  (0, import_node_fs79.mkdirSync)(import_node_path81.default.join(layout2.root, target.path), { recursive: true });
@@ -57573,7 +58071,9 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
57573
58071
  targetFailures,
57574
58072
  generatedOwners,
57575
58073
  targetToolset,
57576
- headerCompiler
58074
+ headerCompiler,
58075
+ usesObjcPrebuilt,
58076
+ nativeStageObjects
57577
58077
  };
57578
58078
  }
57579
58079
  function streamText(value) {
@@ -58659,8 +59159,8 @@ ${cap}` : "";
58659
59159
  work,
58660
59160
  unoptimized
58661
59161
  );
58662
- const baseBuildEnv = {
58663
- ...options2.project?.env ?? process.env,
59162
+ const baseBuildEnv = options2.project?.env ? {
59163
+ ...options2.project.env,
58664
59164
  // shipped host plugins resolve against the selected compiler's runtime.
58665
59165
  ...process.platform === "linux" ? {
58666
59166
  LD_LIBRARY_PATH: [
@@ -58670,7 +59170,7 @@ ${cap}` : "";
58670
59170
  ].filter(Boolean).join(":")
58671
59171
  } : {},
58672
59172
  PEACH_DEFER_WASM_LINK: "1"
58673
- };
59173
+ } : swiftCompilerBaseEnv(options2.toolchainBin, process.env);
58674
59174
  const {
58675
59175
  frameworkRoot,
58676
59176
  compileFrameworkRoot,
@@ -58814,7 +59314,11 @@ ${cap}` : "";
58814
59314
  } : {
58815
59315
  ...buildOptions,
58816
59316
  temporaryDirectory,
58817
- env: { ...buildOptions.env, ...compiler }
59317
+ env: {
59318
+ ...buildOptions.env,
59319
+ ...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
59320
+ ...compiler
59321
+ }
58818
59322
  };
58819
59323
  const unprepared = preparation.targetFailures.map(
58820
59324
  (failure2) => `error: target ${failure2}`
@@ -58861,10 +59365,18 @@ ${cap}` : "";
58861
59365
  // the mirror finds a changed sdk header's readers in their
58862
59366
  // dependency files, which omit system headers by default
58863
59367
  ...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
58864
- // the link strips debug info, so none is generated (as for the framework)
59368
+ // the link strips debug info, so none is generated (as for the framework).
59369
+ // keep -num-threads fixed across caller core caps so llbuild does not
59370
+ // rebuild every target when callers alternate --cores, and bound backend
59371
+ // fan-out under high -j.
58865
59372
  "-Xswiftc",
58866
59373
  "-gnone",
58867
- ...incrementalPreview ? [] : ["-Xswiftc", "-num-threads", "-Xswiftc", String(perFile ? 1 : jobs)],
59374
+ ...incrementalPreview ? [] : [
59375
+ "-Xswiftc",
59376
+ "-num-threads",
59377
+ "-Xswiftc",
59378
+ String(perFile ? 1 : Math.min(8, import_node_os16.default.availableParallelism()))
59379
+ ],
58868
59380
  ...swiftReproducibleBuildFlags([
58869
59381
  [import_node_path81.default.dirname(options2.toolchainBin), "toolchain"],
58870
59382
  [compileFrameworkRoot, "framework"],
@@ -59039,7 +59551,18 @@ ${cap}` : "";
59039
59551
  }))
59040
59552
  ];
59041
59553
  const checkpoints = import_node_path81.default.join(root, ".build", "peach-product-checkpoints");
59554
+ const buildDbExists = (0, import_node_fs79.existsSync)(import_node_path81.default.join(root, ".build", "build.db"));
59555
+ const releaseDir = import_node_path81.default.dirname(linked);
59042
59556
  for (const { target, producers } of stages) {
59557
+ if (!options2.project && producers.length === 0 && buildDbExists) {
59558
+ const expectedObjects = preparation.nativeStageObjects.get(target);
59559
+ if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
59560
+ (relative6) => (0, import_node_fs79.statSync)(import_node_path81.default.join(releaseDir, relative6), {
59561
+ throwIfNoEntry: false
59562
+ })?.isFile()
59563
+ ))
59564
+ continue;
59565
+ }
59043
59566
  const receipt = import_node_path81.default.join(
59044
59567
  checkpoints,
59045
59568
  (0, import_node_crypto47.createHash)("sha256").update(target).digest("hex")
@@ -59264,7 +59787,7 @@ ${cap}` : "";
59264
59787
  options2.signal
59265
59788
  );
59266
59789
  }
59267
- var import_node_child_process40, import_node_crypto47, import_node_fs79, import_node_os16, import_node_path81, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, frameworkProductsReceiptSchema, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN;
59790
+ var import_node_child_process40, import_node_crypto47, import_node_fs79, import_node_os16, import_node_path81, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, SWIFT_COMPILER_ENV_KEYS, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, frameworkProductsReceiptSchema, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN;
59268
59791
  var init_swift_compile = __esm({
59269
59792
  "src/swift-compile.ts"() {
59270
59793
  "use strict";
@@ -59317,6 +59840,29 @@ var init_swift_compile = __esm({
59317
59840
  WASM_TRIPLE = SWIFT_WASM_TRIPLE;
59318
59841
  SWIFTPM_PROGRESS = /^\[\d+\/\d+\] /;
59319
59842
  SWIFTPM_NOISE = /^(?:\[\d+\/\d+\] |Building for production\.\.\.$|warning: '--build-system native' has been deprecated)/;
59843
+ SWIFT_COMPILER_ENV_KEYS = [
59844
+ "PATH",
59845
+ "HOME",
59846
+ "USER",
59847
+ "LOGNAME",
59848
+ "LANG",
59849
+ "LC_ALL",
59850
+ "LC_CTYPE",
59851
+ "TZ",
59852
+ "SDKROOT",
59853
+ "DEVELOPER_DIR",
59854
+ "DYLD_LIBRARY_PATH",
59855
+ "SYSTEMROOT",
59856
+ "COMSPEC",
59857
+ "SSL_CERT_FILE",
59858
+ "SSL_CERT_DIR",
59859
+ "HTTP_PROXY",
59860
+ "HTTPS_PROXY",
59861
+ "NO_PROXY",
59862
+ "http_proxy",
59863
+ "https_proxy",
59864
+ "no_proxy"
59865
+ ];
59320
59866
  distributionManifests = /* @__PURE__ */ new Map();
59321
59867
  distributionCompileViews = /* @__PURE__ */ new WeakMap();
59322
59868
  REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
@@ -59512,7 +60058,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
59512
60058
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
59513
60059
  MULTI_MANIFEST_VERSION = 76;
59514
60060
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
59515
- compilerSourceDigest = true ? "84e8740a8ff00df2947e9a04dd004746185926dfa020e1e4c11e79eb39d1e566" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
60061
+ compilerSourceDigest = true ? "4d55fa7cbb29586c08e4e51867226f96047bae2103c89f4fa59d9cf3ed3862fb" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
59516
60062
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
59517
60063
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
59518
60064
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -121198,7 +121744,7 @@ var init_nitro_superset = __esm({
121198
121744
  init_nitroContract();
121199
121745
  init_swift_standin_digest();
121200
121746
  NITRO_SUPERSET_ENTRY_NAME = "superset";
121201
- NITRO_COMPILER_DIGEST = true ? "158901f2ad5a7ece41419fcbea1164e798d53f94d221ae642a58eb58a002a884" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
121747
+ NITRO_COMPILER_DIGEST = true ? "e035fd2365cc4b70f472d1b90eb9d912a775ab289e281922a22092c6945c4f46" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
121202
121748
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
121203
121749
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
121204
121750
  published3 = /* @__PURE__ */ new Map();