peachsim 0.1.2592 → 0.1.2594

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 +1737 -1648
  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-67PU73QE.mjs → acorn-M67PRRGJ.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-EWHA6X3Z.mjs → chunk-3VEDDAPT.mjs} +5 -5
  28. package/dist-lib/esm-chunks/{chunk-DFF5XZ5M.mjs → chunk-4AOZYVB2.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-PITO2NI2.mjs → chunk-6MZ5FKMK.mjs} +2 -2
  30. package/dist-lib/esm-chunks/{chunk-6DB5FR7S.mjs → chunk-EDBGKIQ2.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-EITX573K.mjs → chunk-FFHDCOXF.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-GY6TE4B4.mjs → chunk-GER2Z6BI.mjs} +4 -4
  33. package/dist-lib/esm-chunks/{chunk-QSFWBVUO.mjs → chunk-HJJI36KV.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-EHRSWFTD.mjs → chunk-INOLFCG5.mjs} +3 -3
  35. package/dist-lib/esm-chunks/{chunk-CF3MTPMY.mjs → chunk-IUDVBSA4.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-GQ3EO2UV.mjs → chunk-NN73CP4F.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-XZ3FX3HW.mjs → chunk-PESI6OUB.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-RV4ACE6R.mjs → chunk-QHYHKB3J.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-KDI5YYQ6.mjs → chunk-QSPPJOT6.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-R3WTQB5J.mjs → chunk-QUMKCF67.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-FYXXFYML.mjs → chunk-RESE3ERA.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-TJZPNFVF.mjs → chunk-SBHXHWKH.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-M4QLI2SY.mjs → chunk-SV76NV36.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-XSQH4R5E.mjs → chunk-UAEIMMNH.mjs} +69 -48
  45. package/dist-lib/esm-chunks/{chunk-D4LYKRRB.mjs → chunk-X242Y5KS.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-L5T3HBPO.mjs → chunk-XM3OLATO.mjs} +240 -206
  47. package/dist-lib/esm-chunks/{chunk-SW4PSSTF.mjs → chunk-YGDCMWUX.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-5FTHILIE.mjs → chunk-Z6E7GAQS.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{metro-layout-parser-EX65MARK.mjs → metro-layout-parser-ZJUAU4C3.mjs} +3 -3
  50. package/dist-lib/esm-chunks/{swift-package-prebuilt-3BPDQVA7.mjs → swift-package-prebuilt-2FFVA7SB.mjs} +10 -10
  51. package/dist-lib/esm-chunks/{swift-sdk-app-module-CRX6E3TR.mjs → swift-sdk-app-module-A2ZJMCBX.mjs} +30 -20
  52. package/dist-lib/esm-chunks/{swift-sdk-image-EJD5TPQH.mjs → swift-sdk-image-HJLWK2B6.mjs} +14 -14
  53. package/dist-lib/esm-chunks/{swift-sdk-image-producer-QAZOSLTZ.mjs → swift-sdk-image-producer-7EM7U2LR.mjs} +4 -4
  54. package/dist-lib/expo-swift-bundle.cjs +324 -235
  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 +480 -255
  59. package/dist-lib/host/fetch-proxy-handler.cjs +67 -16
  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 +5 -5
  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 +71 -71
  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 +480 -255
  93. package/dist-lib/swift-compile.cjs +286 -230
  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/kotlin/sdk.tar.gz +0 -0
  126. package/package.json +1 -1
  127. package/src/binaryen.lock.json +3 -3
  128. package/src/host/fetch-proxy-handler.ts +63 -9
  129. package/src/one-native-controls-package.ts +95 -10
  130. package/src/one-sdk-preparation.ts +40 -2
  131. package/src/swift-guest-compile.ts +11 -2
  132. package/src/swift-guest-projection-storage.ts +45 -26
  133. package/src/swift-guest-runtime-plan.ts +1 -1
  134. package/src/swift-sdk-app-module.ts +15 -6
  135. package/src/swift-sdk-image-wasm.ts +5 -2
  136. package/src/swift-sdk-image.ts +69 -49
  137. package/src/swift-wasm-prune.ts +51 -34
  138. package/src/wasm-optimize.ts +146 -140
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2592 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2594 | (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;
@@ -6955,6 +6955,7 @@ var init_swiftSdkLinkContract = __esm({
6955
6955
 
6956
6956
  // src/swift-sdk-image-wasm.ts
6957
6957
  function wasmReader(bytes, start) {
6958
+ const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
6958
6959
  let at = start;
6959
6960
  const u = () => {
6960
6961
  let value = 0;
@@ -6983,7 +6984,7 @@ function wasmReader(bytes, start) {
6983
6984
  name: () => {
6984
6985
  const length = u();
6985
6986
  at += length;
6986
- return Buffer.from(bytes.subarray(at - length, at)).toString();
6987
+ return rawBuf.toString("utf8", at - length, at);
6987
6988
  },
6988
6989
  skip: (length) => {
6989
6990
  at += length;
@@ -7337,7 +7338,7 @@ function codeOnlySdkImage(bytes, constructorMask) {
7337
7338
  const bodies = m.bodies.map(({ start, end }) => bytes.subarray(start, end));
7338
7339
  const initMemory = functionIndex("__wasm_init_memory") - m.importedFuncs;
7339
7340
  {
7340
- const body = Uint8Array.from(bodies[initMemory]);
7341
+ const body = new Uint8Array(bodies[initMemory]);
7341
7342
  const r = wasmReader(body, 0);
7342
7343
  if (r.u() !== 0) throw new Error("sdk memory initializer has locals");
7343
7344
  while (r.at < body.length) {
@@ -8373,7 +8374,18 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
8373
8374
  dataOwnerSymIdx[kept] = ownerSymIdx;
8374
8375
  kept++;
8375
8376
  }
8376
- const dataRelocs = {
8377
+ const dataRelocs = kept === rawData.count ? {
8378
+ count: kept,
8379
+ bytes: rawData.bytes,
8380
+ start: rawData.start,
8381
+ end: rawData.end,
8382
+ ro: rawData.ro,
8383
+ rs: rawData.rs,
8384
+ addend: rawData.addend,
8385
+ segIdx: dataSegIdx,
8386
+ offInSeg: dataOffInSeg,
8387
+ ownerSymIdx: dataOwnerSymIdx
8388
+ } : {
8377
8389
  count: kept,
8378
8390
  bytes: rawData.bytes,
8379
8391
  start: rawData.start.slice(0, kept),
@@ -8385,26 +8397,29 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
8385
8397
  offInSeg: dataOffInSeg.slice(0, kept),
8386
8398
  ownerSymIdx: dataOwnerSymIdx.slice(0, kept)
8387
8399
  };
8388
- const relocatedWords = /* @__PURE__ */ new Map();
8389
- for (let i = 0; i < dataRelocs.count; i++) {
8390
- const segIdx = dataRelocs.segIdx[i];
8391
- let words = relocatedWords.get(segIdx);
8392
- if (!words) relocatedWords.set(segIdx, words = /* @__PURE__ */ new Set());
8393
- words.add(dataRelocs.offInSeg[i]);
8394
- }
8395
- for (const [segIdx, tops] of segTopSyms) {
8396
- const starts = new Map(tops.map((top) => [top.off, top.symIdx]));
8397
- const relocated = relocatedWords.get(segIdx);
8398
- const payload = dataStart + sPayloadStarts[segIdx];
8399
- const view = new DataView(buf.buffer, buf.byteOffset + payload);
8400
- for (const top of tops) {
8401
- for (let at = top.off; at + 4 <= top.end; at += 4) {
8402
- if (relocated?.has(at)) continue;
8403
- const target = starts.get(at + (view.getInt32(at, true) & ~3));
8404
- if (target === void 0 || target === top.symIdx) continue;
8405
- let list = symDataRelocs.get(top.symIdx);
8406
- if (!list) symDataRelocs.set(top.symIdx, list = []);
8407
- list.push(target);
8400
+ if (segTopSyms.size > 0) {
8401
+ const relocatedWords = /* @__PURE__ */ new Map();
8402
+ for (let i = 0; i < dataRelocs.count; i++) {
8403
+ const segIdx = dataRelocs.segIdx[i];
8404
+ if (!segTopSyms.has(segIdx)) continue;
8405
+ let words = relocatedWords.get(segIdx);
8406
+ if (!words) relocatedWords.set(segIdx, words = /* @__PURE__ */ new Set());
8407
+ words.add(dataRelocs.offInSeg[i]);
8408
+ }
8409
+ for (const [segIdx, tops] of segTopSyms) {
8410
+ const starts = new Map(tops.map((top) => [top.off, top.symIdx]));
8411
+ const relocated = relocatedWords.get(segIdx);
8412
+ const payload = dataStart + sPayloadStarts[segIdx];
8413
+ const view = new DataView(buf.buffer, buf.byteOffset + payload);
8414
+ for (const top of tops) {
8415
+ for (let at = top.off; at + 4 <= top.end; at += 4) {
8416
+ if (relocated?.has(at)) continue;
8417
+ const target = starts.get(at + (view.getInt32(at, true) & ~3));
8418
+ if (target === void 0 || target === top.symIdx) continue;
8419
+ let list = symDataRelocs.get(top.symIdx);
8420
+ if (!list) symDataRelocs.set(top.symIdx, list = []);
8421
+ list.push(target);
8422
+ }
8408
8423
  }
8409
8424
  }
8410
8425
  }
@@ -8576,7 +8591,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
8576
8591
  };
8577
8592
  }
8578
8593
  function parseWasmObjectFile(file, isDist) {
8579
- return parseWasmObjectBytes(file, new Uint8Array(import_node_fs16.default.readFileSync(file)), isDist);
8594
+ return parseWasmObjectBytes(file, import_node_fs16.default.readFileSync(file), isDist);
8580
8595
  }
8581
8596
  function parseWasmObjectCached(file, isDist, entries2) {
8582
8597
  const key = `${isDist ? "1" : "0"}:${file}`;
@@ -11704,18 +11719,6 @@ function readWasmMemoryAndTableImports(bytes, layout2) {
11704
11719
  }
11705
11720
  return { memory, tableImports };
11706
11721
  }
11707
- function hasWasmExport(bytes, name3) {
11708
- const section2 = wasmSections2(bytes).find((value) => value.id === 7);
11709
- if (!section2) return false;
11710
- const input = readWasmSection(bytes, section2.start, section2.end);
11711
- for (let count = input.number(); count > 0; count--) {
11712
- const found = input.name();
11713
- input.byte();
11714
- input.number();
11715
- if (found === name3) return true;
11716
- }
11717
- return false;
11718
- }
11719
11722
  function withSections(bytes, layout2, replacements) {
11720
11723
  const parts = [bytes.subarray(0, 8)];
11721
11724
  let at = 8;
@@ -12434,23 +12437,40 @@ function reserveGuestProjectionStorage(images, capacities) {
12434
12437
  };
12435
12438
  }
12436
12439
  function mergeGuestProjectionSpans(imageCount, spans) {
12437
- const sorted = [...spans].sort(
12438
- (a, b) => a.space.localeCompare(b.space) || a.address - b.address || a.image - b.image
12439
- );
12440
- const merged = [];
12441
- for (const span of sorted) {
12440
+ const tableSpans = [];
12441
+ const memorySpans = [];
12442
+ for (const span of spans) {
12442
12443
  if (!Number.isInteger(span.image) || span.image < 0 || span.image >= imageCount || !Number.isInteger(span.address) || !Number.isInteger(span.length) || span.address < 0 || span.length <= 0 || span.address + span.length > 4294967296)
12443
12444
  throw new Error("invalid linked guest span");
12444
- const previous = merged[merged.length - 1];
12445
- if (previous && previous.space === span.space && span.address < previous.address + previous.length && previous.image !== span.image)
12446
- throw new Error("linked guest span has ambiguous image ownership");
12447
- if (previous && previous.space === span.space && previous.image === span.image && span.address <= previous.address + previous.length) {
12448
- merged[merged.length - 1] = {
12449
- ...previous,
12450
- length: Math.max(previous.address + previous.length, span.address + span.length) - previous.address
12451
- };
12452
- } else merged.push(span);
12445
+ if (span.space === "function-table") tableSpans.push(span);
12446
+ else memorySpans.push(span);
12453
12447
  }
12448
+ const byAddress = (a, b) => a.address - b.address || a.image - b.image;
12449
+ tableSpans.sort(byAddress);
12450
+ memorySpans.sort(byAddress);
12451
+ const merged = [];
12452
+ const mergeGroup = (group) => {
12453
+ let previous = null;
12454
+ for (const span of group) {
12455
+ if (previous && span.address < previous.address + previous.length && previous.image !== span.image)
12456
+ throw new Error("linked guest span has ambiguous image ownership");
12457
+ if (previous && previous.image === span.image && span.address <= previous.address + previous.length) {
12458
+ const end = span.address + span.length;
12459
+ if (end > previous.address + previous.length)
12460
+ previous.length = end - previous.address;
12461
+ } else {
12462
+ previous = {
12463
+ image: span.image,
12464
+ space: span.space,
12465
+ address: span.address,
12466
+ length: span.length
12467
+ };
12468
+ merged.push(previous);
12469
+ }
12470
+ }
12471
+ };
12472
+ mergeGroup(tableSpans);
12473
+ mergeGroup(memorySpans);
12454
12474
  return merged;
12455
12475
  }
12456
12476
  function guestProjectionRegionCounts(imageCount, spans) {
@@ -12646,7 +12666,7 @@ function sdkArtifactBytes(root, artifact) {
12646
12666
  const source = (0, import_node_fs19.readFileSync)(import_node_path19.default.join(sourceDirectory, "libFoundation.a"));
12647
12667
  if (hash(source) !== artifact.sha256)
12648
12668
  throw new Error(`SDK product artifact changed ${file}`);
12649
- const transformed = Uint8Array.from(source);
12669
+ const transformed = new Uint8Array(source);
12650
12670
  weakenFoundationOverridesInArchive(transformed);
12651
12671
  if (!linked.equals(transformed))
12652
12672
  throw new Error(`SDK view transformation changed ${file}`);
@@ -13495,17 +13515,17 @@ var init_binaryen_lock = __esm({
13495
13515
  "linux-x64": {
13496
13516
  asset: "x86_64-linux",
13497
13517
  upstreamSha256: "195ddc94f9bc89f45abdabb0b9eea86023d727ba90eac8b35b80f2544fc30572",
13498
- sha256: "feda0b3a5a24c902ec25e8d674f33c5771a0704e611a2e8e4800ab3c3fc591ca"
13518
+ sha256: "1024974f254c1c2edd738246ec6af5add16d3d36b5f58a94545febda3b33c869"
13499
13519
  },
13500
13520
  "linux-arm64": {
13501
13521
  asset: "aarch64-linux",
13502
13522
  upstreamSha256: "c58562417836c5d0493d89bdefc434933bdc097db641b483df86bcfa557a107f",
13503
- sha256: "0c67b9f36e9337afddf13b5150ab0e30bddf4f58633b02c4604f0cc87c2b89a2"
13523
+ sha256: "7dedfc9f5cb32e75a28831f3b5aa053fd3e0bdd74f73dc4d1b1588947236daef"
13504
13524
  },
13505
13525
  "darwin-arm64": {
13506
13526
  asset: "arm64-macos",
13507
13527
  upstreamSha256: "98aad827847af7ef990ed7098d885725c8e5b5aae75073403635617ae4e259aa",
13508
- sha256: "36373d0901b376c2868f09e0c2c303b1b7117b696e31dd661afa9711f31ea4a0"
13528
+ sha256: "0b56e0a06b6a873877871537a120fd94e2121e67f4bce5f8b5252c47b615854a"
13509
13529
  }
13510
13530
  }
13511
13531
  };
@@ -13558,6 +13578,45 @@ var init_wasm_features = __esm({
13558
13578
  });
13559
13579
 
13560
13580
  // src/wasm-optimize.ts
13581
+ function readWasmMemoryFromFile(file) {
13582
+ const fd = (0, import_node_fs23.openSync)(file, "r");
13583
+ try {
13584
+ const total = (0, import_node_fs23.fstatSync)(fd).size;
13585
+ const header = Buffer.allocUnsafe(8);
13586
+ if (total < 8 || (0, import_node_fs23.readSync)(fd, header, 0, 8, 0) < 8) return void 0;
13587
+ let offset = 8;
13588
+ const probe = Buffer.allocUnsafe(16);
13589
+ let prefixEnd = 8;
13590
+ while (offset < total) {
13591
+ const read = (0, import_node_fs23.readSync)(fd, probe, 0, Math.min(16, total - offset), offset);
13592
+ if (read < 2) break;
13593
+ const id = probe[0];
13594
+ let size = 0;
13595
+ let shift = 0;
13596
+ let at = 1;
13597
+ for (; ; ) {
13598
+ const byte = probe[at++];
13599
+ size += (byte & 127) * 2 ** shift;
13600
+ if (!(byte & 128)) break;
13601
+ shift += 7;
13602
+ }
13603
+ const next = offset + at + size;
13604
+ if (id === 2 || id === 5) prefixEnd = next;
13605
+ if (id > 5) break;
13606
+ offset = next;
13607
+ }
13608
+ const prefix = Buffer.allocUnsafe(prefixEnd);
13609
+ let filled = 0;
13610
+ while (filled < prefixEnd) {
13611
+ const n = (0, import_node_fs23.readSync)(fd, prefix, filled, prefixEnd - filled, filled);
13612
+ if (n <= 0) break;
13613
+ filled += n;
13614
+ }
13615
+ return readWasmMemory(prefix.subarray(0, filled));
13616
+ } finally {
13617
+ (0, import_node_fs23.closeSync)(fd);
13618
+ }
13619
+ }
13561
13620
  async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEnd, wideExports) {
13562
13621
  const admittedCores = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
13563
13622
  const requestedCores = Number(process.env.BINARYEN_CORES);
@@ -13574,25 +13633,75 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEn
13574
13633
  return;
13575
13634
  }
13576
13635
  const optimizeSize = optimize === true || optimize === "app-module";
13577
- const optimizeBeforeGuard = optimize === true;
13578
13636
  const relink = optimize === "relink";
13579
- const names = optimizeBeforeGuard && !KEEP_WASM_NAMES ? [] : ["-g"];
13580
- const outputNames = (optimizeSize || relink) && !KEEP_WASM_NAMES ? [] : names;
13581
- let input = (0, import_node_fs23.readFileSync)(file);
13582
- const memory = readWasmMemory(input);
13583
- const checked = `${output}.stack-checked`;
13637
+ const keepNames = !optimizeSize && !relink || KEEP_WASM_NAMES;
13638
+ const memory = readWasmMemoryFromFile(file);
13584
13639
  if (memory?.shared && memory.maximumPages !== 65536)
13585
13640
  throw new Error("threaded native memory must declare a 65536-page maximum");
13586
- if (memory?.shared && optimizeBeforeGuard) {
13587
- await runBinaryen(binary, [...features, "-g", "--stack-check", file, "-o", checked], {
13588
- env: environment
13589
- });
13590
- input = (0, import_node_fs23.readFileSync)(checked);
13591
- if (!hasWasmExport(input, "__set_stack_limits"))
13592
- throw new Error(
13593
- "threaded native artifact must retain its __stack_pointer name for bounds checks"
13641
+ if (memory?.shared) {
13642
+ const wideExportsFile = wideExports.size ? `${output}.wide-exports` : void 0;
13643
+ const tableTool = (0, import_node_path23.join)((0, import_node_path23.dirname)(binary), "wasm-table-guard");
13644
+ try {
13645
+ if (wideExportsFile)
13646
+ (0, import_node_fs23.writeFileSync)(wideExportsFile, [...wideExports].join("\n") + "\n");
13647
+ const pipelineArgs = [
13648
+ "--pipeline",
13649
+ "--in",
13650
+ file,
13651
+ "--out",
13652
+ output,
13653
+ "--narrow",
13654
+ ...wideExportsFile ? ["--wide-exports-file", wideExportsFile] : [],
13655
+ "--lower",
13656
+ "--shared",
13657
+ ...keepNames ? ["--debug"] : [],
13658
+ ...sdkTableEnd !== void 0 ? ["--slots-range", "1", String(sdkTableEnd), "--adapt"] : [],
13659
+ ...optimizeSize ? ["--optimize", "oz"] : relink ? ["--optimize", "relink"] : [],
13660
+ ...skipPasses.flatMap((pass) => ["--skip-pass", pass])
13661
+ ];
13662
+ const { stdout } = await runBinaryen(tableTool, pipelineArgs, { env: environment });
13663
+ const metadata = JSON.parse(stdout);
13664
+ if (typeof metadata !== "object" || metadata === null || !("tableMinimum" in metadata) || typeof metadata.tableMinimum !== "number" || !Number.isSafeInteger(metadata.tableMinimum) || metadata.tableMinimum < 0)
13665
+ throw new Error("native table tool returned an invalid table minimum");
13666
+ const sectionName = new TextEncoder().encode(NATIVE_IMAGE_SECTION);
13667
+ const layout2 = new TextEncoder().encode(
13668
+ JSON.stringify({
13669
+ initialPages: memory.initialPages,
13670
+ tableMinimum: metadata.tableMinimum
13671
+ })
13672
+ );
13673
+ const encode = (value) => {
13674
+ const bytes2 = [];
13675
+ do {
13676
+ const byte = value & 127;
13677
+ value >>>= 7;
13678
+ bytes2.push(byte | (value ? 128 : 0));
13679
+ } while (value);
13680
+ return bytes2;
13681
+ };
13682
+ const body = new Uint8Array([
13683
+ ...encode(sectionName.length),
13684
+ ...sectionName,
13685
+ ...layout2
13686
+ ]);
13687
+ const bytes = (0, import_node_fs23.readFileSync)(output);
13688
+ (0, import_node_fs23.writeFileSync)(
13689
+ output,
13690
+ Buffer.concat([
13691
+ sdkTableEnd === void 0 ? withWasmTableMinimum(
13692
+ bytes,
13693
+ metadata.tableMinimum + NATIVE_TABLE_RESERVE_SLOTS
13694
+ ) : bytes,
13695
+ Buffer.from([0, ...encode(body.length), ...body])
13696
+ ])
13594
13697
  );
13698
+ } finally {
13699
+ if (wideExportsFile) (0, import_node_fs23.rmSync)(wideExportsFile, { force: true });
13700
+ }
13701
+ return;
13595
13702
  }
13703
+ const outputNames = keepNames ? ["-g"] : [];
13704
+ const input = (0, import_node_fs23.readFileSync)(file);
13596
13705
  const narrowed = narrowWasmBoundary(input, wideExports);
13597
13706
  const merged = `${output}.narrowed`;
13598
13707
  if (narrowed) {
@@ -13604,7 +13713,7 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEn
13604
13713
  (0, import_node_path23.join)((0, import_node_path23.dirname)(binary), "wasm-merge"),
13605
13714
  [
13606
13715
  ...features,
13607
- ...names,
13716
+ ...outputNames,
13608
13717
  guest,
13609
13718
  NARROW_MERGE_NAMES.guest,
13610
13719
  thunks,
@@ -13618,118 +13727,25 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary, sdkTableEn
13618
13727
  (0, import_node_fs23.rmSync)(guest);
13619
13728
  (0, import_node_fs23.rmSync)(thunks);
13620
13729
  }
13621
- const lowered = memory?.shared ? `${output}.lowered` : output;
13622
- const compiled = narrowed ? merged : memory?.shared && optimizeBeforeGuard ? checked : file;
13730
+ const compiled = narrowed ? merged : file;
13623
13731
  const skip = skipPasses.flatMap((pass) => ["--skip-pass", pass]);
13624
13732
  try {
13625
- if (!memory?.shared || optimizeBeforeGuard)
13626
- await runBinaryen(
13627
- binary,
13628
- [
13629
- ...LOWERING,
13630
- ...optimizeSize ? ["-Oz"] : relink ? RELINK_PASSES : [],
13631
- ...outputNames,
13632
- ...skip,
13633
- ...features,
13634
- compiled,
13635
- "-o",
13636
- lowered
13637
- ],
13638
- { env: environment, maxBuffer: Infinity }
13639
- );
13640
- if (memory?.shared) {
13641
- const guarded = `${output}.table.wasm`;
13642
- const sdkGuarded = `${output}.sdk-table.wasm`;
13643
- const sdkSlots = `${output}.sdk-table-slots`;
13644
- const tableTool = (0, import_node_path23.join)((0, import_node_path23.dirname)(binary), "wasm-table-guard");
13645
- try {
13646
- const { stdout } = await runBinaryen(
13647
- tableTool,
13648
- [
13649
- optimizeBeforeGuard ? lowered : compiled,
13650
- guarded,
13651
- names.length ? "1" : "0",
13652
- ...optimizeBeforeGuard ? [] : ["lower"]
13653
- ],
13654
- { env: environment }
13655
- );
13656
- const metadata = JSON.parse(stdout);
13657
- if (typeof metadata !== "object" || metadata === null || !("tableMinimum" in metadata) || typeof metadata.tableMinimum !== "number" || !Number.isSafeInteger(metadata.tableMinimum) || metadata.tableMinimum < 0)
13658
- throw new Error("native table tool returned an invalid table minimum");
13659
- if (sdkTableEnd !== void 0) {
13660
- (0, import_node_fs23.writeFileSync)(
13661
- sdkSlots,
13662
- Array.from({ length: sdkTableEnd - 1 }, (_, index) => index + 1).join("\n")
13663
- );
13664
- await runBinaryen(
13665
- tableTool,
13666
- [guarded, sdkGuarded, names.length ? "1" : "0", "0", sdkSlots, "adapt"],
13667
- { env: environment }
13668
- );
13669
- (0, import_node_fs23.renameSync)(sdkGuarded, guarded);
13670
- }
13671
- if (optimize)
13672
- await runBinaryen(
13673
- binary,
13674
- [
13675
- ...features,
13676
- // an adapted call tests its target's type with a typed function reference.
13677
- ...sdkTableEnd === void 0 ? [] : ["--enable-gc"],
13678
- ...optimizeSize ? ["-Oz"] : RELINK_PASSES,
13679
- ...outputNames,
13680
- ...skip,
13681
- guarded,
13682
- "-o",
13683
- output
13684
- ],
13685
- { env: environment }
13686
- );
13687
- const sectionName = new TextEncoder().encode(NATIVE_IMAGE_SECTION);
13688
- const layout2 = new TextEncoder().encode(
13689
- JSON.stringify({
13690
- initialPages: memory.initialPages,
13691
- tableMinimum: metadata.tableMinimum
13692
- })
13693
- );
13694
- const encode = (value) => {
13695
- const bytes2 = [];
13696
- do {
13697
- const byte = value & 127;
13698
- value >>>= 7;
13699
- bytes2.push(byte | (value ? 128 : 0));
13700
- } while (value);
13701
- return bytes2;
13702
- };
13703
- const body = new Uint8Array([
13704
- ...encode(sectionName.length),
13705
- ...sectionName,
13706
- ...layout2
13707
- ]);
13708
- const image = optimize ? output : guarded;
13709
- const bytes = (0, import_node_fs23.readFileSync)(image);
13710
- (0, import_node_fs23.writeFileSync)(
13711
- image,
13712
- Buffer.concat([
13713
- sdkTableEnd === void 0 ? withWasmTableMinimum(
13714
- bytes,
13715
- metadata.tableMinimum + NATIVE_TABLE_RESERVE_SLOTS
13716
- ) : bytes,
13717
- Buffer.from([0, ...encode(body.length), ...body])
13718
- ])
13719
- );
13720
- if (!optimize) (0, import_node_fs23.renameSync)(guarded, output);
13721
- } finally {
13722
- (0, import_node_fs23.rmSync)(guarded, { force: true });
13723
- (0, import_node_fs23.rmSync)(sdkGuarded, { force: true });
13724
- (0, import_node_fs23.rmSync)(sdkSlots, { force: true });
13725
- }
13726
- }
13733
+ await runBinaryen(
13734
+ binary,
13735
+ [
13736
+ ...LOWERING,
13737
+ ...optimizeSize ? ["-Oz"] : relink ? RELINK_PASSES : [],
13738
+ ...outputNames,
13739
+ ...skip,
13740
+ ...features,
13741
+ compiled,
13742
+ "-o",
13743
+ output
13744
+ ],
13745
+ { env: environment, maxBuffer: Infinity }
13746
+ );
13727
13747
  } finally {
13728
13748
  if (narrowed) (0, import_node_fs23.rmSync)(merged, { force: true });
13729
- if (memory?.shared) {
13730
- (0, import_node_fs23.rmSync)(checked, { force: true });
13731
- (0, import_node_fs23.rmSync)(lowered, { force: true });
13732
- }
13733
13749
  }
13734
13750
  }
13735
13751
  async function installWasmOpt() {
@@ -16963,9 +16979,11 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
16963
16979
  objects.push({ path: object4, bytes, instrumentDynamicLookups: false });
16964
16980
  guestObjects.set(product, objects);
16965
16981
  };
16966
- const classifyFile = (file) => {
16982
+ const classifyFile = (file, collectAutolink = false) => {
16967
16983
  const bytes = (0, import_node_fs35.readFileSync)(file);
16968
16984
  if (!file.endsWith(".a")) {
16985
+ if (collectAutolink)
16986
+ for (const library of autolinkLibraries(bytes)) libraries.add(library);
16969
16987
  const scoped = lookups?.rewrite(file, bytes) ?? bytes;
16970
16988
  return addObject(file, scoped, file);
16971
16989
  }
@@ -16973,6 +16991,8 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
16973
16991
  (0, import_node_fs35.mkdirSync)(import_node_path35.default.join(members, archive));
16974
16992
  const ordinals = /* @__PURE__ */ new Map();
16975
16993
  readArMembers(bytes).forEach((member, index) => {
16994
+ if (collectAutolink)
16995
+ for (const library of autolinkLibraries(member.bytes)) libraries.add(library);
16976
16996
  const object4 = import_node_path35.default.join(members, archive, `${index}-${import_node_path35.default.basename(member.name)}`);
16977
16997
  const ordinal = (ordinals.get(member.name) ?? 0) + 1;
16978
16998
  ordinals.set(member.name, ordinal);
@@ -16987,9 +17007,7 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
16987
17007
  });
16988
17008
  };
16989
17009
  for (const object4 of [...link.objects, ...link.providers]) {
16990
- classifyFile(object4);
16991
- for (const bytes of objectMembers(object4))
16992
- for (const library of autolinkLibraries(bytes)) libraries.add(library);
17010
+ classifyFile(object4, true);
16993
17011
  }
16994
17012
  for (const library of libraries) {
16995
17013
  if (unpacked.has(library.slice(2))) continue;
@@ -17002,6 +17020,7 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
17002
17020
  const hostExports = sdkHostExports(appRoot);
17003
17021
  const guestMap = /* @__PURE__ */ new Map();
17004
17022
  const guestMetadataNames = {};
17023
+ const compiles = [];
17005
17024
  if (lookups) {
17006
17025
  const ledger = lookups.link(guestObjects, [
17007
17026
  ...hostExports,
@@ -17037,33 +17056,38 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
17037
17056
  const scopeLedger = import_node_path35.default.join(work, "guest-ledger.ll");
17038
17057
  const scopeObject = import_node_path35.default.join(work, "guest-ledger.o");
17039
17058
  (0, import_node_fs35.writeFileSync)(scopeLedger, ledger.llvmIR);
17040
- await run2(import_node_path35.default.join(toolchain.toolchainBin, "clang"), [
17041
- `--target=${SWIFT_WASM_TRIPLE}`,
17042
- "-matomics",
17043
- "-mbulk-memory",
17044
- "-c",
17045
- scopeLedger,
17046
- "-o",
17047
- scopeObject
17048
- ]);
17059
+ compiles.push(
17060
+ run2(import_node_path35.default.join(toolchain.toolchainBin, "clang"), [
17061
+ `--target=${SWIFT_WASM_TRIPLE}`,
17062
+ "-matomics",
17063
+ "-mbulk-memory",
17064
+ "-c",
17065
+ scopeLedger,
17066
+ "-o",
17067
+ scopeObject
17068
+ ])
17069
+ );
17049
17070
  eager.push(scopeObject);
17050
17071
  }
17051
17072
  (0, import_node_fs35.writeFileSync)(
17052
17073
  import_node_path35.default.join(work, "image-tables.c"),
17053
17074
  IMAGE_TABLES + (guestLookups?.source ?? "")
17054
17075
  );
17055
- await run2(import_node_path35.default.join(toolchain.toolchainBin, "clang"), [
17056
- `--target=${SWIFT_WASM_TRIPLE}`,
17057
- "-O2",
17058
- "-matomics",
17059
- "-mbulk-memory",
17060
- "-ffreestanding",
17061
- ...lookups ? ["-DPEACH_SDK_GUEST_LINK"] : [],
17062
- "-c",
17063
- import_node_path35.default.join(work, "image-tables.c"),
17064
- "-o",
17065
- tables
17066
- ]);
17076
+ compiles.push(
17077
+ run2(import_node_path35.default.join(toolchain.toolchainBin, "clang"), [
17078
+ `--target=${SWIFT_WASM_TRIPLE}`,
17079
+ "-O2",
17080
+ "-matomics",
17081
+ "-mbulk-memory",
17082
+ "-ffreestanding",
17083
+ ...lookups ? ["-DPEACH_SDK_GUEST_LINK"] : [],
17084
+ "-c",
17085
+ import_node_path35.default.join(work, "image-tables.c"),
17086
+ "-o",
17087
+ tables
17088
+ ])
17089
+ );
17090
+ await Promise.all(compiles);
17067
17091
  const quote2 = (value) => JSON.stringify(value);
17068
17092
  (0, import_node_fs35.writeFileSync)(
17069
17093
  import_node_path35.default.join(work, "exports.rsp"),
@@ -17122,23 +17146,31 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
17122
17146
  if (mask === void 0) throw new Error("sdk image lacks its constructor mask");
17123
17147
  const code = import_node_path35.default.join(work, "code.wasm");
17124
17148
  (0, import_node_fs35.writeFileSync)(code, codeOnlySdkImage(finished, mask));
17125
- await lowerWasm(code, import_node_path35.default.join(work, IMAGE_FILE), {
17149
+ const lowerPromise = lowerWasm(code, import_node_path35.default.join(work, IMAGE_FILE), {
17126
17150
  optimize: true,
17127
17151
  skipPasses: lookups ? ["duplicate-function-elimination"] : void 0
17128
17152
  });
17153
+ await new Promise((resolve) => setImmediate(resolve));
17154
+ try {
17155
+ writeSdkManifest(
17156
+ work,
17157
+ linkMap,
17158
+ linkedBytes,
17159
+ finished,
17160
+ (0, import_node_fs35.readFileSync)(withRelocs),
17161
+ functionSlots,
17162
+ lookups && { inputs: guestMap, metadataNames: guestMetadataNames }
17163
+ );
17164
+ } catch (error) {
17165
+ await lowerPromise.catch(() => {
17166
+ });
17167
+ throw error;
17168
+ }
17169
+ await lowerPromise;
17129
17170
  const image = (0, import_node_fs35.readFileSync)(import_node_path35.default.join(work, IMAGE_FILE));
17130
17171
  sdkInterface.layout.tableEnd += unslottedFunctions(image);
17131
17172
  if (sdkInterface.layout.tableEnd > SWIFT_SDK_APP_TABLE_BASE)
17132
17173
  throw new Error("Swift SDK image exceeds its reserved function table range");
17133
- writeSdkManifest(
17134
- work,
17135
- linkMap,
17136
- linkedBytes,
17137
- finished,
17138
- (0, import_node_fs35.readFileSync)(withRelocs),
17139
- functionSlots,
17140
- lookups && { inputs: guestMap, metadataNames: guestMetadataNames }
17141
- );
17142
17174
  (0, import_node_fs35.writeFileSync)(import_node_path35.default.join(work, INTERFACE_FILE), JSON.stringify(sdkInterface));
17143
17175
  (0, import_node_fs35.writeFileSync)(
17144
17176
  import_node_path35.default.join(work, IMAGE_DIGEST),
@@ -17207,14 +17239,11 @@ function sdkLinkInputs(appRoot) {
17207
17239
  if (!crt) throw new Error("the sdk image link found no reactor startup object");
17208
17240
  return { flags, libraries, objects: [crt, ...objects], providers };
17209
17241
  }
17210
- function objectMembers(file) {
17211
- const bytes = (0, import_node_fs35.readFileSync)(file);
17212
- return file.endsWith(".a") ? readArMembers(bytes).map((member) => member.bytes) : [bytes];
17213
- }
17214
17242
  function autolinkLibraries(bytes) {
17215
17243
  const entries2 = wasmSections(bytes).find((s) => s.name === ".swift1_autolink_entries");
17216
17244
  if (!entries2) return [];
17217
- return Buffer.from(bytes.subarray(entries2.start, entries2.end)).toString().split("\0").filter((entry) => entry.startsWith("-l"));
17245
+ const raw2 = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
17246
+ return raw2.toString("utf8", entries2.start, entries2.end).split("\0").filter((entry) => entry.startsWith("-l"));
17218
17247
  }
17219
17248
  function sdkHostExports(appRoot) {
17220
17249
  const release = import_node_path35.default.join(appRoot, ".build", SWIFT_WASM_TRIPLE, "release");
@@ -17300,9 +17329,17 @@ function writeSdkManifest(work, map, linked, finished, withRelocs, functionSlots
17300
17329
  return { starts, targets };
17301
17330
  };
17302
17331
  const byAddress = (edges2) => {
17303
- const pairs = [];
17304
- for (let i = 0; i < edges2.length; i += 2) pairs.push([edges2[i], edges2[i + 1]]);
17305
- return pairs.sort((a, b) => a[0] - b[0]).flat();
17332
+ const count = edges2.length >>> 1;
17333
+ const order = new Uint32Array(count);
17334
+ for (let i = 0; i < count; i++) order[i] = i;
17335
+ order.sort((a, b) => edges2[a * 2] - edges2[b * 2]);
17336
+ const sorted = new Uint32Array(edges2.length);
17337
+ for (let i = 0; i < count; i++) {
17338
+ const src = order[i] * 2;
17339
+ sorted[i * 2] = edges2[src];
17340
+ sorted[i * 2 + 1] = edges2[src + 1];
17341
+ }
17342
+ return sorted;
17306
17343
  };
17307
17344
  const functionData = flatten(edges.code);
17308
17345
  const functionCalls = flatten(edges.calls);
@@ -17606,12 +17643,22 @@ async function buildSwiftAppModule(options) {
17606
17643
  work,
17607
17644
  readInput
17608
17645
  });
17609
- await link.lower();
17610
- const usage = readSwiftSdkUsage(
17611
- project ? projectOutputFile(buildRoot, map, project) : map,
17612
- pruned
17613
- );
17614
- const binding = createSwiftSdkBinding(link.linkage, sdk, usage);
17646
+ const lowerPromise = link.lower();
17647
+ await new Promise((resolve) => setImmediate(resolve));
17648
+ let usage;
17649
+ let binding;
17650
+ try {
17651
+ usage = readSwiftSdkUsage(
17652
+ project ? projectOutputFile(buildRoot, map, project) : map,
17653
+ pruned
17654
+ );
17655
+ binding = createSwiftSdkBinding(link.linkage, sdk, usage);
17656
+ } catch (error) {
17657
+ await lowerPromise.catch(() => {
17658
+ });
17659
+ throw error;
17660
+ }
17661
+ await lowerPromise;
17615
17662
  if (!project)
17616
17663
  writeSwiftSdkAppLink(import_node_path36.default.join(work, "app-link.json.gz"), {
17617
17664
  linkage: link.linkage,
@@ -19521,7 +19568,6 @@ async function compileGuestLink(options) {
19521
19568
  bindingRows.set((address - values.address) / 8, value);
19522
19569
  } else data.push(address, size, value);
19523
19570
  }
19524
- const binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk, usage);
19525
19571
  const linked = (0, import_node_fs37.readFileSync)(
19526
19572
  project ? projectOutputFile(work, linkedModule, project) : linkedModule
19527
19573
  );
@@ -19546,7 +19592,17 @@ async function compileGuestLink(options) {
19546
19592
  );
19547
19593
  continue;
19548
19594
  }
19549
- await link.lower();
19595
+ const lowerPromise = link.lower();
19596
+ await new Promise((resolve) => setImmediate(resolve));
19597
+ let binding;
19598
+ try {
19599
+ binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk, usage);
19600
+ } catch (error) {
19601
+ await lowerPromise.catch(() => {
19602
+ });
19603
+ throw error;
19604
+ }
19605
+ await lowerPromise;
19550
19606
  const finalized = finalizeGuestProjectionStorage({
19551
19607
  map: map2,
19552
19608
  linked,
@@ -27470,7 +27526,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
27470
27526
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
27471
27527
  MULTI_MANIFEST_VERSION = 76;
27472
27528
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
27473
- compilerSourceDigest = true ? "57c5faa7bb7758647030422e32db0f4a53fbab724723e220c14fea1e41d2391e" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
27529
+ compilerSourceDigest = true ? "834b5c28c27bc5807cbb3c4eed5c44f7de81d47db3e3a8819bea6e6635689b24" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
27474
27530
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
27475
27531
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
27476
27532
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));