peachsim 0.1.2596 → 0.1.2598
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-KBQ33SLR.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-ZVBBDMPW.mjs → chunk-37W5LRA3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DY6PUVXF.mjs → chunk-54WIQP6N.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WPX7HLFR.mjs → chunk-B2DVYADK.mjs} +7 -6
- package/dist-lib/esm-chunks/{chunk-SPKD6UYK.mjs → chunk-C4NFHNW5.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-BNXCKF2B.mjs → chunk-CQHPA2VS.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-C3C5OJG4.mjs → chunk-FKSCP3EF.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-4UUWP6NP.mjs → chunk-I7POLNK4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SYCOZ2CT.mjs → chunk-IB7EAJUO.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-4MMPS5YL.mjs → chunk-J2DSD5ZC.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-HZPXGVY4.mjs → chunk-J5SU2CGP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3C2YVQZH.mjs → chunk-J6DI5ND2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UCIOSXXU.mjs → chunk-NTVANYOL.mjs} +963 -490
- package/dist-lib/esm-chunks/{chunk-FDMS7FWE.mjs → chunk-OQYMCUNM.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-LZF4BVEY.mjs → chunk-PZDQUPFX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BAEOHCN5.mjs → chunk-QPRSUFLC.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-TNZG7SFG.mjs → chunk-SYTFW2W6.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ISZE675P.mjs → chunk-SYWNAT3Z.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-TILPABC4.mjs → chunk-T2I3EXKH.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5NZPSLS4.mjs → chunk-U3X55VHR.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4PMXT2UO.mjs → chunk-UCLJ5PDG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-QEGUUPRI.mjs → chunk-UKE7QBBD.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-IGMABYTC.mjs → chunk-Z7BYGNNX.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-QNM3HYV7.mjs → metro-layout-parser-SOAXKW5M.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-BXXQB7Q2.mjs → swift-package-prebuilt-KK3VRVOF.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-FKL3X2ZC.mjs → swift-sdk-app-module-TEOC7LDK.mjs} +126 -56
- package/dist-lib/esm-chunks/{swift-sdk-image-CCVWDFHB.mjs → swift-sdk-image-ZBA4EYBW.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-OTMZVBDN.mjs → swift-sdk-image-producer-3VLSKMBD.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/compositor-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/native-hot-ops.d.ts +1 -0
- 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
package/dist-lib/skills.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2598 | (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;
|
|
@@ -35538,13 +35538,13 @@ var init_swift_standin_digest = __esm({
|
|
|
35538
35538
|
STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
|
|
35539
35539
|
SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
35540
35540
|
standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
|
|
35541
|
-
STANDIN_SOURCE_DIGEST = true ? "
|
|
35541
|
+
STANDIN_SOURCE_DIGEST = true ? "803880cad876e27e4e621723b8eae85b3c486a882db0f0f745babaf80c070680" : standinSourceDigest();
|
|
35542
35542
|
}
|
|
35543
35543
|
});
|
|
35544
35544
|
|
|
35545
35545
|
// src/expo-native-compiler-digest.ts
|
|
35546
35546
|
function expoNativeCompilerDigestValue() {
|
|
35547
|
-
return true ? "
|
|
35547
|
+
return true ? "4e04e854647f1a1e167543007b405e6d43a936b2b02d7be227ac14a5bcb224f9" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
|
|
35548
35548
|
}
|
|
35549
35549
|
var import_node_crypto12;
|
|
35550
35550
|
var init_expo_native_compiler_digest = __esm({
|
|
@@ -42464,8 +42464,14 @@ var init_podspec_ruby_stdlib = __esm({
|
|
|
42464
42464
|
|
|
42465
42465
|
// src/write-build-file.ts
|
|
42466
42466
|
function writeBuildFile(file, contents2) {
|
|
42467
|
-
|
|
42468
|
-
|
|
42467
|
+
const stat2 = (0, import_node_fs35.statSync)(file, { throwIfNoEntry: false });
|
|
42468
|
+
if (stat2?.isFile()) {
|
|
42469
|
+
if (typeof contents2 === "string") {
|
|
42470
|
+
if ((0, import_node_fs35.readFileSync)(file, "utf8") === contents2) return;
|
|
42471
|
+
} else if (stat2.size === contents2.length && (0, import_node_fs35.readFileSync)(file).equals(contents2)) {
|
|
42472
|
+
return;
|
|
42473
|
+
}
|
|
42474
|
+
}
|
|
42469
42475
|
(0, import_node_fs35.mkdirSync)(import_node_path31.default.dirname(file), { recursive: true });
|
|
42470
42476
|
(0, import_node_fs35.writeFileSync)(file, contents2);
|
|
42471
42477
|
}
|
|
@@ -60176,7 +60182,11 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
60176
60182
|
const sections = wasmSections(bytes);
|
|
60177
60183
|
const linking = sections.find((s) => s.name === "linking");
|
|
60178
60184
|
if (!linking) throw new Error("relocation link has no linking section");
|
|
60179
|
-
|
|
60185
|
+
let symKind = new Uint8Array(0);
|
|
60186
|
+
let symFlags = new Uint32Array(0);
|
|
60187
|
+
let symSegment = new Int32Array(0);
|
|
60188
|
+
let symOffset = new Int32Array(0);
|
|
60189
|
+
let symIndex = new Int32Array(0);
|
|
60180
60190
|
const segmentNames = [];
|
|
60181
60191
|
{
|
|
60182
60192
|
const r = wasmReader(bytes, linking.start);
|
|
@@ -60184,27 +60194,31 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
60184
60194
|
while (r.at < linking.end) {
|
|
60185
60195
|
const type = r.byte();
|
|
60186
60196
|
const end = r.u() + r.at;
|
|
60187
|
-
if (type === 8)
|
|
60188
|
-
|
|
60197
|
+
if (type === 8) {
|
|
60198
|
+
const count = r.u();
|
|
60199
|
+
symKind = new Uint8Array(count);
|
|
60200
|
+
symFlags = new Uint32Array(count);
|
|
60201
|
+
symSegment = new Int32Array(count).fill(-1);
|
|
60202
|
+
symOffset = new Int32Array(count);
|
|
60203
|
+
symIndex = new Int32Array(count).fill(-1);
|
|
60204
|
+
for (let i = 0; i < count; i++) {
|
|
60189
60205
|
const kind = r.byte();
|
|
60190
60206
|
const flags = r.u();
|
|
60191
|
-
|
|
60192
|
-
|
|
60193
|
-
let index = -1;
|
|
60207
|
+
symKind[i] = kind;
|
|
60208
|
+
symFlags[i] = flags;
|
|
60194
60209
|
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
60195
|
-
|
|
60196
|
-
if (!(flags & 16) || flags & 64) r.
|
|
60210
|
+
symIndex[i] = r.u();
|
|
60211
|
+
if (!(flags & 16) || flags & 64) r.skip(r.u());
|
|
60197
60212
|
} else if (kind === 1) {
|
|
60198
|
-
r.
|
|
60213
|
+
r.skip(r.u());
|
|
60199
60214
|
if (!(flags & 16)) {
|
|
60200
|
-
|
|
60201
|
-
|
|
60215
|
+
symSegment[i] = r.u();
|
|
60216
|
+
symOffset[i] = r.u();
|
|
60202
60217
|
r.u();
|
|
60203
60218
|
}
|
|
60204
60219
|
} else if (kind === 3) r.u();
|
|
60205
|
-
symbols.push({ kind, flags, segment: segment2, offset, index });
|
|
60206
60220
|
}
|
|
60207
|
-
else if (type === 5)
|
|
60221
|
+
} else if (type === 5)
|
|
60208
60222
|
for (let n = r.u(); n > 0; n--) {
|
|
60209
60223
|
segmentNames.push(r.name());
|
|
60210
60224
|
r.u();
|
|
@@ -60243,37 +60257,66 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
60243
60257
|
const importedFunctions = readModule(bytes).importedFuncs;
|
|
60244
60258
|
const data = [];
|
|
60245
60259
|
const dataFunctions = [];
|
|
60246
|
-
const
|
|
60247
|
-
const
|
|
60260
|
+
const bodyCount = bodyStarts.length;
|
|
60261
|
+
const code = Array.from({ length: bodyCount }, () => []);
|
|
60262
|
+
const calls = Array.from({ length: bodyCount }, () => []);
|
|
60248
60263
|
for (const s of sections) {
|
|
60249
60264
|
if (!s.name?.startsWith("reloc.")) continue;
|
|
60250
|
-
|
|
60251
|
-
const
|
|
60265
|
+
let cur = s.start;
|
|
60266
|
+
const readU = () => {
|
|
60267
|
+
const b0 = bytes[cur++];
|
|
60268
|
+
if (b0 < 128) return b0;
|
|
60269
|
+
let value = b0 & 127;
|
|
60270
|
+
let shift = 7;
|
|
60271
|
+
for (; ; ) {
|
|
60272
|
+
const byte = bytes[cur++];
|
|
60273
|
+
value += (byte & 127) * 2 ** shift;
|
|
60274
|
+
if (byte < 128) return value;
|
|
60275
|
+
shift += 7;
|
|
60276
|
+
}
|
|
60277
|
+
};
|
|
60278
|
+
const readS = () => {
|
|
60279
|
+
const b0 = bytes[cur++];
|
|
60280
|
+
if (b0 < 128) return b0 & 64 ? b0 - 128 : b0;
|
|
60281
|
+
let value = b0 & 127;
|
|
60282
|
+
let shift = 7;
|
|
60283
|
+
let byte = b0;
|
|
60284
|
+
while (byte >= 128) {
|
|
60285
|
+
byte = bytes[cur++];
|
|
60286
|
+
value += (byte & 127) * 2 ** shift;
|
|
60287
|
+
shift += 7;
|
|
60288
|
+
}
|
|
60289
|
+
if (byte & 64) value -= 2 ** shift;
|
|
60290
|
+
return value;
|
|
60291
|
+
};
|
|
60292
|
+
const target = readU();
|
|
60252
60293
|
if (target !== dataIndex && target !== codeIndex) continue;
|
|
60253
60294
|
let segment2 = 0;
|
|
60254
60295
|
let body = 0;
|
|
60255
|
-
|
|
60256
|
-
|
|
60257
|
-
const
|
|
60258
|
-
const
|
|
60259
|
-
const
|
|
60260
|
-
const
|
|
60261
|
-
const
|
|
60296
|
+
const isData = target === dataIndex;
|
|
60297
|
+
for (let n = readU(); n > 0; n--) {
|
|
60298
|
+
const type = bytes[cur++];
|
|
60299
|
+
const offset = readU();
|
|
60300
|
+
const index = readU();
|
|
60301
|
+
const bit = type < 32 ? 1 << type : 0;
|
|
60302
|
+
const addend = (ADDEND_RELOC_MASK & bit) !== 0 ? readS() : 0;
|
|
60303
|
+
const functionRelocation = (FUNCTION_RELOC_MASK & bit) !== 0;
|
|
60304
|
+
const memoryRelocation = (MEMORY_RELOC_MASK & bit) !== 0;
|
|
60262
60305
|
if (!functionRelocation && !memoryRelocation) continue;
|
|
60263
|
-
|
|
60264
|
-
const
|
|
60265
|
-
|
|
60266
|
-
if (!functionReference && (!memoryRelocation ||
|
|
60306
|
+
if (symFlags[index] & 16) continue;
|
|
60307
|
+
const kind = symKind[index];
|
|
60308
|
+
const functionReference = functionRelocation && kind === 0;
|
|
60309
|
+
if (!functionReference && (!memoryRelocation || kind !== 1 || symSegment[index] < 0))
|
|
60267
60310
|
continue;
|
|
60268
|
-
const to = functionReference ?
|
|
60269
|
-
if (functionReference && (to < 0 || to >=
|
|
60270
|
-
if (
|
|
60311
|
+
const to = functionReference ? symIndex[index] - importedFunctions : addresses[symSegment[index]] + symOffset[index] + addend;
|
|
60312
|
+
if (functionReference && (to < 0 || to >= bodyCount)) continue;
|
|
60313
|
+
if (isData) {
|
|
60271
60314
|
while (payloads[segment2].end <= offset) segment2++;
|
|
60272
60315
|
const payload = payloads[segment2];
|
|
60273
60316
|
const edges = functionReference ? dataFunctions : data;
|
|
60274
60317
|
edges.push(payload.address + offset - payload.start, to);
|
|
60275
60318
|
} else {
|
|
60276
|
-
while (body + 1 <
|
|
60319
|
+
while (body + 1 < bodyCount && bodyStarts[body + 1] <= offset) body++;
|
|
60277
60320
|
const edges = functionReference ? calls : code;
|
|
60278
60321
|
edges[body].push(to);
|
|
60279
60322
|
}
|
|
@@ -60329,7 +60372,7 @@ function unslottedFunctions(bytes) {
|
|
|
60329
60372
|
const slotted = new Set([...m.slots.keys()].filter((index) => index >= m.importedFuncs));
|
|
60330
60373
|
return m.bodies.length - slotted.size;
|
|
60331
60374
|
}
|
|
60332
|
-
var uleb, sleb, encodedName, section, PROCESS_EXPORTS, SWIFT_SDK_CONSTRUCTOR_LIMIT, FUNCTION_RELOCATIONS, MEMORY_RELOCATIONS, ADDEND_RELOCATIONS;
|
|
60375
|
+
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;
|
|
60333
60376
|
var init_swift_sdk_image_wasm = __esm({
|
|
60334
60377
|
"src/swift-sdk-image-wasm.ts"() {
|
|
60335
60378
|
"use strict";
|
|
@@ -60399,6 +60442,12 @@ var init_swift_sdk_image_wasm = __esm({
|
|
|
60399
60442
|
25,
|
|
60400
60443
|
27
|
|
60401
60444
|
]);
|
|
60445
|
+
FUNCTION_RELOC_MASK = 0;
|
|
60446
|
+
for (const type of FUNCTION_RELOCATIONS) FUNCTION_RELOC_MASK |= 1 << type;
|
|
60447
|
+
MEMORY_RELOC_MASK = 0;
|
|
60448
|
+
for (const type of MEMORY_RELOCATIONS) MEMORY_RELOC_MASK |= 1 << type;
|
|
60449
|
+
ADDEND_RELOC_MASK = 0;
|
|
60450
|
+
for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK |= 1 << type;
|
|
60402
60451
|
}
|
|
60403
60452
|
});
|
|
60404
60453
|
|
|
@@ -60566,7 +60615,8 @@ function isRootSegName(name3) {
|
|
|
60566
60615
|
return false;
|
|
60567
60616
|
}
|
|
60568
60617
|
function decodeRelocations(buf, sections) {
|
|
60569
|
-
|
|
60618
|
+
let count = 0;
|
|
60619
|
+
for (let s = 0; s < sections.length; s++) count += sections[s].count;
|
|
60570
60620
|
const start = new Uint32Array(count);
|
|
60571
60621
|
const end = new Uint32Array(count);
|
|
60572
60622
|
const ro = new Int32Array(count);
|
|
@@ -60575,29 +60625,59 @@ function decodeRelocations(buf, sections) {
|
|
|
60575
60625
|
const spans = [];
|
|
60576
60626
|
let i = 0;
|
|
60577
60627
|
let length = 0;
|
|
60578
|
-
for (
|
|
60579
|
-
|
|
60580
|
-
|
|
60581
|
-
|
|
60628
|
+
for (let s = 0; s < sections.length; s++) {
|
|
60629
|
+
const section2 = sections[s];
|
|
60630
|
+
const baseAt = section2.at;
|
|
60631
|
+
const sectionCount = section2.count;
|
|
60632
|
+
let cur = baseAt;
|
|
60633
|
+
for (let k = 0; k < sectionCount; k++, i++) {
|
|
60634
|
+
start[i] = length + cur - baseAt;
|
|
60582
60635
|
const rType = buf[cur++];
|
|
60583
|
-
|
|
60584
|
-
|
|
60585
|
-
|
|
60586
|
-
|
|
60587
|
-
|
|
60636
|
+
let offset = buf[cur++];
|
|
60637
|
+
if (offset >= 128) {
|
|
60638
|
+
offset &= 127;
|
|
60639
|
+
let shift = 7;
|
|
60640
|
+
while (true) {
|
|
60641
|
+
const byte = buf[cur++];
|
|
60642
|
+
offset |= (byte & 127) << shift;
|
|
60643
|
+
if (byte < 128) break;
|
|
60644
|
+
shift += 7;
|
|
60645
|
+
}
|
|
60646
|
+
}
|
|
60647
|
+
let symbol2 = buf[cur++];
|
|
60648
|
+
if (symbol2 >= 128) {
|
|
60649
|
+
symbol2 &= 127;
|
|
60650
|
+
let shift = 7;
|
|
60651
|
+
while (true) {
|
|
60652
|
+
const byte = buf[cur++];
|
|
60653
|
+
symbol2 |= (byte & 127) << shift;
|
|
60654
|
+
if (byte < 128) break;
|
|
60655
|
+
shift += 7;
|
|
60656
|
+
}
|
|
60657
|
+
}
|
|
60658
|
+
if (rType < 32 && (ADDEND_RELOC_MASK2 & 1 << rType) !== 0) {
|
|
60659
|
+
let byte = buf[cur++];
|
|
60660
|
+
let value = byte & 127;
|
|
60661
|
+
let shift = 7;
|
|
60662
|
+
while (byte >= 128) {
|
|
60663
|
+
byte = buf[cur++];
|
|
60664
|
+
value |= (byte & 127) << shift;
|
|
60665
|
+
shift += 7;
|
|
60666
|
+
}
|
|
60667
|
+
if (shift < 32 && (byte & 64) !== 0) value |= ~0 << shift;
|
|
60588
60668
|
addend[i] = value;
|
|
60589
|
-
cur = c4;
|
|
60590
60669
|
}
|
|
60591
60670
|
ro[i] = offset;
|
|
60592
60671
|
rs[i] = symbol2;
|
|
60593
|
-
end[i] = length + cur -
|
|
60672
|
+
end[i] = length + cur - baseAt;
|
|
60594
60673
|
}
|
|
60595
|
-
spans.push([
|
|
60596
|
-
length += cur -
|
|
60674
|
+
spans.push([baseAt, cur]);
|
|
60675
|
+
length += cur - baseAt;
|
|
60597
60676
|
}
|
|
60598
60677
|
const bytes = new Uint8Array(length);
|
|
60599
60678
|
let at = 0;
|
|
60600
|
-
for (
|
|
60679
|
+
for (let s = 0; s < spans.length; s++) {
|
|
60680
|
+
const [from, to] = spans[s];
|
|
60601
60681
|
bytes.set(buf.subarray(from, to), at);
|
|
60602
60682
|
at += to - from;
|
|
60603
60683
|
}
|
|
@@ -60762,6 +60842,27 @@ function patchSwiftrtObject(src) {
|
|
|
60762
60842
|
function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
60763
60843
|
const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
60764
60844
|
let pos = 8;
|
|
60845
|
+
let cur = 8;
|
|
60846
|
+
const readU = () => {
|
|
60847
|
+
const b0 = buf[cur++];
|
|
60848
|
+
if (b0 < 128) return b0;
|
|
60849
|
+
let res = b0 & 127;
|
|
60850
|
+
let shift = 7;
|
|
60851
|
+
while (true) {
|
|
60852
|
+
const byte = buf[cur++];
|
|
60853
|
+
res |= (byte & 127) << shift;
|
|
60854
|
+
if (byte < 128) return res;
|
|
60855
|
+
shift += 7;
|
|
60856
|
+
}
|
|
60857
|
+
};
|
|
60858
|
+
const skipU = () => {
|
|
60859
|
+
while (buf[cur++] >= 128) {
|
|
60860
|
+
}
|
|
60861
|
+
};
|
|
60862
|
+
const skipS = () => {
|
|
60863
|
+
while (buf[cur++] >= 128) {
|
|
60864
|
+
}
|
|
60865
|
+
};
|
|
60765
60866
|
let numImportFuncs = 0;
|
|
60766
60867
|
let importsDlsym = false;
|
|
60767
60868
|
const importFuncNames = [];
|
|
@@ -60790,150 +60891,122 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
60790
60891
|
const dataRelocSections = [];
|
|
60791
60892
|
while (pos < buf.length) {
|
|
60792
60893
|
const id = buf[pos++];
|
|
60793
|
-
|
|
60894
|
+
cur = pos;
|
|
60895
|
+
const sz = readU();
|
|
60896
|
+
const p = cur;
|
|
60794
60897
|
const end = p + sz;
|
|
60795
60898
|
if (id === 2) {
|
|
60796
|
-
|
|
60899
|
+
const cnt = readU();
|
|
60797
60900
|
for (let i = 0; i < cnt; i++) {
|
|
60798
|
-
const
|
|
60799
|
-
const mName = rawBuf.toString("utf8",
|
|
60800
|
-
|
|
60801
|
-
const
|
|
60802
|
-
const fName = rawBuf.toString("utf8",
|
|
60803
|
-
|
|
60804
|
-
const kind = buf[
|
|
60901
|
+
const mLen = readU();
|
|
60902
|
+
const mName = rawBuf.toString("utf8", cur, cur + mLen);
|
|
60903
|
+
cur += mLen;
|
|
60904
|
+
const fLen = readU();
|
|
60905
|
+
const fName = rawBuf.toString("utf8", cur, cur + fLen);
|
|
60906
|
+
cur += fLen;
|
|
60907
|
+
const kind = buf[cur++];
|
|
60805
60908
|
if (kind === 0) {
|
|
60806
|
-
|
|
60807
|
-
cp = c2;
|
|
60909
|
+
skipU();
|
|
60808
60910
|
importFuncNames.push(fName);
|
|
60809
60911
|
importFuncModules.push(mName);
|
|
60810
60912
|
if (mName === "env" && fName === "dlsym") importsDlsym = true;
|
|
60811
60913
|
numImportFuncs++;
|
|
60812
60914
|
} else if (kind === 1) {
|
|
60813
|
-
|
|
60814
|
-
const
|
|
60815
|
-
|
|
60816
|
-
|
|
60817
|
-
cp = c3;
|
|
60818
|
-
if (fl & 1) {
|
|
60819
|
-
const [, c4] = readULEB2(buf, cp);
|
|
60820
|
-
cp = c4;
|
|
60821
|
-
}
|
|
60915
|
+
cur++;
|
|
60916
|
+
const fl = readU();
|
|
60917
|
+
skipU();
|
|
60918
|
+
if (fl & 1) skipU();
|
|
60822
60919
|
importTableNames.push(fName);
|
|
60823
60920
|
} else if (kind === 2) {
|
|
60824
|
-
const
|
|
60825
|
-
|
|
60826
|
-
|
|
60827
|
-
cp = c3;
|
|
60828
|
-
if (fl & 1) {
|
|
60829
|
-
const [, c4] = readULEB2(buf, cp);
|
|
60830
|
-
cp = c4;
|
|
60831
|
-
}
|
|
60921
|
+
const fl = readU();
|
|
60922
|
+
skipU();
|
|
60923
|
+
if (fl & 1) skipU();
|
|
60832
60924
|
} else if (kind === 3) {
|
|
60833
|
-
|
|
60925
|
+
cur += 2;
|
|
60834
60926
|
importGlobalNames.push(fName);
|
|
60835
60927
|
} else if (kind === 4) {
|
|
60836
|
-
|
|
60837
|
-
|
|
60838
|
-
cp = c2;
|
|
60928
|
+
cur++;
|
|
60929
|
+
skipU();
|
|
60839
60930
|
importEventNames.push(fName);
|
|
60840
60931
|
}
|
|
60841
60932
|
}
|
|
60842
60933
|
} else if (id === 10) {
|
|
60843
60934
|
codeStart = p;
|
|
60844
|
-
|
|
60935
|
+
const cnt = readU();
|
|
60845
60936
|
for (let i = 0; i < cnt; i++) {
|
|
60846
|
-
const st =
|
|
60847
|
-
const
|
|
60848
|
-
|
|
60937
|
+
const st = cur - codeStart;
|
|
60938
|
+
const bLen = readU();
|
|
60939
|
+
cur += bLen;
|
|
60849
60940
|
fStarts.push(st);
|
|
60850
|
-
fEnds.push(
|
|
60941
|
+
fEnds.push(cur - codeStart);
|
|
60851
60942
|
}
|
|
60852
60943
|
} else if (id === 11) {
|
|
60853
60944
|
dataStart = p;
|
|
60854
|
-
|
|
60945
|
+
const cnt = readU();
|
|
60855
60946
|
for (let i = 0; i < cnt; i++) {
|
|
60856
|
-
const st =
|
|
60857
|
-
const
|
|
60858
|
-
|
|
60859
|
-
if (mode === 2) {
|
|
60860
|
-
const [, m3] = readULEB2(buf, cp);
|
|
60861
|
-
cp = m3;
|
|
60862
|
-
}
|
|
60947
|
+
const st = cur - dataStart;
|
|
60948
|
+
const mode = readU();
|
|
60949
|
+
if (mode === 2) skipU();
|
|
60863
60950
|
if (mode === 0 || mode === 2) {
|
|
60864
|
-
const op = buf[
|
|
60865
|
-
if (op === 65 || op === 66)
|
|
60866
|
-
|
|
60867
|
-
|
|
60868
|
-
|
|
60869
|
-
|
|
60870
|
-
|
|
60871
|
-
|
|
60872
|
-
cp++;
|
|
60873
|
-
}
|
|
60874
|
-
const [dLen, d2] = readULEB2(buf, cp);
|
|
60875
|
-
sPayloadStarts.push(d2 - dataStart);
|
|
60876
|
-
cp = d2 + dLen;
|
|
60951
|
+
const op = buf[cur++];
|
|
60952
|
+
if (op === 65 || op === 66) skipS();
|
|
60953
|
+
else if (op === 35) skipU();
|
|
60954
|
+
cur++;
|
|
60955
|
+
}
|
|
60956
|
+
const dLen = readU();
|
|
60957
|
+
sPayloadStarts.push(cur - dataStart);
|
|
60958
|
+
cur += dLen;
|
|
60877
60959
|
sStarts.push(st);
|
|
60878
|
-
sEnds.push(
|
|
60960
|
+
sEnds.push(cur - dataStart);
|
|
60879
60961
|
}
|
|
60880
60962
|
} else if (id === 0) {
|
|
60881
|
-
const
|
|
60882
|
-
const name3 = rawBuf.toString("utf8",
|
|
60883
|
-
|
|
60963
|
+
const nLen = readU();
|
|
60964
|
+
const name3 = rawBuf.toString("utf8", cur, cur + nLen);
|
|
60965
|
+
cur += nLen;
|
|
60884
60966
|
if (name3 === "linking") {
|
|
60885
|
-
|
|
60886
|
-
while (
|
|
60887
|
-
const subId = buf[
|
|
60888
|
-
const
|
|
60889
|
-
const subEnd =
|
|
60967
|
+
skipU();
|
|
60968
|
+
while (cur < end) {
|
|
60969
|
+
const subId = buf[cur++];
|
|
60970
|
+
const subLen = readU();
|
|
60971
|
+
const subEnd = cur + subLen;
|
|
60890
60972
|
if (subId === 5) {
|
|
60891
|
-
const
|
|
60892
|
-
let cur = p2;
|
|
60973
|
+
const cnt = readU();
|
|
60893
60974
|
for (let i = 0; i < cnt; i++) {
|
|
60894
|
-
const
|
|
60895
|
-
segNames.push(rawBuf.toString("utf8",
|
|
60896
|
-
cur
|
|
60897
|
-
|
|
60898
|
-
|
|
60899
|
-
segFlags.push(fl);
|
|
60900
|
-
cur = s4;
|
|
60975
|
+
const sLen = readU();
|
|
60976
|
+
segNames.push(rawBuf.toString("utf8", cur, cur + sLen));
|
|
60977
|
+
cur += sLen;
|
|
60978
|
+
skipU();
|
|
60979
|
+
segFlags.push(readU());
|
|
60901
60980
|
}
|
|
60902
60981
|
} else if (subId === 6) {
|
|
60903
|
-
const
|
|
60904
|
-
let cur = p2;
|
|
60982
|
+
const cnt = readU();
|
|
60905
60983
|
for (let i = 0; i < cnt; i++) {
|
|
60906
|
-
|
|
60907
|
-
|
|
60908
|
-
initFuncs.push(symIdx);
|
|
60909
|
-
cur = s3;
|
|
60984
|
+
skipU();
|
|
60985
|
+
initFuncs.push(readU());
|
|
60910
60986
|
}
|
|
60911
60987
|
} else if (subId === 8) {
|
|
60912
|
-
const
|
|
60988
|
+
const cnt = readU();
|
|
60913
60989
|
symKind = new Uint8Array(cnt);
|
|
60914
60990
|
symFlags = new Uint32Array(cnt);
|
|
60915
60991
|
symElemIdx = new Int32Array(cnt).fill(-1);
|
|
60916
|
-
symOff = new Int32Array(cnt)
|
|
60917
|
-
symSz = new Int32Array(cnt)
|
|
60918
|
-
let cur = p2;
|
|
60992
|
+
symOff = new Int32Array(cnt);
|
|
60993
|
+
symSz = new Int32Array(cnt);
|
|
60919
60994
|
for (let i = 0; i < cnt; i++) {
|
|
60920
60995
|
const kind = buf[cur++];
|
|
60921
60996
|
if (symbolFlagOffsets) symbolFlagOffsets[i] = cur;
|
|
60922
|
-
const
|
|
60923
|
-
cur = c2;
|
|
60997
|
+
const fl = readU();
|
|
60924
60998
|
symKind[i] = kind;
|
|
60925
60999
|
symFlags[i] = fl;
|
|
60926
61000
|
const isUndef = (fl & 16) !== 0;
|
|
60927
61001
|
const isExplicitName = (fl & 64) !== 0;
|
|
60928
61002
|
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
60929
|
-
const
|
|
60930
|
-
cur = c3;
|
|
61003
|
+
const el = readU();
|
|
60931
61004
|
if (!isUndef && kind === 0) symElemIdx[i] = el;
|
|
60932
61005
|
let sName = "";
|
|
60933
61006
|
if (!isUndef || isExplicitName) {
|
|
60934
|
-
const
|
|
60935
|
-
sName = rawBuf.toString("utf8",
|
|
60936
|
-
cur
|
|
61007
|
+
const sLen = readU();
|
|
61008
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
61009
|
+
cur += sLen;
|
|
60937
61010
|
} else if (kind === 0) {
|
|
60938
61011
|
sName = importFuncNames[el] ?? "";
|
|
60939
61012
|
} else if (kind === 2) {
|
|
@@ -60947,33 +61020,28 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
60947
61020
|
hostImportNames.add(sName);
|
|
60948
61021
|
symNames.push(sName);
|
|
60949
61022
|
} else if (kind === 1) {
|
|
60950
|
-
const
|
|
60951
|
-
const sName = rawBuf.toString("utf8",
|
|
60952
|
-
cur
|
|
61023
|
+
const sLen = readU();
|
|
61024
|
+
const sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
61025
|
+
cur += sLen;
|
|
60953
61026
|
if (!isUndef) {
|
|
60954
|
-
|
|
60955
|
-
|
|
60956
|
-
|
|
60957
|
-
cur = c6;
|
|
60958
|
-
symElemIdx[i] = segIdx;
|
|
60959
|
-
symOff[i] = sOff;
|
|
60960
|
-
symSz[i] = sSz;
|
|
61027
|
+
symElemIdx[i] = readU();
|
|
61028
|
+
symOff[i] = readU();
|
|
61029
|
+
symSz[i] = readU();
|
|
60961
61030
|
}
|
|
60962
61031
|
symNames.push(sName);
|
|
60963
61032
|
} else if (kind === 3) {
|
|
60964
|
-
|
|
60965
|
-
cur = c3;
|
|
61033
|
+
skipU();
|
|
60966
61034
|
symNames.push("");
|
|
60967
61035
|
}
|
|
60968
61036
|
}
|
|
60969
61037
|
}
|
|
60970
|
-
|
|
61038
|
+
cur = subEnd;
|
|
60971
61039
|
}
|
|
60972
61040
|
} else if (name3 === "reloc.CODE" || name3 === "reloc.DATA") {
|
|
60973
|
-
|
|
60974
|
-
const
|
|
61041
|
+
skipU();
|
|
61042
|
+
const count = readU();
|
|
60975
61043
|
(name3 === "reloc.DATA" ? dataRelocSections : codeRelocSections).push({
|
|
60976
|
-
at,
|
|
61044
|
+
at: cur,
|
|
60977
61045
|
count
|
|
60978
61046
|
});
|
|
60979
61047
|
}
|
|
@@ -61026,40 +61094,63 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
61026
61094
|
segTopSyms.set(segIdx, dedupTop);
|
|
61027
61095
|
}
|
|
61028
61096
|
}
|
|
61029
|
-
const
|
|
61030
|
-
const
|
|
61097
|
+
const funcCount = fEnds.length;
|
|
61098
|
+
const funcRelocs = Array.from({ length: funcCount }, () => []);
|
|
61099
|
+
const rawCode = decodeRelocations(buf, funcCount > 0 ? codeRelocSections : []);
|
|
61031
61100
|
const codeRelocs = { ...rawCode, funcIdx: new Uint32Array(rawCode.count) };
|
|
61101
|
+
let fCursor = 0;
|
|
61102
|
+
let prevCodeRo = -1;
|
|
61032
61103
|
for (let i = 0; i < codeRelocs.count; i++) {
|
|
61033
61104
|
const ro = codeRelocs.ro[i];
|
|
61034
|
-
let lo
|
|
61035
|
-
|
|
61036
|
-
|
|
61037
|
-
|
|
61038
|
-
|
|
61039
|
-
|
|
61105
|
+
let lo;
|
|
61106
|
+
if (ro >= prevCodeRo) {
|
|
61107
|
+
while (fCursor < funcCount - 1 && fEnds[fCursor] <= ro) fCursor++;
|
|
61108
|
+
lo = fCursor;
|
|
61109
|
+
} else {
|
|
61110
|
+
lo = 0;
|
|
61111
|
+
let hi = funcCount - 1;
|
|
61112
|
+
while (lo < hi) {
|
|
61113
|
+
const mid = lo + hi >> 1;
|
|
61114
|
+
if (fEnds[mid] <= ro) lo = mid + 1;
|
|
61115
|
+
else hi = mid;
|
|
61116
|
+
}
|
|
61117
|
+
fCursor = lo;
|
|
61040
61118
|
}
|
|
61119
|
+
prevCodeRo = ro;
|
|
61041
61120
|
if (codeRelocs.bytes[codeRelocs.start[i]] !== 6)
|
|
61042
61121
|
funcRelocs[lo].push(codeRelocs.rs[i]);
|
|
61043
61122
|
codeRelocs.funcIdx[i] = lo;
|
|
61044
61123
|
}
|
|
61045
|
-
const
|
|
61124
|
+
const segCount = segNames.length;
|
|
61125
|
+
const segRelocs = Array.from({ length: segCount }, () => []);
|
|
61046
61126
|
const symDataRelocs = /* @__PURE__ */ new Map();
|
|
61047
61127
|
const rawData = decodeRelocations(buf, sEnds.length > 0 ? dataRelocSections : []);
|
|
61048
61128
|
const dataSegIdx = new Uint32Array(rawData.count);
|
|
61049
61129
|
const dataOffInSeg = new Int32Array(rawData.count);
|
|
61050
61130
|
const dataOwnerSymIdx = new Int32Array(rawData.count);
|
|
61051
61131
|
let kept = 0;
|
|
61132
|
+
let sCursor = 0;
|
|
61133
|
+
let prevDataRo = -1;
|
|
61134
|
+
const sEndLast = sEnds.length - 1;
|
|
61052
61135
|
for (let i = 0; i < rawData.count; i++) {
|
|
61053
61136
|
const ro = rawData.ro[i];
|
|
61054
61137
|
const rs = rawData.rs[i];
|
|
61055
|
-
let lo
|
|
61056
|
-
|
|
61057
|
-
|
|
61058
|
-
|
|
61059
|
-
|
|
61060
|
-
|
|
61138
|
+
let lo;
|
|
61139
|
+
if (ro >= prevDataRo) {
|
|
61140
|
+
while (sCursor < sEndLast && sEnds[sCursor] <= ro) sCursor++;
|
|
61141
|
+
lo = sCursor;
|
|
61142
|
+
} else {
|
|
61143
|
+
lo = 0;
|
|
61144
|
+
let hi = sEndLast;
|
|
61145
|
+
while (lo < hi) {
|
|
61146
|
+
const mid = lo + hi >> 1;
|
|
61147
|
+
if (sEnds[mid] <= ro) lo = mid + 1;
|
|
61148
|
+
else hi = mid;
|
|
61149
|
+
}
|
|
61150
|
+
sCursor = lo;
|
|
61061
61151
|
}
|
|
61062
|
-
|
|
61152
|
+
prevDataRo = ro;
|
|
61153
|
+
if (lo >= segCount) continue;
|
|
61063
61154
|
const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
|
|
61064
61155
|
let ownerSymIdx = -1;
|
|
61065
61156
|
const topList = segTopSyms.get(lo);
|
|
@@ -61206,74 +61297,78 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
61206
61297
|
const conformanceProtocols = /* @__PURE__ */ new Map();
|
|
61207
61298
|
const objcCategoryTargets = [];
|
|
61208
61299
|
if (isDist) {
|
|
61209
|
-
const relocAt = /* @__PURE__ */ new Map();
|
|
61210
|
-
for (let i = 0; i < dataRelocs.count; i++) {
|
|
61211
|
-
relocAt.set(`${dataRelocs.segIdx[i]}:${dataRelocs.offInSeg[i]}`, {
|
|
61212
|
-
rs: dataRelocs.rs[i],
|
|
61213
|
-
addend: dataRelocs.addend[i]
|
|
61214
|
-
});
|
|
61215
|
-
}
|
|
61216
61300
|
const confSegs = /* @__PURE__ */ new Set();
|
|
61217
61301
|
let hasCatsSeg = false;
|
|
61218
61302
|
for (let i = 0; i < segNames.length; i++) {
|
|
61219
61303
|
if (segNames[i] === "swift5_protocol_conformances") confSegs.add(i);
|
|
61220
61304
|
else if (segNames[i] === "__objc_cats") hasCatsSeg = true;
|
|
61221
61305
|
}
|
|
61222
|
-
if (confSegs.size > 0) {
|
|
61223
|
-
const
|
|
61224
|
-
|
|
61225
|
-
if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
|
|
61226
|
-
segOffToMpSym.set(`${symElemIdx[i]}:${symOff[i]}`, symNames[i]);
|
|
61227
|
-
}
|
|
61228
|
-
}
|
|
61229
|
-
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
61306
|
+
if (confSegs.size > 0 || hasCatsSeg) {
|
|
61307
|
+
const relocKey = (seg, off) => seg * 4294967296 + (off >>> 0);
|
|
61308
|
+
const relocAt = /* @__PURE__ */ new Map();
|
|
61230
61309
|
for (let i = 0; i < dataRelocs.count; i++) {
|
|
61231
|
-
|
|
61232
|
-
|
|
61233
|
-
|
|
61234
|
-
|
|
61310
|
+
relocAt.set(relocKey(dataRelocs.segIdx[i], dataRelocs.offInSeg[i]), i);
|
|
61311
|
+
}
|
|
61312
|
+
if (confSegs.size > 0) {
|
|
61313
|
+
const segOffToMpSym = /* @__PURE__ */ new Map();
|
|
61314
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
61315
|
+
if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
|
|
61316
|
+
segOffToMpSym.set(relocKey(symElemIdx[i], symOff[i]), symNames[i]);
|
|
61317
|
+
}
|
|
61235
61318
|
}
|
|
61236
|
-
const
|
|
61237
|
-
|
|
61238
|
-
|
|
61239
|
-
|
|
61240
|
-
|
|
61241
|
-
|
|
61242
|
-
const stripped2 = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
|
|
61243
|
-
if (stripped2.startsWith("$s") && stripped2.endsWith("Mp")) {
|
|
61244
|
-
mp = stripped2;
|
|
61245
|
-
} else if (symKind[pr.rs] === 3 || stripped2 === "") {
|
|
61246
|
-
mp = segOffToMpSym.get(`${mcSeg}:${pr.addend}`) ?? "";
|
|
61319
|
+
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
61320
|
+
for (let i = 0; i < dataRelocs.count; i++) {
|
|
61321
|
+
if (!confSegs.has(dataRelocs.segIdx[i])) continue;
|
|
61322
|
+
const mcIdx = dataRelocs.rs[i];
|
|
61323
|
+
if (symKind[mcIdx] !== 1 || (symFlags[mcIdx] & 16) !== 0 || symElemIdx[mcIdx] < 0) {
|
|
61324
|
+
continue;
|
|
61247
61325
|
}
|
|
61248
|
-
|
|
61249
|
-
const
|
|
61250
|
-
|
|
61251
|
-
|
|
61252
|
-
|
|
61326
|
+
const mcSeg = symElemIdx[mcIdx];
|
|
61327
|
+
const mcOff = symOff[mcIdx];
|
|
61328
|
+
const prIdx = relocAt.get(relocKey(mcSeg, mcOff));
|
|
61329
|
+
let mp = "";
|
|
61330
|
+
if (prIdx !== void 0) {
|
|
61331
|
+
const prRs = dataRelocs.rs[prIdx];
|
|
61332
|
+
const raw2 = symNames[prRs];
|
|
61333
|
+
const stripped2 = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
|
|
61334
|
+
if (stripped2.startsWith("$s") && stripped2.endsWith("Mp")) {
|
|
61335
|
+
mp = stripped2;
|
|
61336
|
+
} else if (symKind[prRs] === 3 || stripped2 === "") {
|
|
61337
|
+
mp = segOffToMpSym.get(relocKey(mcSeg, dataRelocs.addend[prIdx])) ?? "";
|
|
61338
|
+
}
|
|
61339
|
+
} else {
|
|
61340
|
+
const fileOff = dataStart + sPayloadStarts[mcSeg] + mcOff;
|
|
61341
|
+
if (fileOff + 4 <= buf.length) {
|
|
61342
|
+
const delta = dv.getInt32(fileOff, true);
|
|
61343
|
+
mp = segOffToMpSym.get(relocKey(mcSeg, mcOff + delta)) ?? segOffToMpSym.get(relocKey(mcSeg, mcOff + (delta & ~1))) ?? "";
|
|
61344
|
+
}
|
|
61253
61345
|
}
|
|
61346
|
+
if (mp) conformanceProtocols.set(mcIdx, mp);
|
|
61254
61347
|
}
|
|
61255
|
-
if (mp) conformanceProtocols.set(mcIdx, mp);
|
|
61256
61348
|
}
|
|
61257
|
-
|
|
61258
|
-
|
|
61259
|
-
|
|
61260
|
-
|
|
61261
|
-
|
|
61262
|
-
|
|
61263
|
-
|
|
61264
|
-
|
|
61265
|
-
|
|
61266
|
-
|
|
61267
|
-
|
|
61268
|
-
|
|
61269
|
-
|
|
61270
|
-
|
|
61271
|
-
|
|
61272
|
-
|
|
61273
|
-
|
|
61274
|
-
|
|
61275
|
-
|
|
61276
|
-
|
|
61349
|
+
if (hasCatsSeg) {
|
|
61350
|
+
const seenClasses = /* @__PURE__ */ new Set();
|
|
61351
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
61352
|
+
if (symKind[i] !== 1 || (symFlags[i] & 16) !== 0 || symElemIdx[i] < 0 || segNames[symElemIdx[i]] !== "__objc_cats" || !symNames[i].startsWith(".objc_category_")) {
|
|
61353
|
+
continue;
|
|
61354
|
+
}
|
|
61355
|
+
const cSeg = symElemIdx[i];
|
|
61356
|
+
const cOff = symOff[i];
|
|
61357
|
+
const crIdx = relocAt.get(relocKey(cSeg, cOff + 8));
|
|
61358
|
+
if (crIdx !== void 0) {
|
|
61359
|
+
const crRs = dataRelocs.rs[crIdx];
|
|
61360
|
+
if (symKind[crRs] === 1 && (symFlags[crRs] & 16) === 0 && symElemIdx[crRs] >= 0) {
|
|
61361
|
+
const tSeg = symElemIdx[crRs];
|
|
61362
|
+
const strOff = dataStart + sPayloadStarts[tSeg] + symOff[crRs] + dataRelocs.addend[crIdx];
|
|
61363
|
+
let sEnd = strOff;
|
|
61364
|
+
while (sEnd < buf.length && buf[sEnd] !== 0) sEnd++;
|
|
61365
|
+
if (sEnd > strOff) {
|
|
61366
|
+
const clsName = rawBuf.toString("utf8", strOff, sEnd);
|
|
61367
|
+
if (!seenClasses.has(clsName)) {
|
|
61368
|
+
seenClasses.add(clsName);
|
|
61369
|
+
objcCategoryTargets.push(clsName);
|
|
61370
|
+
}
|
|
61371
|
+
}
|
|
61277
61372
|
}
|
|
61278
61373
|
}
|
|
61279
61374
|
}
|
|
@@ -62486,7 +62581,9 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
62486
62581
|
return true;
|
|
62487
62582
|
};
|
|
62488
62583
|
const writePrunedObject = (obj, outFile) => {
|
|
62489
|
-
const
|
|
62584
|
+
const cached5 = objectBytes.get(obj);
|
|
62585
|
+
const buf = cached5 ? new Uint8Array(cached5) : new Uint8Array(import_node_fs58.default.readFileSync(obj.file));
|
|
62586
|
+
const rawBuf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
62490
62587
|
const inputSha256 = link ? (0, import_node_crypto30.createHash)("sha256").update(buf).digest("hex") : "";
|
|
62491
62588
|
const fLive = liveFuncs.get(obj);
|
|
62492
62589
|
const sLive = liveSegs.get(obj);
|
|
@@ -62578,7 +62675,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
62578
62675
|
const end = p + sz;
|
|
62579
62676
|
if (id === 0) {
|
|
62580
62677
|
const [nLen, np] = readULEB2(buf, p);
|
|
62581
|
-
const name3 =
|
|
62678
|
+
const name3 = rawBuf.toString("utf8", np, np + nLen);
|
|
62582
62679
|
const cp = np + nLen;
|
|
62583
62680
|
if (name3 === "linking") {
|
|
62584
62681
|
const [, lpStart] = readULEB2(buf, cp);
|
|
@@ -62840,7 +62937,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
62840
62937
|
);
|
|
62841
62938
|
import_node_fs58.default.rmSync(rspPath, { force: true });
|
|
62842
62939
|
}
|
|
62843
|
-
var import_node_child_process27, import_node_crypto30, import_node_fs58, import_node_path57, v3, WIDE_DATA_RELOCS, ROOT_SEG_PREFIXES, RECORD_SEGS, PARTITIONED_SEGS, PRUNED_SDK_ARCHIVES, OMIT_SDK_LIB_FLAGS, NEUTRALIZED_SWIFTRT_SECTIONS, relocationBytes, parsedObjectCache, PARSED_ROOTS, SWIFTUI_WRAPPER_HOST_PROTOCOLS, SWIFT_PRUNED_LINK_MAP, SWIFT_PRUNED_LINK_RESPONSE;
|
|
62940
|
+
var import_node_child_process27, import_node_crypto30, import_node_fs58, import_node_path57, v3, WIDE_DATA_RELOCS, ROOT_SEG_PREFIXES, RECORD_SEGS, PARTITIONED_SEGS, PRUNED_SDK_ARCHIVES, OMIT_SDK_LIB_FLAGS, NEUTRALIZED_SWIFTRT_SECTIONS, ADDEND_RELOC_MASK2, relocationBytes, parsedObjectCache, PARSED_ROOTS, SWIFTUI_WRAPPER_HOST_PROTOCOLS, SWIFT_PRUNED_LINK_MAP, SWIFT_PRUNED_LINK_RESPONSE;
|
|
62844
62941
|
var init_swift_wasm_prune = __esm({
|
|
62845
62942
|
"src/swift-wasm-prune.ts"() {
|
|
62846
62943
|
"use strict";
|
|
@@ -62920,6 +63017,8 @@ var init_swift_wasm_prune = __esm({
|
|
|
62920
63017
|
"swift5_reflstr",
|
|
62921
63018
|
"swift5_typeref"
|
|
62922
63019
|
]);
|
|
63020
|
+
ADDEND_RELOC_MASK2 = 0;
|
|
63021
|
+
for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK2 |= 1 << type;
|
|
62923
63022
|
relocationBytes = (relocs, i) => relocs.bytes.subarray(relocs.start[i], relocs.end[i]);
|
|
62924
63023
|
parsedObjectCache = /* @__PURE__ */ new Map();
|
|
62925
63024
|
PARSED_ROOTS = 2;
|
|
@@ -63544,7 +63643,7 @@ function llvmType(value) {
|
|
|
63544
63643
|
function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options2 = {}) {
|
|
63545
63644
|
if (!isWasmMagic(bytes)) throw new Error("expected wasm object");
|
|
63546
63645
|
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
63547
|
-
const { sdkLookupOnly, sdkProduct } = options2;
|
|
63646
|
+
const { sdkLookupOnly, sdkProduct, collectRewrittenSymbols } = options2;
|
|
63548
63647
|
const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
|
|
63549
63648
|
const rewrite = binding !== void 0;
|
|
63550
63649
|
const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
|
|
@@ -63553,6 +63652,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63553
63652
|
const definitions = [];
|
|
63554
63653
|
const functionImports = /* @__PURE__ */ new Map();
|
|
63555
63654
|
const functionImportNames = [];
|
|
63655
|
+
const tableImportNames = [];
|
|
63656
|
+
const globalImportNames = [];
|
|
63657
|
+
const eventImportNames = [];
|
|
63556
63658
|
const functionSymbols = [];
|
|
63557
63659
|
const addressTaken = /* @__PURE__ */ new Set();
|
|
63558
63660
|
let usesDlsym = false;
|
|
@@ -63674,12 +63776,18 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63674
63776
|
if (isDlsym) usesDlsym = true;
|
|
63675
63777
|
if (isDlerror) usesDlerror = true;
|
|
63676
63778
|
if (importWriter && binding) {
|
|
63779
|
+
const rewrittenName = isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3;
|
|
63677
63780
|
importWriter.string(module2);
|
|
63678
|
-
importWriter.string(
|
|
63679
|
-
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3
|
|
63680
|
-
);
|
|
63781
|
+
importWriter.string(rewrittenName);
|
|
63681
63782
|
importWriter.byte(kind);
|
|
63682
63783
|
importWriter.bytes(bytes, typeStart, offset);
|
|
63784
|
+
if (collectRewrittenSymbols) {
|
|
63785
|
+
if (kind === 0)
|
|
63786
|
+
functionImportNames[functionImportNames.length - 1] = rewrittenName;
|
|
63787
|
+
else if (kind === 1) tableImportNames.push(rewrittenName);
|
|
63788
|
+
else if (kind === 3) globalImportNames.push(rewrittenName);
|
|
63789
|
+
else if (kind === 4) eventImportNames.push(rewrittenName);
|
|
63790
|
+
}
|
|
63683
63791
|
}
|
|
63684
63792
|
}
|
|
63685
63793
|
if (offset !== end) throw new Error("invalid wasm import section");
|
|
@@ -63762,13 +63870,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63762
63870
|
if (!rewrite && flags & 16 && symbolKind === 1 && alias)
|
|
63763
63871
|
usedSymbols.add(name3);
|
|
63764
63872
|
if (entryWriter && binding) {
|
|
63873
|
+
let rewrittenSym = name3;
|
|
63874
|
+
let addedCanonical;
|
|
63765
63875
|
if ((name3 === "dlsym" && usesDlsym || name3 === "dlerror" && usesDlerror) && flags & 16 && flags & 64 && symbolKind === 0) {
|
|
63876
|
+
rewrittenSym = name3 === "dlsym" ? callerAlias : dlerrorAlias;
|
|
63766
63877
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
63767
|
-
entryWriter.string(
|
|
63878
|
+
entryWriter.string(rewrittenSym);
|
|
63768
63879
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
63769
63880
|
} else if (flags & 16 && name3 !== "dlsym" && name3 !== "dlerror" && binding(name3) !== void 0) {
|
|
63881
|
+
rewrittenSym = binding(name3);
|
|
63770
63882
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
63771
|
-
entryWriter.string(
|
|
63883
|
+
entryWriter.string(rewrittenSym);
|
|
63772
63884
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
63773
63885
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
63774
63886
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
@@ -63782,7 +63894,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63782
63894
|
extraWriter.string(alias);
|
|
63783
63895
|
extraWriter.bytes(bytes, nameEnd, offset);
|
|
63784
63896
|
added++;
|
|
63897
|
+
addedCanonical = alias;
|
|
63785
63898
|
} else {
|
|
63899
|
+
rewrittenSym = alias;
|
|
63786
63900
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
63787
63901
|
entryWriter.string(alias);
|
|
63788
63902
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
@@ -63790,6 +63904,16 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63790
63904
|
} else {
|
|
63791
63905
|
entryWriter.bytes(bytes, begin, offset);
|
|
63792
63906
|
}
|
|
63907
|
+
if (collectRewrittenSymbols) {
|
|
63908
|
+
if (flags & 16) {
|
|
63909
|
+
const resolved = flags & 64 || symbolKind === 1 ? rewrittenSym : symbolKind === 0 ? functionImportNames[index] ?? "" : symbolKind === 2 ? globalImportNames[index] ?? "" : symbolKind === 4 ? eventImportNames[index] ?? "" : symbolKind === 5 ? tableImportNames[index] ?? "" : "";
|
|
63910
|
+
if (resolved) collectRewrittenSymbols.referenced.add(resolved);
|
|
63911
|
+
} else if ((flags & 3) !== 2) {
|
|
63912
|
+
if (rewrittenSym) collectRewrittenSymbols.defined.add(rewrittenSym);
|
|
63913
|
+
if (addedCanonical)
|
|
63914
|
+
collectRewrittenSymbols.defined.add(addedCanonical);
|
|
63915
|
+
}
|
|
63916
|
+
}
|
|
63793
63917
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
63794
63918
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
63795
63919
|
throw new Error(`unsupported symbol ${name3}`);
|
|
@@ -64153,6 +64277,7 @@ function createGuestImageLedger(input) {
|
|
|
64153
64277
|
sdkGlobalBindings.set(name3, first.alias);
|
|
64154
64278
|
}
|
|
64155
64279
|
}
|
|
64280
|
+
const appSymbols = input.registerAppTables ? { referenced: /* @__PURE__ */ new Set(), defined: /* @__PURE__ */ new Set() } : void 0;
|
|
64156
64281
|
const objects = units.map(({ image, object: object9, aliases, functionImports }) => {
|
|
64157
64282
|
const shared = sharedLookupByImage.get(image);
|
|
64158
64283
|
const own2 = startup.get(object9.path);
|
|
@@ -64187,7 +64312,10 @@ function createGuestImageLedger(input) {
|
|
|
64187
64312
|
binding,
|
|
64188
64313
|
object9.instrumentDynamicLookups,
|
|
64189
64314
|
preserveCanonical,
|
|
64190
|
-
{
|
|
64315
|
+
{
|
|
64316
|
+
sdkProduct: object9.sdkProduct,
|
|
64317
|
+
collectRewrittenSymbols: object9.sdkProduct === void 0 ? appSymbols : void 0
|
|
64318
|
+
}
|
|
64191
64319
|
).bytes
|
|
64192
64320
|
};
|
|
64193
64321
|
});
|
|
@@ -64308,7 +64436,9 @@ function createGuestImageLedger(input) {
|
|
|
64308
64436
|
llvmIR: render2(false, lazy),
|
|
64309
64437
|
lazyFunctions: lazy,
|
|
64310
64438
|
appLLVMIR: appLazy && render2(true, appLazy),
|
|
64311
|
-
appLazyFunctions: appLazy
|
|
64439
|
+
appLazyFunctions: appLazy,
|
|
64440
|
+
appReferencedSymbols: appSymbols?.referenced,
|
|
64441
|
+
appDefinedSymbols: appSymbols?.defined
|
|
64312
64442
|
};
|
|
64313
64443
|
}
|
|
64314
64444
|
function guestLazyFunctionRuntime(count) {
|
|
@@ -65202,6 +65332,26 @@ function selectedGuestManifestInputs(plan, selection, identities, readSelected)
|
|
|
65202
65332
|
}
|
|
65203
65333
|
return images;
|
|
65204
65334
|
}
|
|
65335
|
+
function framedLinkOptions(options2) {
|
|
65336
|
+
const cached5 = framedLinkOptionsCache.get(options2);
|
|
65337
|
+
if (cached5) return cached5;
|
|
65338
|
+
const parts2 = new Array(options2.length * 2 + 2);
|
|
65339
|
+
const count = Buffer.from(String(options2.length), "utf8");
|
|
65340
|
+
const countSize = Buffer.allocUnsafe(8);
|
|
65341
|
+
countSize.writeBigUInt64BE(BigInt(count.byteLength));
|
|
65342
|
+
parts2[0] = countSize;
|
|
65343
|
+
parts2[1] = count;
|
|
65344
|
+
for (let i = 0; i < options2.length; i++) {
|
|
65345
|
+
const encoded = Buffer.from(options2[i], "utf8");
|
|
65346
|
+
const size2 = Buffer.allocUnsafe(8);
|
|
65347
|
+
size2.writeBigUInt64BE(BigInt(encoded.byteLength));
|
|
65348
|
+
parts2[i * 2 + 2] = size2;
|
|
65349
|
+
parts2[i * 2 + 3] = encoded;
|
|
65350
|
+
}
|
|
65351
|
+
const framed = Buffer.concat(parts2);
|
|
65352
|
+
framedLinkOptionsCache.set(options2, framed);
|
|
65353
|
+
return framed;
|
|
65354
|
+
}
|
|
65205
65355
|
function createGuestImageManifest(image) {
|
|
65206
65356
|
const target = {
|
|
65207
65357
|
triple: SWIFT_WASM_TRIPLE,
|
|
@@ -65211,10 +65361,10 @@ function createGuestImageManifest(image) {
|
|
|
65211
65361
|
cpuSubtype: 0
|
|
65212
65362
|
};
|
|
65213
65363
|
const digest3 = (0, import_node_crypto34.createHash)("sha256");
|
|
65364
|
+
const sizeBuf = Buffer.allocUnsafe(8);
|
|
65214
65365
|
const add2 = (bytes) => {
|
|
65215
|
-
|
|
65216
|
-
|
|
65217
|
-
digest3.update(size2);
|
|
65366
|
+
sizeBuf.writeBigUInt64BE(BigInt(bytes.byteLength));
|
|
65367
|
+
digest3.update(sizeBuf);
|
|
65218
65368
|
digest3.update(bytes);
|
|
65219
65369
|
};
|
|
65220
65370
|
const text7 = (value) => add2(Buffer.from(value, "utf8"));
|
|
@@ -65231,8 +65381,7 @@ function createGuestImageManifest(image) {
|
|
|
65231
65381
|
`${version2.platform}:${version2.minimum.major}:${version2.minimum.minor}:${version2.minimum.patch}`
|
|
65232
65382
|
);
|
|
65233
65383
|
text7(`${version2.sdk.major}:${version2.sdk.minor}:${version2.sdk.patch}`);
|
|
65234
|
-
|
|
65235
|
-
for (const option2 of image.linkOptions) text7(option2);
|
|
65384
|
+
digest3.update(framedLinkOptions(image.linkOptions));
|
|
65236
65385
|
text7(String(image.inputs.length));
|
|
65237
65386
|
for (const input of image.inputs) {
|
|
65238
65387
|
text7(input.identity);
|
|
@@ -65253,7 +65402,7 @@ function createGuestImageManifest(image) {
|
|
|
65253
65402
|
regions: image.regions
|
|
65254
65403
|
};
|
|
65255
65404
|
}
|
|
65256
|
-
var import_node_crypto34, import_node_fs60;
|
|
65405
|
+
var import_node_crypto34, import_node_fs60, framedLinkOptionsCache;
|
|
65257
65406
|
var init_swift_guest_manifest = __esm({
|
|
65258
65407
|
"src/swift-guest-manifest.ts"() {
|
|
65259
65408
|
"use strict";
|
|
@@ -65262,6 +65411,7 @@ var init_swift_guest_manifest = __esm({
|
|
|
65262
65411
|
init_swift_guest_link_plan();
|
|
65263
65412
|
init_swift_wasm_prune();
|
|
65264
65413
|
init_swiftTargetContract();
|
|
65414
|
+
framedLinkOptionsCache = /* @__PURE__ */ new WeakMap();
|
|
65265
65415
|
}
|
|
65266
65416
|
});
|
|
65267
65417
|
|
|
@@ -66564,7 +66714,7 @@ var init_wasm_optimize = __esm({
|
|
|
66564
66714
|
];
|
|
66565
66715
|
BINARYEN_VERSION = binaryen_lock_default.version;
|
|
66566
66716
|
runBinaryen = (0, import_node_util5.promisify)(import_node_child_process29.execFile);
|
|
66567
|
-
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`;
|
|
66717
|
+
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`;
|
|
66568
66718
|
BINARYEN_RELEASES = new Map(Object.entries(binaryen_lock_default.platforms));
|
|
66569
66719
|
}
|
|
66570
66720
|
});
|
|
@@ -67009,6 +67159,7 @@ function linkGuestImages(options2) {
|
|
|
67009
67159
|
const ledgerObjects = new Map(ledger.objects.map((item) => [item.path, item]));
|
|
67010
67160
|
const appObjects = /* @__PURE__ */ new Map();
|
|
67011
67161
|
const sdkObjects = /* @__PURE__ */ new Map();
|
|
67162
|
+
const finalArchives = /* @__PURE__ */ new Map();
|
|
67012
67163
|
for (const [index, artifact] of plan.artifacts.entries()) {
|
|
67013
67164
|
const prefix = `${artifact.path}(`;
|
|
67014
67165
|
if (artifact.kind === "object") {
|
|
@@ -67062,6 +67213,10 @@ function linkGuestImages(options2) {
|
|
|
67062
67213
|
const response = import_node_path61.default.join(memberDir, "members.rsp");
|
|
67063
67214
|
import_node_fs63.default.writeFileSync(response, inputs2.map((input) => JSON.stringify(input)).join(" "));
|
|
67064
67215
|
(0, import_node_child_process30.execFileSync)(llvmAr, ["rcs", output, `@${response}`], { stdio: "pipe" });
|
|
67216
|
+
finalArchives.set(
|
|
67217
|
+
output,
|
|
67218
|
+
members2.map((member) => ({ name: member.name, bytes: new Uint8Array(0) }))
|
|
67219
|
+
);
|
|
67065
67220
|
replacements.set(artifact.path, output);
|
|
67066
67221
|
}
|
|
67067
67222
|
const compileLedger = (name3, source) => {
|
|
@@ -67193,7 +67348,8 @@ function linkGuestImages(options2) {
|
|
|
67193
67348
|
remapGuestLinkPlan(plan, replacements),
|
|
67194
67349
|
finalArgs,
|
|
67195
67350
|
import_node_fs63.default.readFileSync(finalWhy, "utf8"),
|
|
67196
|
-
finalTrace
|
|
67351
|
+
finalTrace,
|
|
67352
|
+
finalArchives
|
|
67197
67353
|
);
|
|
67198
67354
|
const original = new Map([...replacements].map(([before2, after2]) => [after2, before2]));
|
|
67199
67355
|
const key2 = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
|
|
@@ -67226,12 +67382,25 @@ ${changed2.join("\n")}`
|
|
|
67226
67382
|
])
|
|
67227
67383
|
);
|
|
67228
67384
|
appObjects.set(appLedgerObject, options2.ledgerDataImage);
|
|
67385
|
+
let appReferencedSymbols;
|
|
67386
|
+
let appDefinedSymbols;
|
|
67387
|
+
if (ledger.appReferencedSymbols && ledger.appDefinedSymbols) {
|
|
67388
|
+
const referenced = new Set(ledger.appReferencedSymbols);
|
|
67389
|
+
const defined = new Set(ledger.appDefinedSymbols);
|
|
67390
|
+
const ledgerSyms = guestWasmSymbols(import_node_fs63.default.readFileSync(appLedgerObject));
|
|
67391
|
+
for (const name3 of ledgerSyms.undefined) referenced.add(name3);
|
|
67392
|
+
for (const name3 of ledgerSyms.defined) defined.add(name3);
|
|
67393
|
+
appReferencedSymbols = referenced;
|
|
67394
|
+
appDefinedSymbols = defined;
|
|
67395
|
+
}
|
|
67229
67396
|
options2.onSplitInputs({
|
|
67230
67397
|
appObjects,
|
|
67231
67398
|
appSections,
|
|
67232
67399
|
sdkObjects,
|
|
67233
67400
|
lazyFunctions: ledger.appLazyFunctions ?? [],
|
|
67234
|
-
dyldSymbols: ledger.dyldSymbols
|
|
67401
|
+
dyldSymbols: ledger.dyldSymbols,
|
|
67402
|
+
appReferencedSymbols,
|
|
67403
|
+
appDefinedSymbols
|
|
67235
67404
|
});
|
|
67236
67405
|
}
|
|
67237
67406
|
return selected;
|
|
@@ -68214,6 +68383,93 @@ function sourceGuestInputIdentities(graph, buildDirectory, objects) {
|
|
|
68214
68383
|
}
|
|
68215
68384
|
return identities;
|
|
68216
68385
|
}
|
|
68386
|
+
function wasmAutolinkEntries(bytes, out) {
|
|
68387
|
+
if (bytes.length < 8) return false;
|
|
68388
|
+
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) {
|
|
68389
|
+
for (const member of readArMembers(bytes)) {
|
|
68390
|
+
if (!wasmAutolinkEntries(member.bytes, out)) return false;
|
|
68391
|
+
}
|
|
68392
|
+
return true;
|
|
68393
|
+
}
|
|
68394
|
+
if (bytes[0] !== 0 || bytes[1] !== 97 || bytes[2] !== 115 || bytes[3] !== 109)
|
|
68395
|
+
return false;
|
|
68396
|
+
const raw2 = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
68397
|
+
let pos = 8;
|
|
68398
|
+
const len = bytes.length;
|
|
68399
|
+
while (pos < len) {
|
|
68400
|
+
const id = bytes[pos++];
|
|
68401
|
+
let sz = bytes[pos++];
|
|
68402
|
+
if (sz >= 128) {
|
|
68403
|
+
sz &= 127;
|
|
68404
|
+
let shift = 7;
|
|
68405
|
+
while (true) {
|
|
68406
|
+
const b = bytes[pos++];
|
|
68407
|
+
sz |= (b & 127) << shift;
|
|
68408
|
+
if (b < 128) break;
|
|
68409
|
+
shift += 7;
|
|
68410
|
+
}
|
|
68411
|
+
}
|
|
68412
|
+
const end = pos + sz;
|
|
68413
|
+
if (id === 0) {
|
|
68414
|
+
let nLen = bytes[pos++];
|
|
68415
|
+
if (nLen >= 128) {
|
|
68416
|
+
nLen &= 127;
|
|
68417
|
+
let shift = 7;
|
|
68418
|
+
while (true) {
|
|
68419
|
+
const b = bytes[pos++];
|
|
68420
|
+
nLen |= (b & 127) << shift;
|
|
68421
|
+
if (b < 128) break;
|
|
68422
|
+
shift += 7;
|
|
68423
|
+
}
|
|
68424
|
+
}
|
|
68425
|
+
if (nLen === 24 && raw2.toString("ascii", pos, pos + 24) === ".swift1_autolink_entries") {
|
|
68426
|
+
const payload = raw2.toString("utf8", pos + 24, end);
|
|
68427
|
+
for (const entry of payload.split("\0")) {
|
|
68428
|
+
const trimmed = entry.trim();
|
|
68429
|
+
if (trimmed.length > 0) out.push(trimmed);
|
|
68430
|
+
}
|
|
68431
|
+
}
|
|
68432
|
+
}
|
|
68433
|
+
pos = end;
|
|
68434
|
+
}
|
|
68435
|
+
return true;
|
|
68436
|
+
}
|
|
68437
|
+
function readAutolinkFlags(objects, toolchainBin, responsePath) {
|
|
68438
|
+
if (!objects.length) return [];
|
|
68439
|
+
const rawFlags = [];
|
|
68440
|
+
for (const file of objects) {
|
|
68441
|
+
if (!wasmAutolinkEntries((0, import_node_fs64.readFileSync)(file), rawFlags)) {
|
|
68442
|
+
(0, import_node_fs64.writeFileSync)(
|
|
68443
|
+
responsePath,
|
|
68444
|
+
objects.map((entry) => JSON.stringify(entry)).join("\n") + "\n"
|
|
68445
|
+
);
|
|
68446
|
+
return (0, import_node_child_process31.execFileSync)(
|
|
68447
|
+
import_node_path62.default.join(toolchainBin, "swift-autolink-extract"),
|
|
68448
|
+
[`@${responsePath}`, "-o", "-"],
|
|
68449
|
+
{ encoding: "utf8" }
|
|
68450
|
+
).split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
68451
|
+
}
|
|
68452
|
+
}
|
|
68453
|
+
const seen = /* @__PURE__ */ new Set();
|
|
68454
|
+
const flags = [];
|
|
68455
|
+
for (let i = 0; i < rawFlags.length; i++) {
|
|
68456
|
+
const flag = rawFlags[i];
|
|
68457
|
+
if ((flag === "-framework" || flag === "-weak_framework" || flag === "-l" || flag === "--library") && i + 1 < rawFlags.length) {
|
|
68458
|
+
const value = rawFlags[++i];
|
|
68459
|
+
const key2 = `${flag}\0${value}`;
|
|
68460
|
+
if (!seen.has(key2)) {
|
|
68461
|
+
seen.add(key2);
|
|
68462
|
+
flags.push(flag, value);
|
|
68463
|
+
}
|
|
68464
|
+
continue;
|
|
68465
|
+
}
|
|
68466
|
+
if (!seen.has(flag)) {
|
|
68467
|
+
seen.add(flag);
|
|
68468
|
+
flags.push(flag);
|
|
68469
|
+
}
|
|
68470
|
+
}
|
|
68471
|
+
return flags;
|
|
68472
|
+
}
|
|
68217
68473
|
function sourceGuestRuntimeLinks(options2) {
|
|
68218
68474
|
const aliases = /* @__PURE__ */ new Map();
|
|
68219
68475
|
const artifacts = /* @__PURE__ */ new Map();
|
|
@@ -68301,15 +68557,7 @@ function sourceGuestRuntimeLinks(options2) {
|
|
|
68301
68557
|
for (const image of options2.images) {
|
|
68302
68558
|
if (result.has(image.id)) throw new Error(`duplicate source image ${image.id}`);
|
|
68303
68559
|
const response = import_node_path62.default.join(options2.directory, `image-${image.id}-autolink.rsp`);
|
|
68304
|
-
(
|
|
68305
|
-
response,
|
|
68306
|
-
image.objects.map((file) => JSON.stringify(file)).join("\n") + "\n"
|
|
68307
|
-
);
|
|
68308
|
-
const autolink = image.objects.length ? (0, import_node_child_process31.execFileSync)(
|
|
68309
|
-
import_node_path62.default.join(options2.toolchainBin, "swift-autolink-extract"),
|
|
68310
|
-
[`@${response}`, "-o", "-"],
|
|
68311
|
-
{ encoding: "utf8" }
|
|
68312
|
-
).split("\n").map((line) => line.trim()).filter((line) => line.length > 0) : [];
|
|
68560
|
+
const autolink = readAutolinkFlags(image.objects, options2.toolchainBin, response);
|
|
68313
68561
|
const links = [];
|
|
68314
68562
|
const requests2 = [];
|
|
68315
68563
|
const optionGroups = [
|
|
@@ -68409,6 +68657,7 @@ var init_swift_guest_source_inputs = __esm({
|
|
|
68409
68657
|
init_forked_script_contract();
|
|
68410
68658
|
init_swift_guest_source_plan();
|
|
68411
68659
|
init_swift_runtime_products();
|
|
68660
|
+
init_swift_wasm_prune();
|
|
68412
68661
|
CLANG_TARGET_MODULE_WRAPPER = ".peach-clang";
|
|
68413
68662
|
PARALLEL_REPLAY = `
|
|
68414
68663
|
const { spawn } = require('node:child_process')
|
|
@@ -71935,9 +72184,10 @@ function sdkHostExports(appRoot) {
|
|
|
71935
72184
|
if (!(byte & 128)) return value;
|
|
71936
72185
|
}
|
|
71937
72186
|
};
|
|
72187
|
+
const raw2 = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
71938
72188
|
for (let n = u(); n > 0; n--) {
|
|
71939
72189
|
const length = u();
|
|
71940
|
-
names.push(
|
|
72190
|
+
names.push(raw2.toString("utf8", at, at + length));
|
|
71941
72191
|
at += length + 1;
|
|
71942
72192
|
u();
|
|
71943
72193
|
}
|
|
@@ -72481,56 +72731,109 @@ function swiftAppModuleInputs(tokens2, buildRoot, sdkLibraries) {
|
|
|
72481
72731
|
}
|
|
72482
72732
|
return inputs2;
|
|
72483
72733
|
}
|
|
72484
|
-
|
|
72734
|
+
function llvmQuoted(value) {
|
|
72735
|
+
const bytes = Buffer.from(value, "utf8");
|
|
72736
|
+
let out = '"';
|
|
72737
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
72738
|
+
const b = bytes[i];
|
|
72739
|
+
if (b >= 32 && b <= 126 && b !== 34 && b !== 92) out += String.fromCharCode(b);
|
|
72740
|
+
else out += `\\${b.toString(16).toUpperCase().padStart(2, "0")}`;
|
|
72741
|
+
}
|
|
72742
|
+
return out + '"';
|
|
72743
|
+
}
|
|
72744
|
+
async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project2, readInput, precomputedSymbols) {
|
|
72485
72745
|
const { signatures, tls } = sdk2.sdkInterface;
|
|
72486
|
-
|
|
72487
|
-
|
|
72488
|
-
|
|
72489
|
-
|
|
72490
|
-
|
|
72491
|
-
|
|
72492
|
-
|
|
72746
|
+
let referenced;
|
|
72747
|
+
let defined;
|
|
72748
|
+
if (precomputedSymbols) {
|
|
72749
|
+
referenced = precomputedSymbols.referenced;
|
|
72750
|
+
defined = precomputedSymbols.defined;
|
|
72751
|
+
} else {
|
|
72752
|
+
const directories = inputs2.filter((input) => input.startsWith("-L")).map((input) => input.slice(2));
|
|
72753
|
+
const refSet = /* @__PURE__ */ new Set();
|
|
72754
|
+
const defSet = /* @__PURE__ */ new Set();
|
|
72755
|
+
const scan3 = (bytes) => {
|
|
72756
|
+
const symbols = guestWasmSymbols(bytes);
|
|
72757
|
+
for (const name3 of symbols.undefined) refSet.add(name3);
|
|
72758
|
+
for (const name3 of symbols.defined) defSet.add(name3);
|
|
72759
|
+
};
|
|
72760
|
+
for (const input of inputs2) {
|
|
72761
|
+
const file = input.startsWith("-l") ? directories.map((directory2) => import_node_path71.default.join(directory2, `lib${input.slice(2)}.a`)).find((candidate) => (0, import_node_fs73.existsSync)(candidate)) : input.startsWith("-") ? void 0 : input;
|
|
72762
|
+
if (!file) continue;
|
|
72763
|
+
const bytes = readInput(file);
|
|
72764
|
+
if (file.endsWith(".a"))
|
|
72765
|
+
for (const member of readArMembers(bytes)) scan3(member.bytes);
|
|
72766
|
+
else scan3(bytes);
|
|
72767
|
+
}
|
|
72768
|
+
referenced = refSet;
|
|
72769
|
+
defined = defSet;
|
|
72770
|
+
}
|
|
72771
|
+
const irType = {
|
|
72772
|
+
i: "i32",
|
|
72773
|
+
j: "i64",
|
|
72774
|
+
f: "float",
|
|
72775
|
+
d: "double"
|
|
72776
|
+
};
|
|
72777
|
+
const type = (kinds) => {
|
|
72778
|
+
const out = new Array(kinds.length);
|
|
72779
|
+
for (let i = 0; i < kinds.length; i++) {
|
|
72780
|
+
const kind = kinds[i];
|
|
72781
|
+
const name3 = irType[kind];
|
|
72782
|
+
if (!name3) throw new Error(`sdk signature kind ${kind}`);
|
|
72783
|
+
out[i] = name3;
|
|
72784
|
+
}
|
|
72785
|
+
return out;
|
|
72493
72786
|
};
|
|
72494
|
-
|
|
72495
|
-
|
|
72496
|
-
|
|
72497
|
-
const
|
|
72498
|
-
|
|
72499
|
-
|
|
72500
|
-
|
|
72501
|
-
|
|
72502
|
-
|
|
72503
|
-
|
|
72504
|
-
|
|
72505
|
-
return name3;
|
|
72506
|
-
});
|
|
72507
|
-
const literal6 = (name3) => JSON.stringify(name3);
|
|
72508
|
-
const lines = [];
|
|
72509
|
-
if (signatures.__objc_send_load_messages === ":")
|
|
72787
|
+
const lines = [`target triple = "${SWIFT_WASM_TRIPLE}"`];
|
|
72788
|
+
const attrs = [];
|
|
72789
|
+
const addImportAttr = (name3) => {
|
|
72790
|
+
const id = attrs.length;
|
|
72791
|
+
attrs.push(
|
|
72792
|
+
`attributes #${id} = { "wasm-import-module"="env" "wasm-import-name"=${llvmQuoted(name3)} }`
|
|
72793
|
+
);
|
|
72794
|
+
return id;
|
|
72795
|
+
};
|
|
72796
|
+
if (signatures.__objc_send_load_messages === ":") {
|
|
72797
|
+
const attr = addImportAttr("__objc_send_load_messages");
|
|
72510
72798
|
lines.push(
|
|
72511
|
-
|
|
72512
|
-
|
|
72799
|
+
"@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @send_app_load_messages, ptr null }]",
|
|
72800
|
+
`declare void @sdk_send_load_messages() #${attr}`,
|
|
72801
|
+
"define internal void @send_app_load_messages() {",
|
|
72802
|
+
" tail call void @sdk_send_load_messages()",
|
|
72803
|
+
" ret void",
|
|
72804
|
+
"}"
|
|
72513
72805
|
);
|
|
72806
|
+
}
|
|
72514
72807
|
const forwarders = /* @__PURE__ */ new Set();
|
|
72515
72808
|
let index = 0;
|
|
72516
72809
|
for (const name3 of referenced) {
|
|
72517
72810
|
const signature2 = signatures[name3];
|
|
72518
72811
|
if (signature2 === void 0 || defined.has(name3)) continue;
|
|
72519
|
-
const
|
|
72812
|
+
const colon = signature2.indexOf(":");
|
|
72813
|
+
const params = colon < 0 ? signature2 : signature2.slice(0, colon);
|
|
72814
|
+
const results = colon < 0 ? "" : signature2.slice(colon + 1);
|
|
72520
72815
|
if (results.length > 1) throw new Error(`sdk function ${name3} returns several values`);
|
|
72521
72816
|
const result = results ? type(results)[0] : "void";
|
|
72522
|
-
const
|
|
72523
|
-
const
|
|
72817
|
+
const paramTypes = type(params);
|
|
72818
|
+
const declParams = paramTypes.join(", ");
|
|
72819
|
+
const defParams = paramTypes.map((kind, at) => `${kind} %a${at}`).join(", ");
|
|
72820
|
+
const callArgs = paramTypes.map((kind, at) => `${kind} %a${at}`).join(", ");
|
|
72821
|
+
const attr = addImportAttr(name3);
|
|
72822
|
+
const quoted2 = llvmQuoted(name3);
|
|
72524
72823
|
lines.push(
|
|
72525
|
-
`
|
|
72526
|
-
`
|
|
72527
|
-
|
|
72824
|
+
`declare ${result} @i${index}(${declParams}) #${attr}`,
|
|
72825
|
+
`define weak hidden ${result} @${quoted2}(${defParams}) {`,
|
|
72826
|
+
result === "void" ? ` tail call void @i${index}(${callArgs})
|
|
72827
|
+
ret void` : ` %r = tail call ${result} @i${index}(${callArgs})
|
|
72828
|
+
ret ${result} %r`,
|
|
72829
|
+
"}"
|
|
72528
72830
|
);
|
|
72529
72831
|
forwarders.add(name3);
|
|
72530
72832
|
index++;
|
|
72531
72833
|
}
|
|
72532
72834
|
const errno = tls.errno;
|
|
72533
72835
|
let declaredErrno = false;
|
|
72836
|
+
const usedHelpers = [];
|
|
72534
72837
|
for (const name3 of referenced) {
|
|
72535
72838
|
const offset = tls[name3];
|
|
72536
72839
|
if (offset === void 0 || defined.has(name3)) continue;
|
|
@@ -72538,28 +72841,44 @@ async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project
|
|
|
72538
72841
|
throw new Error("the sdk image has no errno to find its thread block by");
|
|
72539
72842
|
if (!declaredErrno) {
|
|
72540
72843
|
declaredErrno = true;
|
|
72844
|
+
const attr = addImportAttr("__errno_location");
|
|
72541
72845
|
lines.push(
|
|
72542
|
-
`
|
|
72846
|
+
`declare ptr @__peach_errno() #${attr}`,
|
|
72847
|
+
"declare ptr @llvm.wasm.tls.base()"
|
|
72543
72848
|
);
|
|
72544
72849
|
}
|
|
72850
|
+
const helper = `@${llvmQuoted(SDK_TLS_HELPER + name3)}`;
|
|
72851
|
+
const delta = `@${llvmQuoted(SDK_TLS_DELTA + name3)}`;
|
|
72852
|
+
usedHelpers.push(`ptr ${helper}`);
|
|
72545
72853
|
lines.push(
|
|
72546
|
-
|
|
72547
|
-
|
|
72548
|
-
`
|
|
72549
|
-
|
|
72854
|
+
`@${llvmQuoted(name3)} = weak hidden thread_local global i8 0, align 1`,
|
|
72855
|
+
`${delta} = external global i8, align 1`,
|
|
72856
|
+
`define hidden i64 ${helper}() {`,
|
|
72857
|
+
" %e = tail call ptr @__peach_errno()",
|
|
72858
|
+
" %ei = ptrtoint ptr %e to i64",
|
|
72859
|
+
` %di = ptrtoint ptr ${delta} to i64`,
|
|
72860
|
+
" %s = add i64 %ei, %di",
|
|
72861
|
+
" %b = tail call ptr @llvm.wasm.tls.base()",
|
|
72862
|
+
" %bi = ptrtoint ptr %b to i64",
|
|
72863
|
+
" %r = sub i64 %s, %bi",
|
|
72864
|
+
" ret i64 %r",
|
|
72865
|
+
"}"
|
|
72550
72866
|
);
|
|
72551
72867
|
index++;
|
|
72552
72868
|
}
|
|
72553
|
-
|
|
72554
|
-
|
|
72869
|
+
if (usedHelpers.length > 0) {
|
|
72870
|
+
lines.push(
|
|
72871
|
+
`@llvm.used = appending global [${usedHelpers.length} x ptr] [${usedHelpers.join(", ")}], section "llvm.metadata"`
|
|
72872
|
+
);
|
|
72873
|
+
}
|
|
72874
|
+
const source = `${output.slice(0, -2)}.ll`;
|
|
72875
|
+
(0, import_node_fs73.writeFileSync)(source, [...lines, ...attrs].join("\n") + "\n");
|
|
72555
72876
|
await run6(
|
|
72556
72877
|
import_node_path71.default.join(toolchainBin, "clang"),
|
|
72557
72878
|
[
|
|
72558
72879
|
`--target=${SWIFT_WASM_TRIPLE}`,
|
|
72559
|
-
"-O2",
|
|
72560
72880
|
"-matomics",
|
|
72561
72881
|
"-mbulk-memory",
|
|
72562
|
-
"-ffreestanding",
|
|
72563
72882
|
"-c",
|
|
72564
72883
|
source,
|
|
72565
72884
|
"-o",
|
|
@@ -72578,7 +72897,8 @@ async function linkSwiftAppModule(options2) {
|
|
|
72578
72897
|
toolchainBin,
|
|
72579
72898
|
forwarders,
|
|
72580
72899
|
options2.project,
|
|
72581
|
-
options2.readInput ?? import_node_fs73.readFileSync
|
|
72900
|
+
options2.readInput ?? import_node_fs73.readFileSync,
|
|
72901
|
+
options2.precomputedSymbols
|
|
72582
72902
|
);
|
|
72583
72903
|
const lazy = options2.lazyFunctions ?? [];
|
|
72584
72904
|
const lazyExports = import_node_path71.default.join(work, "lazy-exports.rsp");
|
|
@@ -74322,6 +74642,15 @@ async function compileGuestLink(options2) {
|
|
|
74322
74642
|
{ stdio: "pipe" }
|
|
74323
74643
|
);
|
|
74324
74644
|
}
|
|
74645
|
+
let precomputedSymbols;
|
|
74646
|
+
if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
|
|
74647
|
+
const referenced = new Set(splitInputs.appReferencedSymbols);
|
|
74648
|
+
const defined = new Set(splitInputs.appDefinedSymbols);
|
|
74649
|
+
const projSyms = guestWasmSymbols((0, import_node_fs74.readFileSync)(projectionObject));
|
|
74650
|
+
for (const name3 of projSyms.undefined) referenced.add(name3);
|
|
74651
|
+
for (const name3 of projSyms.defined) defined.add(name3);
|
|
74652
|
+
precomputedSymbols = { referenced, defined };
|
|
74653
|
+
}
|
|
74325
74654
|
for (; ; ) {
|
|
74326
74655
|
const link = await linkSwiftAppModule2({
|
|
74327
74656
|
objects: [...owners.keys()],
|
|
@@ -74333,6 +74662,7 @@ async function compileGuestLink(options2) {
|
|
|
74333
74662
|
optimize: options2.optimize,
|
|
74334
74663
|
layoutMap,
|
|
74335
74664
|
project: project2,
|
|
74665
|
+
precomputedSymbols,
|
|
74336
74666
|
loweringCache: project2 ? void 0 : {
|
|
74337
74667
|
file: import_node_path72.default.join(
|
|
74338
74668
|
options2.buildDirectory,
|
|
@@ -74457,6 +74787,7 @@ var init_swift_guest_compile = __esm({
|
|
|
74457
74787
|
init_swift_runtime_products();
|
|
74458
74788
|
init_swift_sdk_guest_lookups();
|
|
74459
74789
|
init_swift_toolchain();
|
|
74790
|
+
init_swift_wasm_prune();
|
|
74460
74791
|
init_swiftTargetContract();
|
|
74461
74792
|
init_wasm_optimize();
|
|
74462
74793
|
}
|
|
@@ -75908,7 +76239,25 @@ function swiftBuildJobs() {
|
|
|
75908
76239
|
return Math.min(cores, memoryJobs);
|
|
75909
76240
|
}
|
|
75910
76241
|
function swiftCompilerJobs() {
|
|
75911
|
-
return Math.min(
|
|
76242
|
+
return Math.min(32, swiftBuildJobs(), Math.max(1, Math.floor(import_node_os16.default.totalmem() / 2 ** 31)));
|
|
76243
|
+
}
|
|
76244
|
+
function swiftCompilerBaseEnv(toolchainBin, sourceEnv, includePeachHome = false) {
|
|
76245
|
+
const env = {};
|
|
76246
|
+
for (const key2 of SWIFT_COMPILER_ENV_KEYS) {
|
|
76247
|
+
const value = sourceEnv[key2];
|
|
76248
|
+
if (value !== void 0) env[key2] = value;
|
|
76249
|
+
}
|
|
76250
|
+
if (includePeachHome && sourceEnv.PEACH_HOME !== void 0)
|
|
76251
|
+
env.PEACH_HOME = sourceEnv.PEACH_HOME;
|
|
76252
|
+
if (process.platform === "linux") {
|
|
76253
|
+
env.LD_LIBRARY_PATH = [
|
|
76254
|
+
import_node_path81.default.resolve(toolchainBin, "../lib/swift/linux"),
|
|
76255
|
+
import_node_path81.default.resolve(toolchainBin, "../lib/swift/host"),
|
|
76256
|
+
sourceEnv.LD_LIBRARY_PATH
|
|
76257
|
+
].filter(Boolean).join(":");
|
|
76258
|
+
}
|
|
76259
|
+
env.PEACH_DEFER_WASM_LINK = "1";
|
|
76260
|
+
return env;
|
|
75912
76261
|
}
|
|
75913
76262
|
function assertSwiftBuildCores() {
|
|
75914
76263
|
const admitted = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
|
|
@@ -77097,10 +77446,22 @@ function emitSwiftPackageManifest(args) {
|
|
|
77097
77446
|
const available2 = distribution.objects.filter(
|
|
77098
77447
|
(object9) => !isProvider(object9) && !replacedObjects.has(object9)
|
|
77099
77448
|
);
|
|
77449
|
+
const targetNamesWithDash = targets.filter((target) => target.name.includes("-")).map((target) => `lib/${target.name}-`);
|
|
77450
|
+
const targetNameSet = new Set(targets.map((target) => target.name));
|
|
77451
|
+
const optionalSet = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...GAME_FAMILY, "PeachBox2D"]);
|
|
77452
|
+
const isTargetObject = (object9) => {
|
|
77453
|
+
const dash = object9.indexOf("-", 4);
|
|
77454
|
+
if (dash > 4 && targetNameSet.has(object9.slice(4, dash))) return true;
|
|
77455
|
+
return targetNamesWithDash.some((prefix) => object9.startsWith(prefix));
|
|
77456
|
+
};
|
|
77457
|
+
const isUnreachedOptional = (object9) => {
|
|
77458
|
+
const dash = object9.indexOf("-", 4);
|
|
77459
|
+
if (dash <= 4) return false;
|
|
77460
|
+
const name3 = object9.slice(4, dash);
|
|
77461
|
+
return optionalSet.has(name3) && !reachedFrameworks.has(name3);
|
|
77462
|
+
};
|
|
77100
77463
|
const objects = available2.filter(
|
|
77101
|
-
(object9) => !
|
|
77102
|
-
(name3) => !object9.startsWith(`lib/${name3}-`) || reachedFrameworks.has(name3)
|
|
77103
|
-
)
|
|
77464
|
+
(object9) => !isTargetObject(object9) && !isUnreachedOptional(object9)
|
|
77104
77465
|
);
|
|
77105
77466
|
const quoted2 = (object9) => `"${import_node_path81.default.join(moduleRoot, object9).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
77106
77467
|
const categoryObjects = new Set(
|
|
@@ -77181,18 +77542,53 @@ function emitSwiftPackageManifest(args) {
|
|
|
77181
77542
|
args.files.set(file, content);
|
|
77182
77543
|
return JSON.stringify([`@${file}`]);
|
|
77183
77544
|
};
|
|
77184
|
-
const
|
|
77185
|
-
|
|
77186
|
-
|
|
77187
|
-
const owner = args.targets.find((other) => other.name === dependency);
|
|
77545
|
+
const targetByName = new Map(targets.map((target) => [target.name, target]));
|
|
77546
|
+
const ownFrameworkDir = /* @__PURE__ */ new Map();
|
|
77547
|
+
for (const target of targets) {
|
|
77188
77548
|
const framework = /^(.*)\/[^/]+\.framework\/Modules$/.exec(
|
|
77189
|
-
|
|
77549
|
+
target.publicHeadersPath ?? ""
|
|
77190
77550
|
);
|
|
77191
|
-
|
|
77192
|
-
|
|
77193
|
-
|
|
77194
|
-
|
|
77195
|
-
|
|
77551
|
+
if (framework)
|
|
77552
|
+
ownFrameworkDir.set(
|
|
77553
|
+
target.name,
|
|
77554
|
+
import_node_path81.default.posix.join(args.root, target.path, framework[1])
|
|
77555
|
+
);
|
|
77556
|
+
}
|
|
77557
|
+
const frameworkDirectoriesCache = /* @__PURE__ */ new Map();
|
|
77558
|
+
const frameworkDirectories = (name3) => {
|
|
77559
|
+
if (ownFrameworkDir.size === 0) return [];
|
|
77560
|
+
const cached5 = frameworkDirectoriesCache.get(name3);
|
|
77561
|
+
if (cached5) return cached5;
|
|
77562
|
+
const dirs = [];
|
|
77563
|
+
const seen = /* @__PURE__ */ new Set();
|
|
77564
|
+
const visit3 = (current2) => {
|
|
77565
|
+
for (const dependency of siblings.get(current2) ?? []) {
|
|
77566
|
+
if (seen.has(dependency)) continue;
|
|
77567
|
+
seen.add(dependency);
|
|
77568
|
+
const dir = ownFrameworkDir.get(dependency);
|
|
77569
|
+
if (dir) dirs.push(dir);
|
|
77570
|
+
visit3(dependency);
|
|
77571
|
+
}
|
|
77572
|
+
};
|
|
77573
|
+
visit3(name3);
|
|
77574
|
+
frameworkDirectoriesCache.set(name3, dirs);
|
|
77575
|
+
return dirs;
|
|
77576
|
+
};
|
|
77577
|
+
const targetSwiftXccFlags = /* @__PURE__ */ new Map();
|
|
77578
|
+
for (const target of targets) {
|
|
77579
|
+
const flags = target.swiftFlags;
|
|
77580
|
+
if (!flags || flags.length === 0) continue;
|
|
77581
|
+
const xcc = [];
|
|
77582
|
+
for (let index = 1; index < flags.length; index++) {
|
|
77583
|
+
if (flags[index - 1] === "-Xcc")
|
|
77584
|
+
xcc.push(flags[index].replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root));
|
|
77585
|
+
}
|
|
77586
|
+
if (xcc.length > 0) targetSwiftXccFlags.set(target.name, xcc);
|
|
77587
|
+
}
|
|
77588
|
+
const binaryImports = args.binaryModules ? `, "-I", ${JSON.stringify(args.binaryModules)}` : "";
|
|
77589
|
+
const sharedImports = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
|
|
77590
|
+
providedModulesPath(args.root, distributionModules, args.moduleExcludes)
|
|
77591
|
+
)}${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("")}` : "");
|
|
77196
77592
|
const frameworkSearchFlags = (target, tool) => frameworkDirectories(target?.name ?? "").map((directory2) => ({
|
|
77197
77593
|
tool,
|
|
77198
77594
|
flags: ["-F", directory2]
|
|
@@ -77241,10 +77637,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
77241
77637
|
const upstream = (target.swiftFlags ?? []).map(
|
|
77242
77638
|
(flag) => `, ${JSON.stringify(flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root))}`
|
|
77243
77639
|
).join("");
|
|
77244
|
-
const
|
|
77245
|
-
const imports2 = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
|
|
77246
|
-
providedModulesPath(args.root, distributionModules, args.moduleExcludes)
|
|
77247
|
-
)}${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("")}` : "");
|
|
77640
|
+
const imports2 = sharedImports;
|
|
77248
77641
|
const nativeFlags = [
|
|
77249
77642
|
...args.nativeFlags?.get(target.name) ?? [],
|
|
77250
77643
|
...args.nativeHeaderFlags ?? []
|
|
@@ -77268,12 +77661,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
77268
77661
|
return map2 ? ["-fmodule-map-file=" + map2] : [];
|
|
77269
77662
|
}),
|
|
77270
77663
|
...[...importContext].flatMap((name3) => args.native?.get(name3)?.importFlags ?? []),
|
|
77271
|
-
...[...importContext].flatMap((name3) =>
|
|
77272
|
-
const flags = targets.find((target2) => target2.name === name3)?.swiftFlags ?? [];
|
|
77273
|
-
return flags.flatMap(
|
|
77274
|
-
(flag, index) => flags[index - 1] === "-Xcc" ? [flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root)] : []
|
|
77275
|
-
);
|
|
77276
|
-
})
|
|
77664
|
+
...[...importContext].flatMap((name3) => targetSwiftXccFlags.get(name3) ?? [])
|
|
77277
77665
|
];
|
|
77278
77666
|
const nativeImportFlags = [
|
|
77279
77667
|
...frameworkDirectories(target.name).flatMap((directory2) => ["-F", directory2]),
|
|
@@ -77288,9 +77676,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
77288
77676
|
...native?.swiftFlags ?? [],
|
|
77289
77677
|
...args.objcImplementationModules?.has(target.name) ? ["-enable-experimental-feature", "ObjCImplementation"] : []
|
|
77290
77678
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
77291
|
-
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] ||
|
|
77292
|
-
(value) => value.late?.producers.includes(target.name)
|
|
77293
|
-
)) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path81.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
77679
|
+
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || lateProducers.has(target.name)) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path81.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
77294
77680
|
const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
|
|
77295
77681
|
const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
|
|
77296
77682
|
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}]`)})]`;
|
|
@@ -77323,9 +77709,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
77323
77709
|
(dependency) => clang && // textual native headers can include one another without imposing
|
|
77324
77710
|
// an object build order. the executable already links every native
|
|
77325
77711
|
// target; only generated Swift headers require producer ordering.
|
|
77326
|
-
(args.native?.get(dependency)?.clang || [
|
|
77327
|
-
(value) => value.late?.producers.includes(dependency)
|
|
77328
|
-
)) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targets.some((candidate) => candidate.name === dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
|
|
77712
|
+
(args.native?.get(dependency)?.clang || lateProducers.has(dependency)) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targetNames.has(dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
|
|
77329
77713
|
),
|
|
77330
77714
|
// a swift importer still needs the producers its clang dependencies
|
|
77331
77715
|
// reached upstream, whose edges the clang targets above dropped.
|
|
@@ -77412,7 +77796,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
77412
77796
|
...args.nativeFlags?.get(name3) ?? [],
|
|
77413
77797
|
...args.nativeHeaderFlags ?? []
|
|
77414
77798
|
];
|
|
77415
|
-
const owner =
|
|
77799
|
+
const owner = targetByName.get(name3);
|
|
77416
77800
|
const context = /* @__PURE__ */ new Set();
|
|
77417
77801
|
const visit3 = (dependency) => {
|
|
77418
77802
|
if (context.has(dependency)) return;
|
|
@@ -77488,10 +77872,16 @@ ${declaration.replace(/,$/, "")}
|
|
|
77488
77872
|
""
|
|
77489
77873
|
].join("\n");
|
|
77490
77874
|
}
|
|
77491
|
-
function syncSwiftTree(base2, files2) {
|
|
77875
|
+
function syncSwiftTree(base2, files2, alreadySynced) {
|
|
77492
77876
|
(0, import_node_fs81.mkdirSync)(base2, { recursive: true });
|
|
77493
|
-
|
|
77494
|
-
|
|
77877
|
+
let kept;
|
|
77878
|
+
if (process.platform !== "linux") {
|
|
77879
|
+
kept = /* @__PURE__ */ new Set();
|
|
77880
|
+
for (const file of files2.keys()) {
|
|
77881
|
+
const stat2 = (0, import_node_fs81.statSync)(file, { throwIfNoEntry: false });
|
|
77882
|
+
if (stat2) kept.add(stat2.ino);
|
|
77883
|
+
}
|
|
77884
|
+
}
|
|
77495
77885
|
const walk4 = (dir) => {
|
|
77496
77886
|
for (const entry of (0, import_node_fs81.readdirSync)(dir, { withFileTypes: true })) {
|
|
77497
77887
|
const full = import_node_path81.default.join(dir, entry.name);
|
|
@@ -77500,12 +77890,13 @@ function syncSwiftTree(base2, files2) {
|
|
|
77500
77890
|
entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP))
|
|
77501
77891
|
continue;
|
|
77502
77892
|
if (entry.isDirectory()) walk4(full);
|
|
77503
|
-
else if (!files2.has(full) && !kept.has((0, import_node_fs81.lstatSync)(full).ino))
|
|
77893
|
+
else if (!files2.has(full) && (!kept || !kept.has((0, import_node_fs81.lstatSync)(full).ino)))
|
|
77504
77894
|
(0, import_node_fs81.rmSync)(full, { force: true });
|
|
77505
77895
|
}
|
|
77506
77896
|
};
|
|
77507
77897
|
walk4(base2);
|
|
77508
77898
|
for (const [full, contents2] of files2) {
|
|
77899
|
+
if (alreadySynced?.get(full) === contents2) continue;
|
|
77509
77900
|
writeBuildFile(full, contents2);
|
|
77510
77901
|
}
|
|
77511
77902
|
}
|
|
@@ -77613,25 +78004,59 @@ function swiftWasmCallGuards(source, unavailable2) {
|
|
|
77613
78004
|
out = out.slice(0, at) + replacement + out.slice(at + width);
|
|
77614
78005
|
return out;
|
|
77615
78006
|
}
|
|
78007
|
+
function matchesPathPrefixSet(file, set2) {
|
|
78008
|
+
if (set2.has(file)) return true;
|
|
78009
|
+
for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
|
|
78010
|
+
if (set2.has(file.slice(0, slash))) return true;
|
|
78011
|
+
}
|
|
78012
|
+
return false;
|
|
78013
|
+
}
|
|
78014
|
+
function indexTargetsByDirectory(targets) {
|
|
78015
|
+
const byDir = /* @__PURE__ */ new Map();
|
|
78016
|
+
for (const target of targets) {
|
|
78017
|
+
const key2 = target.path === "." ? "" : target.path.replace(/\/+$/, "");
|
|
78018
|
+
let list2 = byDir.get(key2);
|
|
78019
|
+
if (!list2) byDir.set(key2, list2 = []);
|
|
78020
|
+
list2.push(target);
|
|
78021
|
+
}
|
|
78022
|
+
return byDir;
|
|
78023
|
+
}
|
|
78024
|
+
function findTargetForFile(file, byDir, predicate) {
|
|
78025
|
+
for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
|
|
78026
|
+
const candidates = byDir.get(file.slice(0, slash));
|
|
78027
|
+
if (!candidates) continue;
|
|
78028
|
+
const relative7 = file.slice(slash + 1);
|
|
78029
|
+
for (const target of candidates) if (predicate(target, relative7)) return target;
|
|
78030
|
+
}
|
|
78031
|
+
const rootCandidates = byDir.get("");
|
|
78032
|
+
if (rootCandidates) {
|
|
78033
|
+
for (const target of rootCandidates) if (predicate(target, file)) return target;
|
|
78034
|
+
}
|
|
78035
|
+
return void 0;
|
|
78036
|
+
}
|
|
77616
78037
|
function compiledSwiftSources(files2, targets, overlayFrameworks, headers, nativeSourceGlue = false) {
|
|
77617
78038
|
const ordered = [...targets].sort((a, b) => b.path.length - a.path.length);
|
|
77618
|
-
const
|
|
77619
|
-
|
|
77620
|
-
|
|
77621
|
-
|
|
77622
|
-
|
|
77623
|
-
|
|
77624
|
-
|
|
77625
|
-
|
|
77626
|
-
|
|
77627
|
-
|
|
77628
|
-
return
|
|
77629
|
-
})
|
|
77630
|
-
|
|
78039
|
+
const byDir = indexTargetsByDirectory(ordered);
|
|
78040
|
+
const excludeSets = /* @__PURE__ */ new Map();
|
|
78041
|
+
for (const target of ordered) {
|
|
78042
|
+
if (target.exclude?.length) excludeSets.set(target.name, new Set(target.exclude));
|
|
78043
|
+
}
|
|
78044
|
+
const owners = /* @__PURE__ */ new Map();
|
|
78045
|
+
for (const [file, source] of Object.entries(files2)) {
|
|
78046
|
+
if (!file.endsWith(".swift")) continue;
|
|
78047
|
+
const owner = findTargetForFile(file, byDir, (target, relative7) => {
|
|
78048
|
+
const excluded = excludeSets.get(target.name);
|
|
78049
|
+
return !excluded || !matchesPathPrefixSet(relative7, excluded);
|
|
78050
|
+
});
|
|
78051
|
+
owners.set(file, { source, owner });
|
|
78052
|
+
}
|
|
77631
78053
|
const swiftSources = /* @__PURE__ */ new Map();
|
|
77632
|
-
for (const { source, owner } of owners.values())
|
|
77633
|
-
if (owner)
|
|
77634
|
-
|
|
78054
|
+
for (const { source, owner } of owners.values()) {
|
|
78055
|
+
if (!owner) continue;
|
|
78056
|
+
let list2 = swiftSources.get(owner.name);
|
|
78057
|
+
if (!list2) swiftSources.set(owner.name, list2 = []);
|
|
78058
|
+
list2.push(source);
|
|
78059
|
+
}
|
|
77635
78060
|
const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
|
|
77636
78061
|
return new Map(
|
|
77637
78062
|
[...owners].map(([file, { source, owner }]) => {
|
|
@@ -78420,18 +78845,46 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78420
78845
|
const bySourcePath = [...targets].sort(
|
|
78421
78846
|
(left, right) => right.path.length - left.path.length
|
|
78422
78847
|
);
|
|
78848
|
+
const targetsByDir = indexTargetsByDirectory(bySourcePath);
|
|
78849
|
+
const targetByName = new Map(targets.map((target) => [target.name, target]));
|
|
78850
|
+
const nativeTargets2 = input.nativeTargets ?? [];
|
|
78851
|
+
const nativeTargetByName = new Map(nativeTargets2.map((target) => [target.name, target]));
|
|
78852
|
+
const nativeTargetIndex = new Map(
|
|
78853
|
+
nativeTargets2.map((target, index) => [target.name, index])
|
|
78854
|
+
);
|
|
78855
|
+
const resourceTargetByName = new Map(
|
|
78856
|
+
resourceTargets.map((target) => [target.name, target])
|
|
78857
|
+
);
|
|
78858
|
+
const targetSourceSets = /* @__PURE__ */ new Map();
|
|
78859
|
+
const targetExcludeFullSets = /* @__PURE__ */ new Map();
|
|
78860
|
+
const targetExcludeExactSets = /* @__PURE__ */ new Map();
|
|
78861
|
+
for (const target of targets) {
|
|
78862
|
+
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
78863
|
+
if (target.sources !== void 0) {
|
|
78864
|
+
targetSourceSets.set(
|
|
78865
|
+
target.name,
|
|
78866
|
+
new Set(target.sources.map((source) => import_node_path81.default.posix.join(prefix, source)))
|
|
78867
|
+
);
|
|
78868
|
+
}
|
|
78869
|
+
if (target.exclude?.length) {
|
|
78870
|
+
targetExcludeFullSets.set(
|
|
78871
|
+
target.name,
|
|
78872
|
+
new Set(target.exclude.map((excluded) => `${prefix}${excluded}`))
|
|
78873
|
+
);
|
|
78874
|
+
targetExcludeExactSets.set(
|
|
78875
|
+
target.name,
|
|
78876
|
+
new Set(target.exclude.map((name3) => import_node_path81.default.posix.join(target.path, name3)))
|
|
78877
|
+
);
|
|
78878
|
+
}
|
|
78879
|
+
}
|
|
78423
78880
|
const swiftTargets = /* @__PURE__ */ new Set();
|
|
78424
78881
|
for (const file of Object.keys(input.files)) {
|
|
78425
78882
|
if (!file.endsWith(".swift")) continue;
|
|
78426
|
-
const target =
|
|
78427
|
-
|
|
78428
|
-
|
|
78429
|
-
|
|
78430
|
-
|
|
78431
|
-
);
|
|
78432
|
-
const excluded = target?.exclude?.some(
|
|
78433
|
-
(name3) => file === import_node_path81.default.posix.join(target.path, name3)
|
|
78434
|
-
);
|
|
78883
|
+
const target = findTargetForFile(file, targetsByDir, (candidate) => {
|
|
78884
|
+
const selected = targetSourceSets.get(candidate.name);
|
|
78885
|
+
return !selected || matchesPathPrefixSet(file, selected);
|
|
78886
|
+
});
|
|
78887
|
+
const excluded = target && targetExcludeExactSets.get(target.name)?.has(file);
|
|
78435
78888
|
if (target && !excluded) swiftTargets.add(target.name);
|
|
78436
78889
|
}
|
|
78437
78890
|
const importedModules = /* @__PURE__ */ new Set();
|
|
@@ -78469,7 +78922,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78469
78922
|
checkedToolchain = swiftToolchain(pin2.release, swiftModuleSdk(moduleRoot));
|
|
78470
78923
|
return checkedToolchain;
|
|
78471
78924
|
};
|
|
78472
|
-
const deploymentTarget = (name3) =>
|
|
78925
|
+
const deploymentTarget = (name3) => nativeTargetByName.get(name3)?.deploymentTarget ?? targetByName.get(name3)?.iosDeploymentTarget ?? null;
|
|
78473
78926
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
78474
78927
|
const stageTargetFile = (target, file, contents2, options2) => {
|
|
78475
78928
|
const relative7 = import_node_path81.default.relative(layout2.root, file).split(import_node_path81.default.sep).join(import_node_path81.default.posix.sep);
|
|
@@ -78481,18 +78934,41 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78481
78934
|
targetStagedFiles.set(target, staged);
|
|
78482
78935
|
files2.set(file, contents2);
|
|
78483
78936
|
};
|
|
78937
|
+
const entriesByPrefix = /* @__PURE__ */ new Map();
|
|
78938
|
+
for (const target of targets) {
|
|
78939
|
+
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
78940
|
+
if (!entriesByPrefix.has(prefix)) entriesByPrefix.set(prefix, []);
|
|
78941
|
+
}
|
|
78942
|
+
for (const entry of Object.entries(input.files)) {
|
|
78943
|
+
const [file] = entry;
|
|
78944
|
+
entriesByPrefix.get("")?.push(entry);
|
|
78945
|
+
for (let end = file.indexOf("/"); end !== -1; end = file.indexOf("/", end + 1)) {
|
|
78946
|
+
entriesByPrefix.get(file.slice(0, end + 1))?.push(entry);
|
|
78947
|
+
}
|
|
78948
|
+
}
|
|
78949
|
+
const targetEntriesCache = /* @__PURE__ */ new Map();
|
|
78484
78950
|
const targetEntries = (target) => {
|
|
78951
|
+
const cached5 = targetEntriesCache.get(target.name);
|
|
78952
|
+
if (cached5) return cached5;
|
|
78485
78953
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
78486
|
-
|
|
78487
|
-
|
|
78488
|
-
|
|
78489
|
-
|
|
78490
|
-
|
|
78491
|
-
(
|
|
78492
|
-
|
|
78493
|
-
|
|
78494
|
-
)
|
|
78495
|
-
|
|
78954
|
+
const selectedSources = targetSourceSets.get(target.name);
|
|
78955
|
+
const excludedPaths = targetExcludeFullSets.get(target.name);
|
|
78956
|
+
const nestedPrefixes = [];
|
|
78957
|
+
for (const candidate of targets) {
|
|
78958
|
+
if (candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix))
|
|
78959
|
+
nestedPrefixes.push(`${candidate.path}/`);
|
|
78960
|
+
}
|
|
78961
|
+
const matched = (entriesByPrefix.get(prefix) ?? []).filter(([file]) => {
|
|
78962
|
+
if (selectedSources !== void 0 && (file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) && !matchesPathPrefixSet(file, selectedSources))
|
|
78963
|
+
return false;
|
|
78964
|
+
if (excludedPaths !== void 0 && matchesPathPrefixSet(file, excludedPaths))
|
|
78965
|
+
return false;
|
|
78966
|
+
if (nestedPrefixes.length > 0 && nestedPrefixes.some((p) => file.startsWith(p)))
|
|
78967
|
+
return false;
|
|
78968
|
+
return true;
|
|
78969
|
+
});
|
|
78970
|
+
targetEntriesCache.set(target.name, matched);
|
|
78971
|
+
return matched;
|
|
78496
78972
|
};
|
|
78497
78973
|
const failTargetPreparation = (target, message) => {
|
|
78498
78974
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
@@ -78537,19 +79013,21 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78537
79013
|
return value;
|
|
78538
79014
|
};
|
|
78539
79015
|
const podHeaders = /* @__PURE__ */ new Map();
|
|
78540
|
-
for (const settings of
|
|
79016
|
+
for (const settings of nativeTargets2)
|
|
78541
79017
|
for (const file of settings.headers) {
|
|
78542
79018
|
const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
|
|
78543
79019
|
file
|
|
78544
79020
|
)?.[1];
|
|
78545
|
-
if (owner)
|
|
78546
|
-
|
|
78547
|
-
|
|
78548
|
-
|
|
78549
|
-
]);
|
|
79021
|
+
if (owner) {
|
|
79022
|
+
const base2 = import_node_path81.default.basename(file);
|
|
79023
|
+
let list2 = podHeaders.get(base2);
|
|
79024
|
+
if (!list2) podHeaders.set(base2, list2 = []);
|
|
79025
|
+
list2.push({ owner, content: input.files[file] });
|
|
79026
|
+
}
|
|
78550
79027
|
}
|
|
78551
79028
|
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(import_node_path81.default.basename(file))?.find((header) => header.content === content)?.owner;
|
|
78552
|
-
|
|
79029
|
+
const alreadySynced = /* @__PURE__ */ new Map();
|
|
79030
|
+
for (const settings of nativeTargets2) {
|
|
78553
79031
|
for (const file of settings.headers) {
|
|
78554
79032
|
const destination = import_node_path81.default.join(layout2.root, file);
|
|
78555
79033
|
if (files2.has(destination)) continue;
|
|
@@ -78566,10 +79044,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78566
79044
|
`#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`
|
|
78567
79045
|
) : rawContents;
|
|
78568
79046
|
writeBuildFile(destination, contents2);
|
|
79047
|
+
alreadySynced.set(destination, contents2);
|
|
78569
79048
|
files2.set(destination, contents2);
|
|
78570
79049
|
}
|
|
78571
79050
|
}
|
|
78572
|
-
const nativeTargets2 = input.nativeTargets ?? [];
|
|
78573
79051
|
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? import_node_path81.default.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
|
|
78574
79052
|
const inRoot = `${layout2.root}${import_node_path81.default.sep}`;
|
|
78575
79053
|
const binaryTree = `${import_node_path81.default.sep}${SWIFT_BINARY_TREES_DIR}${import_node_path81.default.sep}`;
|
|
@@ -78634,12 +79112,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78634
79112
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
78635
79113
|
const entries2 = targetEntries(target);
|
|
78636
79114
|
const units = entries2.filter(([file]) => isSwiftNativeTranslationUnit(file));
|
|
78637
|
-
|
|
78638
|
-
|
|
78639
|
-
)))
|
|
79115
|
+
const settings = nativeTargetByName.get(target.name);
|
|
79116
|
+
if (units.length === 0 && !(entries2.some(([file]) => file.endsWith(".swift")) && settings !== void 0 && (settings.publicHeaders.length > 0 || settings.bridgingHeader !== null)))
|
|
78640
79117
|
continue;
|
|
78641
79118
|
const includes = `${prefix}include/`;
|
|
78642
|
-
const settings = input.nativeTargets?.find((value) => value.name === target.name);
|
|
78643
79119
|
const searchRoots = [
|
|
78644
79120
|
...settings?.userHeaderSearchPaths ?? [],
|
|
78645
79121
|
...settings?.headerSearchPaths ?? [],
|
|
@@ -78670,7 +79146,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78670
79146
|
...searchRoots.map((root) => import_node_path81.default.posix.join(root, include))
|
|
78671
79147
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
78672
79148
|
if (local) {
|
|
78673
|
-
|
|
79149
|
+
let parents = reverse.get(local);
|
|
79150
|
+
if (!parents) reverse.set(local, parents = []);
|
|
79151
|
+
parents.push(file);
|
|
78674
79152
|
if (xcodeTarget && !seenHeaders.has(local)) {
|
|
78675
79153
|
seenHeaders.add(local);
|
|
78676
79154
|
searchEntries.push([local, input.files[local]]);
|
|
@@ -78716,9 +79194,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78716
79194
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
78717
79195
|
(flag) => flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout2.root).replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude2)
|
|
78718
79196
|
);
|
|
79197
|
+
const settingsHeaderFlags = headerSearch.flags[nativeTargetIndex.get(settings.name)];
|
|
78719
79198
|
const originalFlags = [
|
|
78720
79199
|
...settings.flags,
|
|
78721
|
-
...
|
|
79200
|
+
...settingsHeaderFlags,
|
|
78722
79201
|
...search,
|
|
78723
79202
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
78724
79203
|
"-F",
|
|
@@ -78729,7 +79208,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78729
79208
|
];
|
|
78730
79209
|
const importOriginalFlags = settings.flattensPublicHeaders ? [
|
|
78731
79210
|
...settings.importerFlags,
|
|
78732
|
-
...
|
|
79211
|
+
...settingsHeaderFlags,
|
|
78733
79212
|
...search,
|
|
78734
79213
|
...settings.frameworkSearchPaths.flatMap((dir) => [
|
|
78735
79214
|
"-F",
|
|
@@ -78754,7 +79233,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78754
79233
|
}
|
|
78755
79234
|
return [
|
|
78756
79235
|
...kept,
|
|
78757
|
-
...
|
|
79236
|
+
...settingsHeaderFlags,
|
|
78758
79237
|
...search,
|
|
78759
79238
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
78760
79239
|
"-F",
|
|
@@ -78783,7 +79262,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78783
79262
|
const bundleName = entries2.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
78784
79263
|
target: target.name,
|
|
78785
79264
|
path: target.path,
|
|
78786
|
-
resources:
|
|
79265
|
+
resources: resourceTargetByName.get(target.name)?.resources ?? false,
|
|
78787
79266
|
usesBundleMacro: entries2.some(
|
|
78788
79267
|
([file, contents2]) => (isSwiftNativeTranslationUnit(file) || /\.(?:h|hpp|hh|hxx)$/.test(file)) && /\bSWIFTPM_MODULE_BUNDLE\b/.test(contents2)
|
|
78789
79268
|
),
|
|
@@ -78936,10 +79415,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78936
79415
|
.../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
|
|
78937
79416
|
...stageFlags(
|
|
78938
79417
|
[...objcCxx ? settings.cxxFlags : [], ...fileFlags],
|
|
78939
|
-
|
|
78940
|
-
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
78941
|
-
"darwin/usr/include"
|
|
78942
|
-
)
|
|
79418
|
+
sdkInclude
|
|
78943
79419
|
)
|
|
78944
79420
|
];
|
|
78945
79421
|
const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
|
|
@@ -78979,13 +79455,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
78979
79455
|
...flags,
|
|
78980
79456
|
...prefixHeader,
|
|
78981
79457
|
...accessorFlags,
|
|
78982
|
-
...stageFlags(
|
|
78983
|
-
cxx ? settings.cxxFlags : [],
|
|
78984
|
-
import_node_path81.default.join(
|
|
78985
|
-
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
78986
|
-
"darwin/usr/include"
|
|
78987
|
-
)
|
|
78988
|
-
),
|
|
79458
|
+
...stageFlags(cxx ? settings.cxxFlags : [], sdkInclude),
|
|
78989
79459
|
...perFile,
|
|
78990
79460
|
...moduleFlag
|
|
78991
79461
|
]
|
|
@@ -79240,7 +79710,9 @@ module ${moduleName2}.Swift {
|
|
|
79240
79710
|
}
|
|
79241
79711
|
` : swiftObjCModuleMap(
|
|
79242
79712
|
moduleName2,
|
|
79243
|
-
(
|
|
79713
|
+
(nativeTargetByName.get(name3)?.publicHeaders ?? []).map(
|
|
79714
|
+
(header) => import_node_path81.default.join(layout2.root, header)
|
|
79715
|
+
),
|
|
79244
79716
|
submoduleImports2.get(moduleName2),
|
|
79245
79717
|
import_node_path81.default.join(headerDirectory, name3 + "-Swift.h")
|
|
79246
79718
|
)
|
|
@@ -79790,6 +80262,7 @@ ${entry}`);
|
|
|
79790
80262
|
files2.set(destination, Buffer.from(bytes, "base64"));
|
|
79791
80263
|
}
|
|
79792
80264
|
const targetToolset = nativeToolset || native.size > 0;
|
|
80265
|
+
let usesObjcPrebuilt = false;
|
|
79793
80266
|
if (targetToolset) {
|
|
79794
80267
|
const nativeToolsetFlags = [
|
|
79795
80268
|
...headerAliasFlags,
|
|
@@ -79810,6 +80283,7 @@ ${entry}`);
|
|
|
79810
80283
|
[...native.keys()],
|
|
79811
80284
|
objcPrebuiltStage
|
|
79812
80285
|
) : [];
|
|
80286
|
+
usesObjcPrebuilt = prebuiltCompiler.length > 0;
|
|
79813
80287
|
files2.set(
|
|
79814
80288
|
clangWrapper2,
|
|
79815
80289
|
[
|
|
@@ -80118,17 +80592,39 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
80118
80592
|
(name3) => !nativePrerequisiteSet.has(name3)
|
|
80119
80593
|
);
|
|
80120
80594
|
const nativeTargetUnitCount = /* @__PURE__ */ new Map();
|
|
80595
|
+
const nativeTargetSources = /* @__PURE__ */ new Map();
|
|
80121
80596
|
for (const target of manifestTargets)
|
|
80122
|
-
if (target.sources?.length)
|
|
80597
|
+
if (target.sources?.length) {
|
|
80123
80598
|
nativeTargetUnitCount.set(target.name, target.sources.length);
|
|
80599
|
+
nativeTargetSources.set(target.name, target.sources);
|
|
80600
|
+
}
|
|
80124
80601
|
for (const [name3, plan] of native) {
|
|
80125
|
-
if (!plan.mixed && plan.sources.length > 0)
|
|
80126
|
-
|
|
80127
|
-
|
|
80602
|
+
if (!plan.mixed && plan.sources.length > 0) {
|
|
80603
|
+
const sources = plan.clang?.sources ?? plan.sources;
|
|
80604
|
+
nativeTargetUnitCount.set(name3, sources.length);
|
|
80605
|
+
nativeTargetSources.set(name3, sources);
|
|
80606
|
+
}
|
|
80607
|
+
for (const group of plan.groups ?? []) {
|
|
80128
80608
|
nativeTargetUnitCount.set(group.name, group.sources.length);
|
|
80129
|
-
|
|
80609
|
+
nativeTargetSources.set(group.name, group.sources);
|
|
80610
|
+
}
|
|
80611
|
+
if (plan.late && !plan.groups?.length) {
|
|
80130
80612
|
nativeTargetUnitCount.set(plan.late.name, plan.sources.length);
|
|
80613
|
+
nativeTargetSources.set(plan.late.name, plan.lateSources);
|
|
80614
|
+
}
|
|
80131
80615
|
}
|
|
80616
|
+
const nativeStageObjects = /* @__PURE__ */ new Map();
|
|
80617
|
+
const recordStageObjects = (stageTarget, members2) => {
|
|
80618
|
+
const objects = [];
|
|
80619
|
+
for (const member of members2) {
|
|
80620
|
+
const sources = nativeTargetSources.get(member);
|
|
80621
|
+
if (!sources || sources.length === 0) return stageTarget;
|
|
80622
|
+
for (const source of sources)
|
|
80623
|
+
objects.push(import_node_path81.default.join(`${member}.build`, `${source}.o`));
|
|
80624
|
+
}
|
|
80625
|
+
nativeStageObjects.set(stageTarget, objects);
|
|
80626
|
+
return stageTarget;
|
|
80627
|
+
};
|
|
80132
80628
|
const MAX_NATIVE_STAGE_UNITS = 250;
|
|
80133
80629
|
const chunkNativeStageTargets = (prefix, names) => {
|
|
80134
80630
|
if (names.length === 0) return [];
|
|
@@ -80137,7 +80633,7 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
80137
80633
|
0
|
|
80138
80634
|
);
|
|
80139
80635
|
if (names.length === 1 || total <= MAX_NATIVE_STAGE_UNITS)
|
|
80140
|
-
return [buildProduct(prefix, names)];
|
|
80636
|
+
return [recordStageObjects(buildProduct(prefix, names), names)];
|
|
80141
80637
|
const chunks = [];
|
|
80142
80638
|
let current2 = [];
|
|
80143
80639
|
let count = 0;
|
|
@@ -80152,7 +80648,9 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
80152
80648
|
count += size2;
|
|
80153
80649
|
}
|
|
80154
80650
|
if (current2.length > 0) chunks.push(current2);
|
|
80155
|
-
return chunks.map(
|
|
80651
|
+
return chunks.map(
|
|
80652
|
+
(members2, index) => recordStageObjects(buildProduct(`${prefix}${index + 1}`, members2), members2)
|
|
80653
|
+
);
|
|
80156
80654
|
};
|
|
80157
80655
|
const nativePrerequisiteStageTargets = chunkNativeStageTargets(
|
|
80158
80656
|
"PeachHeaderNativePrereqs",
|
|
@@ -80163,7 +80661,7 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
80163
80661
|
remainingNativeBuildTargets
|
|
80164
80662
|
);
|
|
80165
80663
|
files2.set(manifestPath, manifest);
|
|
80166
|
-
syncSwiftTree(layout2.root, files2);
|
|
80664
|
+
syncSwiftTree(layout2.root, files2, alreadySynced);
|
|
80167
80665
|
if (layout2.multi)
|
|
80168
80666
|
for (const target of targets)
|
|
80169
80667
|
(0, import_node_fs81.mkdirSync)(import_node_path81.default.join(layout2.root, target.path), { recursive: true });
|
|
@@ -80178,7 +80676,9 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
80178
80676
|
targetFailures,
|
|
80179
80677
|
generatedOwners,
|
|
80180
80678
|
targetToolset,
|
|
80181
|
-
headerCompiler
|
|
80679
|
+
headerCompiler,
|
|
80680
|
+
usesObjcPrebuilt,
|
|
80681
|
+
nativeStageObjects
|
|
80182
80682
|
};
|
|
80183
80683
|
}
|
|
80184
80684
|
function streamText(value) {
|
|
@@ -81264,8 +81764,8 @@ ${cap}` : "";
|
|
|
81264
81764
|
work,
|
|
81265
81765
|
unoptimized
|
|
81266
81766
|
);
|
|
81267
|
-
const baseBuildEnv = {
|
|
81268
|
-
...options2.project
|
|
81767
|
+
const baseBuildEnv = options2.project?.env ? {
|
|
81768
|
+
...options2.project.env,
|
|
81269
81769
|
// shipped host plugins resolve against the selected compiler's runtime.
|
|
81270
81770
|
...process.platform === "linux" ? {
|
|
81271
81771
|
LD_LIBRARY_PATH: [
|
|
@@ -81275,7 +81775,7 @@ ${cap}` : "";
|
|
|
81275
81775
|
].filter(Boolean).join(":")
|
|
81276
81776
|
} : {},
|
|
81277
81777
|
PEACH_DEFER_WASM_LINK: "1"
|
|
81278
|
-
};
|
|
81778
|
+
} : swiftCompilerBaseEnv(options2.toolchainBin, process.env);
|
|
81279
81779
|
const {
|
|
81280
81780
|
frameworkRoot,
|
|
81281
81781
|
compileFrameworkRoot,
|
|
@@ -81419,7 +81919,11 @@ ${cap}` : "";
|
|
|
81419
81919
|
} : {
|
|
81420
81920
|
...buildOptions,
|
|
81421
81921
|
temporaryDirectory,
|
|
81422
|
-
env: {
|
|
81922
|
+
env: {
|
|
81923
|
+
...buildOptions.env,
|
|
81924
|
+
...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
|
|
81925
|
+
...compiler
|
|
81926
|
+
}
|
|
81423
81927
|
};
|
|
81424
81928
|
const unprepared = preparation.targetFailures.map(
|
|
81425
81929
|
(failure3) => `error: target ${failure3}`
|
|
@@ -81466,10 +81970,18 @@ ${cap}` : "";
|
|
|
81466
81970
|
// the mirror finds a changed sdk header's readers in their
|
|
81467
81971
|
// dependency files, which omit system headers by default
|
|
81468
81972
|
...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
|
|
81469
|
-
// the link strips debug info, so none is generated (as for the framework)
|
|
81973
|
+
// the link strips debug info, so none is generated (as for the framework).
|
|
81974
|
+
// keep -num-threads fixed across caller core caps so llbuild does not
|
|
81975
|
+
// rebuild every target when callers alternate --cores, and bound backend
|
|
81976
|
+
// fan-out under high -j.
|
|
81470
81977
|
"-Xswiftc",
|
|
81471
81978
|
"-gnone",
|
|
81472
|
-
...incrementalPreview ? [] : [
|
|
81979
|
+
...incrementalPreview ? [] : [
|
|
81980
|
+
"-Xswiftc",
|
|
81981
|
+
"-num-threads",
|
|
81982
|
+
"-Xswiftc",
|
|
81983
|
+
String(perFile ? 1 : Math.min(8, import_node_os16.default.availableParallelism()))
|
|
81984
|
+
],
|
|
81473
81985
|
...swiftReproducibleBuildFlags([
|
|
81474
81986
|
[import_node_path81.default.dirname(options2.toolchainBin), "toolchain"],
|
|
81475
81987
|
[compileFrameworkRoot, "framework"],
|
|
@@ -81644,7 +82156,18 @@ ${cap}` : "";
|
|
|
81644
82156
|
}))
|
|
81645
82157
|
];
|
|
81646
82158
|
const checkpoints = import_node_path81.default.join(root, ".build", "peach-product-checkpoints");
|
|
82159
|
+
const buildDbExists = (0, import_node_fs81.existsSync)(import_node_path81.default.join(root, ".build", "build.db"));
|
|
82160
|
+
const releaseDir = import_node_path81.default.dirname(linked);
|
|
81647
82161
|
for (const { target, producers } of stages) {
|
|
82162
|
+
if (!options2.project && producers.length === 0 && buildDbExists) {
|
|
82163
|
+
const expectedObjects = preparation.nativeStageObjects.get(target);
|
|
82164
|
+
if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
|
|
82165
|
+
(relative7) => (0, import_node_fs81.statSync)(import_node_path81.default.join(releaseDir, relative7), {
|
|
82166
|
+
throwIfNoEntry: false
|
|
82167
|
+
})?.isFile()
|
|
82168
|
+
))
|
|
82169
|
+
continue;
|
|
82170
|
+
}
|
|
81648
82171
|
const receipt = import_node_path81.default.join(
|
|
81649
82172
|
checkpoints,
|
|
81650
82173
|
(0, import_node_crypto48.createHash)("sha256").update(target).digest("hex")
|
|
@@ -81869,7 +82392,7 @@ ${cap}` : "";
|
|
|
81869
82392
|
options2.signal
|
|
81870
82393
|
);
|
|
81871
82394
|
}
|
|
81872
|
-
var import_node_child_process42, import_node_crypto48, import_node_fs81, import_node_os16, import_node_path81, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, frameworkProductsReceiptSchema, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN;
|
|
82395
|
+
var import_node_child_process42, import_node_crypto48, import_node_fs81, import_node_os16, import_node_path81, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, SWIFT_COMPILER_ENV_KEYS, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, frameworkProductsReceiptSchema, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN;
|
|
81873
82396
|
var init_swift_compile = __esm({
|
|
81874
82397
|
"src/swift-compile.ts"() {
|
|
81875
82398
|
"use strict";
|
|
@@ -81922,6 +82445,29 @@ var init_swift_compile = __esm({
|
|
|
81922
82445
|
WASM_TRIPLE = SWIFT_WASM_TRIPLE;
|
|
81923
82446
|
SWIFTPM_PROGRESS = /^\[\d+\/\d+\] /;
|
|
81924
82447
|
SWIFTPM_NOISE = /^(?:\[\d+\/\d+\] |Building for production\.\.\.$|warning: '--build-system native' has been deprecated)/;
|
|
82448
|
+
SWIFT_COMPILER_ENV_KEYS = [
|
|
82449
|
+
"PATH",
|
|
82450
|
+
"HOME",
|
|
82451
|
+
"USER",
|
|
82452
|
+
"LOGNAME",
|
|
82453
|
+
"LANG",
|
|
82454
|
+
"LC_ALL",
|
|
82455
|
+
"LC_CTYPE",
|
|
82456
|
+
"TZ",
|
|
82457
|
+
"SDKROOT",
|
|
82458
|
+
"DEVELOPER_DIR",
|
|
82459
|
+
"DYLD_LIBRARY_PATH",
|
|
82460
|
+
"SYSTEMROOT",
|
|
82461
|
+
"COMSPEC",
|
|
82462
|
+
"SSL_CERT_FILE",
|
|
82463
|
+
"SSL_CERT_DIR",
|
|
82464
|
+
"HTTP_PROXY",
|
|
82465
|
+
"HTTPS_PROXY",
|
|
82466
|
+
"NO_PROXY",
|
|
82467
|
+
"http_proxy",
|
|
82468
|
+
"https_proxy",
|
|
82469
|
+
"no_proxy"
|
|
82470
|
+
];
|
|
81925
82471
|
distributionManifests = /* @__PURE__ */ new Map();
|
|
81926
82472
|
distributionCompileViews = /* @__PURE__ */ new WeakMap();
|
|
81927
82473
|
REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
|
|
@@ -82117,7 +82663,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
82117
82663
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
82118
82664
|
MULTI_MANIFEST_VERSION = 76;
|
|
82119
82665
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
82120
|
-
compilerSourceDigest = true ? "
|
|
82666
|
+
compilerSourceDigest = true ? "4d55fa7cbb29586c08e4e51867226f96047bae2103c89f4fa59d9cf3ed3862fb" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
|
|
82121
82667
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
82122
82668
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
82123
82669
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
@@ -145522,7 +146068,7 @@ var init_nitro_superset = __esm({
|
|
|
145522
146068
|
init_nitroContract();
|
|
145523
146069
|
init_swift_standin_digest();
|
|
145524
146070
|
NITRO_SUPERSET_ENTRY_NAME = "superset";
|
|
145525
|
-
NITRO_COMPILER_DIGEST = true ? "
|
|
146071
|
+
NITRO_COMPILER_DIGEST = true ? "e035fd2365cc4b70f472d1b90eb9d912a775ab289e281922a22092c6945c4f46" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
|
|
145526
146072
|
nitroSupersetLock = parseLock(nitro_superset_lock_default);
|
|
145527
146073
|
nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
|
|
145528
146074
|
published3 = /* @__PURE__ */ new Map();
|