peachsim 0.1.2596 → 0.1.2597
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +969 -423
- 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-WGTQK4JN.mjs → acorn-55PXV665.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-IGMABYTC.mjs → chunk-3DRJIOHV.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BNXCKF2B.mjs → chunk-42RIRPTB.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WPX7HLFR.mjs → chunk-56YYEI6C.mjs} +7 -6
- package/dist-lib/esm-chunks/{chunk-FDMS7FWE.mjs → chunk-7ECUAVIA.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-4PMXT2UO.mjs → chunk-7J65FNXI.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SYCOZ2CT.mjs → chunk-AJHFCIEU.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-4MMPS5YL.mjs → chunk-CKUEWEY4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-QEGUUPRI.mjs → chunk-DCL2ZEGA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4UUWP6NP.mjs → chunk-GECWNEHA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5NZPSLS4.mjs → chunk-GRGNTIO7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ZVBBDMPW.mjs → chunk-GZD5CTG7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ISZE675P.mjs → chunk-HATXI62T.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-TILPABC4.mjs → chunk-INA4S3MF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3C2YVQZH.mjs → chunk-IPN35TGX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SPKD6UYK.mjs → chunk-LH524OUR.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-DY6PUVXF.mjs → chunk-MMHNSEZY.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BAEOHCN5.mjs → chunk-NWLCTKBM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-HZPXGVY4.mjs → chunk-O5FDNHDG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-TNZG7SFG.mjs → chunk-ROFBHGEA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UCIOSXXU.mjs → chunk-V6SI2XY7.mjs} +963 -490
- package/dist-lib/esm-chunks/{chunk-C3C5OJG4.mjs → chunk-VN7BXTMG.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-LZF4BVEY.mjs → chunk-Y4XMEBRN.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-QNM3HYV7.mjs → metro-layout-parser-5FUYCP6P.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-BXXQB7Q2.mjs → swift-package-prebuilt-W3VMDYHC.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-FKL3X2ZC.mjs → swift-sdk-app-module-ZHGBY6T7.mjs} +126 -56
- package/dist-lib/esm-chunks/{swift-sdk-image-CCVWDFHB.mjs → swift-sdk-image-2PC4PKHZ.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-OTMZVBDN.mjs → swift-sdk-image-producer-WDN6BXQL.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +968 -422
- 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 +969 -423
- package/dist-lib/host/fetch-proxy-handler.cjs +36 -6
- 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 +34 -4
- package/dist-lib/native-app-identity-project.mjs +16 -16
- 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 +81 -81
- package/dist-lib/public-origins-lib.json +69 -69
- 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 +970 -424
- package/dist-lib/swift-compile.cjs +966 -420
- package/dist-lib/swift-compile.mjs +10 -10
- 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/@xmldom/xmldom.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/bplist-parser.cjs +1 -1
- package/dist-lib/vendor/ignore.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/plist.cjs +1 -1
- package/dist-lib/vendor/smol-toml.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/dist-types/packages/peach-engine/src/render-worker/nativeAnimMirrorContract.d.ts +0 -2
- package/package.json +1 -1
- package/src/swift-compile.ts +421 -175
- package/src/swift-guest-compile.ts +16 -0
- package/src/swift-guest-image-ledger.ts +65 -14
- package/src/swift-guest-link.ts +21 -0
- package/src/swift-guest-manifest.ts +27 -5
- package/src/swift-guest-source-inputs.ts +119 -14
- package/src/swift-sdk-app-module.ts +128 -55
- package/src/swift-sdk-image-wasm.ts +76 -39
- package/src/swift-sdk-image.ts +2 -1
- package/src/swift-wasm-prune.ts +282 -222
- package/src/wasm-optimize.ts +1 -1
- package/src/write-build-file.ts +9 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2597 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -8464,8 +8464,14 @@ var init_podspec_ruby_stdlib = __esm({
|
|
|
8464
8464
|
|
|
8465
8465
|
// src/write-build-file.ts
|
|
8466
8466
|
function writeBuildFile(file, contents2) {
|
|
8467
|
-
|
|
8468
|
-
|
|
8467
|
+
const stat = (0, import_node_fs15.statSync)(file, { throwIfNoEntry: false });
|
|
8468
|
+
if (stat?.isFile()) {
|
|
8469
|
+
if (typeof contents2 === "string") {
|
|
8470
|
+
if ((0, import_node_fs15.readFileSync)(file, "utf8") === contents2) return;
|
|
8471
|
+
} else if (stat.size === contents2.length && (0, import_node_fs15.readFileSync)(file).equals(contents2)) {
|
|
8472
|
+
return;
|
|
8473
|
+
}
|
|
8474
|
+
}
|
|
8469
8475
|
(0, import_node_fs15.mkdirSync)(import_node_path12.default.dirname(file), { recursive: true });
|
|
8470
8476
|
(0, import_node_fs15.writeFileSync)(file, contents2);
|
|
8471
8477
|
}
|
|
@@ -26249,13 +26255,13 @@ var init_swift_standin_digest = __esm({
|
|
|
26249
26255
|
STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
|
|
26250
26256
|
SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
26251
26257
|
standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
|
|
26252
|
-
STANDIN_SOURCE_DIGEST = true ? "
|
|
26258
|
+
STANDIN_SOURCE_DIGEST = true ? "803880cad876e27e4e621723b8eae85b3c486a882db0f0f745babaf80c070680" : standinSourceDigest();
|
|
26253
26259
|
}
|
|
26254
26260
|
});
|
|
26255
26261
|
|
|
26256
26262
|
// src/expo-native-compiler-digest.ts
|
|
26257
26263
|
function expoNativeCompilerDigestValue() {
|
|
26258
|
-
return true ? "
|
|
26264
|
+
return true ? "4e04e854647f1a1e167543007b405e6d43a936b2b02d7be227ac14a5bcb224f9" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
|
|
26259
26265
|
}
|
|
26260
26266
|
var import_node_crypto17;
|
|
26261
26267
|
var init_expo_native_compiler_digest = __esm({
|
|
@@ -32372,7 +32378,11 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
32372
32378
|
const sections = wasmSections(bytes);
|
|
32373
32379
|
const linking = sections.find((s) => s.name === "linking");
|
|
32374
32380
|
if (!linking) throw new Error("relocation link has no linking section");
|
|
32375
|
-
|
|
32381
|
+
let symKind = new Uint8Array(0);
|
|
32382
|
+
let symFlags = new Uint32Array(0);
|
|
32383
|
+
let symSegment = new Int32Array(0);
|
|
32384
|
+
let symOffset = new Int32Array(0);
|
|
32385
|
+
let symIndex = new Int32Array(0);
|
|
32376
32386
|
const segmentNames = [];
|
|
32377
32387
|
{
|
|
32378
32388
|
const r = wasmReader(bytes, linking.start);
|
|
@@ -32380,27 +32390,31 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
32380
32390
|
while (r.at < linking.end) {
|
|
32381
32391
|
const type = r.byte();
|
|
32382
32392
|
const end = r.u() + r.at;
|
|
32383
|
-
if (type === 8)
|
|
32384
|
-
|
|
32393
|
+
if (type === 8) {
|
|
32394
|
+
const count = r.u();
|
|
32395
|
+
symKind = new Uint8Array(count);
|
|
32396
|
+
symFlags = new Uint32Array(count);
|
|
32397
|
+
symSegment = new Int32Array(count).fill(-1);
|
|
32398
|
+
symOffset = new Int32Array(count);
|
|
32399
|
+
symIndex = new Int32Array(count).fill(-1);
|
|
32400
|
+
for (let i = 0; i < count; i++) {
|
|
32385
32401
|
const kind = r.byte();
|
|
32386
32402
|
const flags = r.u();
|
|
32387
|
-
|
|
32388
|
-
|
|
32389
|
-
let index = -1;
|
|
32403
|
+
symKind[i] = kind;
|
|
32404
|
+
symFlags[i] = flags;
|
|
32390
32405
|
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
32391
|
-
|
|
32392
|
-
if (!(flags & 16) || flags & 64) r.
|
|
32406
|
+
symIndex[i] = r.u();
|
|
32407
|
+
if (!(flags & 16) || flags & 64) r.skip(r.u());
|
|
32393
32408
|
} else if (kind === 1) {
|
|
32394
|
-
r.
|
|
32409
|
+
r.skip(r.u());
|
|
32395
32410
|
if (!(flags & 16)) {
|
|
32396
|
-
|
|
32397
|
-
|
|
32411
|
+
symSegment[i] = r.u();
|
|
32412
|
+
symOffset[i] = r.u();
|
|
32398
32413
|
r.u();
|
|
32399
32414
|
}
|
|
32400
32415
|
} else if (kind === 3) r.u();
|
|
32401
|
-
symbols.push({ kind, flags, segment: segment2, offset, index });
|
|
32402
32416
|
}
|
|
32403
|
-
else if (type === 5)
|
|
32417
|
+
} else if (type === 5)
|
|
32404
32418
|
for (let n = r.u(); n > 0; n--) {
|
|
32405
32419
|
segmentNames.push(r.name());
|
|
32406
32420
|
r.u();
|
|
@@ -32439,37 +32453,66 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
32439
32453
|
const importedFunctions = readModule(bytes).importedFuncs;
|
|
32440
32454
|
const data = [];
|
|
32441
32455
|
const dataFunctions = [];
|
|
32442
|
-
const
|
|
32443
|
-
const
|
|
32456
|
+
const bodyCount = bodyStarts.length;
|
|
32457
|
+
const code = Array.from({ length: bodyCount }, () => []);
|
|
32458
|
+
const calls = Array.from({ length: bodyCount }, () => []);
|
|
32444
32459
|
for (const s of sections) {
|
|
32445
32460
|
if (!s.name?.startsWith("reloc.")) continue;
|
|
32446
|
-
|
|
32447
|
-
const
|
|
32461
|
+
let cur = s.start;
|
|
32462
|
+
const readU = () => {
|
|
32463
|
+
const b0 = bytes[cur++];
|
|
32464
|
+
if (b0 < 128) return b0;
|
|
32465
|
+
let value = b0 & 127;
|
|
32466
|
+
let shift = 7;
|
|
32467
|
+
for (; ; ) {
|
|
32468
|
+
const byte = bytes[cur++];
|
|
32469
|
+
value += (byte & 127) * 2 ** shift;
|
|
32470
|
+
if (byte < 128) return value;
|
|
32471
|
+
shift += 7;
|
|
32472
|
+
}
|
|
32473
|
+
};
|
|
32474
|
+
const readS = () => {
|
|
32475
|
+
const b0 = bytes[cur++];
|
|
32476
|
+
if (b0 < 128) return b0 & 64 ? b0 - 128 : b0;
|
|
32477
|
+
let value = b0 & 127;
|
|
32478
|
+
let shift = 7;
|
|
32479
|
+
let byte = b0;
|
|
32480
|
+
while (byte >= 128) {
|
|
32481
|
+
byte = bytes[cur++];
|
|
32482
|
+
value += (byte & 127) * 2 ** shift;
|
|
32483
|
+
shift += 7;
|
|
32484
|
+
}
|
|
32485
|
+
if (byte & 64) value -= 2 ** shift;
|
|
32486
|
+
return value;
|
|
32487
|
+
};
|
|
32488
|
+
const target = readU();
|
|
32448
32489
|
if (target !== dataIndex && target !== codeIndex) continue;
|
|
32449
32490
|
let segment2 = 0;
|
|
32450
32491
|
let body = 0;
|
|
32451
|
-
|
|
32452
|
-
|
|
32453
|
-
const
|
|
32454
|
-
const
|
|
32455
|
-
const
|
|
32456
|
-
const
|
|
32457
|
-
const
|
|
32492
|
+
const isData = target === dataIndex;
|
|
32493
|
+
for (let n = readU(); n > 0; n--) {
|
|
32494
|
+
const type = bytes[cur++];
|
|
32495
|
+
const offset = readU();
|
|
32496
|
+
const index = readU();
|
|
32497
|
+
const bit = type < 32 ? 1 << type : 0;
|
|
32498
|
+
const addend = (ADDEND_RELOC_MASK & bit) !== 0 ? readS() : 0;
|
|
32499
|
+
const functionRelocation = (FUNCTION_RELOC_MASK & bit) !== 0;
|
|
32500
|
+
const memoryRelocation = (MEMORY_RELOC_MASK & bit) !== 0;
|
|
32458
32501
|
if (!functionRelocation && !memoryRelocation) continue;
|
|
32459
|
-
|
|
32460
|
-
const
|
|
32461
|
-
|
|
32462
|
-
if (!functionReference && (!memoryRelocation ||
|
|
32502
|
+
if (symFlags[index] & 16) continue;
|
|
32503
|
+
const kind = symKind[index];
|
|
32504
|
+
const functionReference = functionRelocation && kind === 0;
|
|
32505
|
+
if (!functionReference && (!memoryRelocation || kind !== 1 || symSegment[index] < 0))
|
|
32463
32506
|
continue;
|
|
32464
|
-
const to = functionReference ?
|
|
32465
|
-
if (functionReference && (to < 0 || to >=
|
|
32466
|
-
if (
|
|
32507
|
+
const to = functionReference ? symIndex[index] - importedFunctions : addresses[symSegment[index]] + symOffset[index] + addend;
|
|
32508
|
+
if (functionReference && (to < 0 || to >= bodyCount)) continue;
|
|
32509
|
+
if (isData) {
|
|
32467
32510
|
while (payloads[segment2].end <= offset) segment2++;
|
|
32468
32511
|
const payload = payloads[segment2];
|
|
32469
32512
|
const edges = functionReference ? dataFunctions : data;
|
|
32470
32513
|
edges.push(payload.address + offset - payload.start, to);
|
|
32471
32514
|
} else {
|
|
32472
|
-
while (body + 1 <
|
|
32515
|
+
while (body + 1 < bodyCount && bodyStarts[body + 1] <= offset) body++;
|
|
32473
32516
|
const edges = functionReference ? calls : code;
|
|
32474
32517
|
edges[body].push(to);
|
|
32475
32518
|
}
|
|
@@ -32525,7 +32568,7 @@ function unslottedFunctions(bytes) {
|
|
|
32525
32568
|
const slotted = new Set([...m.slots.keys()].filter((index) => index >= m.importedFuncs));
|
|
32526
32569
|
return m.bodies.length - slotted.size;
|
|
32527
32570
|
}
|
|
32528
|
-
var uleb, sleb, encodedName, section, PROCESS_EXPORTS, SWIFT_SDK_CONSTRUCTOR_LIMIT, FUNCTION_RELOCATIONS, MEMORY_RELOCATIONS, ADDEND_RELOCATIONS;
|
|
32571
|
+
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;
|
|
32529
32572
|
var init_swift_sdk_image_wasm = __esm({
|
|
32530
32573
|
"src/swift-sdk-image-wasm.ts"() {
|
|
32531
32574
|
"use strict";
|
|
@@ -32595,6 +32638,12 @@ var init_swift_sdk_image_wasm = __esm({
|
|
|
32595
32638
|
25,
|
|
32596
32639
|
27
|
|
32597
32640
|
]);
|
|
32641
|
+
FUNCTION_RELOC_MASK = 0;
|
|
32642
|
+
for (const type of FUNCTION_RELOCATIONS) FUNCTION_RELOC_MASK |= 1 << type;
|
|
32643
|
+
MEMORY_RELOC_MASK = 0;
|
|
32644
|
+
for (const type of MEMORY_RELOCATIONS) MEMORY_RELOC_MASK |= 1 << type;
|
|
32645
|
+
ADDEND_RELOC_MASK = 0;
|
|
32646
|
+
for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK |= 1 << type;
|
|
32598
32647
|
}
|
|
32599
32648
|
});
|
|
32600
32649
|
|
|
@@ -32762,7 +32811,8 @@ function isRootSegName(name3) {
|
|
|
32762
32811
|
return false;
|
|
32763
32812
|
}
|
|
32764
32813
|
function decodeRelocations(buf, sections) {
|
|
32765
|
-
|
|
32814
|
+
let count = 0;
|
|
32815
|
+
for (let s = 0; s < sections.length; s++) count += sections[s].count;
|
|
32766
32816
|
const start = new Uint32Array(count);
|
|
32767
32817
|
const end = new Uint32Array(count);
|
|
32768
32818
|
const ro = new Int32Array(count);
|
|
@@ -32771,29 +32821,59 @@ function decodeRelocations(buf, sections) {
|
|
|
32771
32821
|
const spans = [];
|
|
32772
32822
|
let i = 0;
|
|
32773
32823
|
let length = 0;
|
|
32774
|
-
for (
|
|
32775
|
-
|
|
32776
|
-
|
|
32777
|
-
|
|
32824
|
+
for (let s = 0; s < sections.length; s++) {
|
|
32825
|
+
const section2 = sections[s];
|
|
32826
|
+
const baseAt = section2.at;
|
|
32827
|
+
const sectionCount = section2.count;
|
|
32828
|
+
let cur = baseAt;
|
|
32829
|
+
for (let k = 0; k < sectionCount; k++, i++) {
|
|
32830
|
+
start[i] = length + cur - baseAt;
|
|
32778
32831
|
const rType = buf[cur++];
|
|
32779
|
-
|
|
32780
|
-
|
|
32781
|
-
|
|
32782
|
-
|
|
32783
|
-
|
|
32832
|
+
let offset = buf[cur++];
|
|
32833
|
+
if (offset >= 128) {
|
|
32834
|
+
offset &= 127;
|
|
32835
|
+
let shift = 7;
|
|
32836
|
+
while (true) {
|
|
32837
|
+
const byte = buf[cur++];
|
|
32838
|
+
offset |= (byte & 127) << shift;
|
|
32839
|
+
if (byte < 128) break;
|
|
32840
|
+
shift += 7;
|
|
32841
|
+
}
|
|
32842
|
+
}
|
|
32843
|
+
let symbol2 = buf[cur++];
|
|
32844
|
+
if (symbol2 >= 128) {
|
|
32845
|
+
symbol2 &= 127;
|
|
32846
|
+
let shift = 7;
|
|
32847
|
+
while (true) {
|
|
32848
|
+
const byte = buf[cur++];
|
|
32849
|
+
symbol2 |= (byte & 127) << shift;
|
|
32850
|
+
if (byte < 128) break;
|
|
32851
|
+
shift += 7;
|
|
32852
|
+
}
|
|
32853
|
+
}
|
|
32854
|
+
if (rType < 32 && (ADDEND_RELOC_MASK2 & 1 << rType) !== 0) {
|
|
32855
|
+
let byte = buf[cur++];
|
|
32856
|
+
let value = byte & 127;
|
|
32857
|
+
let shift = 7;
|
|
32858
|
+
while (byte >= 128) {
|
|
32859
|
+
byte = buf[cur++];
|
|
32860
|
+
value |= (byte & 127) << shift;
|
|
32861
|
+
shift += 7;
|
|
32862
|
+
}
|
|
32863
|
+
if (shift < 32 && (byte & 64) !== 0) value |= ~0 << shift;
|
|
32784
32864
|
addend[i] = value;
|
|
32785
|
-
cur = c4;
|
|
32786
32865
|
}
|
|
32787
32866
|
ro[i] = offset;
|
|
32788
32867
|
rs[i] = symbol2;
|
|
32789
|
-
end[i] = length + cur -
|
|
32868
|
+
end[i] = length + cur - baseAt;
|
|
32790
32869
|
}
|
|
32791
|
-
spans.push([
|
|
32792
|
-
length += cur -
|
|
32870
|
+
spans.push([baseAt, cur]);
|
|
32871
|
+
length += cur - baseAt;
|
|
32793
32872
|
}
|
|
32794
32873
|
const bytes = new Uint8Array(length);
|
|
32795
32874
|
let at = 0;
|
|
32796
|
-
for (
|
|
32875
|
+
for (let s = 0; s < spans.length; s++) {
|
|
32876
|
+
const [from, to] = spans[s];
|
|
32797
32877
|
bytes.set(buf.subarray(from, to), at);
|
|
32798
32878
|
at += to - from;
|
|
32799
32879
|
}
|
|
@@ -32958,6 +33038,27 @@ function patchSwiftrtObject(src) {
|
|
|
32958
33038
|
function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
32959
33039
|
const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
32960
33040
|
let pos = 8;
|
|
33041
|
+
let cur = 8;
|
|
33042
|
+
const readU = () => {
|
|
33043
|
+
const b0 = buf[cur++];
|
|
33044
|
+
if (b0 < 128) return b0;
|
|
33045
|
+
let res = b0 & 127;
|
|
33046
|
+
let shift = 7;
|
|
33047
|
+
while (true) {
|
|
33048
|
+
const byte = buf[cur++];
|
|
33049
|
+
res |= (byte & 127) << shift;
|
|
33050
|
+
if (byte < 128) return res;
|
|
33051
|
+
shift += 7;
|
|
33052
|
+
}
|
|
33053
|
+
};
|
|
33054
|
+
const skipU = () => {
|
|
33055
|
+
while (buf[cur++] >= 128) {
|
|
33056
|
+
}
|
|
33057
|
+
};
|
|
33058
|
+
const skipS = () => {
|
|
33059
|
+
while (buf[cur++] >= 128) {
|
|
33060
|
+
}
|
|
33061
|
+
};
|
|
32961
33062
|
let numImportFuncs = 0;
|
|
32962
33063
|
let importsDlsym = false;
|
|
32963
33064
|
const importFuncNames = [];
|
|
@@ -32986,150 +33087,122 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32986
33087
|
const dataRelocSections = [];
|
|
32987
33088
|
while (pos < buf.length) {
|
|
32988
33089
|
const id = buf[pos++];
|
|
32989
|
-
|
|
33090
|
+
cur = pos;
|
|
33091
|
+
const sz = readU();
|
|
33092
|
+
const p = cur;
|
|
32990
33093
|
const end = p + sz;
|
|
32991
33094
|
if (id === 2) {
|
|
32992
|
-
|
|
33095
|
+
const cnt = readU();
|
|
32993
33096
|
for (let i = 0; i < cnt; i++) {
|
|
32994
|
-
const
|
|
32995
|
-
const mName = rawBuf.toString("utf8",
|
|
32996
|
-
|
|
32997
|
-
const
|
|
32998
|
-
const fName = rawBuf.toString("utf8",
|
|
32999
|
-
|
|
33000
|
-
const kind = buf[
|
|
33097
|
+
const mLen = readU();
|
|
33098
|
+
const mName = rawBuf.toString("utf8", cur, cur + mLen);
|
|
33099
|
+
cur += mLen;
|
|
33100
|
+
const fLen = readU();
|
|
33101
|
+
const fName = rawBuf.toString("utf8", cur, cur + fLen);
|
|
33102
|
+
cur += fLen;
|
|
33103
|
+
const kind = buf[cur++];
|
|
33001
33104
|
if (kind === 0) {
|
|
33002
|
-
|
|
33003
|
-
cp = c2;
|
|
33105
|
+
skipU();
|
|
33004
33106
|
importFuncNames.push(fName);
|
|
33005
33107
|
importFuncModules.push(mName);
|
|
33006
33108
|
if (mName === "env" && fName === "dlsym") importsDlsym = true;
|
|
33007
33109
|
numImportFuncs++;
|
|
33008
33110
|
} else if (kind === 1) {
|
|
33009
|
-
|
|
33010
|
-
const
|
|
33011
|
-
|
|
33012
|
-
|
|
33013
|
-
cp = c3;
|
|
33014
|
-
if (fl & 1) {
|
|
33015
|
-
const [, c4] = readULEB2(buf, cp);
|
|
33016
|
-
cp = c4;
|
|
33017
|
-
}
|
|
33111
|
+
cur++;
|
|
33112
|
+
const fl = readU();
|
|
33113
|
+
skipU();
|
|
33114
|
+
if (fl & 1) skipU();
|
|
33018
33115
|
importTableNames.push(fName);
|
|
33019
33116
|
} else if (kind === 2) {
|
|
33020
|
-
const
|
|
33021
|
-
|
|
33022
|
-
|
|
33023
|
-
cp = c3;
|
|
33024
|
-
if (fl & 1) {
|
|
33025
|
-
const [, c4] = readULEB2(buf, cp);
|
|
33026
|
-
cp = c4;
|
|
33027
|
-
}
|
|
33117
|
+
const fl = readU();
|
|
33118
|
+
skipU();
|
|
33119
|
+
if (fl & 1) skipU();
|
|
33028
33120
|
} else if (kind === 3) {
|
|
33029
|
-
|
|
33121
|
+
cur += 2;
|
|
33030
33122
|
importGlobalNames.push(fName);
|
|
33031
33123
|
} else if (kind === 4) {
|
|
33032
|
-
|
|
33033
|
-
|
|
33034
|
-
cp = c2;
|
|
33124
|
+
cur++;
|
|
33125
|
+
skipU();
|
|
33035
33126
|
importEventNames.push(fName);
|
|
33036
33127
|
}
|
|
33037
33128
|
}
|
|
33038
33129
|
} else if (id === 10) {
|
|
33039
33130
|
codeStart = p;
|
|
33040
|
-
|
|
33131
|
+
const cnt = readU();
|
|
33041
33132
|
for (let i = 0; i < cnt; i++) {
|
|
33042
|
-
const st =
|
|
33043
|
-
const
|
|
33044
|
-
|
|
33133
|
+
const st = cur - codeStart;
|
|
33134
|
+
const bLen = readU();
|
|
33135
|
+
cur += bLen;
|
|
33045
33136
|
fStarts.push(st);
|
|
33046
|
-
fEnds.push(
|
|
33137
|
+
fEnds.push(cur - codeStart);
|
|
33047
33138
|
}
|
|
33048
33139
|
} else if (id === 11) {
|
|
33049
33140
|
dataStart = p;
|
|
33050
|
-
|
|
33141
|
+
const cnt = readU();
|
|
33051
33142
|
for (let i = 0; i < cnt; i++) {
|
|
33052
|
-
const st =
|
|
33053
|
-
const
|
|
33054
|
-
|
|
33055
|
-
if (mode === 2) {
|
|
33056
|
-
const [, m3] = readULEB2(buf, cp);
|
|
33057
|
-
cp = m3;
|
|
33058
|
-
}
|
|
33143
|
+
const st = cur - dataStart;
|
|
33144
|
+
const mode = readU();
|
|
33145
|
+
if (mode === 2) skipU();
|
|
33059
33146
|
if (mode === 0 || mode === 2) {
|
|
33060
|
-
const op = buf[
|
|
33061
|
-
if (op === 65 || op === 66)
|
|
33062
|
-
|
|
33063
|
-
|
|
33064
|
-
} else if (op === 35) {
|
|
33065
|
-
const [, m4] = readULEB2(buf, cp);
|
|
33066
|
-
cp = m4;
|
|
33067
|
-
}
|
|
33068
|
-
cp++;
|
|
33147
|
+
const op = buf[cur++];
|
|
33148
|
+
if (op === 65 || op === 66) skipS();
|
|
33149
|
+
else if (op === 35) skipU();
|
|
33150
|
+
cur++;
|
|
33069
33151
|
}
|
|
33070
|
-
const
|
|
33071
|
-
sPayloadStarts.push(
|
|
33072
|
-
|
|
33152
|
+
const dLen = readU();
|
|
33153
|
+
sPayloadStarts.push(cur - dataStart);
|
|
33154
|
+
cur += dLen;
|
|
33073
33155
|
sStarts.push(st);
|
|
33074
|
-
sEnds.push(
|
|
33156
|
+
sEnds.push(cur - dataStart);
|
|
33075
33157
|
}
|
|
33076
33158
|
} else if (id === 0) {
|
|
33077
|
-
const
|
|
33078
|
-
const name3 = rawBuf.toString("utf8",
|
|
33079
|
-
|
|
33159
|
+
const nLen = readU();
|
|
33160
|
+
const name3 = rawBuf.toString("utf8", cur, cur + nLen);
|
|
33161
|
+
cur += nLen;
|
|
33080
33162
|
if (name3 === "linking") {
|
|
33081
|
-
|
|
33082
|
-
while (
|
|
33083
|
-
const subId = buf[
|
|
33084
|
-
const
|
|
33085
|
-
const subEnd =
|
|
33163
|
+
skipU();
|
|
33164
|
+
while (cur < end) {
|
|
33165
|
+
const subId = buf[cur++];
|
|
33166
|
+
const subLen = readU();
|
|
33167
|
+
const subEnd = cur + subLen;
|
|
33086
33168
|
if (subId === 5) {
|
|
33087
|
-
const
|
|
33088
|
-
let cur = p2;
|
|
33169
|
+
const cnt = readU();
|
|
33089
33170
|
for (let i = 0; i < cnt; i++) {
|
|
33090
|
-
const
|
|
33091
|
-
segNames.push(rawBuf.toString("utf8",
|
|
33092
|
-
cur
|
|
33093
|
-
|
|
33094
|
-
|
|
33095
|
-
segFlags.push(fl);
|
|
33096
|
-
cur = s4;
|
|
33171
|
+
const sLen = readU();
|
|
33172
|
+
segNames.push(rawBuf.toString("utf8", cur, cur + sLen));
|
|
33173
|
+
cur += sLen;
|
|
33174
|
+
skipU();
|
|
33175
|
+
segFlags.push(readU());
|
|
33097
33176
|
}
|
|
33098
33177
|
} else if (subId === 6) {
|
|
33099
|
-
const
|
|
33100
|
-
let cur = p2;
|
|
33178
|
+
const cnt = readU();
|
|
33101
33179
|
for (let i = 0; i < cnt; i++) {
|
|
33102
|
-
|
|
33103
|
-
|
|
33104
|
-
initFuncs.push(symIdx);
|
|
33105
|
-
cur = s3;
|
|
33180
|
+
skipU();
|
|
33181
|
+
initFuncs.push(readU());
|
|
33106
33182
|
}
|
|
33107
33183
|
} else if (subId === 8) {
|
|
33108
|
-
const
|
|
33184
|
+
const cnt = readU();
|
|
33109
33185
|
symKind = new Uint8Array(cnt);
|
|
33110
33186
|
symFlags = new Uint32Array(cnt);
|
|
33111
33187
|
symElemIdx = new Int32Array(cnt).fill(-1);
|
|
33112
|
-
symOff = new Int32Array(cnt)
|
|
33113
|
-
symSz = new Int32Array(cnt)
|
|
33114
|
-
let cur = p2;
|
|
33188
|
+
symOff = new Int32Array(cnt);
|
|
33189
|
+
symSz = new Int32Array(cnt);
|
|
33115
33190
|
for (let i = 0; i < cnt; i++) {
|
|
33116
33191
|
const kind = buf[cur++];
|
|
33117
33192
|
if (symbolFlagOffsets) symbolFlagOffsets[i] = cur;
|
|
33118
|
-
const
|
|
33119
|
-
cur = c2;
|
|
33193
|
+
const fl = readU();
|
|
33120
33194
|
symKind[i] = kind;
|
|
33121
33195
|
symFlags[i] = fl;
|
|
33122
33196
|
const isUndef = (fl & 16) !== 0;
|
|
33123
33197
|
const isExplicitName = (fl & 64) !== 0;
|
|
33124
33198
|
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
33125
|
-
const
|
|
33126
|
-
cur = c3;
|
|
33199
|
+
const el = readU();
|
|
33127
33200
|
if (!isUndef && kind === 0) symElemIdx[i] = el;
|
|
33128
33201
|
let sName = "";
|
|
33129
33202
|
if (!isUndef || isExplicitName) {
|
|
33130
|
-
const
|
|
33131
|
-
sName = rawBuf.toString("utf8",
|
|
33132
|
-
cur
|
|
33203
|
+
const sLen = readU();
|
|
33204
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
33205
|
+
cur += sLen;
|
|
33133
33206
|
} else if (kind === 0) {
|
|
33134
33207
|
sName = importFuncNames[el] ?? "";
|
|
33135
33208
|
} else if (kind === 2) {
|
|
@@ -33143,33 +33216,28 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
33143
33216
|
hostImportNames.add(sName);
|
|
33144
33217
|
symNames.push(sName);
|
|
33145
33218
|
} else if (kind === 1) {
|
|
33146
|
-
const
|
|
33147
|
-
const sName = rawBuf.toString("utf8",
|
|
33148
|
-
cur
|
|
33219
|
+
const sLen = readU();
|
|
33220
|
+
const sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
33221
|
+
cur += sLen;
|
|
33149
33222
|
if (!isUndef) {
|
|
33150
|
-
|
|
33151
|
-
|
|
33152
|
-
|
|
33153
|
-
cur = c6;
|
|
33154
|
-
symElemIdx[i] = segIdx;
|
|
33155
|
-
symOff[i] = sOff;
|
|
33156
|
-
symSz[i] = sSz;
|
|
33223
|
+
symElemIdx[i] = readU();
|
|
33224
|
+
symOff[i] = readU();
|
|
33225
|
+
symSz[i] = readU();
|
|
33157
33226
|
}
|
|
33158
33227
|
symNames.push(sName);
|
|
33159
33228
|
} else if (kind === 3) {
|
|
33160
|
-
|
|
33161
|
-
cur = c3;
|
|
33229
|
+
skipU();
|
|
33162
33230
|
symNames.push("");
|
|
33163
33231
|
}
|
|
33164
33232
|
}
|
|
33165
33233
|
}
|
|
33166
|
-
|
|
33234
|
+
cur = subEnd;
|
|
33167
33235
|
}
|
|
33168
33236
|
} else if (name3 === "reloc.CODE" || name3 === "reloc.DATA") {
|
|
33169
|
-
|
|
33170
|
-
const
|
|
33237
|
+
skipU();
|
|
33238
|
+
const count = readU();
|
|
33171
33239
|
(name3 === "reloc.DATA" ? dataRelocSections : codeRelocSections).push({
|
|
33172
|
-
at,
|
|
33240
|
+
at: cur,
|
|
33173
33241
|
count
|
|
33174
33242
|
});
|
|
33175
33243
|
}
|
|
@@ -33222,40 +33290,63 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
33222
33290
|
segTopSyms.set(segIdx, dedupTop);
|
|
33223
33291
|
}
|
|
33224
33292
|
}
|
|
33225
|
-
const
|
|
33226
|
-
const
|
|
33293
|
+
const funcCount = fEnds.length;
|
|
33294
|
+
const funcRelocs = Array.from({ length: funcCount }, () => []);
|
|
33295
|
+
const rawCode = decodeRelocations(buf, funcCount > 0 ? codeRelocSections : []);
|
|
33227
33296
|
const codeRelocs = { ...rawCode, funcIdx: new Uint32Array(rawCode.count) };
|
|
33297
|
+
let fCursor = 0;
|
|
33298
|
+
let prevCodeRo = -1;
|
|
33228
33299
|
for (let i = 0; i < codeRelocs.count; i++) {
|
|
33229
33300
|
const ro = codeRelocs.ro[i];
|
|
33230
|
-
let lo
|
|
33231
|
-
|
|
33232
|
-
|
|
33233
|
-
|
|
33234
|
-
|
|
33235
|
-
|
|
33301
|
+
let lo;
|
|
33302
|
+
if (ro >= prevCodeRo) {
|
|
33303
|
+
while (fCursor < funcCount - 1 && fEnds[fCursor] <= ro) fCursor++;
|
|
33304
|
+
lo = fCursor;
|
|
33305
|
+
} else {
|
|
33306
|
+
lo = 0;
|
|
33307
|
+
let hi = funcCount - 1;
|
|
33308
|
+
while (lo < hi) {
|
|
33309
|
+
const mid = lo + hi >> 1;
|
|
33310
|
+
if (fEnds[mid] <= ro) lo = mid + 1;
|
|
33311
|
+
else hi = mid;
|
|
33312
|
+
}
|
|
33313
|
+
fCursor = lo;
|
|
33236
33314
|
}
|
|
33315
|
+
prevCodeRo = ro;
|
|
33237
33316
|
if (codeRelocs.bytes[codeRelocs.start[i]] !== 6)
|
|
33238
33317
|
funcRelocs[lo].push(codeRelocs.rs[i]);
|
|
33239
33318
|
codeRelocs.funcIdx[i] = lo;
|
|
33240
33319
|
}
|
|
33241
|
-
const
|
|
33320
|
+
const segCount = segNames.length;
|
|
33321
|
+
const segRelocs = Array.from({ length: segCount }, () => []);
|
|
33242
33322
|
const symDataRelocs = /* @__PURE__ */ new Map();
|
|
33243
33323
|
const rawData = decodeRelocations(buf, sEnds.length > 0 ? dataRelocSections : []);
|
|
33244
33324
|
const dataSegIdx = new Uint32Array(rawData.count);
|
|
33245
33325
|
const dataOffInSeg = new Int32Array(rawData.count);
|
|
33246
33326
|
const dataOwnerSymIdx = new Int32Array(rawData.count);
|
|
33247
33327
|
let kept = 0;
|
|
33328
|
+
let sCursor = 0;
|
|
33329
|
+
let prevDataRo = -1;
|
|
33330
|
+
const sEndLast = sEnds.length - 1;
|
|
33248
33331
|
for (let i = 0; i < rawData.count; i++) {
|
|
33249
33332
|
const ro = rawData.ro[i];
|
|
33250
33333
|
const rs = rawData.rs[i];
|
|
33251
|
-
let lo
|
|
33252
|
-
|
|
33253
|
-
|
|
33254
|
-
|
|
33255
|
-
|
|
33256
|
-
|
|
33334
|
+
let lo;
|
|
33335
|
+
if (ro >= prevDataRo) {
|
|
33336
|
+
while (sCursor < sEndLast && sEnds[sCursor] <= ro) sCursor++;
|
|
33337
|
+
lo = sCursor;
|
|
33338
|
+
} else {
|
|
33339
|
+
lo = 0;
|
|
33340
|
+
let hi = sEndLast;
|
|
33341
|
+
while (lo < hi) {
|
|
33342
|
+
const mid = lo + hi >> 1;
|
|
33343
|
+
if (sEnds[mid] <= ro) lo = mid + 1;
|
|
33344
|
+
else hi = mid;
|
|
33345
|
+
}
|
|
33346
|
+
sCursor = lo;
|
|
33257
33347
|
}
|
|
33258
|
-
|
|
33348
|
+
prevDataRo = ro;
|
|
33349
|
+
if (lo >= segCount) continue;
|
|
33259
33350
|
const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
|
|
33260
33351
|
let ownerSymIdx = -1;
|
|
33261
33352
|
const topList = segTopSyms.get(lo);
|
|
@@ -33402,74 +33493,78 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
33402
33493
|
const conformanceProtocols = /* @__PURE__ */ new Map();
|
|
33403
33494
|
const objcCategoryTargets = [];
|
|
33404
33495
|
if (isDist) {
|
|
33405
|
-
const relocAt = /* @__PURE__ */ new Map();
|
|
33406
|
-
for (let i = 0; i < dataRelocs.count; i++) {
|
|
33407
|
-
relocAt.set(`${dataRelocs.segIdx[i]}:${dataRelocs.offInSeg[i]}`, {
|
|
33408
|
-
rs: dataRelocs.rs[i],
|
|
33409
|
-
addend: dataRelocs.addend[i]
|
|
33410
|
-
});
|
|
33411
|
-
}
|
|
33412
33496
|
const confSegs = /* @__PURE__ */ new Set();
|
|
33413
33497
|
let hasCatsSeg = false;
|
|
33414
33498
|
for (let i = 0; i < segNames.length; i++) {
|
|
33415
33499
|
if (segNames[i] === "swift5_protocol_conformances") confSegs.add(i);
|
|
33416
33500
|
else if (segNames[i] === "__objc_cats") hasCatsSeg = true;
|
|
33417
33501
|
}
|
|
33418
|
-
if (confSegs.size > 0) {
|
|
33419
|
-
const
|
|
33420
|
-
|
|
33421
|
-
if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
|
|
33422
|
-
segOffToMpSym.set(`${symElemIdx[i]}:${symOff[i]}`, symNames[i]);
|
|
33423
|
-
}
|
|
33424
|
-
}
|
|
33425
|
-
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
33502
|
+
if (confSegs.size > 0 || hasCatsSeg) {
|
|
33503
|
+
const relocKey = (seg, off) => seg * 4294967296 + (off >>> 0);
|
|
33504
|
+
const relocAt = /* @__PURE__ */ new Map();
|
|
33426
33505
|
for (let i = 0; i < dataRelocs.count; i++) {
|
|
33427
|
-
|
|
33428
|
-
|
|
33429
|
-
|
|
33430
|
-
|
|
33506
|
+
relocAt.set(relocKey(dataRelocs.segIdx[i], dataRelocs.offInSeg[i]), i);
|
|
33507
|
+
}
|
|
33508
|
+
if (confSegs.size > 0) {
|
|
33509
|
+
const segOffToMpSym = /* @__PURE__ */ new Map();
|
|
33510
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
33511
|
+
if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
|
|
33512
|
+
segOffToMpSym.set(relocKey(symElemIdx[i], symOff[i]), symNames[i]);
|
|
33513
|
+
}
|
|
33431
33514
|
}
|
|
33432
|
-
const
|
|
33433
|
-
|
|
33434
|
-
|
|
33435
|
-
|
|
33436
|
-
|
|
33437
|
-
|
|
33438
|
-
const stripped2 = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
|
|
33439
|
-
if (stripped2.startsWith("$s") && stripped2.endsWith("Mp")) {
|
|
33440
|
-
mp = stripped2;
|
|
33441
|
-
} else if (symKind[pr.rs] === 3 || stripped2 === "") {
|
|
33442
|
-
mp = segOffToMpSym.get(`${mcSeg}:${pr.addend}`) ?? "";
|
|
33515
|
+
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
33516
|
+
for (let i = 0; i < dataRelocs.count; i++) {
|
|
33517
|
+
if (!confSegs.has(dataRelocs.segIdx[i])) continue;
|
|
33518
|
+
const mcIdx = dataRelocs.rs[i];
|
|
33519
|
+
if (symKind[mcIdx] !== 1 || (symFlags[mcIdx] & 16) !== 0 || symElemIdx[mcIdx] < 0) {
|
|
33520
|
+
continue;
|
|
33443
33521
|
}
|
|
33444
|
-
|
|
33445
|
-
const
|
|
33446
|
-
|
|
33447
|
-
|
|
33448
|
-
|
|
33522
|
+
const mcSeg = symElemIdx[mcIdx];
|
|
33523
|
+
const mcOff = symOff[mcIdx];
|
|
33524
|
+
const prIdx = relocAt.get(relocKey(mcSeg, mcOff));
|
|
33525
|
+
let mp = "";
|
|
33526
|
+
if (prIdx !== void 0) {
|
|
33527
|
+
const prRs = dataRelocs.rs[prIdx];
|
|
33528
|
+
const raw2 = symNames[prRs];
|
|
33529
|
+
const stripped2 = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
|
|
33530
|
+
if (stripped2.startsWith("$s") && stripped2.endsWith("Mp")) {
|
|
33531
|
+
mp = stripped2;
|
|
33532
|
+
} else if (symKind[prRs] === 3 || stripped2 === "") {
|
|
33533
|
+
mp = segOffToMpSym.get(relocKey(mcSeg, dataRelocs.addend[prIdx])) ?? "";
|
|
33534
|
+
}
|
|
33535
|
+
} else {
|
|
33536
|
+
const fileOff = dataStart + sPayloadStarts[mcSeg] + mcOff;
|
|
33537
|
+
if (fileOff + 4 <= buf.length) {
|
|
33538
|
+
const delta = dv.getInt32(fileOff, true);
|
|
33539
|
+
mp = segOffToMpSym.get(relocKey(mcSeg, mcOff + delta)) ?? segOffToMpSym.get(relocKey(mcSeg, mcOff + (delta & ~1))) ?? "";
|
|
33540
|
+
}
|
|
33449
33541
|
}
|
|
33542
|
+
if (mp) conformanceProtocols.set(mcIdx, mp);
|
|
33450
33543
|
}
|
|
33451
|
-
if (mp) conformanceProtocols.set(mcIdx, mp);
|
|
33452
33544
|
}
|
|
33453
|
-
|
|
33454
|
-
|
|
33455
|
-
|
|
33456
|
-
|
|
33457
|
-
|
|
33458
|
-
|
|
33459
|
-
|
|
33460
|
-
|
|
33461
|
-
|
|
33462
|
-
|
|
33463
|
-
|
|
33464
|
-
|
|
33465
|
-
|
|
33466
|
-
|
|
33467
|
-
|
|
33468
|
-
|
|
33469
|
-
|
|
33470
|
-
|
|
33471
|
-
|
|
33472
|
-
|
|
33545
|
+
if (hasCatsSeg) {
|
|
33546
|
+
const seenClasses = /* @__PURE__ */ new Set();
|
|
33547
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
33548
|
+
if (symKind[i] !== 1 || (symFlags[i] & 16) !== 0 || symElemIdx[i] < 0 || segNames[symElemIdx[i]] !== "__objc_cats" || !symNames[i].startsWith(".objc_category_")) {
|
|
33549
|
+
continue;
|
|
33550
|
+
}
|
|
33551
|
+
const cSeg = symElemIdx[i];
|
|
33552
|
+
const cOff = symOff[i];
|
|
33553
|
+
const crIdx = relocAt.get(relocKey(cSeg, cOff + 8));
|
|
33554
|
+
if (crIdx !== void 0) {
|
|
33555
|
+
const crRs = dataRelocs.rs[crIdx];
|
|
33556
|
+
if (symKind[crRs] === 1 && (symFlags[crRs] & 16) === 0 && symElemIdx[crRs] >= 0) {
|
|
33557
|
+
const tSeg = symElemIdx[crRs];
|
|
33558
|
+
const strOff = dataStart + sPayloadStarts[tSeg] + symOff[crRs] + dataRelocs.addend[crIdx];
|
|
33559
|
+
let sEnd = strOff;
|
|
33560
|
+
while (sEnd < buf.length && buf[sEnd] !== 0) sEnd++;
|
|
33561
|
+
if (sEnd > strOff) {
|
|
33562
|
+
const clsName = rawBuf.toString("utf8", strOff, sEnd);
|
|
33563
|
+
if (!seenClasses.has(clsName)) {
|
|
33564
|
+
seenClasses.add(clsName);
|
|
33565
|
+
objcCategoryTargets.push(clsName);
|
|
33566
|
+
}
|
|
33567
|
+
}
|
|
33473
33568
|
}
|
|
33474
33569
|
}
|
|
33475
33570
|
}
|
|
@@ -34682,7 +34777,9 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
34682
34777
|
return true;
|
|
34683
34778
|
};
|
|
34684
34779
|
const writePrunedObject = (obj, outFile) => {
|
|
34685
|
-
const
|
|
34780
|
+
const cached2 = objectBytes.get(obj);
|
|
34781
|
+
const buf = cached2 ? new Uint8Array(cached2) : new Uint8Array(import_node_fs44.default.readFileSync(obj.file));
|
|
34782
|
+
const rawBuf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
34686
34783
|
const inputSha256 = link ? (0, import_node_crypto24.createHash)("sha256").update(buf).digest("hex") : "";
|
|
34687
34784
|
const fLive = liveFuncs.get(obj);
|
|
34688
34785
|
const sLive = liveSegs.get(obj);
|
|
@@ -34774,7 +34871,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
34774
34871
|
const end = p + sz;
|
|
34775
34872
|
if (id === 0) {
|
|
34776
34873
|
const [nLen, np] = readULEB2(buf, p);
|
|
34777
|
-
const name3 =
|
|
34874
|
+
const name3 = rawBuf.toString("utf8", np, np + nLen);
|
|
34778
34875
|
const cp = np + nLen;
|
|
34779
34876
|
if (name3 === "linking") {
|
|
34780
34877
|
const [, lpStart] = readULEB2(buf, cp);
|
|
@@ -35036,7 +35133,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
35036
35133
|
);
|
|
35037
35134
|
import_node_fs44.default.rmSync(rspPath, { force: true });
|
|
35038
35135
|
}
|
|
35039
|
-
var import_node_child_process22, import_node_crypto24, import_node_fs44, import_node_path43, v3, WIDE_DATA_RELOCS, ROOT_SEG_PREFIXES, RECORD_SEGS, PARTITIONED_SEGS, PRUNED_SDK_ARCHIVES, OMIT_SDK_LIB_FLAGS, NEUTRALIZED_SWIFTRT_SECTIONS, relocationBytes, parsedObjectCache, PARSED_ROOTS, SWIFTUI_WRAPPER_HOST_PROTOCOLS, SWIFT_PRUNED_LINK_MAP, SWIFT_PRUNED_LINK_RESPONSE;
|
|
35136
|
+
var import_node_child_process22, import_node_crypto24, import_node_fs44, import_node_path43, v3, WIDE_DATA_RELOCS, ROOT_SEG_PREFIXES, RECORD_SEGS, PARTITIONED_SEGS, PRUNED_SDK_ARCHIVES, OMIT_SDK_LIB_FLAGS, NEUTRALIZED_SWIFTRT_SECTIONS, ADDEND_RELOC_MASK2, relocationBytes, parsedObjectCache, PARSED_ROOTS, SWIFTUI_WRAPPER_HOST_PROTOCOLS, SWIFT_PRUNED_LINK_MAP, SWIFT_PRUNED_LINK_RESPONSE;
|
|
35040
35137
|
var init_swift_wasm_prune = __esm({
|
|
35041
35138
|
"src/swift-wasm-prune.ts"() {
|
|
35042
35139
|
"use strict";
|
|
@@ -35116,6 +35213,8 @@ var init_swift_wasm_prune = __esm({
|
|
|
35116
35213
|
"swift5_reflstr",
|
|
35117
35214
|
"swift5_typeref"
|
|
35118
35215
|
]);
|
|
35216
|
+
ADDEND_RELOC_MASK2 = 0;
|
|
35217
|
+
for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK2 |= 1 << type;
|
|
35119
35218
|
relocationBytes = (relocs, i) => relocs.bytes.subarray(relocs.start[i], relocs.end[i]);
|
|
35120
35219
|
parsedObjectCache = /* @__PURE__ */ new Map();
|
|
35121
35220
|
PARSED_ROOTS = 2;
|
|
@@ -35623,7 +35722,7 @@ function llvmType(value) {
|
|
|
35623
35722
|
function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options2 = {}) {
|
|
35624
35723
|
if (!isWasmMagic(bytes)) throw new Error("expected wasm object");
|
|
35625
35724
|
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
35626
|
-
const { sdkLookupOnly, sdkProduct } = options2;
|
|
35725
|
+
const { sdkLookupOnly, sdkProduct, collectRewrittenSymbols } = options2;
|
|
35627
35726
|
const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
|
|
35628
35727
|
const rewrite = binding !== void 0;
|
|
35629
35728
|
const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
|
|
@@ -35632,6 +35731,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35632
35731
|
const definitions = [];
|
|
35633
35732
|
const functionImports = /* @__PURE__ */ new Map();
|
|
35634
35733
|
const functionImportNames = [];
|
|
35734
|
+
const tableImportNames = [];
|
|
35735
|
+
const globalImportNames = [];
|
|
35736
|
+
const eventImportNames = [];
|
|
35635
35737
|
const functionSymbols = [];
|
|
35636
35738
|
const addressTaken = /* @__PURE__ */ new Set();
|
|
35637
35739
|
let usesDlsym = false;
|
|
@@ -35753,12 +35855,18 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35753
35855
|
if (isDlsym) usesDlsym = true;
|
|
35754
35856
|
if (isDlerror) usesDlerror = true;
|
|
35755
35857
|
if (importWriter && binding) {
|
|
35858
|
+
const rewrittenName = isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3;
|
|
35756
35859
|
importWriter.string(module2);
|
|
35757
|
-
importWriter.string(
|
|
35758
|
-
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3
|
|
35759
|
-
);
|
|
35860
|
+
importWriter.string(rewrittenName);
|
|
35760
35861
|
importWriter.byte(kind);
|
|
35761
35862
|
importWriter.bytes(bytes, typeStart, offset);
|
|
35863
|
+
if (collectRewrittenSymbols) {
|
|
35864
|
+
if (kind === 0)
|
|
35865
|
+
functionImportNames[functionImportNames.length - 1] = rewrittenName;
|
|
35866
|
+
else if (kind === 1) tableImportNames.push(rewrittenName);
|
|
35867
|
+
else if (kind === 3) globalImportNames.push(rewrittenName);
|
|
35868
|
+
else if (kind === 4) eventImportNames.push(rewrittenName);
|
|
35869
|
+
}
|
|
35762
35870
|
}
|
|
35763
35871
|
}
|
|
35764
35872
|
if (offset !== end) throw new Error("invalid wasm import section");
|
|
@@ -35841,13 +35949,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35841
35949
|
if (!rewrite && flags & 16 && symbolKind === 1 && alias)
|
|
35842
35950
|
usedSymbols.add(name3);
|
|
35843
35951
|
if (entryWriter && binding) {
|
|
35952
|
+
let rewrittenSym = name3;
|
|
35953
|
+
let addedCanonical;
|
|
35844
35954
|
if ((name3 === "dlsym" && usesDlsym || name3 === "dlerror" && usesDlerror) && flags & 16 && flags & 64 && symbolKind === 0) {
|
|
35955
|
+
rewrittenSym = name3 === "dlsym" ? callerAlias : dlerrorAlias;
|
|
35845
35956
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
35846
|
-
entryWriter.string(
|
|
35957
|
+
entryWriter.string(rewrittenSym);
|
|
35847
35958
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
35848
35959
|
} else if (flags & 16 && name3 !== "dlsym" && name3 !== "dlerror" && binding(name3) !== void 0) {
|
|
35960
|
+
rewrittenSym = binding(name3);
|
|
35849
35961
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
35850
|
-
entryWriter.string(
|
|
35962
|
+
entryWriter.string(rewrittenSym);
|
|
35851
35963
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
35852
35964
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
35853
35965
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
@@ -35861,7 +35973,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35861
35973
|
extraWriter.string(alias);
|
|
35862
35974
|
extraWriter.bytes(bytes, nameEnd, offset);
|
|
35863
35975
|
added++;
|
|
35976
|
+
addedCanonical = alias;
|
|
35864
35977
|
} else {
|
|
35978
|
+
rewrittenSym = alias;
|
|
35865
35979
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
35866
35980
|
entryWriter.string(alias);
|
|
35867
35981
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
@@ -35869,6 +35983,16 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35869
35983
|
} else {
|
|
35870
35984
|
entryWriter.bytes(bytes, begin, offset);
|
|
35871
35985
|
}
|
|
35986
|
+
if (collectRewrittenSymbols) {
|
|
35987
|
+
if (flags & 16) {
|
|
35988
|
+
const resolved = flags & 64 || symbolKind === 1 ? rewrittenSym : symbolKind === 0 ? functionImportNames[index] ?? "" : symbolKind === 2 ? globalImportNames[index] ?? "" : symbolKind === 4 ? eventImportNames[index] ?? "" : symbolKind === 5 ? tableImportNames[index] ?? "" : "";
|
|
35989
|
+
if (resolved) collectRewrittenSymbols.referenced.add(resolved);
|
|
35990
|
+
} else if ((flags & 3) !== 2) {
|
|
35991
|
+
if (rewrittenSym) collectRewrittenSymbols.defined.add(rewrittenSym);
|
|
35992
|
+
if (addedCanonical)
|
|
35993
|
+
collectRewrittenSymbols.defined.add(addedCanonical);
|
|
35994
|
+
}
|
|
35995
|
+
}
|
|
35872
35996
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
35873
35997
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
35874
35998
|
throw new Error(`unsupported symbol ${name3}`);
|
|
@@ -36232,6 +36356,7 @@ function createGuestImageLedger(input) {
|
|
|
36232
36356
|
sdkGlobalBindings.set(name3, first.alias);
|
|
36233
36357
|
}
|
|
36234
36358
|
}
|
|
36359
|
+
const appSymbols = input.registerAppTables ? { referenced: /* @__PURE__ */ new Set(), defined: /* @__PURE__ */ new Set() } : void 0;
|
|
36235
36360
|
const objects = units.map(({ image, object: object8, aliases, functionImports }) => {
|
|
36236
36361
|
const shared = sharedLookupByImage.get(image);
|
|
36237
36362
|
const own2 = startup.get(object8.path);
|
|
@@ -36266,7 +36391,10 @@ function createGuestImageLedger(input) {
|
|
|
36266
36391
|
binding,
|
|
36267
36392
|
object8.instrumentDynamicLookups,
|
|
36268
36393
|
preserveCanonical,
|
|
36269
|
-
{
|
|
36394
|
+
{
|
|
36395
|
+
sdkProduct: object8.sdkProduct,
|
|
36396
|
+
collectRewrittenSymbols: object8.sdkProduct === void 0 ? appSymbols : void 0
|
|
36397
|
+
}
|
|
36270
36398
|
).bytes
|
|
36271
36399
|
};
|
|
36272
36400
|
});
|
|
@@ -36387,7 +36515,9 @@ function createGuestImageLedger(input) {
|
|
|
36387
36515
|
llvmIR: render2(false, lazy),
|
|
36388
36516
|
lazyFunctions: lazy,
|
|
36389
36517
|
appLLVMIR: appLazy && render2(true, appLazy),
|
|
36390
|
-
appLazyFunctions: appLazy
|
|
36518
|
+
appLazyFunctions: appLazy,
|
|
36519
|
+
appReferencedSymbols: appSymbols?.referenced,
|
|
36520
|
+
appDefinedSymbols: appSymbols?.defined
|
|
36391
36521
|
};
|
|
36392
36522
|
}
|
|
36393
36523
|
function guestLazyFunctionRuntime(count) {
|
|
@@ -37115,6 +37245,26 @@ function selectedGuestManifestInputs(plan, selection, identities, readSelected)
|
|
|
37115
37245
|
}
|
|
37116
37246
|
return images;
|
|
37117
37247
|
}
|
|
37248
|
+
function framedLinkOptions(options2) {
|
|
37249
|
+
const cached2 = framedLinkOptionsCache.get(options2);
|
|
37250
|
+
if (cached2) return cached2;
|
|
37251
|
+
const parts = new Array(options2.length * 2 + 2);
|
|
37252
|
+
const count = Buffer.from(String(options2.length), "utf8");
|
|
37253
|
+
const countSize = Buffer.allocUnsafe(8);
|
|
37254
|
+
countSize.writeBigUInt64BE(BigInt(count.byteLength));
|
|
37255
|
+
parts[0] = countSize;
|
|
37256
|
+
parts[1] = count;
|
|
37257
|
+
for (let i = 0; i < options2.length; i++) {
|
|
37258
|
+
const encoded = Buffer.from(options2[i], "utf8");
|
|
37259
|
+
const size2 = Buffer.allocUnsafe(8);
|
|
37260
|
+
size2.writeBigUInt64BE(BigInt(encoded.byteLength));
|
|
37261
|
+
parts[i * 2 + 2] = size2;
|
|
37262
|
+
parts[i * 2 + 3] = encoded;
|
|
37263
|
+
}
|
|
37264
|
+
const framed = Buffer.concat(parts);
|
|
37265
|
+
framedLinkOptionsCache.set(options2, framed);
|
|
37266
|
+
return framed;
|
|
37267
|
+
}
|
|
37118
37268
|
function createGuestImageManifest(image) {
|
|
37119
37269
|
const target = {
|
|
37120
37270
|
triple: SWIFT_WASM_TRIPLE,
|
|
@@ -37124,10 +37274,10 @@ function createGuestImageManifest(image) {
|
|
|
37124
37274
|
cpuSubtype: 0
|
|
37125
37275
|
};
|
|
37126
37276
|
const digest2 = (0, import_node_crypto28.createHash)("sha256");
|
|
37277
|
+
const sizeBuf = Buffer.allocUnsafe(8);
|
|
37127
37278
|
const add = (bytes) => {
|
|
37128
|
-
|
|
37129
|
-
|
|
37130
|
-
digest2.update(size2);
|
|
37279
|
+
sizeBuf.writeBigUInt64BE(BigInt(bytes.byteLength));
|
|
37280
|
+
digest2.update(sizeBuf);
|
|
37131
37281
|
digest2.update(bytes);
|
|
37132
37282
|
};
|
|
37133
37283
|
const text7 = (value) => add(Buffer.from(value, "utf8"));
|
|
@@ -37144,8 +37294,7 @@ function createGuestImageManifest(image) {
|
|
|
37144
37294
|
`${version2.platform}:${version2.minimum.major}:${version2.minimum.minor}:${version2.minimum.patch}`
|
|
37145
37295
|
);
|
|
37146
37296
|
text7(`${version2.sdk.major}:${version2.sdk.minor}:${version2.sdk.patch}`);
|
|
37147
|
-
|
|
37148
|
-
for (const option of image.linkOptions) text7(option);
|
|
37297
|
+
digest2.update(framedLinkOptions(image.linkOptions));
|
|
37149
37298
|
text7(String(image.inputs.length));
|
|
37150
37299
|
for (const input of image.inputs) {
|
|
37151
37300
|
text7(input.identity);
|
|
@@ -37166,7 +37315,7 @@ function createGuestImageManifest(image) {
|
|
|
37166
37315
|
regions: image.regions
|
|
37167
37316
|
};
|
|
37168
37317
|
}
|
|
37169
|
-
var import_node_crypto28, import_node_fs46;
|
|
37318
|
+
var import_node_crypto28, import_node_fs46, framedLinkOptionsCache;
|
|
37170
37319
|
var init_swift_guest_manifest = __esm({
|
|
37171
37320
|
"src/swift-guest-manifest.ts"() {
|
|
37172
37321
|
"use strict";
|
|
@@ -37175,6 +37324,7 @@ var init_swift_guest_manifest = __esm({
|
|
|
37175
37324
|
init_swift_guest_link_plan();
|
|
37176
37325
|
init_swift_wasm_prune();
|
|
37177
37326
|
init_swiftTargetContract();
|
|
37327
|
+
framedLinkOptionsCache = /* @__PURE__ */ new WeakMap();
|
|
37178
37328
|
}
|
|
37179
37329
|
});
|
|
37180
37330
|
|
|
@@ -38477,7 +38627,7 @@ var init_wasm_optimize = __esm({
|
|
|
38477
38627
|
];
|
|
38478
38628
|
BINARYEN_VERSION = binaryen_lock_default.version;
|
|
38479
38629
|
runBinaryen = (0, import_node_util5.promisify)(import_node_child_process24.execFile);
|
|
38480
|
-
WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} shared-stack-check-v2 native-image-v1 table-reserve-v2 ${NATIVE_TABLE_ABI} unoptimized-names`;
|
|
38630
|
+
WASM_LOWER_IDENTITY = `binaryen ${BINARYEN_VERSION} fused-pipeline-v1 narrow ${LOWERING.join(" ")} ${FEATURES.join(",")} shared-stack-check-v2 native-image-v1 table-reserve-v2 ${NATIVE_TABLE_ABI} unoptimized-names`;
|
|
38481
38631
|
BINARYEN_RELEASES = new Map(Object.entries(binaryen_lock_default.platforms));
|
|
38482
38632
|
}
|
|
38483
38633
|
});
|
|
@@ -38922,6 +39072,7 @@ function linkGuestImages(options2) {
|
|
|
38922
39072
|
const ledgerObjects = new Map(ledger.objects.map((item) => [item.path, item]));
|
|
38923
39073
|
const appObjects = /* @__PURE__ */ new Map();
|
|
38924
39074
|
const sdkObjects = /* @__PURE__ */ new Map();
|
|
39075
|
+
const finalArchives = /* @__PURE__ */ new Map();
|
|
38925
39076
|
for (const [index, artifact] of plan.artifacts.entries()) {
|
|
38926
39077
|
const prefix = `${artifact.path}(`;
|
|
38927
39078
|
if (artifact.kind === "object") {
|
|
@@ -38975,6 +39126,10 @@ function linkGuestImages(options2) {
|
|
|
38975
39126
|
const response = import_node_path47.default.join(memberDir, "members.rsp");
|
|
38976
39127
|
import_node_fs49.default.writeFileSync(response, inputs2.map((input) => JSON.stringify(input)).join(" "));
|
|
38977
39128
|
(0, import_node_child_process25.execFileSync)(llvmAr, ["rcs", output, `@${response}`], { stdio: "pipe" });
|
|
39129
|
+
finalArchives.set(
|
|
39130
|
+
output,
|
|
39131
|
+
members2.map((member) => ({ name: member.name, bytes: new Uint8Array(0) }))
|
|
39132
|
+
);
|
|
38978
39133
|
replacements.set(artifact.path, output);
|
|
38979
39134
|
}
|
|
38980
39135
|
const compileLedger = (name3, source) => {
|
|
@@ -39106,7 +39261,8 @@ function linkGuestImages(options2) {
|
|
|
39106
39261
|
remapGuestLinkPlan(plan, replacements),
|
|
39107
39262
|
finalArgs,
|
|
39108
39263
|
import_node_fs49.default.readFileSync(finalWhy, "utf8"),
|
|
39109
|
-
finalTrace
|
|
39264
|
+
finalTrace,
|
|
39265
|
+
finalArchives
|
|
39110
39266
|
);
|
|
39111
39267
|
const original = new Map([...replacements].map(([before2, after2]) => [after2, before2]));
|
|
39112
39268
|
const key2 = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
|
|
@@ -39139,12 +39295,25 @@ ${changed.join("\n")}`
|
|
|
39139
39295
|
])
|
|
39140
39296
|
);
|
|
39141
39297
|
appObjects.set(appLedgerObject, options2.ledgerDataImage);
|
|
39298
|
+
let appReferencedSymbols;
|
|
39299
|
+
let appDefinedSymbols;
|
|
39300
|
+
if (ledger.appReferencedSymbols && ledger.appDefinedSymbols) {
|
|
39301
|
+
const referenced = new Set(ledger.appReferencedSymbols);
|
|
39302
|
+
const defined = new Set(ledger.appDefinedSymbols);
|
|
39303
|
+
const ledgerSyms = guestWasmSymbols(import_node_fs49.default.readFileSync(appLedgerObject));
|
|
39304
|
+
for (const name3 of ledgerSyms.undefined) referenced.add(name3);
|
|
39305
|
+
for (const name3 of ledgerSyms.defined) defined.add(name3);
|
|
39306
|
+
appReferencedSymbols = referenced;
|
|
39307
|
+
appDefinedSymbols = defined;
|
|
39308
|
+
}
|
|
39142
39309
|
options2.onSplitInputs({
|
|
39143
39310
|
appObjects,
|
|
39144
39311
|
appSections,
|
|
39145
39312
|
sdkObjects,
|
|
39146
39313
|
lazyFunctions: ledger.appLazyFunctions ?? [],
|
|
39147
|
-
dyldSymbols: ledger.dyldSymbols
|
|
39314
|
+
dyldSymbols: ledger.dyldSymbols,
|
|
39315
|
+
appReferencedSymbols,
|
|
39316
|
+
appDefinedSymbols
|
|
39148
39317
|
});
|
|
39149
39318
|
}
|
|
39150
39319
|
return selected;
|
|
@@ -40127,6 +40296,93 @@ function sourceGuestInputIdentities(graph, buildDirectory, objects) {
|
|
|
40127
40296
|
}
|
|
40128
40297
|
return identities;
|
|
40129
40298
|
}
|
|
40299
|
+
function wasmAutolinkEntries(bytes, out) {
|
|
40300
|
+
if (bytes.length < 8) return false;
|
|
40301
|
+
if (bytes[0] === 33 && bytes[1] === 60 && bytes[2] === 97 && bytes[3] === 114 && bytes[4] === 99 && bytes[5] === 104 && bytes[6] === 62 && bytes[7] === 10) {
|
|
40302
|
+
for (const member of readArMembers(bytes)) {
|
|
40303
|
+
if (!wasmAutolinkEntries(member.bytes, out)) return false;
|
|
40304
|
+
}
|
|
40305
|
+
return true;
|
|
40306
|
+
}
|
|
40307
|
+
if (bytes[0] !== 0 || bytes[1] !== 97 || bytes[2] !== 115 || bytes[3] !== 109)
|
|
40308
|
+
return false;
|
|
40309
|
+
const raw2 = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
40310
|
+
let pos = 8;
|
|
40311
|
+
const len = bytes.length;
|
|
40312
|
+
while (pos < len) {
|
|
40313
|
+
const id = bytes[pos++];
|
|
40314
|
+
let sz = bytes[pos++];
|
|
40315
|
+
if (sz >= 128) {
|
|
40316
|
+
sz &= 127;
|
|
40317
|
+
let shift = 7;
|
|
40318
|
+
while (true) {
|
|
40319
|
+
const b = bytes[pos++];
|
|
40320
|
+
sz |= (b & 127) << shift;
|
|
40321
|
+
if (b < 128) break;
|
|
40322
|
+
shift += 7;
|
|
40323
|
+
}
|
|
40324
|
+
}
|
|
40325
|
+
const end = pos + sz;
|
|
40326
|
+
if (id === 0) {
|
|
40327
|
+
let nLen = bytes[pos++];
|
|
40328
|
+
if (nLen >= 128) {
|
|
40329
|
+
nLen &= 127;
|
|
40330
|
+
let shift = 7;
|
|
40331
|
+
while (true) {
|
|
40332
|
+
const b = bytes[pos++];
|
|
40333
|
+
nLen |= (b & 127) << shift;
|
|
40334
|
+
if (b < 128) break;
|
|
40335
|
+
shift += 7;
|
|
40336
|
+
}
|
|
40337
|
+
}
|
|
40338
|
+
if (nLen === 24 && raw2.toString("ascii", pos, pos + 24) === ".swift1_autolink_entries") {
|
|
40339
|
+
const payload = raw2.toString("utf8", pos + 24, end);
|
|
40340
|
+
for (const entry of payload.split("\0")) {
|
|
40341
|
+
const trimmed = entry.trim();
|
|
40342
|
+
if (trimmed.length > 0) out.push(trimmed);
|
|
40343
|
+
}
|
|
40344
|
+
}
|
|
40345
|
+
}
|
|
40346
|
+
pos = end;
|
|
40347
|
+
}
|
|
40348
|
+
return true;
|
|
40349
|
+
}
|
|
40350
|
+
function readAutolinkFlags(objects, toolchainBin, responsePath) {
|
|
40351
|
+
if (!objects.length) return [];
|
|
40352
|
+
const rawFlags = [];
|
|
40353
|
+
for (const file of objects) {
|
|
40354
|
+
if (!wasmAutolinkEntries((0, import_node_fs50.readFileSync)(file), rawFlags)) {
|
|
40355
|
+
(0, import_node_fs50.writeFileSync)(
|
|
40356
|
+
responsePath,
|
|
40357
|
+
objects.map((entry) => JSON.stringify(entry)).join("\n") + "\n"
|
|
40358
|
+
);
|
|
40359
|
+
return (0, import_node_child_process26.execFileSync)(
|
|
40360
|
+
import_node_path48.default.join(toolchainBin, "swift-autolink-extract"),
|
|
40361
|
+
[`@${responsePath}`, "-o", "-"],
|
|
40362
|
+
{ encoding: "utf8" }
|
|
40363
|
+
).split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
40364
|
+
}
|
|
40365
|
+
}
|
|
40366
|
+
const seen = /* @__PURE__ */ new Set();
|
|
40367
|
+
const flags = [];
|
|
40368
|
+
for (let i = 0; i < rawFlags.length; i++) {
|
|
40369
|
+
const flag = rawFlags[i];
|
|
40370
|
+
if ((flag === "-framework" || flag === "-weak_framework" || flag === "-l" || flag === "--library") && i + 1 < rawFlags.length) {
|
|
40371
|
+
const value = rawFlags[++i];
|
|
40372
|
+
const key2 = `${flag}\0${value}`;
|
|
40373
|
+
if (!seen.has(key2)) {
|
|
40374
|
+
seen.add(key2);
|
|
40375
|
+
flags.push(flag, value);
|
|
40376
|
+
}
|
|
40377
|
+
continue;
|
|
40378
|
+
}
|
|
40379
|
+
if (!seen.has(flag)) {
|
|
40380
|
+
seen.add(flag);
|
|
40381
|
+
flags.push(flag);
|
|
40382
|
+
}
|
|
40383
|
+
}
|
|
40384
|
+
return flags;
|
|
40385
|
+
}
|
|
40130
40386
|
function sourceGuestRuntimeLinks(options2) {
|
|
40131
40387
|
const aliases = /* @__PURE__ */ new Map();
|
|
40132
40388
|
const artifacts = /* @__PURE__ */ new Map();
|
|
@@ -40214,15 +40470,7 @@ function sourceGuestRuntimeLinks(options2) {
|
|
|
40214
40470
|
for (const image of options2.images) {
|
|
40215
40471
|
if (result.has(image.id)) throw new Error(`duplicate source image ${image.id}`);
|
|
40216
40472
|
const response = import_node_path48.default.join(options2.directory, `image-${image.id}-autolink.rsp`);
|
|
40217
|
-
(
|
|
40218
|
-
response,
|
|
40219
|
-
image.objects.map((file) => JSON.stringify(file)).join("\n") + "\n"
|
|
40220
|
-
);
|
|
40221
|
-
const autolink = image.objects.length ? (0, import_node_child_process26.execFileSync)(
|
|
40222
|
-
import_node_path48.default.join(options2.toolchainBin, "swift-autolink-extract"),
|
|
40223
|
-
[`@${response}`, "-o", "-"],
|
|
40224
|
-
{ encoding: "utf8" }
|
|
40225
|
-
).split("\n").map((line) => line.trim()).filter((line) => line.length > 0) : [];
|
|
40473
|
+
const autolink = readAutolinkFlags(image.objects, options2.toolchainBin, response);
|
|
40226
40474
|
const links = [];
|
|
40227
40475
|
const requests = [];
|
|
40228
40476
|
const optionGroups = [
|
|
@@ -40322,6 +40570,7 @@ var init_swift_guest_source_inputs = __esm({
|
|
|
40322
40570
|
init_forked_script_contract();
|
|
40323
40571
|
init_swift_guest_source_plan();
|
|
40324
40572
|
init_swift_runtime_products();
|
|
40573
|
+
init_swift_wasm_prune();
|
|
40325
40574
|
CLANG_TARGET_MODULE_WRAPPER = ".peach-clang";
|
|
40326
40575
|
PARALLEL_REPLAY = `
|
|
40327
40576
|
const { spawn } = require('node:child_process')
|
|
@@ -43686,9 +43935,10 @@ function sdkHostExports(appRoot) {
|
|
|
43686
43935
|
if (!(byte & 128)) return value;
|
|
43687
43936
|
}
|
|
43688
43937
|
};
|
|
43938
|
+
const raw2 = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
43689
43939
|
for (let n = u(); n > 0; n--) {
|
|
43690
43940
|
const length = u();
|
|
43691
|
-
names.push(
|
|
43941
|
+
names.push(raw2.toString("utf8", at, at + length));
|
|
43692
43942
|
at += length + 1;
|
|
43693
43943
|
u();
|
|
43694
43944
|
}
|
|
@@ -44114,56 +44364,109 @@ function swiftAppModuleInputs(tokens2, buildRoot, sdkLibraries) {
|
|
|
44114
44364
|
}
|
|
44115
44365
|
return inputs2;
|
|
44116
44366
|
}
|
|
44117
|
-
|
|
44367
|
+
function llvmQuoted(value) {
|
|
44368
|
+
const bytes = Buffer.from(value, "utf8");
|
|
44369
|
+
let out = '"';
|
|
44370
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
44371
|
+
const b = bytes[i];
|
|
44372
|
+
if (b >= 32 && b <= 126 && b !== 34 && b !== 92) out += String.fromCharCode(b);
|
|
44373
|
+
else out += `\\${b.toString(16).toUpperCase().padStart(2, "0")}`;
|
|
44374
|
+
}
|
|
44375
|
+
return out + '"';
|
|
44376
|
+
}
|
|
44377
|
+
async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project, readInput, precomputedSymbols) {
|
|
44118
44378
|
const { signatures, tls } = sdk2.sdkInterface;
|
|
44119
|
-
|
|
44120
|
-
|
|
44121
|
-
|
|
44122
|
-
|
|
44123
|
-
|
|
44124
|
-
|
|
44125
|
-
|
|
44379
|
+
let referenced;
|
|
44380
|
+
let defined;
|
|
44381
|
+
if (precomputedSymbols) {
|
|
44382
|
+
referenced = precomputedSymbols.referenced;
|
|
44383
|
+
defined = precomputedSymbols.defined;
|
|
44384
|
+
} else {
|
|
44385
|
+
const directories = inputs2.filter((input) => input.startsWith("-L")).map((input) => input.slice(2));
|
|
44386
|
+
const refSet = /* @__PURE__ */ new Set();
|
|
44387
|
+
const defSet = /* @__PURE__ */ new Set();
|
|
44388
|
+
const scan3 = (bytes) => {
|
|
44389
|
+
const symbols = guestWasmSymbols(bytes);
|
|
44390
|
+
for (const name3 of symbols.undefined) refSet.add(name3);
|
|
44391
|
+
for (const name3 of symbols.defined) defSet.add(name3);
|
|
44392
|
+
};
|
|
44393
|
+
for (const input of inputs2) {
|
|
44394
|
+
const file = input.startsWith("-l") ? directories.map((directory2) => import_node_path57.default.join(directory2, `lib${input.slice(2)}.a`)).find((candidate) => (0, import_node_fs59.existsSync)(candidate)) : input.startsWith("-") ? void 0 : input;
|
|
44395
|
+
if (!file) continue;
|
|
44396
|
+
const bytes = readInput(file);
|
|
44397
|
+
if (file.endsWith(".a"))
|
|
44398
|
+
for (const member of readArMembers(bytes)) scan3(member.bytes);
|
|
44399
|
+
else scan3(bytes);
|
|
44400
|
+
}
|
|
44401
|
+
referenced = refSet;
|
|
44402
|
+
defined = defSet;
|
|
44403
|
+
}
|
|
44404
|
+
const irType = {
|
|
44405
|
+
i: "i32",
|
|
44406
|
+
j: "i64",
|
|
44407
|
+
f: "float",
|
|
44408
|
+
d: "double"
|
|
44409
|
+
};
|
|
44410
|
+
const type = (kinds) => {
|
|
44411
|
+
const out = new Array(kinds.length);
|
|
44412
|
+
for (let i = 0; i < kinds.length; i++) {
|
|
44413
|
+
const kind = kinds[i];
|
|
44414
|
+
const name3 = irType[kind];
|
|
44415
|
+
if (!name3) throw new Error(`sdk signature kind ${kind}`);
|
|
44416
|
+
out[i] = name3;
|
|
44417
|
+
}
|
|
44418
|
+
return out;
|
|
44126
44419
|
};
|
|
44127
|
-
|
|
44128
|
-
|
|
44129
|
-
|
|
44130
|
-
const
|
|
44131
|
-
|
|
44132
|
-
|
|
44133
|
-
|
|
44134
|
-
|
|
44135
|
-
|
|
44136
|
-
|
|
44137
|
-
|
|
44138
|
-
return name3;
|
|
44139
|
-
});
|
|
44140
|
-
const literal2 = (name3) => JSON.stringify(name3);
|
|
44141
|
-
const lines = [];
|
|
44142
|
-
if (signatures.__objc_send_load_messages === ":")
|
|
44420
|
+
const lines = [`target triple = "${SWIFT_WASM_TRIPLE}"`];
|
|
44421
|
+
const attrs = [];
|
|
44422
|
+
const addImportAttr = (name3) => {
|
|
44423
|
+
const id = attrs.length;
|
|
44424
|
+
attrs.push(
|
|
44425
|
+
`attributes #${id} = { "wasm-import-module"="env" "wasm-import-name"=${llvmQuoted(name3)} }`
|
|
44426
|
+
);
|
|
44427
|
+
return id;
|
|
44428
|
+
};
|
|
44429
|
+
if (signatures.__objc_send_load_messages === ":") {
|
|
44430
|
+
const attr = addImportAttr("__objc_send_load_messages");
|
|
44143
44431
|
lines.push(
|
|
44144
|
-
|
|
44145
|
-
|
|
44432
|
+
"@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @send_app_load_messages, ptr null }]",
|
|
44433
|
+
`declare void @sdk_send_load_messages() #${attr}`,
|
|
44434
|
+
"define internal void @send_app_load_messages() {",
|
|
44435
|
+
" tail call void @sdk_send_load_messages()",
|
|
44436
|
+
" ret void",
|
|
44437
|
+
"}"
|
|
44146
44438
|
);
|
|
44439
|
+
}
|
|
44147
44440
|
const forwarders = /* @__PURE__ */ new Set();
|
|
44148
44441
|
let index = 0;
|
|
44149
44442
|
for (const name3 of referenced) {
|
|
44150
44443
|
const signature2 = signatures[name3];
|
|
44151
44444
|
if (signature2 === void 0 || defined.has(name3)) continue;
|
|
44152
|
-
const
|
|
44445
|
+
const colon = signature2.indexOf(":");
|
|
44446
|
+
const params = colon < 0 ? signature2 : signature2.slice(0, colon);
|
|
44447
|
+
const results = colon < 0 ? "" : signature2.slice(colon + 1);
|
|
44153
44448
|
if (results.length > 1) throw new Error(`sdk function ${name3} returns several values`);
|
|
44154
44449
|
const result = results ? type(results)[0] : "void";
|
|
44155
|
-
const
|
|
44156
|
-
const
|
|
44450
|
+
const paramTypes = type(params);
|
|
44451
|
+
const declParams = paramTypes.join(", ");
|
|
44452
|
+
const defParams = paramTypes.map((kind, at) => `${kind} %a${at}`).join(", ");
|
|
44453
|
+
const callArgs = paramTypes.map((kind, at) => `${kind} %a${at}`).join(", ");
|
|
44454
|
+
const attr = addImportAttr(name3);
|
|
44455
|
+
const quoted2 = llvmQuoted(name3);
|
|
44157
44456
|
lines.push(
|
|
44158
|
-
`
|
|
44159
|
-
`
|
|
44160
|
-
|
|
44457
|
+
`declare ${result} @i${index}(${declParams}) #${attr}`,
|
|
44458
|
+
`define weak hidden ${result} @${quoted2}(${defParams}) {`,
|
|
44459
|
+
result === "void" ? ` tail call void @i${index}(${callArgs})
|
|
44460
|
+
ret void` : ` %r = tail call ${result} @i${index}(${callArgs})
|
|
44461
|
+
ret ${result} %r`,
|
|
44462
|
+
"}"
|
|
44161
44463
|
);
|
|
44162
44464
|
forwarders.add(name3);
|
|
44163
44465
|
index++;
|
|
44164
44466
|
}
|
|
44165
44467
|
const errno = tls.errno;
|
|
44166
44468
|
let declaredErrno = false;
|
|
44469
|
+
const usedHelpers = [];
|
|
44167
44470
|
for (const name3 of referenced) {
|
|
44168
44471
|
const offset = tls[name3];
|
|
44169
44472
|
if (offset === void 0 || defined.has(name3)) continue;
|
|
@@ -44171,28 +44474,44 @@ async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project
|
|
|
44171
44474
|
throw new Error("the sdk image has no errno to find its thread block by");
|
|
44172
44475
|
if (!declaredErrno) {
|
|
44173
44476
|
declaredErrno = true;
|
|
44477
|
+
const attr = addImportAttr("__errno_location");
|
|
44174
44478
|
lines.push(
|
|
44175
|
-
`
|
|
44479
|
+
`declare ptr @__peach_errno() #${attr}`,
|
|
44480
|
+
"declare ptr @llvm.wasm.tls.base()"
|
|
44176
44481
|
);
|
|
44177
44482
|
}
|
|
44483
|
+
const helper = `@${llvmQuoted(SDK_TLS_HELPER + name3)}`;
|
|
44484
|
+
const delta = `@${llvmQuoted(SDK_TLS_DELTA + name3)}`;
|
|
44485
|
+
usedHelpers.push(`ptr ${helper}`);
|
|
44178
44486
|
lines.push(
|
|
44179
|
-
|
|
44180
|
-
|
|
44181
|
-
`
|
|
44182
|
-
|
|
44487
|
+
`@${llvmQuoted(name3)} = weak hidden thread_local global i8 0, align 1`,
|
|
44488
|
+
`${delta} = external global i8, align 1`,
|
|
44489
|
+
`define hidden i64 ${helper}() {`,
|
|
44490
|
+
" %e = tail call ptr @__peach_errno()",
|
|
44491
|
+
" %ei = ptrtoint ptr %e to i64",
|
|
44492
|
+
` %di = ptrtoint ptr ${delta} to i64`,
|
|
44493
|
+
" %s = add i64 %ei, %di",
|
|
44494
|
+
" %b = tail call ptr @llvm.wasm.tls.base()",
|
|
44495
|
+
" %bi = ptrtoint ptr %b to i64",
|
|
44496
|
+
" %r = sub i64 %s, %bi",
|
|
44497
|
+
" ret i64 %r",
|
|
44498
|
+
"}"
|
|
44183
44499
|
);
|
|
44184
44500
|
index++;
|
|
44185
44501
|
}
|
|
44186
|
-
|
|
44187
|
-
|
|
44502
|
+
if (usedHelpers.length > 0) {
|
|
44503
|
+
lines.push(
|
|
44504
|
+
`@llvm.used = appending global [${usedHelpers.length} x ptr] [${usedHelpers.join(", ")}], section "llvm.metadata"`
|
|
44505
|
+
);
|
|
44506
|
+
}
|
|
44507
|
+
const source = `${output.slice(0, -2)}.ll`;
|
|
44508
|
+
(0, import_node_fs59.writeFileSync)(source, [...lines, ...attrs].join("\n") + "\n");
|
|
44188
44509
|
await run5(
|
|
44189
44510
|
import_node_path57.default.join(toolchainBin, "clang"),
|
|
44190
44511
|
[
|
|
44191
44512
|
`--target=${SWIFT_WASM_TRIPLE}`,
|
|
44192
|
-
"-O2",
|
|
44193
44513
|
"-matomics",
|
|
44194
44514
|
"-mbulk-memory",
|
|
44195
|
-
"-ffreestanding",
|
|
44196
44515
|
"-c",
|
|
44197
44516
|
source,
|
|
44198
44517
|
"-o",
|
|
@@ -44211,7 +44530,8 @@ async function linkSwiftAppModule(options2) {
|
|
|
44211
44530
|
toolchainBin,
|
|
44212
44531
|
forwarders,
|
|
44213
44532
|
options2.project,
|
|
44214
|
-
options2.readInput ?? import_node_fs59.readFileSync
|
|
44533
|
+
options2.readInput ?? import_node_fs59.readFileSync,
|
|
44534
|
+
options2.precomputedSymbols
|
|
44215
44535
|
);
|
|
44216
44536
|
const lazy = options2.lazyFunctions ?? [];
|
|
44217
44537
|
const lazyExports = import_node_path57.default.join(work, "lazy-exports.rsp");
|
|
@@ -45955,6 +46275,15 @@ async function compileGuestLink(options2) {
|
|
|
45955
46275
|
{ stdio: "pipe" }
|
|
45956
46276
|
);
|
|
45957
46277
|
}
|
|
46278
|
+
let precomputedSymbols;
|
|
46279
|
+
if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
|
|
46280
|
+
const referenced = new Set(splitInputs.appReferencedSymbols);
|
|
46281
|
+
const defined = new Set(splitInputs.appDefinedSymbols);
|
|
46282
|
+
const projSyms = guestWasmSymbols((0, import_node_fs60.readFileSync)(projectionObject));
|
|
46283
|
+
for (const name3 of projSyms.undefined) referenced.add(name3);
|
|
46284
|
+
for (const name3 of projSyms.defined) defined.add(name3);
|
|
46285
|
+
precomputedSymbols = { referenced, defined };
|
|
46286
|
+
}
|
|
45958
46287
|
for (; ; ) {
|
|
45959
46288
|
const link = await linkSwiftAppModule2({
|
|
45960
46289
|
objects: [...owners.keys()],
|
|
@@ -45966,6 +46295,7 @@ async function compileGuestLink(options2) {
|
|
|
45966
46295
|
optimize: options2.optimize,
|
|
45967
46296
|
layoutMap,
|
|
45968
46297
|
project,
|
|
46298
|
+
precomputedSymbols,
|
|
45969
46299
|
loweringCache: project ? void 0 : {
|
|
45970
46300
|
file: import_node_path58.default.join(
|
|
45971
46301
|
options2.buildDirectory,
|
|
@@ -46090,6 +46420,7 @@ var init_swift_guest_compile = __esm({
|
|
|
46090
46420
|
init_swift_runtime_products();
|
|
46091
46421
|
init_swift_sdk_guest_lookups();
|
|
46092
46422
|
init_swift_toolchain();
|
|
46423
|
+
init_swift_wasm_prune();
|
|
46093
46424
|
init_swiftTargetContract();
|
|
46094
46425
|
init_wasm_optimize();
|
|
46095
46426
|
}
|
|
@@ -47553,7 +47884,25 @@ function swiftBuildJobs() {
|
|
|
47553
47884
|
return Math.min(cores, memoryJobs);
|
|
47554
47885
|
}
|
|
47555
47886
|
function swiftCompilerJobs() {
|
|
47556
|
-
return Math.min(
|
|
47887
|
+
return Math.min(32, swiftBuildJobs(), Math.max(1, Math.floor(import_node_os14.default.totalmem() / 2 ** 31)));
|
|
47888
|
+
}
|
|
47889
|
+
function swiftCompilerBaseEnv(toolchainBin, sourceEnv, includePeachHome = false) {
|
|
47890
|
+
const env = {};
|
|
47891
|
+
for (const key2 of SWIFT_COMPILER_ENV_KEYS) {
|
|
47892
|
+
const value = sourceEnv[key2];
|
|
47893
|
+
if (value !== void 0) env[key2] = value;
|
|
47894
|
+
}
|
|
47895
|
+
if (includePeachHome && sourceEnv.PEACH_HOME !== void 0)
|
|
47896
|
+
env.PEACH_HOME = sourceEnv.PEACH_HOME;
|
|
47897
|
+
if (process.platform === "linux") {
|
|
47898
|
+
env.LD_LIBRARY_PATH = [
|
|
47899
|
+
import_node_path68.default.resolve(toolchainBin, "../lib/swift/linux"),
|
|
47900
|
+
import_node_path68.default.resolve(toolchainBin, "../lib/swift/host"),
|
|
47901
|
+
sourceEnv.LD_LIBRARY_PATH
|
|
47902
|
+
].filter(Boolean).join(":");
|
|
47903
|
+
}
|
|
47904
|
+
env.PEACH_DEFER_WASM_LINK = "1";
|
|
47905
|
+
return env;
|
|
47557
47906
|
}
|
|
47558
47907
|
function assertSwiftBuildCores() {
|
|
47559
47908
|
const admitted = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
|
|
@@ -48742,10 +49091,22 @@ function emitSwiftPackageManifest(args) {
|
|
|
48742
49091
|
const available2 = distribution.objects.filter(
|
|
48743
49092
|
(object8) => !isProvider(object8) && !replacedObjects.has(object8)
|
|
48744
49093
|
);
|
|
49094
|
+
const targetNamesWithDash = targets.filter((target) => target.name.includes("-")).map((target) => `lib/${target.name}-`);
|
|
49095
|
+
const targetNameSet = new Set(targets.map((target) => target.name));
|
|
49096
|
+
const optionalSet = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...GAME_FAMILY, "PeachBox2D"]);
|
|
49097
|
+
const isTargetObject = (object8) => {
|
|
49098
|
+
const dash = object8.indexOf("-", 4);
|
|
49099
|
+
if (dash > 4 && targetNameSet.has(object8.slice(4, dash))) return true;
|
|
49100
|
+
return targetNamesWithDash.some((prefix) => object8.startsWith(prefix));
|
|
49101
|
+
};
|
|
49102
|
+
const isUnreachedOptional = (object8) => {
|
|
49103
|
+
const dash = object8.indexOf("-", 4);
|
|
49104
|
+
if (dash <= 4) return false;
|
|
49105
|
+
const name3 = object8.slice(4, dash);
|
|
49106
|
+
return optionalSet.has(name3) && !reachedFrameworks.has(name3);
|
|
49107
|
+
};
|
|
48745
49108
|
const objects = available2.filter(
|
|
48746
|
-
(object8) => !
|
|
48747
|
-
(name3) => !object8.startsWith(`lib/${name3}-`) || reachedFrameworks.has(name3)
|
|
48748
|
-
)
|
|
49109
|
+
(object8) => !isTargetObject(object8) && !isUnreachedOptional(object8)
|
|
48749
49110
|
);
|
|
48750
49111
|
const quoted2 = (object8) => `"${import_node_path68.default.join(moduleRoot, object8).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
48751
49112
|
const categoryObjects = new Set(
|
|
@@ -48826,18 +49187,53 @@ function emitSwiftPackageManifest(args) {
|
|
|
48826
49187
|
args.files.set(file, content);
|
|
48827
49188
|
return JSON.stringify([`@${file}`]);
|
|
48828
49189
|
};
|
|
48829
|
-
const
|
|
48830
|
-
|
|
48831
|
-
|
|
48832
|
-
const owner = args.targets.find((other) => other.name === dependency);
|
|
49190
|
+
const targetByName = new Map(targets.map((target) => [target.name, target]));
|
|
49191
|
+
const ownFrameworkDir = /* @__PURE__ */ new Map();
|
|
49192
|
+
for (const target of targets) {
|
|
48833
49193
|
const framework = /^(.*)\/[^/]+\.framework\/Modules$/.exec(
|
|
48834
|
-
|
|
49194
|
+
target.publicHeadersPath ?? ""
|
|
48835
49195
|
);
|
|
48836
|
-
|
|
48837
|
-
|
|
48838
|
-
|
|
48839
|
-
|
|
48840
|
-
|
|
49196
|
+
if (framework)
|
|
49197
|
+
ownFrameworkDir.set(
|
|
49198
|
+
target.name,
|
|
49199
|
+
import_node_path68.default.posix.join(args.root, target.path, framework[1])
|
|
49200
|
+
);
|
|
49201
|
+
}
|
|
49202
|
+
const frameworkDirectoriesCache = /* @__PURE__ */ new Map();
|
|
49203
|
+
const frameworkDirectories = (name3) => {
|
|
49204
|
+
if (ownFrameworkDir.size === 0) return [];
|
|
49205
|
+
const cached2 = frameworkDirectoriesCache.get(name3);
|
|
49206
|
+
if (cached2) return cached2;
|
|
49207
|
+
const dirs = [];
|
|
49208
|
+
const seen = /* @__PURE__ */ new Set();
|
|
49209
|
+
const visit3 = (current2) => {
|
|
49210
|
+
for (const dependency of siblings.get(current2) ?? []) {
|
|
49211
|
+
if (seen.has(dependency)) continue;
|
|
49212
|
+
seen.add(dependency);
|
|
49213
|
+
const dir = ownFrameworkDir.get(dependency);
|
|
49214
|
+
if (dir) dirs.push(dir);
|
|
49215
|
+
visit3(dependency);
|
|
49216
|
+
}
|
|
49217
|
+
};
|
|
49218
|
+
visit3(name3);
|
|
49219
|
+
frameworkDirectoriesCache.set(name3, dirs);
|
|
49220
|
+
return dirs;
|
|
49221
|
+
};
|
|
49222
|
+
const targetSwiftXccFlags = /* @__PURE__ */ new Map();
|
|
49223
|
+
for (const target of targets) {
|
|
49224
|
+
const flags = target.swiftFlags;
|
|
49225
|
+
if (!flags || flags.length === 0) continue;
|
|
49226
|
+
const xcc = [];
|
|
49227
|
+
for (let index = 1; index < flags.length; index++) {
|
|
49228
|
+
if (flags[index - 1] === "-Xcc")
|
|
49229
|
+
xcc.push(flags[index].replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root));
|
|
49230
|
+
}
|
|
49231
|
+
if (xcc.length > 0) targetSwiftXccFlags.set(target.name, xcc);
|
|
49232
|
+
}
|
|
49233
|
+
const binaryImports = args.binaryModules ? `, "-I", ${JSON.stringify(args.binaryModules)}` : "";
|
|
49234
|
+
const sharedImports = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
|
|
49235
|
+
providedModulesPath(args.root, distributionModules, args.moduleExcludes)
|
|
49236
|
+
)}${distributionClangModuleOptions(args.root, distributionModules).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map2) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map2}`)}`).join("")}` : "");
|
|
48841
49237
|
const frameworkSearchFlags = (target, tool) => frameworkDirectories(target?.name ?? "").map((directory2) => ({
|
|
48842
49238
|
tool,
|
|
48843
49239
|
flags: ["-F", directory2]
|
|
@@ -48886,10 +49282,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
48886
49282
|
const upstream = (target.swiftFlags ?? []).map(
|
|
48887
49283
|
(flag) => `, ${JSON.stringify(flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root))}`
|
|
48888
49284
|
).join("");
|
|
48889
|
-
const
|
|
48890
|
-
const imports2 = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
|
|
48891
|
-
providedModulesPath(args.root, distributionModules, args.moduleExcludes)
|
|
48892
|
-
)}${distributionClangModuleOptions(args.root, distributionModules).map((flag) => `, ${JSON.stringify(flag)}`).join("")}` : prebuilt ? `, "-Isystem", ${JSON.stringify(providedModulesPath(args.root, prebuilt.modules, args.moduleExcludes))}${prebuilt.moduleMaps.map((map2) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map2}`)}`).join("")}` : "");
|
|
49285
|
+
const imports2 = sharedImports;
|
|
48893
49286
|
const nativeFlags = [
|
|
48894
49287
|
...args.nativeFlags?.get(target.name) ?? [],
|
|
48895
49288
|
...args.nativeHeaderFlags ?? []
|
|
@@ -48913,12 +49306,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
48913
49306
|
return map2 ? ["-fmodule-map-file=" + map2] : [];
|
|
48914
49307
|
}),
|
|
48915
49308
|
...[...importContext].flatMap((name3) => args.native?.get(name3)?.importFlags ?? []),
|
|
48916
|
-
...[...importContext].flatMap((name3) =>
|
|
48917
|
-
const flags = targets.find((target2) => target2.name === name3)?.swiftFlags ?? [];
|
|
48918
|
-
return flags.flatMap(
|
|
48919
|
-
(flag, index) => flags[index - 1] === "-Xcc" ? [flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root)] : []
|
|
48920
|
-
);
|
|
48921
|
-
})
|
|
49309
|
+
...[...importContext].flatMap((name3) => targetSwiftXccFlags.get(name3) ?? [])
|
|
48922
49310
|
];
|
|
48923
49311
|
const nativeImportFlags = [
|
|
48924
49312
|
...frameworkDirectories(target.name).flatMap((directory2) => ["-F", directory2]),
|
|
@@ -48933,9 +49321,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
48933
49321
|
...native?.swiftFlags ?? [],
|
|
48934
49322
|
...args.objcImplementationModules?.has(target.name) ? ["-enable-experimental-feature", "ObjCImplementation"] : []
|
|
48935
49323
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
48936
|
-
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] ||
|
|
48937
|
-
(value) => value.late?.producers.includes(target.name)
|
|
48938
|
-
)) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path68.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
49324
|
+
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || lateProducers.has(target.name)) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path68.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
48939
49325
|
const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
|
|
48940
49326
|
const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
|
|
48941
49327
|
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports2}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`;
|
|
@@ -48968,9 +49354,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
48968
49354
|
(dependency) => clang && // textual native headers can include one another without imposing
|
|
48969
49355
|
// an object build order. the executable already links every native
|
|
48970
49356
|
// target; only generated Swift headers require producer ordering.
|
|
48971
|
-
(args.native?.get(dependency)?.clang || [
|
|
48972
|
-
(value) => value.late?.producers.includes(dependency)
|
|
48973
|
-
)) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targets.some((candidate) => candidate.name === dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
|
|
49357
|
+
(args.native?.get(dependency)?.clang || lateProducers.has(dependency)) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targetNames.has(dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
|
|
48974
49358
|
),
|
|
48975
49359
|
// a swift importer still needs the producers its clang dependencies
|
|
48976
49360
|
// reached upstream, whose edges the clang targets above dropped.
|
|
@@ -49057,7 +49441,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
49057
49441
|
...args.nativeFlags?.get(name3) ?? [],
|
|
49058
49442
|
...args.nativeHeaderFlags ?? []
|
|
49059
49443
|
];
|
|
49060
|
-
const owner =
|
|
49444
|
+
const owner = targetByName.get(name3);
|
|
49061
49445
|
const context = /* @__PURE__ */ new Set();
|
|
49062
49446
|
const visit3 = (dependency) => {
|
|
49063
49447
|
if (context.has(dependency)) return;
|
|
@@ -49133,10 +49517,16 @@ ${declaration.replace(/,$/, "")}
|
|
|
49133
49517
|
""
|
|
49134
49518
|
].join("\n");
|
|
49135
49519
|
}
|
|
49136
|
-
function syncSwiftTree(base, files2) {
|
|
49520
|
+
function syncSwiftTree(base, files2, alreadySynced) {
|
|
49137
49521
|
(0, import_node_fs68.mkdirSync)(base, { recursive: true });
|
|
49138
|
-
|
|
49139
|
-
|
|
49522
|
+
let kept;
|
|
49523
|
+
if (process.platform !== "linux") {
|
|
49524
|
+
kept = /* @__PURE__ */ new Set();
|
|
49525
|
+
for (const file of files2.keys()) {
|
|
49526
|
+
const stat = (0, import_node_fs68.statSync)(file, { throwIfNoEntry: false });
|
|
49527
|
+
if (stat) kept.add(stat.ino);
|
|
49528
|
+
}
|
|
49529
|
+
}
|
|
49140
49530
|
const walk4 = (dir) => {
|
|
49141
49531
|
for (const entry of (0, import_node_fs68.readdirSync)(dir, { withFileTypes: true })) {
|
|
49142
49532
|
const full = import_node_path68.default.join(dir, entry.name);
|
|
@@ -49145,12 +49535,13 @@ function syncSwiftTree(base, files2) {
|
|
|
49145
49535
|
entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP))
|
|
49146
49536
|
continue;
|
|
49147
49537
|
if (entry.isDirectory()) walk4(full);
|
|
49148
|
-
else if (!files2.has(full) && !kept.has((0, import_node_fs68.lstatSync)(full).ino))
|
|
49538
|
+
else if (!files2.has(full) && (!kept || !kept.has((0, import_node_fs68.lstatSync)(full).ino)))
|
|
49149
49539
|
(0, import_node_fs68.rmSync)(full, { force: true });
|
|
49150
49540
|
}
|
|
49151
49541
|
};
|
|
49152
49542
|
walk4(base);
|
|
49153
49543
|
for (const [full, contents2] of files2) {
|
|
49544
|
+
if (alreadySynced?.get(full) === contents2) continue;
|
|
49154
49545
|
writeBuildFile(full, contents2);
|
|
49155
49546
|
}
|
|
49156
49547
|
}
|
|
@@ -49258,25 +49649,59 @@ function swiftWasmCallGuards(source, unavailable2) {
|
|
|
49258
49649
|
out = out.slice(0, at) + replacement + out.slice(at + width);
|
|
49259
49650
|
return out;
|
|
49260
49651
|
}
|
|
49652
|
+
function matchesPathPrefixSet(file, set2) {
|
|
49653
|
+
if (set2.has(file)) return true;
|
|
49654
|
+
for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
|
|
49655
|
+
if (set2.has(file.slice(0, slash))) return true;
|
|
49656
|
+
}
|
|
49657
|
+
return false;
|
|
49658
|
+
}
|
|
49659
|
+
function indexTargetsByDirectory(targets) {
|
|
49660
|
+
const byDir = /* @__PURE__ */ new Map();
|
|
49661
|
+
for (const target of targets) {
|
|
49662
|
+
const key2 = target.path === "." ? "" : target.path.replace(/\/+$/, "");
|
|
49663
|
+
let list2 = byDir.get(key2);
|
|
49664
|
+
if (!list2) byDir.set(key2, list2 = []);
|
|
49665
|
+
list2.push(target);
|
|
49666
|
+
}
|
|
49667
|
+
return byDir;
|
|
49668
|
+
}
|
|
49669
|
+
function findTargetForFile(file, byDir, predicate) {
|
|
49670
|
+
for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
|
|
49671
|
+
const candidates = byDir.get(file.slice(0, slash));
|
|
49672
|
+
if (!candidates) continue;
|
|
49673
|
+
const relative3 = file.slice(slash + 1);
|
|
49674
|
+
for (const target of candidates) if (predicate(target, relative3)) return target;
|
|
49675
|
+
}
|
|
49676
|
+
const rootCandidates = byDir.get("");
|
|
49677
|
+
if (rootCandidates) {
|
|
49678
|
+
for (const target of rootCandidates) if (predicate(target, file)) return target;
|
|
49679
|
+
}
|
|
49680
|
+
return void 0;
|
|
49681
|
+
}
|
|
49261
49682
|
function compiledSwiftSources(files2, targets, overlayFrameworks, headers, nativeSourceGlue = false) {
|
|
49262
49683
|
const ordered = [...targets].sort((a, b) => b.path.length - a.path.length);
|
|
49263
|
-
const
|
|
49264
|
-
|
|
49265
|
-
|
|
49266
|
-
|
|
49267
|
-
|
|
49268
|
-
|
|
49269
|
-
|
|
49270
|
-
|
|
49271
|
-
|
|
49272
|
-
|
|
49273
|
-
return
|
|
49274
|
-
})
|
|
49275
|
-
|
|
49684
|
+
const byDir = indexTargetsByDirectory(ordered);
|
|
49685
|
+
const excludeSets = /* @__PURE__ */ new Map();
|
|
49686
|
+
for (const target of ordered) {
|
|
49687
|
+
if (target.exclude?.length) excludeSets.set(target.name, new Set(target.exclude));
|
|
49688
|
+
}
|
|
49689
|
+
const owners = /* @__PURE__ */ new Map();
|
|
49690
|
+
for (const [file, source] of Object.entries(files2)) {
|
|
49691
|
+
if (!file.endsWith(".swift")) continue;
|
|
49692
|
+
const owner = findTargetForFile(file, byDir, (target, relative3) => {
|
|
49693
|
+
const excluded = excludeSets.get(target.name);
|
|
49694
|
+
return !excluded || !matchesPathPrefixSet(relative3, excluded);
|
|
49695
|
+
});
|
|
49696
|
+
owners.set(file, { source, owner });
|
|
49697
|
+
}
|
|
49276
49698
|
const swiftSources = /* @__PURE__ */ new Map();
|
|
49277
|
-
for (const { source, owner } of owners.values())
|
|
49278
|
-
if (owner)
|
|
49279
|
-
|
|
49699
|
+
for (const { source, owner } of owners.values()) {
|
|
49700
|
+
if (!owner) continue;
|
|
49701
|
+
let list2 = swiftSources.get(owner.name);
|
|
49702
|
+
if (!list2) swiftSources.set(owner.name, list2 = []);
|
|
49703
|
+
list2.push(source);
|
|
49704
|
+
}
|
|
49280
49705
|
const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
|
|
49281
49706
|
return new Map(
|
|
49282
49707
|
[...owners].map(([file, { source, owner }]) => {
|
|
@@ -50056,18 +50481,46 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50056
50481
|
const bySourcePath = [...targets].sort(
|
|
50057
50482
|
(left, right) => right.path.length - left.path.length
|
|
50058
50483
|
);
|
|
50484
|
+
const targetsByDir = indexTargetsByDirectory(bySourcePath);
|
|
50485
|
+
const targetByName = new Map(targets.map((target) => [target.name, target]));
|
|
50486
|
+
const nativeTargets2 = input.nativeTargets ?? [];
|
|
50487
|
+
const nativeTargetByName = new Map(nativeTargets2.map((target) => [target.name, target]));
|
|
50488
|
+
const nativeTargetIndex = new Map(
|
|
50489
|
+
nativeTargets2.map((target, index) => [target.name, index])
|
|
50490
|
+
);
|
|
50491
|
+
const resourceTargetByName = new Map(
|
|
50492
|
+
resourceTargets.map((target) => [target.name, target])
|
|
50493
|
+
);
|
|
50494
|
+
const targetSourceSets = /* @__PURE__ */ new Map();
|
|
50495
|
+
const targetExcludeFullSets = /* @__PURE__ */ new Map();
|
|
50496
|
+
const targetExcludeExactSets = /* @__PURE__ */ new Map();
|
|
50497
|
+
for (const target of targets) {
|
|
50498
|
+
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
50499
|
+
if (target.sources !== void 0) {
|
|
50500
|
+
targetSourceSets.set(
|
|
50501
|
+
target.name,
|
|
50502
|
+
new Set(target.sources.map((source) => import_node_path68.default.posix.join(prefix, source)))
|
|
50503
|
+
);
|
|
50504
|
+
}
|
|
50505
|
+
if (target.exclude?.length) {
|
|
50506
|
+
targetExcludeFullSets.set(
|
|
50507
|
+
target.name,
|
|
50508
|
+
new Set(target.exclude.map((excluded) => `${prefix}${excluded}`))
|
|
50509
|
+
);
|
|
50510
|
+
targetExcludeExactSets.set(
|
|
50511
|
+
target.name,
|
|
50512
|
+
new Set(target.exclude.map((name3) => import_node_path68.default.posix.join(target.path, name3)))
|
|
50513
|
+
);
|
|
50514
|
+
}
|
|
50515
|
+
}
|
|
50059
50516
|
const swiftTargets = /* @__PURE__ */ new Set();
|
|
50060
50517
|
for (const file of Object.keys(input.files)) {
|
|
50061
50518
|
if (!file.endsWith(".swift")) continue;
|
|
50062
|
-
const target =
|
|
50063
|
-
|
|
50064
|
-
|
|
50065
|
-
|
|
50066
|
-
|
|
50067
|
-
);
|
|
50068
|
-
const excluded = target?.exclude?.some(
|
|
50069
|
-
(name3) => file === import_node_path68.default.posix.join(target.path, name3)
|
|
50070
|
-
);
|
|
50519
|
+
const target = findTargetForFile(file, targetsByDir, (candidate) => {
|
|
50520
|
+
const selected = targetSourceSets.get(candidate.name);
|
|
50521
|
+
return !selected || matchesPathPrefixSet(file, selected);
|
|
50522
|
+
});
|
|
50523
|
+
const excluded = target && targetExcludeExactSets.get(target.name)?.has(file);
|
|
50071
50524
|
if (target && !excluded) swiftTargets.add(target.name);
|
|
50072
50525
|
}
|
|
50073
50526
|
const importedModules = /* @__PURE__ */ new Set();
|
|
@@ -50105,7 +50558,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50105
50558
|
checkedToolchain = swiftToolchain(pin2.release, swiftModuleSdk(moduleRoot));
|
|
50106
50559
|
return checkedToolchain;
|
|
50107
50560
|
};
|
|
50108
|
-
const deploymentTarget = (name3) =>
|
|
50561
|
+
const deploymentTarget = (name3) => nativeTargetByName.get(name3)?.deploymentTarget ?? targetByName.get(name3)?.iosDeploymentTarget ?? null;
|
|
50109
50562
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
50110
50563
|
const stageTargetFile = (target, file, contents2, options2) => {
|
|
50111
50564
|
const relative3 = import_node_path68.default.relative(layout2.root, file).split(import_node_path68.default.sep).join(import_node_path68.default.posix.sep);
|
|
@@ -50117,18 +50570,41 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50117
50570
|
targetStagedFiles.set(target, staged);
|
|
50118
50571
|
files2.set(file, contents2);
|
|
50119
50572
|
};
|
|
50573
|
+
const entriesByPrefix = /* @__PURE__ */ new Map();
|
|
50574
|
+
for (const target of targets) {
|
|
50575
|
+
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
50576
|
+
if (!entriesByPrefix.has(prefix)) entriesByPrefix.set(prefix, []);
|
|
50577
|
+
}
|
|
50578
|
+
for (const entry of Object.entries(input.files)) {
|
|
50579
|
+
const [file] = entry;
|
|
50580
|
+
entriesByPrefix.get("")?.push(entry);
|
|
50581
|
+
for (let end = file.indexOf("/"); end !== -1; end = file.indexOf("/", end + 1)) {
|
|
50582
|
+
entriesByPrefix.get(file.slice(0, end + 1))?.push(entry);
|
|
50583
|
+
}
|
|
50584
|
+
}
|
|
50585
|
+
const targetEntriesCache = /* @__PURE__ */ new Map();
|
|
50120
50586
|
const targetEntries = (target) => {
|
|
50587
|
+
const cached2 = targetEntriesCache.get(target.name);
|
|
50588
|
+
if (cached2) return cached2;
|
|
50121
50589
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
50122
|
-
|
|
50123
|
-
|
|
50124
|
-
|
|
50125
|
-
|
|
50126
|
-
|
|
50127
|
-
(
|
|
50128
|
-
|
|
50129
|
-
|
|
50130
|
-
)
|
|
50131
|
-
|
|
50590
|
+
const selectedSources = targetSourceSets.get(target.name);
|
|
50591
|
+
const excludedPaths = targetExcludeFullSets.get(target.name);
|
|
50592
|
+
const nestedPrefixes = [];
|
|
50593
|
+
for (const candidate of targets) {
|
|
50594
|
+
if (candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix))
|
|
50595
|
+
nestedPrefixes.push(`${candidate.path}/`);
|
|
50596
|
+
}
|
|
50597
|
+
const matched = (entriesByPrefix.get(prefix) ?? []).filter(([file]) => {
|
|
50598
|
+
if (selectedSources !== void 0 && (file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) && !matchesPathPrefixSet(file, selectedSources))
|
|
50599
|
+
return false;
|
|
50600
|
+
if (excludedPaths !== void 0 && matchesPathPrefixSet(file, excludedPaths))
|
|
50601
|
+
return false;
|
|
50602
|
+
if (nestedPrefixes.length > 0 && nestedPrefixes.some((p) => file.startsWith(p)))
|
|
50603
|
+
return false;
|
|
50604
|
+
return true;
|
|
50605
|
+
});
|
|
50606
|
+
targetEntriesCache.set(target.name, matched);
|
|
50607
|
+
return matched;
|
|
50132
50608
|
};
|
|
50133
50609
|
const failTargetPreparation = (target, message) => {
|
|
50134
50610
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
@@ -50173,19 +50649,21 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50173
50649
|
return value;
|
|
50174
50650
|
};
|
|
50175
50651
|
const podHeaders = /* @__PURE__ */ new Map();
|
|
50176
|
-
for (const settings of
|
|
50652
|
+
for (const settings of nativeTargets2)
|
|
50177
50653
|
for (const file of settings.headers) {
|
|
50178
50654
|
const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
|
|
50179
50655
|
file
|
|
50180
50656
|
)?.[1];
|
|
50181
|
-
if (owner)
|
|
50182
|
-
|
|
50183
|
-
|
|
50184
|
-
|
|
50185
|
-
]);
|
|
50657
|
+
if (owner) {
|
|
50658
|
+
const base = import_node_path68.default.basename(file);
|
|
50659
|
+
let list2 = podHeaders.get(base);
|
|
50660
|
+
if (!list2) podHeaders.set(base, list2 = []);
|
|
50661
|
+
list2.push({ owner, content: input.files[file] });
|
|
50662
|
+
}
|
|
50186
50663
|
}
|
|
50187
50664
|
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(import_node_path68.default.basename(file))?.find((header) => header.content === content)?.owner;
|
|
50188
|
-
|
|
50665
|
+
const alreadySynced = /* @__PURE__ */ new Map();
|
|
50666
|
+
for (const settings of nativeTargets2) {
|
|
50189
50667
|
for (const file of settings.headers) {
|
|
50190
50668
|
const destination = import_node_path68.default.join(layout2.root, file);
|
|
50191
50669
|
if (files2.has(destination)) continue;
|
|
@@ -50202,10 +50680,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50202
50680
|
`#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`
|
|
50203
50681
|
) : rawContents;
|
|
50204
50682
|
writeBuildFile(destination, contents2);
|
|
50683
|
+
alreadySynced.set(destination, contents2);
|
|
50205
50684
|
files2.set(destination, contents2);
|
|
50206
50685
|
}
|
|
50207
50686
|
}
|
|
50208
|
-
const nativeTargets2 = input.nativeTargets ?? [];
|
|
50209
50687
|
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? import_node_path68.default.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
|
|
50210
50688
|
const inRoot = `${layout2.root}${import_node_path68.default.sep}`;
|
|
50211
50689
|
const binaryTree = `${import_node_path68.default.sep}${SWIFT_BINARY_TREES_DIR}${import_node_path68.default.sep}`;
|
|
@@ -50270,12 +50748,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50270
50748
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
50271
50749
|
const entries2 = targetEntries(target);
|
|
50272
50750
|
const units = entries2.filter(([file]) => isSwiftNativeTranslationUnit(file));
|
|
50273
|
-
|
|
50274
|
-
|
|
50275
|
-
)))
|
|
50751
|
+
const settings = nativeTargetByName.get(target.name);
|
|
50752
|
+
if (units.length === 0 && !(entries2.some(([file]) => file.endsWith(".swift")) && settings !== void 0 && (settings.publicHeaders.length > 0 || settings.bridgingHeader !== null)))
|
|
50276
50753
|
continue;
|
|
50277
50754
|
const includes = `${prefix}include/`;
|
|
50278
|
-
const settings = input.nativeTargets?.find((value) => value.name === target.name);
|
|
50279
50755
|
const searchRoots = [
|
|
50280
50756
|
...settings?.userHeaderSearchPaths ?? [],
|
|
50281
50757
|
...settings?.headerSearchPaths ?? [],
|
|
@@ -50306,7 +50782,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50306
50782
|
...searchRoots.map((root) => import_node_path68.default.posix.join(root, include))
|
|
50307
50783
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
50308
50784
|
if (local) {
|
|
50309
|
-
|
|
50785
|
+
let parents = reverse.get(local);
|
|
50786
|
+
if (!parents) reverse.set(local, parents = []);
|
|
50787
|
+
parents.push(file);
|
|
50310
50788
|
if (xcodeTarget && !seenHeaders.has(local)) {
|
|
50311
50789
|
seenHeaders.add(local);
|
|
50312
50790
|
searchEntries.push([local, input.files[local]]);
|
|
@@ -50352,9 +50830,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50352
50830
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
50353
50831
|
(flag) => flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout2.root).replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude2)
|
|
50354
50832
|
);
|
|
50833
|
+
const settingsHeaderFlags = headerSearch.flags[nativeTargetIndex.get(settings.name)];
|
|
50355
50834
|
const originalFlags = [
|
|
50356
50835
|
...settings.flags,
|
|
50357
|
-
...
|
|
50836
|
+
...settingsHeaderFlags,
|
|
50358
50837
|
...search,
|
|
50359
50838
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
50360
50839
|
"-F",
|
|
@@ -50365,7 +50844,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50365
50844
|
];
|
|
50366
50845
|
const importOriginalFlags = settings.flattensPublicHeaders ? [
|
|
50367
50846
|
...settings.importerFlags,
|
|
50368
|
-
...
|
|
50847
|
+
...settingsHeaderFlags,
|
|
50369
50848
|
...search,
|
|
50370
50849
|
...settings.frameworkSearchPaths.flatMap((dir) => [
|
|
50371
50850
|
"-F",
|
|
@@ -50390,7 +50869,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50390
50869
|
}
|
|
50391
50870
|
return [
|
|
50392
50871
|
...kept,
|
|
50393
|
-
...
|
|
50872
|
+
...settingsHeaderFlags,
|
|
50394
50873
|
...search,
|
|
50395
50874
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
50396
50875
|
"-F",
|
|
@@ -50419,7 +50898,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50419
50898
|
const bundleName = entries2.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
50420
50899
|
target: target.name,
|
|
50421
50900
|
path: target.path,
|
|
50422
|
-
resources:
|
|
50901
|
+
resources: resourceTargetByName.get(target.name)?.resources ?? false,
|
|
50423
50902
|
usesBundleMacro: entries2.some(
|
|
50424
50903
|
([file, contents2]) => (isSwiftNativeTranslationUnit(file) || /\.(?:h|hpp|hh|hxx)$/.test(file)) && /\bSWIFTPM_MODULE_BUNDLE\b/.test(contents2)
|
|
50425
50904
|
),
|
|
@@ -50572,10 +51051,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50572
51051
|
.../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
|
|
50573
51052
|
...stageFlags(
|
|
50574
51053
|
[...objcCxx ? settings.cxxFlags : [], ...fileFlags],
|
|
50575
|
-
|
|
50576
|
-
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
50577
|
-
"darwin/usr/include"
|
|
50578
|
-
)
|
|
51054
|
+
sdkInclude
|
|
50579
51055
|
)
|
|
50580
51056
|
];
|
|
50581
51057
|
const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
|
|
@@ -50615,13 +51091,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
50615
51091
|
...flags,
|
|
50616
51092
|
...prefixHeader,
|
|
50617
51093
|
...accessorFlags,
|
|
50618
|
-
...stageFlags(
|
|
50619
|
-
cxx ? settings.cxxFlags : [],
|
|
50620
|
-
import_node_path68.default.join(
|
|
50621
|
-
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
50622
|
-
"darwin/usr/include"
|
|
50623
|
-
)
|
|
50624
|
-
),
|
|
51094
|
+
...stageFlags(cxx ? settings.cxxFlags : [], sdkInclude),
|
|
50625
51095
|
...perFile,
|
|
50626
51096
|
...moduleFlag
|
|
50627
51097
|
]
|
|
@@ -50876,7 +51346,9 @@ module ${moduleName}.Swift {
|
|
|
50876
51346
|
}
|
|
50877
51347
|
` : swiftObjCModuleMap(
|
|
50878
51348
|
moduleName,
|
|
50879
|
-
(
|
|
51349
|
+
(nativeTargetByName.get(name3)?.publicHeaders ?? []).map(
|
|
51350
|
+
(header) => import_node_path68.default.join(layout2.root, header)
|
|
51351
|
+
),
|
|
50880
51352
|
submoduleImports2.get(moduleName),
|
|
50881
51353
|
import_node_path68.default.join(headerDirectory, name3 + "-Swift.h")
|
|
50882
51354
|
)
|
|
@@ -51426,6 +51898,7 @@ ${entry}`);
|
|
|
51426
51898
|
files2.set(destination, Buffer.from(bytes, "base64"));
|
|
51427
51899
|
}
|
|
51428
51900
|
const targetToolset = nativeToolset || native.size > 0;
|
|
51901
|
+
let usesObjcPrebuilt = false;
|
|
51429
51902
|
if (targetToolset) {
|
|
51430
51903
|
const nativeToolsetFlags = [
|
|
51431
51904
|
...headerAliasFlags,
|
|
@@ -51446,6 +51919,7 @@ ${entry}`);
|
|
|
51446
51919
|
[...native.keys()],
|
|
51447
51920
|
objcPrebuiltStage
|
|
51448
51921
|
) : [];
|
|
51922
|
+
usesObjcPrebuilt = prebuiltCompiler.length > 0;
|
|
51449
51923
|
files2.set(
|
|
51450
51924
|
clangWrapper2,
|
|
51451
51925
|
[
|
|
@@ -51754,17 +52228,39 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
51754
52228
|
(name3) => !nativePrerequisiteSet.has(name3)
|
|
51755
52229
|
);
|
|
51756
52230
|
const nativeTargetUnitCount = /* @__PURE__ */ new Map();
|
|
52231
|
+
const nativeTargetSources = /* @__PURE__ */ new Map();
|
|
51757
52232
|
for (const target of manifestTargets)
|
|
51758
|
-
if (target.sources?.length)
|
|
52233
|
+
if (target.sources?.length) {
|
|
51759
52234
|
nativeTargetUnitCount.set(target.name, target.sources.length);
|
|
52235
|
+
nativeTargetSources.set(target.name, target.sources);
|
|
52236
|
+
}
|
|
51760
52237
|
for (const [name3, plan] of native) {
|
|
51761
|
-
if (!plan.mixed && plan.sources.length > 0)
|
|
51762
|
-
|
|
51763
|
-
|
|
52238
|
+
if (!plan.mixed && plan.sources.length > 0) {
|
|
52239
|
+
const sources = plan.clang?.sources ?? plan.sources;
|
|
52240
|
+
nativeTargetUnitCount.set(name3, sources.length);
|
|
52241
|
+
nativeTargetSources.set(name3, sources);
|
|
52242
|
+
}
|
|
52243
|
+
for (const group of plan.groups ?? []) {
|
|
51764
52244
|
nativeTargetUnitCount.set(group.name, group.sources.length);
|
|
51765
|
-
|
|
52245
|
+
nativeTargetSources.set(group.name, group.sources);
|
|
52246
|
+
}
|
|
52247
|
+
if (plan.late && !plan.groups?.length) {
|
|
51766
52248
|
nativeTargetUnitCount.set(plan.late.name, plan.sources.length);
|
|
52249
|
+
nativeTargetSources.set(plan.late.name, plan.lateSources);
|
|
52250
|
+
}
|
|
51767
52251
|
}
|
|
52252
|
+
const nativeStageObjects = /* @__PURE__ */ new Map();
|
|
52253
|
+
const recordStageObjects = (stageTarget, members2) => {
|
|
52254
|
+
const objects = [];
|
|
52255
|
+
for (const member of members2) {
|
|
52256
|
+
const sources = nativeTargetSources.get(member);
|
|
52257
|
+
if (!sources || sources.length === 0) return stageTarget;
|
|
52258
|
+
for (const source of sources)
|
|
52259
|
+
objects.push(import_node_path68.default.join(`${member}.build`, `${source}.o`));
|
|
52260
|
+
}
|
|
52261
|
+
nativeStageObjects.set(stageTarget, objects);
|
|
52262
|
+
return stageTarget;
|
|
52263
|
+
};
|
|
51768
52264
|
const MAX_NATIVE_STAGE_UNITS = 250;
|
|
51769
52265
|
const chunkNativeStageTargets = (prefix, names) => {
|
|
51770
52266
|
if (names.length === 0) return [];
|
|
@@ -51773,7 +52269,7 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
51773
52269
|
0
|
|
51774
52270
|
);
|
|
51775
52271
|
if (names.length === 1 || total <= MAX_NATIVE_STAGE_UNITS)
|
|
51776
|
-
return [buildProduct(prefix, names)];
|
|
52272
|
+
return [recordStageObjects(buildProduct(prefix, names), names)];
|
|
51777
52273
|
const chunks = [];
|
|
51778
52274
|
let current2 = [];
|
|
51779
52275
|
let count = 0;
|
|
@@ -51788,7 +52284,9 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
51788
52284
|
count += size2;
|
|
51789
52285
|
}
|
|
51790
52286
|
if (current2.length > 0) chunks.push(current2);
|
|
51791
|
-
return chunks.map(
|
|
52287
|
+
return chunks.map(
|
|
52288
|
+
(members2, index) => recordStageObjects(buildProduct(`${prefix}${index + 1}`, members2), members2)
|
|
52289
|
+
);
|
|
51792
52290
|
};
|
|
51793
52291
|
const nativePrerequisiteStageTargets = chunkNativeStageTargets(
|
|
51794
52292
|
"PeachHeaderNativePrereqs",
|
|
@@ -51799,7 +52297,7 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
51799
52297
|
remainingNativeBuildTargets
|
|
51800
52298
|
);
|
|
51801
52299
|
files2.set(manifestPath, manifest);
|
|
51802
|
-
syncSwiftTree(layout2.root, files2);
|
|
52300
|
+
syncSwiftTree(layout2.root, files2, alreadySynced);
|
|
51803
52301
|
if (layout2.multi)
|
|
51804
52302
|
for (const target of targets)
|
|
51805
52303
|
(0, import_node_fs68.mkdirSync)(import_node_path68.default.join(layout2.root, target.path), { recursive: true });
|
|
@@ -51814,7 +52312,9 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
51814
52312
|
targetFailures,
|
|
51815
52313
|
generatedOwners,
|
|
51816
52314
|
targetToolset,
|
|
51817
|
-
headerCompiler
|
|
52315
|
+
headerCompiler,
|
|
52316
|
+
usesObjcPrebuilt,
|
|
52317
|
+
nativeStageObjects
|
|
51818
52318
|
};
|
|
51819
52319
|
}
|
|
51820
52320
|
function streamText(value) {
|
|
@@ -52900,8 +53400,8 @@ ${cap}` : "";
|
|
|
52900
53400
|
work,
|
|
52901
53401
|
unoptimized
|
|
52902
53402
|
);
|
|
52903
|
-
const baseBuildEnv = {
|
|
52904
|
-
...options2.project
|
|
53403
|
+
const baseBuildEnv = options2.project?.env ? {
|
|
53404
|
+
...options2.project.env,
|
|
52905
53405
|
// shipped host plugins resolve against the selected compiler's runtime.
|
|
52906
53406
|
...process.platform === "linux" ? {
|
|
52907
53407
|
LD_LIBRARY_PATH: [
|
|
@@ -52911,7 +53411,7 @@ ${cap}` : "";
|
|
|
52911
53411
|
].filter(Boolean).join(":")
|
|
52912
53412
|
} : {},
|
|
52913
53413
|
PEACH_DEFER_WASM_LINK: "1"
|
|
52914
|
-
};
|
|
53414
|
+
} : swiftCompilerBaseEnv(options2.toolchainBin, process.env);
|
|
52915
53415
|
const {
|
|
52916
53416
|
frameworkRoot,
|
|
52917
53417
|
compileFrameworkRoot,
|
|
@@ -53055,7 +53555,11 @@ ${cap}` : "";
|
|
|
53055
53555
|
} : {
|
|
53056
53556
|
...buildOptions,
|
|
53057
53557
|
temporaryDirectory,
|
|
53058
|
-
env: {
|
|
53558
|
+
env: {
|
|
53559
|
+
...buildOptions.env,
|
|
53560
|
+
...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
|
|
53561
|
+
...compiler
|
|
53562
|
+
}
|
|
53059
53563
|
};
|
|
53060
53564
|
const unprepared = preparation.targetFailures.map(
|
|
53061
53565
|
(failure2) => `error: target ${failure2}`
|
|
@@ -53102,10 +53606,18 @@ ${cap}` : "";
|
|
|
53102
53606
|
// the mirror finds a changed sdk header's readers in their
|
|
53103
53607
|
// dependency files, which omit system headers by default
|
|
53104
53608
|
...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
|
|
53105
|
-
// the link strips debug info, so none is generated (as for the framework)
|
|
53609
|
+
// the link strips debug info, so none is generated (as for the framework).
|
|
53610
|
+
// keep -num-threads fixed across caller core caps so llbuild does not
|
|
53611
|
+
// rebuild every target when callers alternate --cores, and bound backend
|
|
53612
|
+
// fan-out under high -j.
|
|
53106
53613
|
"-Xswiftc",
|
|
53107
53614
|
"-gnone",
|
|
53108
|
-
...incrementalPreview ? [] : [
|
|
53615
|
+
...incrementalPreview ? [] : [
|
|
53616
|
+
"-Xswiftc",
|
|
53617
|
+
"-num-threads",
|
|
53618
|
+
"-Xswiftc",
|
|
53619
|
+
String(perFile ? 1 : Math.min(8, import_node_os14.default.availableParallelism()))
|
|
53620
|
+
],
|
|
53109
53621
|
...swiftReproducibleBuildFlags([
|
|
53110
53622
|
[import_node_path68.default.dirname(options2.toolchainBin), "toolchain"],
|
|
53111
53623
|
[compileFrameworkRoot, "framework"],
|
|
@@ -53280,7 +53792,18 @@ ${cap}` : "";
|
|
|
53280
53792
|
}))
|
|
53281
53793
|
];
|
|
53282
53794
|
const checkpoints = import_node_path68.default.join(root, ".build", "peach-product-checkpoints");
|
|
53795
|
+
const buildDbExists = (0, import_node_fs68.existsSync)(import_node_path68.default.join(root, ".build", "build.db"));
|
|
53796
|
+
const releaseDir = import_node_path68.default.dirname(linked);
|
|
53283
53797
|
for (const { target, producers } of stages) {
|
|
53798
|
+
if (!options2.project && producers.length === 0 && buildDbExists) {
|
|
53799
|
+
const expectedObjects = preparation.nativeStageObjects.get(target);
|
|
53800
|
+
if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
|
|
53801
|
+
(relative3) => (0, import_node_fs68.statSync)(import_node_path68.default.join(releaseDir, relative3), {
|
|
53802
|
+
throwIfNoEntry: false
|
|
53803
|
+
})?.isFile()
|
|
53804
|
+
))
|
|
53805
|
+
continue;
|
|
53806
|
+
}
|
|
53284
53807
|
const receipt = import_node_path68.default.join(
|
|
53285
53808
|
checkpoints,
|
|
53286
53809
|
(0, import_node_crypto42.createHash)("sha256").update(target).digest("hex")
|
|
@@ -53505,7 +54028,7 @@ ${cap}` : "";
|
|
|
53505
54028
|
options2.signal
|
|
53506
54029
|
);
|
|
53507
54030
|
}
|
|
53508
|
-
var import_node_child_process38, import_node_crypto42, import_node_fs68, import_node_os14, import_node_path68, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, frameworkProductsReceiptSchema, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN;
|
|
54031
|
+
var import_node_child_process38, import_node_crypto42, import_node_fs68, import_node_os14, import_node_path68, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, SWIFT_COMPILER_ENV_KEYS, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, frameworkProductsReceiptSchema, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN;
|
|
53509
54032
|
var init_swift_compile = __esm({
|
|
53510
54033
|
"src/swift-compile.ts"() {
|
|
53511
54034
|
"use strict";
|
|
@@ -53558,6 +54081,29 @@ var init_swift_compile = __esm({
|
|
|
53558
54081
|
WASM_TRIPLE = SWIFT_WASM_TRIPLE;
|
|
53559
54082
|
SWIFTPM_PROGRESS = /^\[\d+\/\d+\] /;
|
|
53560
54083
|
SWIFTPM_NOISE = /^(?:\[\d+\/\d+\] |Building for production\.\.\.$|warning: '--build-system native' has been deprecated)/;
|
|
54084
|
+
SWIFT_COMPILER_ENV_KEYS = [
|
|
54085
|
+
"PATH",
|
|
54086
|
+
"HOME",
|
|
54087
|
+
"USER",
|
|
54088
|
+
"LOGNAME",
|
|
54089
|
+
"LANG",
|
|
54090
|
+
"LC_ALL",
|
|
54091
|
+
"LC_CTYPE",
|
|
54092
|
+
"TZ",
|
|
54093
|
+
"SDKROOT",
|
|
54094
|
+
"DEVELOPER_DIR",
|
|
54095
|
+
"DYLD_LIBRARY_PATH",
|
|
54096
|
+
"SYSTEMROOT",
|
|
54097
|
+
"COMSPEC",
|
|
54098
|
+
"SSL_CERT_FILE",
|
|
54099
|
+
"SSL_CERT_DIR",
|
|
54100
|
+
"HTTP_PROXY",
|
|
54101
|
+
"HTTPS_PROXY",
|
|
54102
|
+
"NO_PROXY",
|
|
54103
|
+
"http_proxy",
|
|
54104
|
+
"https_proxy",
|
|
54105
|
+
"no_proxy"
|
|
54106
|
+
];
|
|
53561
54107
|
distributionManifests = /* @__PURE__ */ new Map();
|
|
53562
54108
|
distributionCompileViews = /* @__PURE__ */ new WeakMap();
|
|
53563
54109
|
REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
|
|
@@ -53753,7 +54299,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
53753
54299
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
53754
54300
|
MULTI_MANIFEST_VERSION = 76;
|
|
53755
54301
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
53756
|
-
compilerSourceDigest = true ? "
|
|
54302
|
+
compilerSourceDigest = true ? "4d55fa7cbb29586c08e4e51867226f96047bae2103c89f4fa59d9cf3ed3862fb" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
|
|
53757
54303
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
53758
54304
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
53759
54305
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|