peachsim 0.1.2622 → 0.1.2624
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.
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +693 -306
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-FYCW5KQE.mjs → acorn-DH6VFUJ3.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-UQ3ACQY7.mjs → chunk-265THLTP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5SDBXLYL.mjs → chunk-2YHIYKY2.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-SKVUSWJU.mjs → chunk-3XA5HYI5.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-W7AGZLTK.mjs → chunk-A2WMBGJO.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-HY7D6BBU.mjs → chunk-AV7G5PTE.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-HMWCDFVQ.mjs → chunk-CM2NU5MS.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-C2QXEBC5.mjs → chunk-EFQFJ7M6.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-7Z4ESZI7.mjs → chunk-HKPKCJI5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-N3LFPMVM.mjs → chunk-IMI2NE4A.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-G7NMIYJW.mjs → chunk-JHMD4G4V.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-67RCWRPX.mjs → chunk-LCO2EXKF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DOCJYFRP.mjs → chunk-LD7Z3NDO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-7DFBTAWA.mjs → chunk-LMWSFXYN.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-IEVIGGKG.mjs → chunk-LOQBWIPM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-X62EBL6H.mjs → chunk-LT533AHJ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-P64OR3XD.mjs → chunk-N4ZJZUCO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UR2EIB2I.mjs → chunk-OLAYY7SG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-G4CIR7M6.mjs → chunk-QNXV766K.mjs} +565 -290
- package/dist-lib/esm-chunks/{chunk-3XZWIVAA.mjs → chunk-QZ5HTMWV.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-V7CGV5XO.mjs → chunk-T7C6Z5UH.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-Y2RPOAEE.mjs → chunk-UJORQHAE.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-IRUQ2NMF.mjs → chunk-VH4BJS5V.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5UDR743S.mjs → chunk-XONCLAVA.mjs} +8 -7
- package/dist-lib/esm-chunks/{chunk-WRQCYESG.mjs → chunk-YOD53JTM.mjs} +2 -2
- package/dist-lib/esm-chunks/{metro-layout-parser-GR4EJUCZ.mjs → metro-layout-parser-MDVTDJ65.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-CW6VQ6A5.mjs → swift-package-prebuilt-ZN7I4FYC.mjs} +12 -12
- package/dist-lib/esm-chunks/{swift-sdk-app-module-NULACNZJ.mjs → swift-sdk-app-module-DUVE2OXH.mjs} +107 -20
- package/dist-lib/esm-chunks/{swift-sdk-image-ZFATI6XZ.mjs → swift-sdk-image-YSWQBCYV.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-WKVRKIRF.mjs → swift-sdk-image-producer-MZ235WSK.mjs} +5 -5
- package/dist-lib/expo-swift-bundle.cjs +686 -299
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +7 -7
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +691 -304
- package/dist-lib/host/fetch-proxy-handler.cjs +7 -7
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +3 -3
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +3 -3
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +30 -15
- package/dist-lib/native-app-identity-project.mjs +44 -29
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +3 -3
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +85 -85
- package/dist-lib/public-origins-lib.json +64 -64
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +8 -8
- package/dist-lib/skills.cjs +691 -304
- package/dist-lib/swift-compile.cjs +638 -280
- package/dist-lib/swift-compile.mjs +12 -12
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +6 -6
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/package.json +1 -1
- package/src/bazel-project.ts +34 -18
- package/src/binaryen.lock.json +3 -3
- package/src/swift-compile.ts +8 -0
- package/src/swift-distribution.lock.json +8 -3
- package/src/swift-guest-compile.ts +170 -160
- package/src/swift-guest-dyld-table.ts +22 -9
- package/src/swift-guest-link.ts +116 -42
- package/src/swift-guest-linked-spans.ts +63 -14
- package/src/swift-guest-projection-storage.ts +7 -6
- package/src/swift-guest-source-inputs.ts +35 -21
- package/src/swift-objc-compile.ts +1 -0
- package/src/swift-sdk-app-module.ts +118 -15
- package/src/swift-sdk-image-wasm.ts +119 -17
- package/src/swift-sdk-image.ts +4 -1
- package/src/swift-wasm-prune.ts +71 -41
- package/src/wasm-narrow-boundary.ts +31 -6
package/dist-lib/skills.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2624 | (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;
|
|
@@ -35826,13 +35826,13 @@ var init_swift_standin_digest = __esm({
|
|
|
35826
35826
|
];
|
|
35827
35827
|
RUNTIME_IMPORT = /(?:^|[;\n])[ \t]*(?:import|export)\s+(?!type(?:\s|\{))([\s\S]*?)\s+from\s*['"]([^'"]+)['"]|(?:^|[;\n])[ \t]*import\s+['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
35828
35828
|
standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS, STANDIN_DIGEST_EXCLUDED_FILES);
|
|
35829
|
-
STANDIN_SOURCE_DIGEST = true ? "
|
|
35829
|
+
STANDIN_SOURCE_DIGEST = true ? "7f9a1a548c5ea58c56b73bfc2a755a05031acbd1b10c1c79dc32b1d6c9bea9e4" : standinSourceDigest();
|
|
35830
35830
|
}
|
|
35831
35831
|
});
|
|
35832
35832
|
|
|
35833
35833
|
// src/expo-native-compiler-digest.ts
|
|
35834
35834
|
function expoNativeCompilerDigestValue() {
|
|
35835
|
-
return true ? "
|
|
35835
|
+
return true ? "ee97927d0c41fd6dd7d1290da2bbe36d7c9ec0fe81e3d5a7aa101cd4d446e5ab" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
|
|
35836
35836
|
}
|
|
35837
35837
|
var import_node_crypto12;
|
|
35838
35838
|
var init_expo_native_compiler_digest = __esm({
|
|
@@ -58484,6 +58484,15 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
58484
58484
|
const unchanged = before === after;
|
|
58485
58485
|
const original = layout(before, !unchanged, !importsLayout);
|
|
58486
58486
|
const optimized = unchanged ? original : layout(after, true, !importsLayout);
|
|
58487
|
+
if (extra?.optimizedDataSegments) {
|
|
58488
|
+
for (const segment2 of optimized.data) {
|
|
58489
|
+
extra.optimizedDataSegments.push({
|
|
58490
|
+
address: segment2.address,
|
|
58491
|
+
offset: segment2.bytes.byteOffset - after.byteOffset,
|
|
58492
|
+
length: segment2.bytes.length
|
|
58493
|
+
});
|
|
58494
|
+
}
|
|
58495
|
+
}
|
|
58487
58496
|
const collectSymbols = extra?.collectSymbols;
|
|
58488
58497
|
const trackedObject = extra?.trackedObject;
|
|
58489
58498
|
const trackedObjectOwner = extra?.trackedObjectOwner;
|
|
@@ -58652,12 +58661,39 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
58652
58661
|
}
|
|
58653
58662
|
return result;
|
|
58654
58663
|
};
|
|
58664
|
+
const singleSegmentSlice = (module2, start, length) => {
|
|
58665
|
+
const segs = module2.dataByAddress;
|
|
58666
|
+
let low = 0;
|
|
58667
|
+
let high = segs.length;
|
|
58668
|
+
while (low < high) {
|
|
58669
|
+
const middle = low + high >> 1;
|
|
58670
|
+
if (segs[middle].maximumEnd <= start) low = middle + 1;
|
|
58671
|
+
else high = middle;
|
|
58672
|
+
}
|
|
58673
|
+
let found2;
|
|
58674
|
+
const end = start + length;
|
|
58675
|
+
for (let index = low; index < segs.length; index++) {
|
|
58676
|
+
const segment2 = segs[index];
|
|
58677
|
+
if (segment2.address >= end) break;
|
|
58678
|
+
if (segment2.address + segment2.bytes.length > start) {
|
|
58679
|
+
if (found2) return void 0;
|
|
58680
|
+
found2 = segment2;
|
|
58681
|
+
}
|
|
58682
|
+
}
|
|
58683
|
+
if (!found2 || found2.address > start || found2.address + found2.bytes.length < end)
|
|
58684
|
+
return void 0;
|
|
58685
|
+
return found2.bytes.subarray(start - found2.address, end - found2.address);
|
|
58686
|
+
};
|
|
58687
|
+
const sameDataAt = (start, length) => {
|
|
58688
|
+
const origSlice = singleSegmentSlice(original, start, length);
|
|
58689
|
+
const optSlice = origSlice ? singleSegmentSlice(optimized, start, length) : void 0;
|
|
58690
|
+
if (origSlice && optSlice) return Buffer.compare(origSlice, optSlice) === 0;
|
|
58691
|
+
return dataAt(original, start, length).equals(dataAt(optimized, start, length));
|
|
58692
|
+
};
|
|
58655
58693
|
for (const span of spans) {
|
|
58656
58694
|
if (span.address + span.length > original.memoryBytes || span.address + span.length > optimized.memoryBytes)
|
|
58657
58695
|
throw new Error(`linked data lies outside guest memory at ${span.address}`);
|
|
58658
|
-
if (!unchanged && !
|
|
58659
|
-
dataAt(optimized, span.address, span.length)
|
|
58660
|
-
))
|
|
58696
|
+
if (!unchanged && !sameDataAt(span.address, span.length))
|
|
58661
58697
|
throw new Error(`optimization changed linked data at ${span.address}`);
|
|
58662
58698
|
}
|
|
58663
58699
|
let previous;
|
|
@@ -58791,7 +58827,7 @@ function takeGuestStartupData(wasm, address, length) {
|
|
|
58791
58827
|
const bytes = new Uint8Array(length);
|
|
58792
58828
|
const emptied = /* @__PURE__ */ new Set();
|
|
58793
58829
|
let covered = 0;
|
|
58794
|
-
const
|
|
58830
|
+
const patchedBody = Buffer.from(wasm.subarray(body[0], body[1]));
|
|
58795
58831
|
for (const initializer of startupDataInitializers(wasm.subarray(...body))) {
|
|
58796
58832
|
const end = initializer.address + initializer.length;
|
|
58797
58833
|
if (end <= address || initializer.address >= address + length || !initializer.length)
|
|
@@ -58806,19 +58842,18 @@ function takeGuestStartupData(wasm, address, length) {
|
|
|
58806
58842
|
covered += segment2.length;
|
|
58807
58843
|
emptied.add(initializer.segment);
|
|
58808
58844
|
const [at, immediateEnd] = initializer.lengthImmediate;
|
|
58809
|
-
|
|
58810
|
-
|
|
58845
|
+
patchedBody.fill(128, at, immediateEnd - 1);
|
|
58846
|
+
patchedBody[immediateEnd - 1] = 0;
|
|
58811
58847
|
}
|
|
58812
58848
|
if (covered !== length)
|
|
58813
58849
|
throw new Error("guest startup data does not initialize the whole range");
|
|
58814
|
-
const
|
|
58815
|
-
const payload = [result.subarray(data[1], segments[0].header)];
|
|
58850
|
+
const payload = [wasm.subarray(data[1], segments[0].header)];
|
|
58816
58851
|
for (const [index, segment2] of segments.entries()) {
|
|
58817
58852
|
if (!emptied.has(index)) {
|
|
58818
|
-
payload.push(
|
|
58853
|
+
payload.push(wasm.subarray(segment2.header, segment2.payload + segment2.length));
|
|
58819
58854
|
continue;
|
|
58820
58855
|
}
|
|
58821
|
-
payload.push(
|
|
58856
|
+
payload.push(wasm.subarray(segment2.header, segment2.sizeAt), Uint8Array.of(0));
|
|
58822
58857
|
}
|
|
58823
58858
|
const section2 = Buffer.concat(payload);
|
|
58824
58859
|
const size2 = [];
|
|
@@ -58829,7 +58864,14 @@ function takeGuestStartupData(wasm, address, length) {
|
|
|
58829
58864
|
}
|
|
58830
58865
|
size2.push(rest % 128 | 128);
|
|
58831
58866
|
}
|
|
58832
|
-
parts2
|
|
58867
|
+
const parts2 = [
|
|
58868
|
+
wasm.subarray(0, body[0]),
|
|
58869
|
+
patchedBody,
|
|
58870
|
+
wasm.subarray(body[1], data[0]),
|
|
58871
|
+
Uint8Array.of(11, ...size2),
|
|
58872
|
+
section2,
|
|
58873
|
+
wasm.subarray(data[2])
|
|
58874
|
+
];
|
|
58833
58875
|
return { wasm: Buffer.concat(parts2), bytes };
|
|
58834
58876
|
}
|
|
58835
58877
|
var import_node_fs57, import_node_string_decoder, constant;
|
|
@@ -59138,6 +59180,32 @@ function readImports(bytes, imports2) {
|
|
|
59138
59180
|
}
|
|
59139
59181
|
return { functionTypes, importedGlobals, memoryPages };
|
|
59140
59182
|
}
|
|
59183
|
+
function countImportedFunctions(bytes, imports2) {
|
|
59184
|
+
let count = 0;
|
|
59185
|
+
if (!imports2) return count;
|
|
59186
|
+
const r = wasmReader(bytes, imports2.start);
|
|
59187
|
+
for (let n = r.u(); n > 0; n--) {
|
|
59188
|
+
r.skip(r.u());
|
|
59189
|
+
r.skip(r.u());
|
|
59190
|
+
const kind = r.byte();
|
|
59191
|
+
if (kind === 0) {
|
|
59192
|
+
r.u();
|
|
59193
|
+
count++;
|
|
59194
|
+
} else if (kind === 1) {
|
|
59195
|
+
r.byte();
|
|
59196
|
+
skipLimits(r);
|
|
59197
|
+
} else if (kind === 2) {
|
|
59198
|
+
skipLimits(r);
|
|
59199
|
+
} else if (kind === 3) {
|
|
59200
|
+
r.byte();
|
|
59201
|
+
r.byte();
|
|
59202
|
+
} else if (kind === 4) {
|
|
59203
|
+
r.byte();
|
|
59204
|
+
r.u();
|
|
59205
|
+
} else throw new Error(`unknown wasm import kind ${kind}`);
|
|
59206
|
+
}
|
|
59207
|
+
return count;
|
|
59208
|
+
}
|
|
59141
59209
|
function* readFunctionNames(bytes, names) {
|
|
59142
59210
|
for (const r = wasmReader(bytes, names.start); r.at < names.end; ) {
|
|
59143
59211
|
const id = r.byte();
|
|
@@ -59505,28 +59573,73 @@ function codeOnlySdkImage(bytes, constructorMask) {
|
|
|
59505
59573
|
return Buffer.concat(out);
|
|
59506
59574
|
}
|
|
59507
59575
|
function constructorKeys(map2, bytes) {
|
|
59508
|
-
const m = readModule(bytes);
|
|
59509
59576
|
const first = map2.code[0];
|
|
59510
|
-
if (!first
|
|
59511
|
-
const
|
|
59512
|
-
const
|
|
59513
|
-
|
|
59577
|
+
if (!first) throw new Error("link has no code");
|
|
59578
|
+
const sections = wasmSections(bytes);
|
|
59579
|
+
const code = sections.find((s) => s.id === 10);
|
|
59580
|
+
if (!code) throw new Error("link has no code");
|
|
59514
59581
|
const ctors = map2.code.find((chunk) => chunk.section === "__wasm_call_ctors");
|
|
59515
59582
|
if (!ctors) throw new Error("link has no constructors");
|
|
59516
|
-
const
|
|
59517
|
-
|
|
59518
|
-
|
|
59519
|
-
|
|
59583
|
+
const importedFuncs = countImportedFunctions(
|
|
59584
|
+
bytes,
|
|
59585
|
+
sections.find((s) => s.id === 2)
|
|
59586
|
+
);
|
|
59587
|
+
const codeReader = wasmReader(bytes, code.start);
|
|
59588
|
+
const bodyCount = codeReader.u();
|
|
59589
|
+
if (!bodyCount) throw new Error("link has no code");
|
|
59590
|
+
const prefixes = new Uint32Array(bodyCount);
|
|
59591
|
+
let delta = 0;
|
|
59592
|
+
let ctorPrefix = -1;
|
|
59593
|
+
let ctorStart = -1;
|
|
59594
|
+
let ctorEnd = -1;
|
|
59595
|
+
for (let i = 0; i < bodyCount; i++) {
|
|
59596
|
+
const prefix = codeReader.at;
|
|
59597
|
+
const size2 = codeReader.u();
|
|
59598
|
+
prefixes[i] = prefix;
|
|
59599
|
+
if (i === 0) {
|
|
59600
|
+
delta = prefix - first.offset;
|
|
59601
|
+
ctorPrefix = ctors.offset + delta;
|
|
59602
|
+
}
|
|
59603
|
+
if (prefix === ctorPrefix) {
|
|
59604
|
+
ctorStart = codeReader.at;
|
|
59605
|
+
ctorEnd = ctorStart + size2;
|
|
59606
|
+
}
|
|
59607
|
+
codeReader.skip(size2);
|
|
59608
|
+
}
|
|
59609
|
+
if (ctorStart < 0) throw new Error("constructor function not found by map offset");
|
|
59610
|
+
let sorted3 = true;
|
|
59611
|
+
for (let i = 1; i < map2.code.length; i++) {
|
|
59612
|
+
if (map2.code[i].offset < map2.code[i - 1].offset) {
|
|
59613
|
+
sorted3 = false;
|
|
59614
|
+
break;
|
|
59615
|
+
}
|
|
59616
|
+
}
|
|
59617
|
+
const byOffset = sorted3 ? void 0 : new Map(map2.code.map((chunk) => [chunk.offset + delta, chunk]));
|
|
59618
|
+
const findChunk = (targetPrefix) => {
|
|
59619
|
+
if (byOffset) return byOffset.get(targetPrefix);
|
|
59620
|
+
const targetOffset = targetPrefix - delta;
|
|
59621
|
+
let lo = 0;
|
|
59622
|
+
let hi = map2.code.length - 1;
|
|
59623
|
+
while (lo <= hi) {
|
|
59624
|
+
const mid = lo + hi >> 1;
|
|
59625
|
+
const offset = map2.code[mid].offset;
|
|
59626
|
+
if (offset < targetOffset) lo = mid + 1;
|
|
59627
|
+
else if (offset > targetOffset) hi = mid - 1;
|
|
59628
|
+
else return map2.code[mid];
|
|
59629
|
+
}
|
|
59630
|
+
return void 0;
|
|
59631
|
+
};
|
|
59632
|
+
const r = wasmReader(bytes, ctorStart);
|
|
59520
59633
|
for (let n = r.u(); n > 0; n--) {
|
|
59521
59634
|
r.u();
|
|
59522
59635
|
r.byte();
|
|
59523
59636
|
}
|
|
59524
59637
|
const keys = [];
|
|
59525
|
-
while (r.at <
|
|
59638
|
+
while (r.at < ctorEnd) {
|
|
59526
59639
|
const op = r.byte();
|
|
59527
59640
|
if (op === 16) {
|
|
59528
|
-
const callee = r.u() -
|
|
59529
|
-
const chunk =
|
|
59641
|
+
const callee = r.u() - importedFuncs;
|
|
59642
|
+
const chunk = callee >= 0 && callee < bodyCount ? findChunk(prefixes[callee]) : void 0;
|
|
59530
59643
|
if (!chunk) throw new Error("constructor without a map chunk");
|
|
59531
59644
|
keys.push(chunkKey(chunk, ""));
|
|
59532
59645
|
} else if (op !== 26 && op !== 11) throw new Error(`constructor op ${op}`);
|
|
@@ -59609,7 +59722,10 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
59609
59722
|
r.skip(r.u());
|
|
59610
59723
|
}
|
|
59611
59724
|
}
|
|
59612
|
-
const importedFunctions =
|
|
59725
|
+
const importedFunctions = countImportedFunctions(
|
|
59726
|
+
bytes,
|
|
59727
|
+
sections.find((s) => s.id === 2)
|
|
59728
|
+
);
|
|
59613
59729
|
const data = [];
|
|
59614
59730
|
const dataFunctions = [];
|
|
59615
59731
|
const bodyCount = bodyStarts.length;
|
|
@@ -59723,9 +59839,30 @@ function strongDefinitions(bytes) {
|
|
|
59723
59839
|
).map((s) => s.name);
|
|
59724
59840
|
}
|
|
59725
59841
|
function unslottedFunctions(bytes) {
|
|
59726
|
-
const
|
|
59727
|
-
const
|
|
59728
|
-
|
|
59842
|
+
const sections = wasmSections(bytes);
|
|
59843
|
+
const importedFuncs = countImportedFunctions(
|
|
59844
|
+
bytes,
|
|
59845
|
+
sections.find((s) => s.id === 2)
|
|
59846
|
+
);
|
|
59847
|
+
const code = sections.find((s) => s.id === 10);
|
|
59848
|
+
const definedFuncs = code ? wasmReader(bytes, code.start).u() : 0;
|
|
59849
|
+
const slotted = /* @__PURE__ */ new Set();
|
|
59850
|
+
const elements = sections.find((s) => s.id === 9);
|
|
59851
|
+
if (elements) {
|
|
59852
|
+
const r = wasmReader(bytes, elements.start);
|
|
59853
|
+
for (let n = r.u(); n > 0; n--) {
|
|
59854
|
+
const flags = r.u();
|
|
59855
|
+
if (flags !== 0 && flags !== 2) throw new Error(`sdk image element flags ${flags}`);
|
|
59856
|
+
if (flags === 2) r.u();
|
|
59857
|
+
constant2(r);
|
|
59858
|
+
if (flags === 2) r.byte();
|
|
59859
|
+
for (let i = 0, count = r.u(); i < count; i++) {
|
|
59860
|
+
const index = r.u();
|
|
59861
|
+
if (index >= importedFuncs) slotted.add(index);
|
|
59862
|
+
}
|
|
59863
|
+
}
|
|
59864
|
+
}
|
|
59865
|
+
return definedFuncs - slotted.size;
|
|
59729
59866
|
}
|
|
59730
59867
|
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;
|
|
59731
59868
|
var init_swift_sdk_image_wasm = __esm({
|
|
@@ -60109,6 +60246,11 @@ var init_swiftRuntimeProductContract = __esm({
|
|
|
60109
60246
|
});
|
|
60110
60247
|
|
|
60111
60248
|
// src/swift-wasm-prune.ts
|
|
60249
|
+
function sha256Hex(bytes) {
|
|
60250
|
+
if (typeof Bun !== "undefined")
|
|
60251
|
+
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
60252
|
+
return (0, import_node_crypto30.createHash)("sha256").update(bytes).digest("hex");
|
|
60253
|
+
}
|
|
60112
60254
|
function readULEB2(b, o) {
|
|
60113
60255
|
let res = 0;
|
|
60114
60256
|
let shift = 0;
|
|
@@ -60861,6 +61003,42 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
60861
61003
|
}
|
|
60862
61004
|
}
|
|
60863
61005
|
}
|
|
61006
|
+
const segObjCClasses = /* @__PURE__ */ new Map();
|
|
61007
|
+
for (let segIdx = 0; segIdx < sEnds.length; segIdx++) {
|
|
61008
|
+
const rangeStart = dataStart + sPayloadStarts[segIdx];
|
|
61009
|
+
const rangeEnd = dataStart + sEnds[segIdx];
|
|
61010
|
+
const sliceLen = rangeEnd - rangeStart;
|
|
61011
|
+
if (sliceLen < 4) continue;
|
|
61012
|
+
const slice = Buffer.from(rawBuf.buffer, rawBuf.byteOffset + rangeStart, sliceLen);
|
|
61013
|
+
let segPos = 0;
|
|
61014
|
+
let classes;
|
|
61015
|
+
while (segPos < sliceLen - 3) {
|
|
61016
|
+
const at = slice.indexOf("So", segPos);
|
|
61017
|
+
if (at < 0 || at >= sliceLen - 2) break;
|
|
61018
|
+
let digitEnd = at + 2;
|
|
61019
|
+
let length = 0;
|
|
61020
|
+
while (digitEnd < sliceLen) {
|
|
61021
|
+
const ch = slice[digitEnd];
|
|
61022
|
+
if (ch < 48 || ch > 57) break;
|
|
61023
|
+
length = length * 10 + (ch - 48);
|
|
61024
|
+
digitEnd++;
|
|
61025
|
+
}
|
|
61026
|
+
if (digitEnd === at + 2) {
|
|
61027
|
+
segPos = at + 2;
|
|
61028
|
+
continue;
|
|
61029
|
+
}
|
|
61030
|
+
segPos = digitEnd;
|
|
61031
|
+
const nameEnd = digitEnd + length;
|
|
61032
|
+
if (nameEnd >= sliceLen || slice[nameEnd] !== 67) continue;
|
|
61033
|
+
const symbol2 = `._OBJC_CLASS_${slice.toString("latin1", digitEnd, nameEnd)}`;
|
|
61034
|
+
if (!classes) {
|
|
61035
|
+
classes = [symbol2];
|
|
61036
|
+
segObjCClasses.set(segIdx, classes);
|
|
61037
|
+
} else if (!classes.includes(symbol2)) {
|
|
61038
|
+
classes.push(symbol2);
|
|
61039
|
+
}
|
|
61040
|
+
}
|
|
61041
|
+
}
|
|
60864
61042
|
return {
|
|
60865
61043
|
file,
|
|
60866
61044
|
isDist,
|
|
@@ -60890,10 +61068,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
60890
61068
|
objcCategoryTargets,
|
|
60891
61069
|
rootFuncs,
|
|
60892
61070
|
rootSegs,
|
|
60893
|
-
|
|
60894
|
-
dataStart + sPayloadStarts[i],
|
|
60895
|
-
dataStart + end
|
|
60896
|
-
])
|
|
61071
|
+
segObjCClasses
|
|
60897
61072
|
};
|
|
60898
61073
|
}
|
|
60899
61074
|
function parseWasmObjectFile(file, isDist) {
|
|
@@ -61261,16 +61436,26 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61261
61436
|
transformations.set(file, {
|
|
61262
61437
|
output,
|
|
61263
61438
|
inputSha256,
|
|
61264
|
-
outputSha256: (
|
|
61439
|
+
outputSha256: sha256Hex(result),
|
|
61265
61440
|
kind
|
|
61266
61441
|
});
|
|
61267
61442
|
};
|
|
61268
61443
|
const distFiles = [];
|
|
61269
61444
|
const distBaseNames = /* @__PURE__ */ new Set();
|
|
61270
61445
|
const eagerFiles = [];
|
|
61446
|
+
const parsedBuildObjects = /* @__PURE__ */ new Map();
|
|
61271
61447
|
const lazyBuildObjects = /* @__PURE__ */ new Map();
|
|
61272
61448
|
const extraArchiveObjs = [];
|
|
61273
61449
|
const objectBytes = /* @__PURE__ */ new Map();
|
|
61450
|
+
const archiveMembers = /* @__PURE__ */ new Map();
|
|
61451
|
+
const readArchiveMembers = (archive) => {
|
|
61452
|
+
let members2 = archiveMembers.get(archive);
|
|
61453
|
+
if (!members2) {
|
|
61454
|
+
members2 = readArMembers(new Uint8Array(import_node_fs58.default.readFileSync(archive)));
|
|
61455
|
+
archiveMembers.set(archive, members2);
|
|
61456
|
+
}
|
|
61457
|
+
return members2;
|
|
61458
|
+
};
|
|
61274
61459
|
let inStartLib = false;
|
|
61275
61460
|
let swiftrtOrigPath = "";
|
|
61276
61461
|
for (const t of tokens2) {
|
|
@@ -61307,8 +61492,10 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61307
61492
|
break;
|
|
61308
61493
|
}
|
|
61309
61494
|
}
|
|
61310
|
-
if (definesObjCClassOrCategory)
|
|
61311
|
-
|
|
61495
|
+
if (definesObjCClassOrCategory) {
|
|
61496
|
+
parsedBuildObjects.set(t, obj);
|
|
61497
|
+
eagerFiles.push(t);
|
|
61498
|
+
} else lazyBuildObjects.set(t, obj);
|
|
61312
61499
|
} else {
|
|
61313
61500
|
eagerFiles.push(t);
|
|
61314
61501
|
}
|
|
@@ -61316,7 +61503,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61316
61503
|
lazyBuildObjects.set(t, parseWasmObjectFile(t, false));
|
|
61317
61504
|
}
|
|
61318
61505
|
} else if (!inStartLib && t.endsWith(".a") && !t.endsWith("libclang_rt.builtins-wasm64.a") && import_node_fs58.default.existsSync(t)) {
|
|
61319
|
-
const members2 =
|
|
61506
|
+
const members2 = readArchiveMembers(t);
|
|
61320
61507
|
for (const m of members2) {
|
|
61321
61508
|
const object9 = parseWasmObjectBytes(`${t}(${m.name})`, m.bytes, false);
|
|
61322
61509
|
extraArchiveObjs.push(object9);
|
|
@@ -61339,7 +61526,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61339
61526
|
);
|
|
61340
61527
|
const archiveOverlapsDist = (archive) => {
|
|
61341
61528
|
if (!import_node_fs58.default.existsSync(archive)) return false;
|
|
61342
|
-
const members2 =
|
|
61529
|
+
const members2 = readArchiveMembers(archive);
|
|
61343
61530
|
return members2.some((m) => distBaseNames.has(m.name));
|
|
61344
61531
|
};
|
|
61345
61532
|
for (const t of tokens2) {
|
|
@@ -61361,7 +61548,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61361
61548
|
import_node_path57.default.basename(archive)
|
|
61362
61549
|
);
|
|
61363
61550
|
const ordinals = /* @__PURE__ */ new Map();
|
|
61364
|
-
for (const m of
|
|
61551
|
+
for (const m of readArchiveMembers(archive)) {
|
|
61365
61552
|
const ordinal = (ordinals.get(m.name) ?? 0) + 1;
|
|
61366
61553
|
ordinals.set(m.name, ordinal);
|
|
61367
61554
|
if (distBaseNames.has(m.name) || writtenLeftovers.has(m.name)) continue;
|
|
@@ -61395,7 +61582,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61395
61582
|
recordTransformation(
|
|
61396
61583
|
swiftrtOrigPath,
|
|
61397
61584
|
patchedSwiftrtPath,
|
|
61398
|
-
link ? (
|
|
61585
|
+
link ? sha256Hex(input) : "",
|
|
61399
61586
|
result,
|
|
61400
61587
|
"swiftrt"
|
|
61401
61588
|
);
|
|
@@ -61882,7 +62069,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61882
62069
|
}
|
|
61883
62070
|
for (const f of eagerFiles) {
|
|
61884
62071
|
const isDist = f.startsWith(distDir);
|
|
61885
|
-
const obj = distObjs.get(f) ?? parseWasmObjectFile(f, isDist);
|
|
62072
|
+
const obj = distObjs.get(f) ?? parsedBuildObjects.get(f) ?? parseWasmObjectFile(f, isDist);
|
|
61886
62073
|
extractObject(obj);
|
|
61887
62074
|
if (isDist) {
|
|
61888
62075
|
const base2 = import_node_path57.default.basename(f);
|
|
@@ -61932,32 +62119,9 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61932
62119
|
"$s10Foundation6BundleC22preferredLocalizations4fromSaySSGAF_tFZTf4nd_n"
|
|
61933
62120
|
]);
|
|
61934
62121
|
const keepObjCClassesNamedInSegment = (obj, segIdx) => {
|
|
61935
|
-
const
|
|
61936
|
-
if (!
|
|
61937
|
-
const
|
|
61938
|
-
if (rangeEnd - rangeStart < 4) return;
|
|
61939
|
-
let bytes = objectBytes.get(obj);
|
|
61940
|
-
if (!bytes) objectBytes.set(obj, bytes = import_node_fs58.default.readFileSync(obj.file));
|
|
61941
|
-
let pos = rangeStart;
|
|
61942
|
-
while (pos < rangeEnd - 3) {
|
|
61943
|
-
const at = bytes.indexOf("So", pos);
|
|
61944
|
-
if (at < 0 || at >= rangeEnd - 2) break;
|
|
61945
|
-
let digitEnd = at + 2;
|
|
61946
|
-
let length = 0;
|
|
61947
|
-
while (digitEnd < rangeEnd) {
|
|
61948
|
-
const ch = bytes[digitEnd];
|
|
61949
|
-
if (ch < 48 || ch > 57) break;
|
|
61950
|
-
length = length * 10 + (ch - 48);
|
|
61951
|
-
digitEnd++;
|
|
61952
|
-
}
|
|
61953
|
-
if (digitEnd === at + 2) {
|
|
61954
|
-
pos = at + 2;
|
|
61955
|
-
continue;
|
|
61956
|
-
}
|
|
61957
|
-
pos = digitEnd;
|
|
61958
|
-
const nameEnd = digitEnd + length;
|
|
61959
|
-
if (nameEnd >= rangeEnd || bytes[nameEnd] !== 67) continue;
|
|
61960
|
-
const symbol2 = `._OBJC_CLASS_${bytes.toString("latin1", digitEnd, nameEnd)}`;
|
|
62122
|
+
const symbols = obj.segObjCClasses.get(segIdx);
|
|
62123
|
+
if (!symbols) return;
|
|
62124
|
+
for (const symbol2 of symbols) {
|
|
61961
62125
|
for (const provider of lazyProviders.get(symbol2) ?? []) {
|
|
61962
62126
|
eagerDynamicObjects.add(provider);
|
|
61963
62127
|
extractObject(provider);
|
|
@@ -62053,7 +62217,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
62053
62217
|
const cached5 = objectBytes.get(obj);
|
|
62054
62218
|
const buf = cached5 ? new Uint8Array(cached5) : new Uint8Array(import_node_fs58.default.readFileSync(obj.file));
|
|
62055
62219
|
const rawBuf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
62056
|
-
const inputSha256 = link ? (
|
|
62220
|
+
const inputSha256 = link ? sha256Hex(buf) : "";
|
|
62057
62221
|
const fLive = liveFuncs.get(obj);
|
|
62058
62222
|
const sLive = liveSegs.get(obj);
|
|
62059
62223
|
const dLive = liveDataSyms.get(obj);
|
|
@@ -64432,13 +64596,34 @@ function dropWasmCustomSection(bytes, name3) {
|
|
|
64432
64596
|
}
|
|
64433
64597
|
return Buffer.concat(parts2);
|
|
64434
64598
|
}
|
|
64599
|
+
function writeWasmCustomSections(bytes, entries2) {
|
|
64600
|
+
if (entries2.length === 0) return Buffer.concat([bytes]);
|
|
64601
|
+
const replaced = new Set(entries2.map(([name3]) => name3));
|
|
64602
|
+
const parts2 = [];
|
|
64603
|
+
let sliceStart = 0;
|
|
64604
|
+
let sliceEnd = 8;
|
|
64605
|
+
for (const { id, start, end } of wasmSections2(bytes)) {
|
|
64606
|
+
if (id === 0 && replaced.has(readWasmSection(bytes, start, end).name())) {
|
|
64607
|
+
if (sliceEnd > sliceStart) parts2.push(bytes.subarray(sliceStart, sliceEnd));
|
|
64608
|
+
sliceStart = end;
|
|
64609
|
+
sliceEnd = end;
|
|
64610
|
+
} else {
|
|
64611
|
+
sliceEnd = end;
|
|
64612
|
+
}
|
|
64613
|
+
}
|
|
64614
|
+
if (sliceEnd > sliceStart) parts2.push(bytes.subarray(sliceStart, sliceEnd));
|
|
64615
|
+
for (const [name3, data] of entries2) {
|
|
64616
|
+
const nameBytes = Buffer.from(encodeWasmName(name3));
|
|
64617
|
+
parts2.push(
|
|
64618
|
+
Buffer.from([0, ...encodeWasmNumber(nameBytes.length + data.length)]),
|
|
64619
|
+
nameBytes,
|
|
64620
|
+
data
|
|
64621
|
+
);
|
|
64622
|
+
}
|
|
64623
|
+
return Buffer.concat(parts2);
|
|
64624
|
+
}
|
|
64435
64625
|
function writeWasmCustomSection(bytes, name3, data) {
|
|
64436
|
-
|
|
64437
|
-
return Buffer.concat([
|
|
64438
|
-
dropWasmCustomSection(bytes, name3),
|
|
64439
|
-
Buffer.from([0, ...encodeWasmNumber(section2.length)]),
|
|
64440
|
-
section2
|
|
64441
|
-
]);
|
|
64626
|
+
return writeWasmCustomSections(bytes, [[name3, data]]);
|
|
64442
64627
|
}
|
|
64443
64628
|
function readWasmFunctionNames(bytes) {
|
|
64444
64629
|
const section2 = readWasmCustomSection(bytes, "name");
|
|
@@ -64868,6 +65053,16 @@ var init_wasm_narrow_boundary = __esm({
|
|
|
64868
65053
|
});
|
|
64869
65054
|
|
|
64870
65055
|
// src/swift-guest-dyld-table.ts
|
|
65056
|
+
function sha256Buffer(bytes) {
|
|
65057
|
+
if (typeof Bun !== "undefined")
|
|
65058
|
+
return Buffer.from(new Bun.CryptoHasher("sha256").update(bytes).digest());
|
|
65059
|
+
return (0, import_node_crypto33.createHash)("sha256").update(bytes).digest();
|
|
65060
|
+
}
|
|
65061
|
+
function sha256Hex2(bytes) {
|
|
65062
|
+
if (typeof Bun !== "undefined")
|
|
65063
|
+
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
65064
|
+
return (0, import_node_crypto33.createHash)("sha256").update(bytes).digest("hex");
|
|
65065
|
+
}
|
|
64871
65066
|
function uleb3(value) {
|
|
64872
65067
|
const bytes = [];
|
|
64873
65068
|
for (let rest = value; ; rest = Math.floor(rest / 128)) {
|
|
@@ -64902,7 +65097,7 @@ function encodeGuestDyldTable(rows) {
|
|
|
64902
65097
|
}
|
|
64903
65098
|
const file = Buffer.concat(packs);
|
|
64904
65099
|
const header = Buffer.alloc(40 + packs.length * 8);
|
|
64905
|
-
(
|
|
65100
|
+
sha256Buffer(file).copy(header, 0);
|
|
64906
65101
|
header.writeUInt32LE(file.length, 32);
|
|
64907
65102
|
header.writeUInt32LE(packs.length, 36);
|
|
64908
65103
|
let offset = 0;
|
|
@@ -64914,11 +65109,11 @@ function encodeGuestDyldTable(rows) {
|
|
|
64914
65109
|
const names = firsts.flatMap((name3) => [name3, Buffer.of(0)]);
|
|
64915
65110
|
return { index: Buffer.concat([header, ...names]), packs: file };
|
|
64916
65111
|
}
|
|
64917
|
-
function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */ new Map()) {
|
|
65112
|
+
function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */ new Map(), extraSections = []) {
|
|
64918
65113
|
const range3 = guestDyldValueRange(map2);
|
|
64919
65114
|
if (!range3) {
|
|
64920
65115
|
if (symbols.length) throw new Error("link map has no dyld values");
|
|
64921
|
-
return wasm;
|
|
65116
|
+
return extraSections.length ? writeWasmCustomSections(wasm, extraSections) : wasm;
|
|
64922
65117
|
}
|
|
64923
65118
|
if (range3.length !== symbols.length * 8)
|
|
64924
65119
|
throw new Error("linked dyld values do not match the ledger rows");
|
|
@@ -64933,11 +65128,11 @@ function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */
|
|
|
64933
65128
|
return binding === void 0 ? { name: name3, image, kind: 0, value: view.getBigUint64(index2 * 8, true) } : { name: name3, image, kind: 1, value: BigInt(binding) };
|
|
64934
65129
|
});
|
|
64935
65130
|
const { index, packs } = encodeGuestDyldTable(rows);
|
|
64936
|
-
return
|
|
64937
|
-
|
|
64938
|
-
NATIVE_DYLD_PACKS_SECTION,
|
|
64939
|
-
|
|
64940
|
-
);
|
|
65131
|
+
return writeWasmCustomSections(taken.wasm, [
|
|
65132
|
+
[NATIVE_DYLD_TABLE_SECTION, index],
|
|
65133
|
+
[NATIVE_DYLD_PACKS_SECTION, packs],
|
|
65134
|
+
...extraSections
|
|
65135
|
+
]);
|
|
64941
65136
|
}
|
|
64942
65137
|
function guestDyldValueRange(map2) {
|
|
64943
65138
|
const suffix = `:(${GUEST_DYLD_VALUES_SECTION})`;
|
|
@@ -64966,7 +65161,7 @@ function splitSwiftDyldTable(wasm) {
|
|
|
64966
65161
|
const bytes = Buffer.from(packs);
|
|
64967
65162
|
return {
|
|
64968
65163
|
module: dropWasmCustomSection(wasm, NATIVE_DYLD_PACKS_SECTION),
|
|
64969
|
-
table: { sha256: (
|
|
65164
|
+
table: { sha256: sha256Hex2(bytes), bytes }
|
|
64970
65165
|
};
|
|
64971
65166
|
}
|
|
64972
65167
|
var import_node_crypto33, import_node_zlib4, PACK_BYTES;
|
|
@@ -65502,6 +65697,7 @@ function finalizeGuestProjectionStorage(options2) {
|
|
|
65502
65697
|
const owner = options2.owners.get(options2.projectionObject);
|
|
65503
65698
|
if (owner === void 0) throw new Error("guest projection object has no image owner");
|
|
65504
65699
|
const ranges = [];
|
|
65700
|
+
const data = [];
|
|
65505
65701
|
const spans = guestLinkedSpans(
|
|
65506
65702
|
options2.map,
|
|
65507
65703
|
options2.linked,
|
|
@@ -65512,7 +65708,8 @@ function finalizeGuestProjectionStorage(options2) {
|
|
|
65512
65708
|
{
|
|
65513
65709
|
trackedObject: options2.projectionObject,
|
|
65514
65710
|
trackedObjectOwner: owner,
|
|
65515
|
-
trackedLinearSpans: ranges
|
|
65711
|
+
trackedLinearSpans: ranges,
|
|
65712
|
+
optimizedDataSegments: data
|
|
65516
65713
|
}
|
|
65517
65714
|
);
|
|
65518
65715
|
const images = planGuestProjectionRegions(
|
|
@@ -65521,7 +65718,6 @@ function finalizeGuestProjectionStorage(options2) {
|
|
|
65521
65718
|
options2.sdkSpans ? [...spans, ...options2.sdkSpans] : spans
|
|
65522
65719
|
);
|
|
65523
65720
|
const result = Buffer.from(options2.optimized);
|
|
65524
|
-
const data = guestWasmDataSegments(options2.optimized, options2.sdkSpans === void 0);
|
|
65525
65721
|
const locations = /* @__PURE__ */ new Map();
|
|
65526
65722
|
const counts = /* @__PURE__ */ new Map();
|
|
65527
65723
|
const uuids = /* @__PURE__ */ new Map();
|
|
@@ -66195,17 +66391,17 @@ var init_binaryen_lock = __esm({
|
|
|
66195
66391
|
"linux-x64": {
|
|
66196
66392
|
asset: "x86_64-linux",
|
|
66197
66393
|
upstreamSha256: "195ddc94f9bc89f45abdabb0b9eea86023d727ba90eac8b35b80f2544fc30572",
|
|
66198
|
-
sha256: "
|
|
66394
|
+
sha256: "40062fb1ebbad7f04f361c1e3bb309dffb1d2318dd2e12235a0e7e820e18d6c9"
|
|
66199
66395
|
},
|
|
66200
66396
|
"linux-arm64": {
|
|
66201
66397
|
asset: "aarch64-linux",
|
|
66202
66398
|
upstreamSha256: "c58562417836c5d0493d89bdefc434933bdc097db641b483df86bcfa557a107f",
|
|
66203
|
-
sha256: "
|
|
66399
|
+
sha256: "d79b09d5b66f62f9e4bb691517b174b42bcdc0b7f40769d1993b7c565b0a54c7"
|
|
66204
66400
|
},
|
|
66205
66401
|
"darwin-arm64": {
|
|
66206
66402
|
asset: "arm64-macos",
|
|
66207
66403
|
upstreamSha256: "98aad827847af7ef990ed7098d885725c8e5b5aae75073403635617ae4e259aa",
|
|
66208
|
-
sha256: "
|
|
66404
|
+
sha256: "29342632a4fa52466c4feea846698fe5aa56ff46226a914d60b65b8735373d63"
|
|
66209
66405
|
}
|
|
66210
66406
|
}
|
|
66211
66407
|
};
|
|
@@ -66699,6 +66895,7 @@ function outputPath(args) {
|
|
|
66699
66895
|
}
|
|
66700
66896
|
function withOutput(args, output, discovery) {
|
|
66701
66897
|
const result = [];
|
|
66898
|
+
let stripsDebug = false;
|
|
66702
66899
|
for (let i = 0; i < args.length; i++) {
|
|
66703
66900
|
const arg = args[i];
|
|
66704
66901
|
if (arg === "-o" || arg === "--output") {
|
|
@@ -66708,9 +66905,12 @@ function withOutput(args, output, discovery) {
|
|
|
66708
66905
|
if (arg.startsWith("--output=")) continue;
|
|
66709
66906
|
if (discovery && (arg.startsWith("--why-extract=") || arg.startsWith("--Map=")))
|
|
66710
66907
|
continue;
|
|
66908
|
+
if (arg === "--strip-debug" || arg === "-S" || arg === "--strip-all" || arg === "-s")
|
|
66909
|
+
stripsDebug = true;
|
|
66711
66910
|
result.push(arg);
|
|
66712
66911
|
}
|
|
66713
66912
|
if (discovery) result.push("--allow-multiple-definition");
|
|
66913
|
+
if (!stripsDebug) result.push("--strip-debug");
|
|
66714
66914
|
result.push("-o", output);
|
|
66715
66915
|
return result;
|
|
66716
66916
|
}
|
|
@@ -66741,6 +66941,37 @@ async function linkGuestImages(options2) {
|
|
|
66741
66941
|
}
|
|
66742
66942
|
return import_node_fs63.default.readFileSync(trace, "utf8");
|
|
66743
66943
|
};
|
|
66944
|
+
const runLinkAsync = async (name3, arguments_) => {
|
|
66945
|
+
const response = import_node_path61.default.join(directory2, `${name3}.rsp`);
|
|
66946
|
+
const trace = import_node_path61.default.join(directory2, `${name3}-inputs.txt`);
|
|
66947
|
+
import_node_fs63.default.writeFileSync(
|
|
66948
|
+
response,
|
|
66949
|
+
[...arguments_, "--trace"].map((argument2) => JSON.stringify(argument2)).join(" ")
|
|
66950
|
+
);
|
|
66951
|
+
const output = import_node_fs63.default.openSync(trace, "w");
|
|
66952
|
+
try {
|
|
66953
|
+
await new Promise((resolve16, reject) => {
|
|
66954
|
+
const child = (0, import_node_child_process30.spawn)(wasmLd, [`@${response}`], {
|
|
66955
|
+
stdio: ["ignore", output, "pipe"]
|
|
66956
|
+
});
|
|
66957
|
+
const stderr = [];
|
|
66958
|
+
child.stderr?.on("data", (chunk) => stderr.push(chunk));
|
|
66959
|
+
child.once("error", reject);
|
|
66960
|
+
child.once("close", (code, signal) => {
|
|
66961
|
+
if (code === 0) resolve16();
|
|
66962
|
+
else
|
|
66963
|
+
reject(
|
|
66964
|
+
new Error(
|
|
66965
|
+
`wasm-ld (${name3}) failed (${signal ?? code}): ${Buffer.concat(stderr).toString("utf8")}`
|
|
66966
|
+
)
|
|
66967
|
+
);
|
|
66968
|
+
});
|
|
66969
|
+
});
|
|
66970
|
+
} finally {
|
|
66971
|
+
import_node_fs63.default.closeSync(output);
|
|
66972
|
+
}
|
|
66973
|
+
return import_node_fs63.default.readFileSync(trace, "utf8");
|
|
66974
|
+
};
|
|
66744
66975
|
const preselection = options2.projection && options2.preselectionDiscovery ? options2.preselectionDiscovery : void 0;
|
|
66745
66976
|
let discoveryProjection;
|
|
66746
66977
|
if (options2.projection) {
|
|
@@ -66970,6 +67201,7 @@ async function linkGuestImages(options2) {
|
|
|
66970
67201
|
};
|
|
66971
67202
|
const ledgerObjectPromise = compileLedgerAsync("ledger", ledger.llvmIR);
|
|
66972
67203
|
const appLedgerObjectPromise = options2.onSplitInputs && ledger.appLLVMIR ? compileLedgerAsync("app-ledger", ledger.appLLVMIR) : void 0;
|
|
67204
|
+
let deferredFinalLink;
|
|
66973
67205
|
try {
|
|
66974
67206
|
const replacements = /* @__PURE__ */ new Map();
|
|
66975
67207
|
const linkedOwners = /* @__PURE__ */ new Map();
|
|
@@ -67071,7 +67303,7 @@ async function linkGuestImages(options2) {
|
|
|
67071
67303
|
});
|
|
67072
67304
|
const finalOutput = import_node_path61.default.join(directory2, "final.wasm");
|
|
67073
67305
|
const finalWhy = import_node_path61.default.join(directory2, "final-why-extract.txt");
|
|
67074
|
-
const
|
|
67306
|
+
const finalLinkArgs = (projectionObject2, layoutMap) => [
|
|
67075
67307
|
...withOutput(finalArgs, finalOutput, false),
|
|
67076
67308
|
ledgerObject,
|
|
67077
67309
|
`@${lazyExports}`,
|
|
@@ -67079,10 +67311,38 @@ async function linkGuestImages(options2) {
|
|
|
67079
67311
|
...provider ? [`--undefined=${providerSymbol}`] : [],
|
|
67080
67312
|
...layoutMap ? [`--Map=${layoutMap}`] : [],
|
|
67081
67313
|
`--why-extract=${finalWhy}`
|
|
67082
|
-
]
|
|
67314
|
+
];
|
|
67315
|
+
const linkFinal = (projectionObject2, layoutMap) => runLink("final", finalLinkArgs(projectionObject2, layoutMap));
|
|
67316
|
+
const finalizeFinalLink = (trace) => {
|
|
67317
|
+
const finalSelection = selectedGuestLinkInputs(
|
|
67318
|
+
remapGuestLinkPlan(plan, replacements),
|
|
67319
|
+
finalArgs,
|
|
67320
|
+
import_node_fs63.default.readFileSync(finalWhy, "utf8"),
|
|
67321
|
+
trace,
|
|
67322
|
+
finalArchives
|
|
67323
|
+
);
|
|
67324
|
+
const original = new Map(
|
|
67325
|
+
[...replacements].map(([before2, after2]) => [after2, before2])
|
|
67326
|
+
);
|
|
67327
|
+
const key2 = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
|
|
67328
|
+
const before = new Set(selected.map(key2));
|
|
67329
|
+
const after = new Set(finalSelection.map(key2));
|
|
67330
|
+
const changed2 = [...before].filter((item) => !after.has(item));
|
|
67331
|
+
changed2.push(...[...after].filter((item) => !before.has(item)));
|
|
67332
|
+
if (changed2.length)
|
|
67333
|
+
throw new Error(
|
|
67334
|
+
`guest link selected different inputs after rewriting:
|
|
67335
|
+
${changed2.join("\n")}`
|
|
67336
|
+
);
|
|
67337
|
+
import_node_fs63.default.renameSync(finalOutput, outputPath(args));
|
|
67338
|
+
if (KEEP_WASM_NAMES)
|
|
67339
|
+
import_node_fs63.default.writeFileSync(
|
|
67340
|
+
outputPath(args),
|
|
67341
|
+
nameGuestImageAliases(import_node_fs63.default.readFileSync(outputPath(args)), plan.symbols)
|
|
67342
|
+
);
|
|
67343
|
+
};
|
|
67083
67344
|
let projectionObject;
|
|
67084
67345
|
let projectionStorage;
|
|
67085
|
-
let finalTrace;
|
|
67086
67346
|
if (options2.projection) {
|
|
67087
67347
|
const projection = options2.projection;
|
|
67088
67348
|
if (!plan.images.some((image) => image.id === projection.image))
|
|
@@ -67135,8 +67395,18 @@ async function linkGuestImages(options2) {
|
|
|
67135
67395
|
[...projection.clangOptions, "-c", projectionSource, "-o", projectionObject],
|
|
67136
67396
|
{ stdio: "pipe" }
|
|
67137
67397
|
);
|
|
67138
|
-
|
|
67139
|
-
|
|
67398
|
+
if (sharedSdk && options2.onFinalLink && options2.onSplitInputs && appLedgerObjectPromise) {
|
|
67399
|
+
deferredFinalLink = runLinkAsync(
|
|
67400
|
+
"final",
|
|
67401
|
+
finalLinkArgs(projectionObject, callerMap ? void 0 : layoutMap)
|
|
67402
|
+
).then((trace) => finalizeFinalLink(trace));
|
|
67403
|
+
break;
|
|
67404
|
+
}
|
|
67405
|
+
const finalTrace = linkFinal(projectionObject, callerMap ? void 0 : layoutMap);
|
|
67406
|
+
if (sharedSdk) {
|
|
67407
|
+
finalizeFinalLink(finalTrace);
|
|
67408
|
+
break;
|
|
67409
|
+
}
|
|
67140
67410
|
const wasm = import_node_fs63.default.readFileSync(finalOutput);
|
|
67141
67411
|
const actual = guestProjectionRegionCounts(
|
|
67142
67412
|
images.length,
|
|
@@ -67148,38 +67418,17 @@ async function linkGuestImages(options2) {
|
|
|
67148
67418
|
sectionOwners
|
|
67149
67419
|
)
|
|
67150
67420
|
);
|
|
67151
|
-
if (actual.every((count, index) => count <= capacities[index].regions))
|
|
67421
|
+
if (actual.every((count, index) => count <= capacities[index].regions)) {
|
|
67422
|
+
finalizeFinalLink(finalTrace);
|
|
67423
|
+
break;
|
|
67424
|
+
}
|
|
67152
67425
|
capacities = capacities.map((capacity, index) => ({
|
|
67153
67426
|
...capacity,
|
|
67154
67427
|
regions: Math.max(actual[index], capacity.regions)
|
|
67155
67428
|
}));
|
|
67156
67429
|
}
|
|
67157
67430
|
linkedOwners.set(projectionObject, projection.image);
|
|
67158
|
-
} else
|
|
67159
|
-
const finalSelection = selectedGuestLinkInputs(
|
|
67160
|
-
remapGuestLinkPlan(plan, replacements),
|
|
67161
|
-
finalArgs,
|
|
67162
|
-
import_node_fs63.default.readFileSync(finalWhy, "utf8"),
|
|
67163
|
-
finalTrace,
|
|
67164
|
-
finalArchives
|
|
67165
|
-
);
|
|
67166
|
-
const original = new Map([...replacements].map(([before2, after2]) => [after2, before2]));
|
|
67167
|
-
const key2 = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
|
|
67168
|
-
const before = new Set(selected.map(key2));
|
|
67169
|
-
const after = new Set(finalSelection.map(key2));
|
|
67170
|
-
const changed2 = [...before].filter((item) => !after.has(item));
|
|
67171
|
-
changed2.push(...[...after].filter((item) => !before.has(item)));
|
|
67172
|
-
if (changed2.length)
|
|
67173
|
-
throw new Error(
|
|
67174
|
-
`guest link selected different inputs after rewriting:
|
|
67175
|
-
${changed2.join("\n")}`
|
|
67176
|
-
);
|
|
67177
|
-
import_node_fs63.default.renameSync(finalOutput, outputPath(args));
|
|
67178
|
-
if (KEEP_WASM_NAMES)
|
|
67179
|
-
import_node_fs63.default.writeFileSync(
|
|
67180
|
-
outputPath(args),
|
|
67181
|
-
nameGuestImageAliases(import_node_fs63.default.readFileSync(outputPath(args)), plan.symbols)
|
|
67182
|
-
);
|
|
67431
|
+
} else finalizeFinalLink(linkFinal());
|
|
67183
67432
|
if (projectionStorage && projectionObject)
|
|
67184
67433
|
options2.projection.onReserved(projectionStorage, projectionObject);
|
|
67185
67434
|
options2.onLinkedOwners?.(linkedOwners);
|
|
@@ -67215,11 +67464,13 @@ ${changed2.join("\n")}`
|
|
|
67215
67464
|
appDefinedSymbols
|
|
67216
67465
|
});
|
|
67217
67466
|
}
|
|
67467
|
+
if (deferredFinalLink) options2.onFinalLink?.(deferredFinalLink);
|
|
67218
67468
|
return selected;
|
|
67219
67469
|
} catch (error) {
|
|
67220
67470
|
await Promise.allSettled([
|
|
67221
67471
|
ledgerObjectPromise,
|
|
67222
|
-
...appLedgerObjectPromise ? [appLedgerObjectPromise] : []
|
|
67472
|
+
...appLedgerObjectPromise ? [appLedgerObjectPromise] : [],
|
|
67473
|
+
...deferredFinalLink ? [deferredFinalLink] : []
|
|
67223
67474
|
]);
|
|
67224
67475
|
throw error;
|
|
67225
67476
|
}
|
|
@@ -67851,6 +68102,7 @@ async function linkPrunedGuestImages(options2) {
|
|
|
67851
68102
|
identities: aliasGuestLinkIdentities(identities, prepared.archives)
|
|
67852
68103
|
};
|
|
67853
68104
|
}
|
|
68105
|
+
let finalLinkDone;
|
|
67854
68106
|
const selected = await linkCompleteGuestImages({
|
|
67855
68107
|
plan,
|
|
67856
68108
|
args: [...linkedArgs, `--Map=${options2.mapPath}`],
|
|
@@ -67864,6 +68116,9 @@ async function linkPrunedGuestImages(options2) {
|
|
|
67864
68116
|
resolvePlan: options2.resolvePlan,
|
|
67865
68117
|
sharedSdk: options2.sharedSdk,
|
|
67866
68118
|
onSplitInputs: options2.onSplitInputs,
|
|
68119
|
+
onFinalLink: options2.deferFinalLink ? (done) => {
|
|
68120
|
+
finalLinkDone = done;
|
|
68121
|
+
} : void 0,
|
|
67867
68122
|
onDyldRows: options2.onDyldRows,
|
|
67868
68123
|
onLinkedOwners: (value) => {
|
|
67869
68124
|
owners = value;
|
|
@@ -67877,7 +68132,8 @@ async function linkPrunedGuestImages(options2) {
|
|
|
67877
68132
|
owners,
|
|
67878
68133
|
generatedSectionOwners,
|
|
67879
68134
|
sdk: sdk2,
|
|
67880
|
-
mapPath: options2.mapPath
|
|
68135
|
+
mapPath: options2.mapPath,
|
|
68136
|
+
finalLinkDone
|
|
67881
68137
|
};
|
|
67882
68138
|
}
|
|
67883
68139
|
var import_node_child_process30, import_node_fs63, import_node_path61, import_node_util6, execFileAsync, WASM_MAGIC, BITCODE_MAGIC;
|
|
@@ -67946,8 +68202,13 @@ function clangBinaryStamp(file) {
|
|
|
67946
68202
|
const stat2 = (0, import_node_fs64.statSync)(file, { bigint: true });
|
|
67947
68203
|
return [file, stat2.size, stat2.mtimeNs].join(":");
|
|
67948
68204
|
}
|
|
68205
|
+
function sha256Hex3(bytes) {
|
|
68206
|
+
if (typeof Bun !== "undefined")
|
|
68207
|
+
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
68208
|
+
return (0, import_node_crypto37.createHash)("sha256").update(bytes).digest("hex");
|
|
68209
|
+
}
|
|
67949
68210
|
function clangWrapperStamp(file) {
|
|
67950
|
-
return (
|
|
68211
|
+
return sha256Hex3((0, import_node_fs64.readFileSync)(file));
|
|
67951
68212
|
}
|
|
67952
68213
|
function clangArgsNeedCwd(args) {
|
|
67953
68214
|
const pathFlags = /* @__PURE__ */ new Set([
|
|
@@ -68097,22 +68358,35 @@ function sourceGuestClangLinkOptions(options2) {
|
|
|
68097
68358
|
"SOURCE_DATE_EPOCH"
|
|
68098
68359
|
].map((name3) => process.env[name3] ?? "");
|
|
68099
68360
|
const replays = [];
|
|
68361
|
+
const realPathCache = /* @__PURE__ */ new Map();
|
|
68362
|
+
const cachedRealpath = (file) => {
|
|
68363
|
+
let resolved = realPathCache.get(file);
|
|
68364
|
+
if (resolved === void 0) {
|
|
68365
|
+
resolved = (0, import_node_fs64.realpathSync)(file);
|
|
68366
|
+
realPathCache.set(file, resolved);
|
|
68367
|
+
}
|
|
68368
|
+
return resolved;
|
|
68369
|
+
};
|
|
68370
|
+
const resolvedSwiftCompiler = cachedRealpath(options2.swiftCompiler);
|
|
68100
68371
|
let clang;
|
|
68372
|
+
let clangWrapper;
|
|
68101
68373
|
let clangStamp;
|
|
68102
68374
|
let wrapperStamp;
|
|
68103
68375
|
for (const file of wanted) {
|
|
68104
68376
|
const command = commands.get(file);
|
|
68105
68377
|
if (!command) throw new Error(`missing source object producer ${file}`);
|
|
68106
68378
|
if (command.tool === "shell") {
|
|
68107
|
-
if (!command.args.length || (
|
|
68379
|
+
if (!command.args.length || cachedRealpath(command.args[0]) !== resolvedSwiftCompiler)
|
|
68108
68380
|
throw new Error(`unsupported source object producer ${file}`);
|
|
68109
68381
|
continue;
|
|
68110
68382
|
}
|
|
68111
|
-
const compiler = command.args[0] ? (
|
|
68112
|
-
clang ??= (
|
|
68113
|
-
if (command.tool !== "clang" || compiler !== clang && compiler !== (
|
|
68383
|
+
const compiler = command.args[0] ? cachedRealpath(command.args[0]) : "";
|
|
68384
|
+
clang ??= cachedRealpath(import_node_path62.default.join(options2.toolchainBin, "clang"));
|
|
68385
|
+
if (command.tool !== "clang" || compiler !== clang && compiler !== (clangWrapper ??= cachedRealpath(
|
|
68386
|
+
import_node_path62.default.join(options2.buildDirectory, CLANG_TARGET_MODULE_WRAPPER)
|
|
68387
|
+
)))
|
|
68114
68388
|
throw new Error(`unsupported source object producer ${file}`);
|
|
68115
|
-
const key2 = (
|
|
68389
|
+
const key2 = sha256Hex3(
|
|
68116
68390
|
JSON.stringify([
|
|
68117
68391
|
"clang-link-options/v2",
|
|
68118
68392
|
clangArgsNeedCwd(command.args) ? process.cwd() : null,
|
|
@@ -68122,11 +68396,8 @@ function sourceGuestClangLinkOptions(options2) {
|
|
|
68122
68396
|
compiler === clang ? null : wrapperStamp ??= clangWrapperStamp(compiler),
|
|
68123
68397
|
clangProducerStamp(file)
|
|
68124
68398
|
])
|
|
68125
|
-
).digest("hex");
|
|
68126
|
-
const cacheFile = import_node_path62.default.join(
|
|
68127
|
-
cacheDirectory,
|
|
68128
|
-
(0, import_node_crypto37.createHash)("sha256").update(file).digest("hex") + ".json"
|
|
68129
68399
|
);
|
|
68400
|
+
const cacheFile = import_node_path62.default.join(cacheDirectory, sha256Hex3(file) + ".json");
|
|
68130
68401
|
const cached5 = readClangLinkOptions(cacheFile, key2);
|
|
68131
68402
|
if (cached5) {
|
|
68132
68403
|
validateClangLinkOptions(cached5);
|
|
@@ -70349,7 +70620,7 @@ function headerClosure(roots) {
|
|
|
70349
70620
|
).filter((file) => !file.endsWith(`/${j.exclude}`));
|
|
70350
70621
|
const nitroFiles = roots.nitroModules ? headerFiles2(roots.nitroModules, n.from, n.skip, new RegExp(n.keep)) : [];
|
|
70351
70622
|
const hashes = (base2, files2) => Object.fromEntries(
|
|
70352
|
-
files2.map((file) => [file,
|
|
70623
|
+
files2.map((file) => [file, sha256Hex4((0, import_node_fs68.readFileSync)(import_node_path66.default.join(base2, file)))])
|
|
70353
70624
|
);
|
|
70354
70625
|
return {
|
|
70355
70626
|
jsi: hashes(roots.reactNative, jsiFiles),
|
|
@@ -70513,11 +70784,11 @@ function verifyInstalledAdapter(family, directory2, pin2) {
|
|
|
70513
70784
|
if (JSON.stringify(recorded) !== JSON.stringify(pinned))
|
|
70514
70785
|
throw new Error(`${label} manifest does not match the lock this build carries`);
|
|
70515
70786
|
const bytes = (0, import_node_fs68.readFileSync)(import_node_path66.default.join(directory2, archive.path));
|
|
70516
|
-
if (bytes.length !== archive.size ||
|
|
70787
|
+
if (bytes.length !== archive.size || sha256Hex4(bytes) !== archive.sha256)
|
|
70517
70788
|
throw new Error(`${label} library does not match its manifest`);
|
|
70518
70789
|
return manifest;
|
|
70519
70790
|
}
|
|
70520
|
-
var import_node_crypto39, import_node_fs68, import_node_path66, ADAPTER_MANIFEST, ADAPTER_FAMILIES, TURBO_RUNTIME_HEADER, HEADER_STAGE,
|
|
70791
|
+
var import_node_crypto39, import_node_fs68, import_node_path66, ADAPTER_MANIFEST, ADAPTER_FAMILIES, TURBO_RUNTIME_HEADER, HEADER_STAGE, sha256Hex4, hex64, sameHeaders;
|
|
70521
70792
|
var init_nitroAdapterContract = __esm({
|
|
70522
70793
|
"src/nitroAdapterContract.ts"() {
|
|
70523
70794
|
"use strict";
|
|
@@ -70567,7 +70838,7 @@ void scheduleDrain();
|
|
|
70567
70838
|
to: ["core", "core/NitroModules"]
|
|
70568
70839
|
}
|
|
70569
70840
|
};
|
|
70570
|
-
|
|
70841
|
+
sha256Hex4 = (data) => (0, import_node_crypto39.createHash)("sha256").update(data).digest("hex");
|
|
70571
70842
|
hex64 = (value) => typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
70572
70843
|
sameHeaders = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
70573
70844
|
}
|
|
@@ -74052,6 +74323,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
|
|
|
74052
74323
|
].map((name3) => `--export=${name3}`),
|
|
74053
74324
|
`@${import_node_path72.default.join(work, "exports.rsp")}`,
|
|
74054
74325
|
"--gc-sections",
|
|
74326
|
+
"--strip-debug",
|
|
74055
74327
|
// strings stay with their objects, so an app loads only the ones its pieces reference
|
|
74056
74328
|
"-O0"
|
|
74057
74329
|
];
|
|
@@ -74112,7 +74384,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
|
|
|
74112
74384
|
(0, import_node_fs74.writeFileSync)(import_node_path72.default.join(work, INTERFACE_FILE), JSON.stringify(sdkInterface));
|
|
74113
74385
|
(0, import_node_fs74.writeFileSync)(
|
|
74114
74386
|
import_node_path72.default.join(work, IMAGE_DIGEST),
|
|
74115
|
-
(0, import_node_crypto44.createHash)("sha256").update(image).digest("hex")
|
|
74387
|
+
typeof Bun !== "undefined" ? new Bun.CryptoHasher("sha256").update(image).digest("hex") : (0, import_node_crypto44.createHash)("sha256").update(image).digest("hex")
|
|
74116
74388
|
);
|
|
74117
74389
|
if (swiftSdkImageKey(
|
|
74118
74390
|
moduleRoot,
|
|
@@ -74670,6 +74942,7 @@ __export(swift_sdk_app_module_exports, {
|
|
|
74670
74942
|
readSwiftSdkUsage: () => readSwiftSdkUsage,
|
|
74671
74943
|
selectSwiftSdkData: () => selectSwiftSdkData,
|
|
74672
74944
|
swiftAppModuleInputs: () => swiftAppModuleInputs,
|
|
74945
|
+
swiftAppModuleThunkSection: () => swiftAppModuleThunkSection,
|
|
74673
74946
|
swiftSdkProjectionSpans: () => swiftSdkProjectionSpans,
|
|
74674
74947
|
writeSwiftSdkAppLink: () => writeSwiftSdkAppLink
|
|
74675
74948
|
});
|
|
@@ -74721,9 +74994,12 @@ async function buildSwiftAppModule(options2) {
|
|
|
74721
74994
|
linkage: link.linkage,
|
|
74722
74995
|
usage
|
|
74723
74996
|
});
|
|
74724
|
-
(
|
|
74997
|
+
finishSwiftAppModuleFile(options2.output);
|
|
74725
74998
|
return binding;
|
|
74726
74999
|
}
|
|
75000
|
+
function swiftAppModuleThunkSection(lowered) {
|
|
75001
|
+
return [NATIVE_SDK_THUNK_SECTION, sdkImportThunks(lowered)];
|
|
75002
|
+
}
|
|
74727
75003
|
function finishSwiftAppModule(lowered) {
|
|
74728
75004
|
return writeWasmCustomSection(
|
|
74729
75005
|
lowered,
|
|
@@ -74731,6 +75007,73 @@ function finishSwiftAppModule(lowered) {
|
|
|
74731
75007
|
sdkImportThunks(lowered)
|
|
74732
75008
|
);
|
|
74733
75009
|
}
|
|
75010
|
+
function finishSwiftAppModuleFile(file) {
|
|
75011
|
+
const fd = (0, import_node_fs75.openSync)(file, "r");
|
|
75012
|
+
let prefixEnd = 8;
|
|
75013
|
+
let hasExistingThunk = false;
|
|
75014
|
+
let prefix;
|
|
75015
|
+
try {
|
|
75016
|
+
const total = (0, import_node_fs75.fstatSync)(fd).size;
|
|
75017
|
+
const probe2 = Buffer.allocUnsafe(16);
|
|
75018
|
+
let offset = 8;
|
|
75019
|
+
while (offset < total) {
|
|
75020
|
+
const read = (0, import_node_fs75.readSync)(fd, probe2, 0, Math.min(16, total - offset), offset);
|
|
75021
|
+
if (read < 2) break;
|
|
75022
|
+
const id = probe2[0];
|
|
75023
|
+
let size2 = 0;
|
|
75024
|
+
let shift = 0;
|
|
75025
|
+
let at = 1;
|
|
75026
|
+
for (; ; ) {
|
|
75027
|
+
const byte = probe2[at++];
|
|
75028
|
+
size2 += (byte & 127) * 2 ** shift;
|
|
75029
|
+
if (!(byte & 128)) break;
|
|
75030
|
+
shift += 7;
|
|
75031
|
+
}
|
|
75032
|
+
const start = offset + at;
|
|
75033
|
+
const next = start + size2;
|
|
75034
|
+
if (id === 1 || id === 2) prefixEnd = next;
|
|
75035
|
+
else if (id === 0) {
|
|
75036
|
+
const nameBuf = Buffer.allocUnsafe(Math.min(128, size2));
|
|
75037
|
+
const nRead = (0, import_node_fs75.readSync)(fd, nameBuf, 0, nameBuf.length, start);
|
|
75038
|
+
let nLen = 0;
|
|
75039
|
+
let nShift = 0;
|
|
75040
|
+
let nAt = 0;
|
|
75041
|
+
for (; ; ) {
|
|
75042
|
+
if (nAt >= nRead) break;
|
|
75043
|
+
const byte = nameBuf[nAt++];
|
|
75044
|
+
nLen += (byte & 127) * 2 ** nShift;
|
|
75045
|
+
if (!(byte & 128)) break;
|
|
75046
|
+
nShift += 7;
|
|
75047
|
+
}
|
|
75048
|
+
if (nAt + nLen <= nRead && nameBuf.toString("utf8", nAt, nAt + nLen) === NATIVE_SDK_THUNK_SECTION) {
|
|
75049
|
+
hasExistingThunk = true;
|
|
75050
|
+
break;
|
|
75051
|
+
}
|
|
75052
|
+
}
|
|
75053
|
+
offset = next;
|
|
75054
|
+
}
|
|
75055
|
+
if (!hasExistingThunk) {
|
|
75056
|
+
prefix = Buffer.allocUnsafe(prefixEnd);
|
|
75057
|
+
let filled = 0;
|
|
75058
|
+
while (filled < prefixEnd) {
|
|
75059
|
+
const n = (0, import_node_fs75.readSync)(fd, prefix, filled, prefixEnd - filled, filled);
|
|
75060
|
+
if (n <= 0) break;
|
|
75061
|
+
filled += n;
|
|
75062
|
+
}
|
|
75063
|
+
prefix = prefix.subarray(0, filled);
|
|
75064
|
+
}
|
|
75065
|
+
} finally {
|
|
75066
|
+
(0, import_node_fs75.closeSync)(fd);
|
|
75067
|
+
}
|
|
75068
|
+
if (hasExistingThunk || !prefix) {
|
|
75069
|
+
(0, import_node_fs75.writeFileSync)(file, finishSwiftAppModule((0, import_node_fs75.readFileSync)(file)));
|
|
75070
|
+
return;
|
|
75071
|
+
}
|
|
75072
|
+
const thunks = sdkImportThunks(prefix);
|
|
75073
|
+
const nameBytes = Buffer.from(encodedName2(NATIVE_SDK_THUNK_SECTION));
|
|
75074
|
+
const header = Buffer.from([0, ...uleb4(nameBytes.length + thunks.length)]);
|
|
75075
|
+
(0, import_node_fs75.appendFileSync)(file, Buffer.concat([header, nameBytes, thunks]));
|
|
75076
|
+
}
|
|
74734
75077
|
function swiftAppModuleInputs(tokens2, buildRoot, sdkLibraries) {
|
|
74735
75078
|
const owned = (token) => import_node_path73.default.resolve(token).startsWith(`${buildRoot}/`) && (!token.includes("/.peach-pruned-objs/") || token.endsWith("/swiftrt-patched.o"));
|
|
74736
75079
|
const inputs2 = [];
|
|
@@ -74945,6 +75288,7 @@ async function linkSwiftAppModule(options2) {
|
|
|
74945
75288
|
"--unresolved-symbols=ignore-all",
|
|
74946
75289
|
"--import-undefined",
|
|
74947
75290
|
"--emit-relocs",
|
|
75291
|
+
"--strip-debug",
|
|
74948
75292
|
"--gc-sections",
|
|
74949
75293
|
"--keep-section=target_features",
|
|
74950
75294
|
"--error-limit=0",
|
|
@@ -74967,7 +75311,16 @@ async function linkSwiftAppModule(options2) {
|
|
|
74967
75311
|
const skipPasses = options2.layoutMap ? ["duplicate-function-elimination"] : void 0;
|
|
74968
75312
|
const sdkTableEnd = sdk2.sdkInterface.layout.tableEnd;
|
|
74969
75313
|
const { loweringCache } = options2;
|
|
74970
|
-
const loweringKey = loweringCache && (
|
|
75314
|
+
const loweringKey = loweringCache && (typeof Bun !== "undefined" ? new Bun.CryptoHasher("sha256").update(
|
|
75315
|
+
JSON.stringify([
|
|
75316
|
+
loweringCache.compilerDigest,
|
|
75317
|
+
optimize,
|
|
75318
|
+
skipPasses,
|
|
75319
|
+
sdkTableEnd,
|
|
75320
|
+
lazy,
|
|
75321
|
+
KEEP_WASM_NAMES
|
|
75322
|
+
])
|
|
75323
|
+
).update(bytes).digest("hex") : (0, import_node_crypto45.createHash)("sha256").update(
|
|
74971
75324
|
JSON.stringify([
|
|
74972
75325
|
loweringCache.compilerDigest,
|
|
74973
75326
|
optimize,
|
|
@@ -74976,7 +75329,7 @@ async function linkSwiftAppModule(options2) {
|
|
|
74976
75329
|
lazy,
|
|
74977
75330
|
KEEP_WASM_NAMES
|
|
74978
75331
|
])
|
|
74979
|
-
).update(bytes).digest("hex");
|
|
75332
|
+
).update(bytes).digest("hex"));
|
|
74980
75333
|
return {
|
|
74981
75334
|
linkage,
|
|
74982
75335
|
async lower() {
|
|
@@ -75586,7 +75939,8 @@ function createSwiftSdkBinding(linkage, sdk2, usage, projection) {
|
|
|
75586
75939
|
bindSwiftAppModule(linkage, sdk2),
|
|
75587
75940
|
selectSwiftSdkData(sdk2, usage, linkage, projection)
|
|
75588
75941
|
]);
|
|
75589
|
-
|
|
75942
|
+
const sha2565 = typeof Bun !== "undefined" ? new Bun.CryptoHasher("sha256").update(bytes).digest("hex") : (0, import_node_crypto45.createHash)("sha256").update(bytes).digest("hex");
|
|
75943
|
+
return { bytes, sha256: sha2565 };
|
|
75590
75944
|
}
|
|
75591
75945
|
function readSwiftSdkUsage(mapFile, linkedFile, sdkObjects) {
|
|
75592
75946
|
const map2 = readWasmLinkMap(mapFile, false);
|
|
@@ -76342,6 +76696,7 @@ async function compileGuestLink(options2) {
|
|
|
76342
76696
|
onSplitInputs: sdk2 ? (value) => {
|
|
76343
76697
|
splitInputs = value;
|
|
76344
76698
|
} : void 0,
|
|
76699
|
+
deferFinalLink: Boolean(sdk2),
|
|
76345
76700
|
onDyldRows: (rows) => {
|
|
76346
76701
|
lazyFunctions = rows.lazyFunctions;
|
|
76347
76702
|
dyldSymbols = rows.dyldSymbols;
|
|
@@ -76610,156 +76965,164 @@ async function compileGuestLink(options2) {
|
|
|
76610
76965
|
});
|
|
76611
76966
|
if (!reserved2 || !projectionObject) throw new Error("guest projection was not reserved");
|
|
76612
76967
|
if (sdk2) {
|
|
76613
|
-
|
|
76614
|
-
|
|
76615
|
-
|
|
76616
|
-
|
|
76617
|
-
|
|
76618
|
-
|
|
76619
|
-
|
|
76620
|
-
|
|
76621
|
-
|
|
76622
|
-
|
|
76623
|
-
|
|
76624
|
-
|
|
76625
|
-
|
|
76626
|
-
|
|
76627
|
-
|
|
76628
|
-
|
|
76629
|
-
|
|
76630
|
-
|
|
76631
|
-
const
|
|
76632
|
-
|
|
76633
|
-
|
|
76634
|
-
|
|
76635
|
-
|
|
76636
|
-
|
|
76637
|
-
|
|
76638
|
-
|
|
76639
|
-
|
|
76640
|
-
|
|
76641
|
-
|
|
76642
|
-
|
|
76643
|
-
|
|
76644
|
-
|
|
76645
|
-
let storage = reserved2;
|
|
76646
|
-
if (sdkSpans.length > 0) {
|
|
76647
|
-
const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
|
|
76648
|
-
storage = reserveGuestProjectionStorage(
|
|
76649
|
-
storage.images,
|
|
76650
|
-
storage.capacities.map((capacity, index) => ({
|
|
76651
|
-
...capacity,
|
|
76652
|
-
regions: capacity.regions + sdkCounts[index] + 16
|
|
76653
|
-
}))
|
|
76654
|
-
);
|
|
76655
|
-
const projectionSource = import_node_path74.default.join(work, "projection.c");
|
|
76656
|
-
(0, import_node_fs76.writeFileSync)(projectionSource, storage.source);
|
|
76657
|
-
(0, import_node_child_process41.execFileSync)(
|
|
76658
|
-
import_node_path74.default.join(options2.toolchainBin, "clang"),
|
|
76659
|
-
[...clangOptions, "-c", projectionSource, "-o", projectionObject],
|
|
76660
|
-
{ stdio: "pipe" }
|
|
76661
|
-
);
|
|
76662
|
-
}
|
|
76663
|
-
let precomputedSymbols;
|
|
76664
|
-
if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
|
|
76665
|
-
const referenced = new Set(splitInputs.appReferencedSymbols);
|
|
76666
|
-
const defined = new Set(splitInputs.appDefinedSymbols);
|
|
76667
|
-
const projSyms = guestWasmSymbols((0, import_node_fs76.readFileSync)(projectionObject));
|
|
76668
|
-
for (const name3 of projSyms.undefined) referenced.add(name3);
|
|
76669
|
-
for (const name3 of projSyms.defined) defined.add(name3);
|
|
76670
|
-
precomputedSymbols = { referenced, defined };
|
|
76671
|
-
}
|
|
76672
|
-
for (; ; ) {
|
|
76673
|
-
const link = await linkSwiftAppModule2({
|
|
76674
|
-
objects: [...owners.keys()],
|
|
76675
|
-
lazyFunctions: splitInputs.lazyFunctions,
|
|
76676
|
-
toolchainBin: options2.toolchainBin,
|
|
76677
|
-
sdk: sdk2,
|
|
76678
|
-
work,
|
|
76679
|
-
output: options2.optimized,
|
|
76680
|
-
optimize: options2.optimize,
|
|
76681
|
-
layoutMap,
|
|
76682
|
-
project: project2,
|
|
76683
|
-
precomputedSymbols,
|
|
76684
|
-
loweringCache: project2 ? void 0 : {
|
|
76685
|
-
file: import_node_path74.default.join(
|
|
76686
|
-
options2.buildDirectory,
|
|
76687
|
-
".build",
|
|
76688
|
-
"peach-app-module-lowered.wasm"
|
|
76689
|
-
),
|
|
76690
|
-
compilerDigest: options2.compilerDigest
|
|
76691
|
-
}
|
|
76692
|
-
});
|
|
76693
|
-
const map3 = (0, import_node_fs76.readFileSync)(
|
|
76694
|
-
project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
|
|
76695
|
-
"utf8"
|
|
76968
|
+
try {
|
|
76969
|
+
if (!splitInputs) throw new Error("guest link did not select shared SDK inputs");
|
|
76970
|
+
const {
|
|
76971
|
+
createSwiftSdkBinding: createSwiftSdkBinding2,
|
|
76972
|
+
linkSwiftAppModule: linkSwiftAppModule2,
|
|
76973
|
+
readSwiftSdkUsage: readSwiftSdkUsage2,
|
|
76974
|
+
swiftAppModuleThunkSection: swiftAppModuleThunkSection2,
|
|
76975
|
+
swiftSdkProjectionSpans: swiftSdkProjectionSpans2
|
|
76976
|
+
} = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
|
|
76977
|
+
const project2 = options2.project;
|
|
76978
|
+
const work = project2 ? (0, import_node_fs76.mkdtempSync)(import_node_path74.default.join(directory2, "app-module-")) : import_node_path74.default.join(directory2, "app-module");
|
|
76979
|
+
if (project2) (0, import_node_fs76.chownSync)(work, project2.uid, project2.gid);
|
|
76980
|
+
else (0, import_node_fs76.mkdirSync)(work, { recursive: true });
|
|
76981
|
+
const layoutMap = import_node_path74.default.join(work, "app.map");
|
|
76982
|
+
let appProjectionObject = projectionObject;
|
|
76983
|
+
const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0);
|
|
76984
|
+
const sdkObjectKeys = /* @__PURE__ */ new Map();
|
|
76985
|
+
const sdkObjectImages = /* @__PURE__ */ new Map();
|
|
76986
|
+
const sdkProductImages = new Map(prepared?.sdkProducts.images);
|
|
76987
|
+
for (const [file, { image, product, identity: identity2 }] of splitInputs.sdkObjects) {
|
|
76988
|
+
const key2 = sdkGuestObjectKey(identity2);
|
|
76989
|
+
sdkObjectKeys.set(file, key2);
|
|
76990
|
+
sdkObjectImages.set(key2, image);
|
|
76991
|
+
const priorImage = sdkProductImages.get(product);
|
|
76992
|
+
if (priorImage !== void 0 && priorImage !== image)
|
|
76993
|
+
throw new Error(`SDK product ${product} has several guest images`);
|
|
76994
|
+
sdkProductImages.set(product, image);
|
|
76995
|
+
}
|
|
76996
|
+
const linkedModule = import_node_path74.default.join(work, "app.wasm");
|
|
76997
|
+
const sdkSpans = swiftSdkProjectionSpans2(
|
|
76998
|
+
sdk2,
|
|
76999
|
+
(object9, product) => sdkObjectImages.get(object9) ?? sdkProductImages.get(product)
|
|
76696
77000
|
);
|
|
76697
|
-
const
|
|
76698
|
-
const bindingRows = /* @__PURE__ */ new Map();
|
|
76699
|
-
const data = [];
|
|
76700
|
-
for (let at = 0; at < link.linkage.data.length; at += 3) {
|
|
76701
|
-
const address = link.linkage.data[at];
|
|
76702
|
-
const size2 = link.linkage.data[at + 1];
|
|
76703
|
-
const value = link.linkage.data[at + 2];
|
|
76704
|
-
if (values && address >= values.address && address < values.address + values.length) {
|
|
76705
|
-
if (size2 !== 8 || (address - values.address) % 8)
|
|
76706
|
-
throw new Error("sdk binding splits a dyld value");
|
|
76707
|
-
bindingRows.set((address - values.address) / 8, value);
|
|
76708
|
-
} else data.push(address, size2, value);
|
|
76709
|
-
}
|
|
76710
|
-
const linked = (0, import_node_fs76.readFileSync)(
|
|
76711
|
-
project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
|
|
76712
|
-
);
|
|
76713
|
-
const required = guestProjectionRegionCounts(storage.images.length, [
|
|
76714
|
-
...guestLinkedSpans(map3, linked, linked, owners, splitInputs.appSections, true),
|
|
76715
|
-
...sdkSpans
|
|
76716
|
-
]);
|
|
76717
|
-
if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
|
|
76718
|
-
storage = reserveGuestProjectionStorage(
|
|
76719
|
-
storage.images,
|
|
76720
|
-
storage.capacities.map((capacity, index) => {
|
|
76721
|
-
const count = required[index];
|
|
76722
|
-
return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
|
|
76723
|
-
})
|
|
76724
|
-
);
|
|
77001
|
+
const compileAppProjection = (source) => {
|
|
76725
77002
|
const projectionSource = import_node_path74.default.join(work, "projection.c");
|
|
76726
|
-
|
|
77003
|
+
const nextObject = import_node_path74.default.join(work, "projection.o");
|
|
77004
|
+
(0, import_node_fs76.writeFileSync)(projectionSource, source);
|
|
76727
77005
|
(0, import_node_child_process41.execFileSync)(
|
|
76728
77006
|
import_node_path74.default.join(options2.toolchainBin, "clang"),
|
|
76729
|
-
[...clangOptions, "-c", projectionSource, "-o",
|
|
77007
|
+
[...clangOptions, "-c", projectionSource, "-o", nextObject],
|
|
76730
77008
|
{ stdio: "pipe" }
|
|
76731
77009
|
);
|
|
76732
|
-
|
|
77010
|
+
if (nextObject !== appProjectionObject) {
|
|
77011
|
+
owners.delete(appProjectionObject);
|
|
77012
|
+
appProjectionObject = nextObject;
|
|
77013
|
+
owners.set(appProjectionObject, 0);
|
|
77014
|
+
}
|
|
77015
|
+
};
|
|
77016
|
+
let storage = reserved2;
|
|
77017
|
+
if (sdkSpans.length > 0) {
|
|
77018
|
+
const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
|
|
77019
|
+
storage = reserveGuestProjectionStorage(
|
|
77020
|
+
storage.images,
|
|
77021
|
+
storage.capacities.map((capacity, index) => ({
|
|
77022
|
+
...capacity,
|
|
77023
|
+
regions: capacity.regions + sdkCounts[index] + 16
|
|
77024
|
+
}))
|
|
77025
|
+
);
|
|
77026
|
+
compileAppProjection(storage.source);
|
|
76733
77027
|
}
|
|
76734
|
-
|
|
76735
|
-
|
|
76736
|
-
|
|
76737
|
-
|
|
76738
|
-
|
|
76739
|
-
|
|
76740
|
-
|
|
76741
|
-
|
|
77028
|
+
let precomputedSymbols;
|
|
77029
|
+
if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
|
|
77030
|
+
const referenced = new Set(splitInputs.appReferencedSymbols);
|
|
77031
|
+
const defined = new Set(splitInputs.appDefinedSymbols);
|
|
77032
|
+
const projSyms = guestWasmSymbols((0, import_node_fs76.readFileSync)(appProjectionObject));
|
|
77033
|
+
for (const name3 of projSyms.undefined) referenced.add(name3);
|
|
77034
|
+
for (const name3 of projSyms.defined) defined.add(name3);
|
|
77035
|
+
precomputedSymbols = { referenced, defined };
|
|
77036
|
+
}
|
|
77037
|
+
for (; ; ) {
|
|
77038
|
+
const link = await linkSwiftAppModule2({
|
|
77039
|
+
objects: [...owners.keys()],
|
|
77040
|
+
lazyFunctions: splitInputs.lazyFunctions,
|
|
77041
|
+
toolchainBin: options2.toolchainBin,
|
|
77042
|
+
sdk: sdk2,
|
|
77043
|
+
work,
|
|
77044
|
+
output: options2.optimized,
|
|
77045
|
+
optimize: options2.optimize,
|
|
77046
|
+
layoutMap,
|
|
77047
|
+
project: project2,
|
|
77048
|
+
precomputedSymbols,
|
|
77049
|
+
loweringCache: project2 ? void 0 : {
|
|
77050
|
+
file: import_node_path74.default.join(
|
|
77051
|
+
options2.buildDirectory,
|
|
77052
|
+
".build",
|
|
77053
|
+
"peach-app-module-lowered.wasm"
|
|
77054
|
+
),
|
|
77055
|
+
compilerDigest: options2.compilerDigest
|
|
77056
|
+
}
|
|
76742
77057
|
});
|
|
76743
|
-
|
|
77058
|
+
const map3 = (0, import_node_fs76.readFileSync)(
|
|
77059
|
+
project2 ? projectOutputFile(work, layoutMap, project2) : layoutMap,
|
|
77060
|
+
"utf8"
|
|
77061
|
+
);
|
|
77062
|
+
const values = guestDyldValueRange(map3);
|
|
77063
|
+
const bindingRows = /* @__PURE__ */ new Map();
|
|
77064
|
+
const data = [];
|
|
77065
|
+
for (let at = 0; at < link.linkage.data.length; at += 3) {
|
|
77066
|
+
const address = link.linkage.data[at];
|
|
77067
|
+
const size2 = link.linkage.data[at + 1];
|
|
77068
|
+
const value = link.linkage.data[at + 2];
|
|
77069
|
+
if (values && address >= values.address && address < values.address + values.length) {
|
|
77070
|
+
if (size2 !== 8 || (address - values.address) % 8)
|
|
77071
|
+
throw new Error("sdk binding splits a dyld value");
|
|
77072
|
+
bindingRows.set((address - values.address) / 8, value);
|
|
77073
|
+
} else data.push(address, size2, value);
|
|
77074
|
+
}
|
|
77075
|
+
const linked = (0, import_node_fs76.readFileSync)(
|
|
77076
|
+
project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
|
|
77077
|
+
);
|
|
77078
|
+
const required = guestProjectionRegionCounts(storage.images.length, [
|
|
77079
|
+
...guestLinkedSpans(map3, linked, linked, owners, splitInputs.appSections, true),
|
|
77080
|
+
...sdkSpans
|
|
77081
|
+
]);
|
|
77082
|
+
if (storage.capacities.some(({ regions }, index) => required[index] > regions)) {
|
|
77083
|
+
storage = reserveGuestProjectionStorage(
|
|
77084
|
+
storage.images,
|
|
77085
|
+
storage.capacities.map((capacity, index) => {
|
|
77086
|
+
const count = required[index];
|
|
77087
|
+
return count > capacity.regions ? { ...capacity, regions: Math.max(count, capacity.regions * 2) } : capacity;
|
|
77088
|
+
})
|
|
77089
|
+
);
|
|
77090
|
+
compileAppProjection(storage.source);
|
|
77091
|
+
continue;
|
|
77092
|
+
}
|
|
77093
|
+
options2.onStage("lowering the app image");
|
|
77094
|
+
const lowerPromise = link.lower();
|
|
77095
|
+
await new Promise((resolve16) => setImmediate(resolve16));
|
|
77096
|
+
let binding;
|
|
77097
|
+
try {
|
|
77098
|
+
if (result.finalLinkDone) await result.finalLinkDone;
|
|
77099
|
+
const usage = readSwiftSdkUsage2(result.mapPath, options2.output, sdkObjectKeys);
|
|
77100
|
+
binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
|
|
77101
|
+
} catch (error) {
|
|
77102
|
+
await Promise.allSettled([lowerPromise]);
|
|
77103
|
+
throw error;
|
|
77104
|
+
}
|
|
77105
|
+
await lowerPromise;
|
|
77106
|
+
const finalized = finalizeGuestProjectionStorage({
|
|
77107
|
+
map: map3,
|
|
77108
|
+
linked,
|
|
77109
|
+
optimized: (0, import_node_fs76.readFileSync)(options2.optimized),
|
|
77110
|
+
owners,
|
|
77111
|
+
sectionOwners: splitInputs.appSections,
|
|
77112
|
+
projectionObject: appProjectionObject,
|
|
77113
|
+
reserved: storage,
|
|
77114
|
+
sdkSpans
|
|
77115
|
+
});
|
|
77116
|
+
(0, import_node_fs76.writeFileSync)(
|
|
77117
|
+
options2.optimized,
|
|
77118
|
+
moveGuestDyldTable(map3, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
|
|
77119
|
+
swiftAppModuleThunkSection2(finalized.wasm)
|
|
77120
|
+
])
|
|
77121
|
+
);
|
|
77122
|
+
return binding;
|
|
76744
77123
|
}
|
|
76745
|
-
|
|
76746
|
-
|
|
76747
|
-
map: map3,
|
|
76748
|
-
linked,
|
|
76749
|
-
optimized: (0, import_node_fs76.readFileSync)(options2.optimized),
|
|
76750
|
-
owners,
|
|
76751
|
-
sectionOwners: splitInputs.appSections,
|
|
76752
|
-
projectionObject,
|
|
76753
|
-
reserved: storage,
|
|
76754
|
-
sdkSpans
|
|
76755
|
-
});
|
|
76756
|
-
(0, import_node_fs76.writeFileSync)(
|
|
76757
|
-
options2.optimized,
|
|
76758
|
-
finishSwiftAppModule2(
|
|
76759
|
-
moveGuestDyldTable(map3, finalized.wasm, splitInputs.dyldSymbols, bindingRows)
|
|
76760
|
-
)
|
|
76761
|
-
);
|
|
76762
|
-
return binding;
|
|
77124
|
+
} finally {
|
|
77125
|
+
if (result.finalLinkDone) await Promise.allSettled([result.finalLinkDone]);
|
|
76763
77126
|
}
|
|
76764
77127
|
}
|
|
76765
77128
|
options2.onStage("lowering the app image");
|
|
@@ -82177,6 +82540,10 @@ async function buildFrameworkProducts(scratch2, args) {
|
|
|
82177
82540
|
// every framework target when callers alternate --cores.
|
|
82178
82541
|
"-Xswiftc",
|
|
82179
82542
|
"-gnone",
|
|
82543
|
+
"-Xcc",
|
|
82544
|
+
"-g0",
|
|
82545
|
+
"-Xcxx",
|
|
82546
|
+
"-g0",
|
|
82180
82547
|
"-Xswiftc",
|
|
82181
82548
|
"-num-threads",
|
|
82182
82549
|
"-Xswiftc",
|
|
@@ -83067,6 +83434,10 @@ ${cap}` : "";
|
|
|
83067
83434
|
// fan-out under high -j.
|
|
83068
83435
|
"-Xswiftc",
|
|
83069
83436
|
"-gnone",
|
|
83437
|
+
"-Xcc",
|
|
83438
|
+
"-g0",
|
|
83439
|
+
"-Xcxx",
|
|
83440
|
+
"-g0",
|
|
83070
83441
|
...incrementalPreview ? [] : [
|
|
83071
83442
|
"-Xswiftc",
|
|
83072
83443
|
"-num-threads",
|
|
@@ -83717,7 +84088,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
83717
84088
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
83718
84089
|
MULTI_MANIFEST_VERSION = 76;
|
|
83719
84090
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
83720
|
-
compilerSourceDigest = true ? "
|
|
84091
|
+
compilerSourceDigest = true ? "ab7e385f5b9ca10737de11d59802a2b57ee084a172b96aa971acb4c26a58a573" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
|
|
83721
84092
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
83722
84093
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
83723
84094
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
@@ -94227,6 +94598,11 @@ end
|
|
|
94227
94598
|
});
|
|
94228
94599
|
|
|
94229
94600
|
// src/bazel-project.ts
|
|
94601
|
+
function sha256Hex5(bytes) {
|
|
94602
|
+
if (typeof Bun !== "undefined")
|
|
94603
|
+
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
94604
|
+
return (0, import_node_crypto54.createHash)("sha256").update(bytes).digest("hex");
|
|
94605
|
+
}
|
|
94230
94606
|
function isBazelPackage(input) {
|
|
94231
94607
|
return /^BUILD(?:\.bazel)?$/.test(import_node_path96.default.basename(input)) && import_node_fs95.default.statSync(input).isFile();
|
|
94232
94608
|
}
|
|
@@ -94793,6 +95169,18 @@ ${published4.map(
|
|
|
94793
95169
|
`bazel application has ${missing2.length} unbuilt inputs: ${missing2.slice(0, 5).map((file) => import_node_path96.default.relative(root, file)).join(", ")}`
|
|
94794
95170
|
);
|
|
94795
95171
|
const archives = /* @__PURE__ */ new Map();
|
|
95172
|
+
let outputOwner;
|
|
95173
|
+
const ownerOfOutput = (file) => {
|
|
95174
|
+
if (!outputOwner) {
|
|
95175
|
+
outputOwner = /* @__PURE__ */ new Map();
|
|
95176
|
+
for (const item of graph.rules.values())
|
|
95177
|
+
for (const output of item.outputs) {
|
|
95178
|
+
const outputPath2 = files2.path(output);
|
|
95179
|
+
if (!outputOwner.has(outputPath2)) outputOwner.set(outputPath2, item);
|
|
95180
|
+
}
|
|
95181
|
+
}
|
|
95182
|
+
return outputOwner.get(file);
|
|
95183
|
+
};
|
|
94796
95184
|
for (const rule of order) {
|
|
94797
95185
|
for (const dep of rule.attrs.get("deps")?.list ?? []) {
|
|
94798
95186
|
const owner = ruleOf(dep, rule.label);
|
|
@@ -94810,9 +95198,7 @@ ${published4.map(
|
|
|
94810
95198
|
for (const raw2 of rule.attrs.get("srcs")?.list ?? []) {
|
|
94811
95199
|
const label2 = canonicalLabel(raw2, rule.label);
|
|
94812
95200
|
for (const archive of files2.expand([raw2], rule.label).filter((file) => file.endsWith(".a"))) {
|
|
94813
|
-
const owner =
|
|
94814
|
-
(item) => item.outputs.some((output) => files2.path(output) === archive)
|
|
94815
|
-
);
|
|
95201
|
+
const owner = ownerOfOutput(archive);
|
|
94816
95202
|
const key2 = owner?.label ?? label2;
|
|
94817
95203
|
const entry = archives.get(key2) ?? {
|
|
94818
95204
|
library: import_node_path96.default.basename(archive),
|
|
@@ -94838,6 +95224,13 @@ ${published4.map(
|
|
|
94838
95224
|
)
|
|
94839
95225
|
)
|
|
94840
95226
|
);
|
|
95227
|
+
const matchesAppInclude = (name3) => {
|
|
95228
|
+
if (appIncludes.has(name3)) return true;
|
|
95229
|
+
for (let slash = name3.indexOf("/"); slash >= 0; slash = name3.indexOf("/", slash + 1)) {
|
|
95230
|
+
if (appIncludes.has(name3.slice(slash + 1))) return true;
|
|
95231
|
+
}
|
|
95232
|
+
return false;
|
|
95233
|
+
};
|
|
94841
95234
|
let generatedBy;
|
|
94842
95235
|
const generators = () => {
|
|
94843
95236
|
if (!generatedBy) {
|
|
@@ -94918,9 +95311,7 @@ ${published4.map(
|
|
|
94918
95311
|
[...linkers].filter((rule) => rule.attrs.get("module_name")?.value).flatMap((rule) => files2.expand(rule.attrs.get("hdrs")?.list ?? [], rule.label))
|
|
94919
95312
|
);
|
|
94920
95313
|
const entries2 = headers.filter(
|
|
94921
|
-
(header) => imported.has(header.file) ||
|
|
94922
|
-
(include) => header.name === include || header.name.endsWith(`/${include}`)
|
|
94923
|
-
)
|
|
95314
|
+
(header) => imported.has(header.file) || matchesAppInclude(header.name)
|
|
94924
95315
|
);
|
|
94925
95316
|
const bundle = import_node_path96.default.join(products, "archives", `${name3}.xcframework`);
|
|
94926
95317
|
const slice = import_node_path96.default.join(bundle, "ios-arm64-simulator");
|
|
@@ -94966,14 +95357,9 @@ ${published4.map(
|
|
|
94966
95357
|
]
|
|
94967
95358
|
)
|
|
94968
95359
|
]);
|
|
94969
|
-
const digest3 = (
|
|
94970
|
-
JSON.stringify(
|
|
94971
|
-
|
|
94972
|
-
file,
|
|
94973
|
-
(0, import_node_crypto54.createHash)("sha256").update(bytes).digest("hex")
|
|
94974
|
-
])
|
|
94975
|
-
)
|
|
94976
|
-
).digest("hex");
|
|
95360
|
+
const digest3 = sha256Hex5(
|
|
95361
|
+
JSON.stringify([...contents2].map(([file, bytes]) => [file, sha256Hex5(bytes)]))
|
|
95362
|
+
);
|
|
94977
95363
|
const stamp = import_node_path96.default.join(bundle, ".peach-digest");
|
|
94978
95364
|
if (!import_node_fs95.default.existsSync(stamp) || import_node_fs95.default.readFileSync(stamp, "utf8") !== digest3) {
|
|
94979
95365
|
import_node_fs95.default.rmSync(bundle, { recursive: true, force: true });
|
|
@@ -111085,7 +111471,7 @@ function compiledFrameworkImports(app, products) {
|
|
|
111085
111471
|
}
|
|
111086
111472
|
return imports2;
|
|
111087
111473
|
}
|
|
111088
|
-
function
|
|
111474
|
+
function sha256Hex6(bytes) {
|
|
111089
111475
|
if (typeof Bun !== "undefined")
|
|
111090
111476
|
return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
|
|
111091
111477
|
return (0, import_node_crypto73.createHash)("sha256").update(bytes).digest("hex");
|
|
@@ -111103,7 +111489,7 @@ function verifyRetainedFile(work, file, hash, stamps) {
|
|
|
111103
111489
|
if (typeof expectedStamp === "string" && regularFileStamp(resolved) === expectedStamp)
|
|
111104
111490
|
return true;
|
|
111105
111491
|
if (!import_node_fs121.default.existsSync(resolved)) return false;
|
|
111106
|
-
return
|
|
111492
|
+
return sha256Hex6(readPackageFile(work, resolved, Infinity)) === hash;
|
|
111107
111493
|
}
|
|
111108
111494
|
function recordRetainedStamps(work, files2) {
|
|
111109
111495
|
const stamps = {};
|
|
@@ -111120,7 +111506,7 @@ function cachedBinaryFileDigest(file) {
|
|
|
111120
111506
|
const memory = binaryFileDigests.get(real);
|
|
111121
111507
|
if (memory?.stamp === stamp) return memory.digest;
|
|
111122
111508
|
const dir = import_node_path123.default.join(cacheDir(), "swift-binary-digests");
|
|
111123
|
-
const record6 = import_node_path123.default.join(dir, `${
|
|
111509
|
+
const record6 = import_node_path123.default.join(dir, `${sha256Hex6(real)}.json`);
|
|
111124
111510
|
if (import_node_fs121.default.existsSync(record6)) {
|
|
111125
111511
|
const saved = JSON.parse(import_node_fs121.default.readFileSync(record6, "utf8"));
|
|
111126
111512
|
if (isRecord(saved) && saved.stamp === stamp && typeof saved.digest === "string") {
|
|
@@ -111128,7 +111514,7 @@ function cachedBinaryFileDigest(file) {
|
|
|
111128
111514
|
return saved.digest;
|
|
111129
111515
|
}
|
|
111130
111516
|
}
|
|
111131
|
-
const digest3 =
|
|
111517
|
+
const digest3 = sha256Hex6(import_node_fs121.default.readFileSync(real));
|
|
111132
111518
|
binaryFileDigests.set(real, { stamp, digest: digest3 });
|
|
111133
111519
|
import_node_fs121.default.mkdirSync(dir, { recursive: true });
|
|
111134
111520
|
const partial = `${record6}.${process.pid}.${(0, import_node_crypto73.randomUUID)()}`;
|
|
@@ -111663,7 +112049,7 @@ function prepareXcodeSwiftProducts(app, binaries, moduleRoot) {
|
|
|
111663
112049
|
const staged = withFrameworkCompanionImports(original);
|
|
111664
112050
|
if (staged !== original) sources.set(file, Buffer.from(staged));
|
|
111665
112051
|
}
|
|
111666
|
-
const digest3 =
|
|
112052
|
+
const digest3 = sha256Hex6;
|
|
111667
112053
|
const providers = /* @__PURE__ */ new Map();
|
|
111668
112054
|
for (const target of targets) {
|
|
111669
112055
|
if (!supplied.has(target.moduleName)) continue;
|
|
@@ -112019,7 +112405,7 @@ async function prepareXcodeNativeInputs(app, binaries, moduleRoot, purpose) {
|
|
|
112019
112405
|
products
|
|
112020
112406
|
);
|
|
112021
112407
|
const checkouts = remoteSwiftCheckouts(app.rootDir);
|
|
112022
|
-
const digest3 =
|
|
112408
|
+
const digest3 = sha256Hex6;
|
|
112023
112409
|
const inputs2 = Object.fromEntries(
|
|
112024
112410
|
[...sources].map(([file, bytes]) => [file, digest3(bytes)])
|
|
112025
112411
|
);
|
|
@@ -112301,6 +112687,7 @@ async function prepareXcodeNativeInputs(app, binaries, moduleRoot, purpose) {
|
|
|
112301
112687
|
...flags,
|
|
112302
112688
|
...target.prefix ? ["-include", staged(target.prefix)] : [],
|
|
112303
112689
|
"-Os",
|
|
112690
|
+
...purpose === "objects" ? ["-g0"] : [],
|
|
112304
112691
|
"-c",
|
|
112305
112692
|
staged(file),
|
|
112306
112693
|
"-o",
|
|
@@ -147329,7 +147716,7 @@ var init_nitro_superset = __esm({
|
|
|
147329
147716
|
init_nitroContract();
|
|
147330
147717
|
init_swift_standin_digest();
|
|
147331
147718
|
NITRO_SUPERSET_ENTRY_NAME = "superset";
|
|
147332
|
-
NITRO_COMPILER_DIGEST = true ? "
|
|
147719
|
+
NITRO_COMPILER_DIGEST = true ? "2b748ed5d0850b2ccb4eb8842bbcfdec5254b56ef63760418c6e2795f3b68e10" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
|
|
147333
147720
|
nitroSupersetLock = parseLock(nitro_superset_lock_default);
|
|
147334
147721
|
nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
|
|
147335
147722
|
published3 = /* @__PURE__ */ new Map();
|