peachsim 0.1.2595 → 0.1.2597
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +982 -431
- 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-J5DSQG5R.mjs → acorn-55PXV665.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-D4XFTOV2.mjs → chunk-3DRJIOHV.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NZEHZIHZ.mjs → chunk-42RIRPTB.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CDGSSOLF.mjs → chunk-56YYEI6C.mjs} +16 -13
- package/dist-lib/esm-chunks/{chunk-MTGZYNXH.mjs → chunk-7ECUAVIA.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-YYAPBU4L.mjs → chunk-7J65FNXI.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FHFNRCCX.mjs → chunk-AJHFCIEU.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-G35VGABO.mjs → chunk-CKUEWEY4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NCMIX32U.mjs → chunk-DCL2ZEGA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3Z2POHJV.mjs → chunk-GECWNEHA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BCLZPP3O.mjs → chunk-GRGNTIO7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-RYCGXYYL.mjs → chunk-GZD5CTG7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5U76J6OF.mjs → chunk-HATXI62T.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GCOZNVG7.mjs → chunk-INA4S3MF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-AEI4FOZK.mjs → chunk-IPN35TGX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-U4X644Y4.mjs → chunk-LH524OUR.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-ESKLJRT5.mjs → chunk-MMHNSEZY.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-POM7QBEW.mjs → chunk-NWLCTKBM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ZSJEHQ3R.mjs → chunk-O5FDNHDG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-D6RI7LMX.mjs → chunk-ROFBHGEA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-LLO2FLAP.mjs → chunk-V6SI2XY7.mjs} +967 -491
- package/dist-lib/esm-chunks/{chunk-JVVPCJEO.mjs → chunk-VN7BXTMG.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-VZY2J2YJ.mjs → chunk-Y4XMEBRN.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-ZHPHHXG3.mjs → metro-layout-parser-5FUYCP6P.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-UXU6DFC3.mjs → swift-package-prebuilt-W3VMDYHC.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-25XPGJ4P.mjs → swift-sdk-app-module-ZHGBY6T7.mjs} +126 -56
- package/dist-lib/esm-chunks/{swift-sdk-image-7JKGAHEW.mjs → swift-sdk-image-2PC4PKHZ.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-KG5I2NUP.mjs → swift-sdk-image-producer-WDN6BXQL.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +981 -430
- 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 +1019 -434
- 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 +1020 -435
- package/dist-lib/swift-compile.cjs +979 -428
- package/dist-lib/swift-compile.mjs +10 -10
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +6 -6
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/bplist-parser.cjs +1 -1
- package/dist-lib/vendor/ignore.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/plist.cjs +1 -1
- package/dist-lib/vendor/smol-toml.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/dist-types/packages/peach-engine/src/render-worker/nativeAnimMirrorContract.d.ts +0 -2
- package/package.json +1 -1
- package/src/one-native-controls-package.ts +32 -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 +25 -3
- 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 +13 -9
- package/src/swift-wasm-prune.ts +282 -222
- package/src/wasm-optimize.ts +1 -1
- package/src/write-build-file.ts +9 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2597 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -18260,8 +18260,14 @@ var init_swift_objc_runtime = __esm({
|
|
|
18260
18260
|
|
|
18261
18261
|
// src/write-build-file.ts
|
|
18262
18262
|
function writeBuildFile(file, contents2) {
|
|
18263
|
-
|
|
18264
|
-
|
|
18263
|
+
const stat = (0, import_node_fs21.statSync)(file, { throwIfNoEntry: false });
|
|
18264
|
+
if (stat?.isFile()) {
|
|
18265
|
+
if (typeof contents2 === "string") {
|
|
18266
|
+
if ((0, import_node_fs21.readFileSync)(file, "utf8") === contents2) return;
|
|
18267
|
+
} else if (stat.size === contents2.length && (0, import_node_fs21.readFileSync)(file).equals(contents2)) {
|
|
18268
|
+
return;
|
|
18269
|
+
}
|
|
18270
|
+
}
|
|
18265
18271
|
(0, import_node_fs21.mkdirSync)(import_node_path18.default.dirname(file), { recursive: true });
|
|
18266
18272
|
(0, import_node_fs21.writeFileSync)(file, contents2);
|
|
18267
18273
|
}
|
|
@@ -25086,7 +25092,11 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
25086
25092
|
const sections = wasmSections(bytes);
|
|
25087
25093
|
const linking = sections.find((s) => s.name === "linking");
|
|
25088
25094
|
if (!linking) throw new Error("relocation link has no linking section");
|
|
25089
|
-
|
|
25095
|
+
let symKind = new Uint8Array(0);
|
|
25096
|
+
let symFlags = new Uint32Array(0);
|
|
25097
|
+
let symSegment = new Int32Array(0);
|
|
25098
|
+
let symOffset = new Int32Array(0);
|
|
25099
|
+
let symIndex = new Int32Array(0);
|
|
25090
25100
|
const segmentNames = [];
|
|
25091
25101
|
{
|
|
25092
25102
|
const r = wasmReader(bytes, linking.start);
|
|
@@ -25094,27 +25104,31 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
25094
25104
|
while (r.at < linking.end) {
|
|
25095
25105
|
const type = r.byte();
|
|
25096
25106
|
const end = r.u() + r.at;
|
|
25097
|
-
if (type === 8)
|
|
25098
|
-
|
|
25107
|
+
if (type === 8) {
|
|
25108
|
+
const count = r.u();
|
|
25109
|
+
symKind = new Uint8Array(count);
|
|
25110
|
+
symFlags = new Uint32Array(count);
|
|
25111
|
+
symSegment = new Int32Array(count).fill(-1);
|
|
25112
|
+
symOffset = new Int32Array(count);
|
|
25113
|
+
symIndex = new Int32Array(count).fill(-1);
|
|
25114
|
+
for (let i = 0; i < count; i++) {
|
|
25099
25115
|
const kind = r.byte();
|
|
25100
25116
|
const flags = r.u();
|
|
25101
|
-
|
|
25102
|
-
|
|
25103
|
-
let index = -1;
|
|
25117
|
+
symKind[i] = kind;
|
|
25118
|
+
symFlags[i] = flags;
|
|
25104
25119
|
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
25105
|
-
|
|
25106
|
-
if (!(flags & 16) || flags & 64) r.
|
|
25120
|
+
symIndex[i] = r.u();
|
|
25121
|
+
if (!(flags & 16) || flags & 64) r.skip(r.u());
|
|
25107
25122
|
} else if (kind === 1) {
|
|
25108
|
-
r.
|
|
25123
|
+
r.skip(r.u());
|
|
25109
25124
|
if (!(flags & 16)) {
|
|
25110
|
-
|
|
25111
|
-
|
|
25125
|
+
symSegment[i] = r.u();
|
|
25126
|
+
symOffset[i] = r.u();
|
|
25112
25127
|
r.u();
|
|
25113
25128
|
}
|
|
25114
25129
|
} else if (kind === 3) r.u();
|
|
25115
|
-
symbols.push({ kind, flags, segment: segment3, offset, index });
|
|
25116
25130
|
}
|
|
25117
|
-
else if (type === 5)
|
|
25131
|
+
} else if (type === 5)
|
|
25118
25132
|
for (let n = r.u(); n > 0; n--) {
|
|
25119
25133
|
segmentNames.push(r.name());
|
|
25120
25134
|
r.u();
|
|
@@ -25153,37 +25167,66 @@ function relocationEdges(bytes, segmentAddress) {
|
|
|
25153
25167
|
const importedFunctions = readModule(bytes).importedFuncs;
|
|
25154
25168
|
const data = [];
|
|
25155
25169
|
const dataFunctions = [];
|
|
25156
|
-
const
|
|
25157
|
-
const
|
|
25170
|
+
const bodyCount = bodyStarts.length;
|
|
25171
|
+
const code = Array.from({ length: bodyCount }, () => []);
|
|
25172
|
+
const calls = Array.from({ length: bodyCount }, () => []);
|
|
25158
25173
|
for (const s of sections) {
|
|
25159
25174
|
if (!s.name?.startsWith("reloc.")) continue;
|
|
25160
|
-
|
|
25161
|
-
const
|
|
25175
|
+
let cur = s.start;
|
|
25176
|
+
const readU = () => {
|
|
25177
|
+
const b0 = bytes[cur++];
|
|
25178
|
+
if (b0 < 128) return b0;
|
|
25179
|
+
let value = b0 & 127;
|
|
25180
|
+
let shift = 7;
|
|
25181
|
+
for (; ; ) {
|
|
25182
|
+
const byte = bytes[cur++];
|
|
25183
|
+
value += (byte & 127) * 2 ** shift;
|
|
25184
|
+
if (byte < 128) return value;
|
|
25185
|
+
shift += 7;
|
|
25186
|
+
}
|
|
25187
|
+
};
|
|
25188
|
+
const readS = () => {
|
|
25189
|
+
const b0 = bytes[cur++];
|
|
25190
|
+
if (b0 < 128) return b0 & 64 ? b0 - 128 : b0;
|
|
25191
|
+
let value = b0 & 127;
|
|
25192
|
+
let shift = 7;
|
|
25193
|
+
let byte = b0;
|
|
25194
|
+
while (byte >= 128) {
|
|
25195
|
+
byte = bytes[cur++];
|
|
25196
|
+
value += (byte & 127) * 2 ** shift;
|
|
25197
|
+
shift += 7;
|
|
25198
|
+
}
|
|
25199
|
+
if (byte & 64) value -= 2 ** shift;
|
|
25200
|
+
return value;
|
|
25201
|
+
};
|
|
25202
|
+
const target = readU();
|
|
25162
25203
|
if (target !== dataIndex && target !== codeIndex) continue;
|
|
25163
25204
|
let segment3 = 0;
|
|
25164
25205
|
let body = 0;
|
|
25165
|
-
|
|
25166
|
-
|
|
25167
|
-
const
|
|
25168
|
-
const
|
|
25169
|
-
const
|
|
25170
|
-
const
|
|
25171
|
-
const
|
|
25206
|
+
const isData = target === dataIndex;
|
|
25207
|
+
for (let n = readU(); n > 0; n--) {
|
|
25208
|
+
const type = bytes[cur++];
|
|
25209
|
+
const offset = readU();
|
|
25210
|
+
const index = readU();
|
|
25211
|
+
const bit = type < 32 ? 1 << type : 0;
|
|
25212
|
+
const addend = (ADDEND_RELOC_MASK & bit) !== 0 ? readS() : 0;
|
|
25213
|
+
const functionRelocation = (FUNCTION_RELOC_MASK & bit) !== 0;
|
|
25214
|
+
const memoryRelocation = (MEMORY_RELOC_MASK & bit) !== 0;
|
|
25172
25215
|
if (!functionRelocation && !memoryRelocation) continue;
|
|
25173
|
-
|
|
25174
|
-
const
|
|
25175
|
-
|
|
25176
|
-
if (!functionReference && (!memoryRelocation ||
|
|
25216
|
+
if (symFlags[index] & 16) continue;
|
|
25217
|
+
const kind = symKind[index];
|
|
25218
|
+
const functionReference = functionRelocation && kind === 0;
|
|
25219
|
+
if (!functionReference && (!memoryRelocation || kind !== 1 || symSegment[index] < 0))
|
|
25177
25220
|
continue;
|
|
25178
|
-
const to = functionReference ?
|
|
25179
|
-
if (functionReference && (to < 0 || to >=
|
|
25180
|
-
if (
|
|
25221
|
+
const to = functionReference ? symIndex[index] - importedFunctions : addresses[symSegment[index]] + symOffset[index] + addend;
|
|
25222
|
+
if (functionReference && (to < 0 || to >= bodyCount)) continue;
|
|
25223
|
+
if (isData) {
|
|
25181
25224
|
while (payloads[segment3].end <= offset) segment3++;
|
|
25182
25225
|
const payload = payloads[segment3];
|
|
25183
25226
|
const edges = functionReference ? dataFunctions : data;
|
|
25184
25227
|
edges.push(payload.address + offset - payload.start, to);
|
|
25185
25228
|
} else {
|
|
25186
|
-
while (body + 1 <
|
|
25229
|
+
while (body + 1 < bodyCount && bodyStarts[body + 1] <= offset) body++;
|
|
25187
25230
|
const edges = functionReference ? calls : code;
|
|
25188
25231
|
edges[body].push(to);
|
|
25189
25232
|
}
|
|
@@ -25239,7 +25282,7 @@ function unslottedFunctions(bytes) {
|
|
|
25239
25282
|
const slotted = new Set([...m.slots.keys()].filter((index) => index >= m.importedFuncs));
|
|
25240
25283
|
return m.bodies.length - slotted.size;
|
|
25241
25284
|
}
|
|
25242
|
-
var uleb, sleb, encodedName, section, PROCESS_EXPORTS, SWIFT_SDK_CONSTRUCTOR_LIMIT, FUNCTION_RELOCATIONS, MEMORY_RELOCATIONS, ADDEND_RELOCATIONS;
|
|
25285
|
+
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;
|
|
25243
25286
|
var init_swift_sdk_image_wasm = __esm({
|
|
25244
25287
|
"src/swift-sdk-image-wasm.ts"() {
|
|
25245
25288
|
"use strict";
|
|
@@ -25309,6 +25352,12 @@ var init_swift_sdk_image_wasm = __esm({
|
|
|
25309
25352
|
25,
|
|
25310
25353
|
27
|
|
25311
25354
|
]);
|
|
25355
|
+
FUNCTION_RELOC_MASK = 0;
|
|
25356
|
+
for (const type of FUNCTION_RELOCATIONS) FUNCTION_RELOC_MASK |= 1 << type;
|
|
25357
|
+
MEMORY_RELOC_MASK = 0;
|
|
25358
|
+
for (const type of MEMORY_RELOCATIONS) MEMORY_RELOC_MASK |= 1 << type;
|
|
25359
|
+
ADDEND_RELOC_MASK = 0;
|
|
25360
|
+
for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK |= 1 << type;
|
|
25312
25361
|
}
|
|
25313
25362
|
});
|
|
25314
25363
|
|
|
@@ -25476,7 +25525,8 @@ function isRootSegName(name3) {
|
|
|
25476
25525
|
return false;
|
|
25477
25526
|
}
|
|
25478
25527
|
function decodeRelocations(buf, sections) {
|
|
25479
|
-
|
|
25528
|
+
let count = 0;
|
|
25529
|
+
for (let s = 0; s < sections.length; s++) count += sections[s].count;
|
|
25480
25530
|
const start = new Uint32Array(count);
|
|
25481
25531
|
const end = new Uint32Array(count);
|
|
25482
25532
|
const ro = new Int32Array(count);
|
|
@@ -25485,29 +25535,59 @@ function decodeRelocations(buf, sections) {
|
|
|
25485
25535
|
const spans = [];
|
|
25486
25536
|
let i = 0;
|
|
25487
25537
|
let length = 0;
|
|
25488
|
-
for (
|
|
25489
|
-
|
|
25490
|
-
|
|
25491
|
-
|
|
25538
|
+
for (let s = 0; s < sections.length; s++) {
|
|
25539
|
+
const section2 = sections[s];
|
|
25540
|
+
const baseAt = section2.at;
|
|
25541
|
+
const sectionCount = section2.count;
|
|
25542
|
+
let cur = baseAt;
|
|
25543
|
+
for (let k = 0; k < sectionCount; k++, i++) {
|
|
25544
|
+
start[i] = length + cur - baseAt;
|
|
25492
25545
|
const rType = buf[cur++];
|
|
25493
|
-
|
|
25494
|
-
|
|
25495
|
-
|
|
25496
|
-
|
|
25497
|
-
|
|
25546
|
+
let offset = buf[cur++];
|
|
25547
|
+
if (offset >= 128) {
|
|
25548
|
+
offset &= 127;
|
|
25549
|
+
let shift = 7;
|
|
25550
|
+
while (true) {
|
|
25551
|
+
const byte = buf[cur++];
|
|
25552
|
+
offset |= (byte & 127) << shift;
|
|
25553
|
+
if (byte < 128) break;
|
|
25554
|
+
shift += 7;
|
|
25555
|
+
}
|
|
25556
|
+
}
|
|
25557
|
+
let symbol2 = buf[cur++];
|
|
25558
|
+
if (symbol2 >= 128) {
|
|
25559
|
+
symbol2 &= 127;
|
|
25560
|
+
let shift = 7;
|
|
25561
|
+
while (true) {
|
|
25562
|
+
const byte = buf[cur++];
|
|
25563
|
+
symbol2 |= (byte & 127) << shift;
|
|
25564
|
+
if (byte < 128) break;
|
|
25565
|
+
shift += 7;
|
|
25566
|
+
}
|
|
25567
|
+
}
|
|
25568
|
+
if (rType < 32 && (ADDEND_RELOC_MASK2 & 1 << rType) !== 0) {
|
|
25569
|
+
let byte = buf[cur++];
|
|
25570
|
+
let value = byte & 127;
|
|
25571
|
+
let shift = 7;
|
|
25572
|
+
while (byte >= 128) {
|
|
25573
|
+
byte = buf[cur++];
|
|
25574
|
+
value |= (byte & 127) << shift;
|
|
25575
|
+
shift += 7;
|
|
25576
|
+
}
|
|
25577
|
+
if (shift < 32 && (byte & 64) !== 0) value |= ~0 << shift;
|
|
25498
25578
|
addend[i] = value;
|
|
25499
|
-
cur = c4;
|
|
25500
25579
|
}
|
|
25501
25580
|
ro[i] = offset;
|
|
25502
25581
|
rs[i] = symbol2;
|
|
25503
|
-
end[i] = length + cur -
|
|
25582
|
+
end[i] = length + cur - baseAt;
|
|
25504
25583
|
}
|
|
25505
|
-
spans.push([
|
|
25506
|
-
length += cur -
|
|
25584
|
+
spans.push([baseAt, cur]);
|
|
25585
|
+
length += cur - baseAt;
|
|
25507
25586
|
}
|
|
25508
25587
|
const bytes = new Uint8Array(length);
|
|
25509
25588
|
let at = 0;
|
|
25510
|
-
for (
|
|
25589
|
+
for (let s = 0; s < spans.length; s++) {
|
|
25590
|
+
const [from, to] = spans[s];
|
|
25511
25591
|
bytes.set(buf.subarray(from, to), at);
|
|
25512
25592
|
at += to - from;
|
|
25513
25593
|
}
|
|
@@ -25672,6 +25752,27 @@ function patchSwiftrtObject(src) {
|
|
|
25672
25752
|
function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
25673
25753
|
const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
25674
25754
|
let pos = 8;
|
|
25755
|
+
let cur = 8;
|
|
25756
|
+
const readU = () => {
|
|
25757
|
+
const b0 = buf[cur++];
|
|
25758
|
+
if (b0 < 128) return b0;
|
|
25759
|
+
let res = b0 & 127;
|
|
25760
|
+
let shift = 7;
|
|
25761
|
+
while (true) {
|
|
25762
|
+
const byte = buf[cur++];
|
|
25763
|
+
res |= (byte & 127) << shift;
|
|
25764
|
+
if (byte < 128) return res;
|
|
25765
|
+
shift += 7;
|
|
25766
|
+
}
|
|
25767
|
+
};
|
|
25768
|
+
const skipU = () => {
|
|
25769
|
+
while (buf[cur++] >= 128) {
|
|
25770
|
+
}
|
|
25771
|
+
};
|
|
25772
|
+
const skipS = () => {
|
|
25773
|
+
while (buf[cur++] >= 128) {
|
|
25774
|
+
}
|
|
25775
|
+
};
|
|
25675
25776
|
let numImportFuncs = 0;
|
|
25676
25777
|
let importsDlsym = false;
|
|
25677
25778
|
const importFuncNames = [];
|
|
@@ -25700,150 +25801,122 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
25700
25801
|
const dataRelocSections = [];
|
|
25701
25802
|
while (pos < buf.length) {
|
|
25702
25803
|
const id = buf[pos++];
|
|
25703
|
-
|
|
25804
|
+
cur = pos;
|
|
25805
|
+
const sz = readU();
|
|
25806
|
+
const p = cur;
|
|
25704
25807
|
const end = p + sz;
|
|
25705
25808
|
if (id === 2) {
|
|
25706
|
-
|
|
25809
|
+
const cnt = readU();
|
|
25707
25810
|
for (let i = 0; i < cnt; i++) {
|
|
25708
|
-
const
|
|
25709
|
-
const mName = rawBuf.toString("utf8",
|
|
25710
|
-
|
|
25711
|
-
const
|
|
25712
|
-
const fName = rawBuf.toString("utf8",
|
|
25713
|
-
|
|
25714
|
-
const kind = buf[
|
|
25811
|
+
const mLen = readU();
|
|
25812
|
+
const mName = rawBuf.toString("utf8", cur, cur + mLen);
|
|
25813
|
+
cur += mLen;
|
|
25814
|
+
const fLen = readU();
|
|
25815
|
+
const fName = rawBuf.toString("utf8", cur, cur + fLen);
|
|
25816
|
+
cur += fLen;
|
|
25817
|
+
const kind = buf[cur++];
|
|
25715
25818
|
if (kind === 0) {
|
|
25716
|
-
|
|
25717
|
-
cp = c2;
|
|
25819
|
+
skipU();
|
|
25718
25820
|
importFuncNames.push(fName);
|
|
25719
25821
|
importFuncModules.push(mName);
|
|
25720
25822
|
if (mName === "env" && fName === "dlsym") importsDlsym = true;
|
|
25721
25823
|
numImportFuncs++;
|
|
25722
25824
|
} else if (kind === 1) {
|
|
25723
|
-
|
|
25724
|
-
const
|
|
25725
|
-
|
|
25726
|
-
|
|
25727
|
-
cp = c3;
|
|
25728
|
-
if (fl & 1) {
|
|
25729
|
-
const [, c4] = readULEB2(buf, cp);
|
|
25730
|
-
cp = c4;
|
|
25731
|
-
}
|
|
25825
|
+
cur++;
|
|
25826
|
+
const fl = readU();
|
|
25827
|
+
skipU();
|
|
25828
|
+
if (fl & 1) skipU();
|
|
25732
25829
|
importTableNames.push(fName);
|
|
25733
25830
|
} else if (kind === 2) {
|
|
25734
|
-
const
|
|
25735
|
-
|
|
25736
|
-
|
|
25737
|
-
cp = c3;
|
|
25738
|
-
if (fl & 1) {
|
|
25739
|
-
const [, c4] = readULEB2(buf, cp);
|
|
25740
|
-
cp = c4;
|
|
25741
|
-
}
|
|
25831
|
+
const fl = readU();
|
|
25832
|
+
skipU();
|
|
25833
|
+
if (fl & 1) skipU();
|
|
25742
25834
|
} else if (kind === 3) {
|
|
25743
|
-
|
|
25835
|
+
cur += 2;
|
|
25744
25836
|
importGlobalNames.push(fName);
|
|
25745
25837
|
} else if (kind === 4) {
|
|
25746
|
-
|
|
25747
|
-
|
|
25748
|
-
cp = c2;
|
|
25838
|
+
cur++;
|
|
25839
|
+
skipU();
|
|
25749
25840
|
importEventNames.push(fName);
|
|
25750
25841
|
}
|
|
25751
25842
|
}
|
|
25752
25843
|
} else if (id === 10) {
|
|
25753
25844
|
codeStart = p;
|
|
25754
|
-
|
|
25845
|
+
const cnt = readU();
|
|
25755
25846
|
for (let i = 0; i < cnt; i++) {
|
|
25756
|
-
const st =
|
|
25757
|
-
const
|
|
25758
|
-
|
|
25847
|
+
const st = cur - codeStart;
|
|
25848
|
+
const bLen = readU();
|
|
25849
|
+
cur += bLen;
|
|
25759
25850
|
fStarts.push(st);
|
|
25760
|
-
fEnds.push(
|
|
25851
|
+
fEnds.push(cur - codeStart);
|
|
25761
25852
|
}
|
|
25762
25853
|
} else if (id === 11) {
|
|
25763
25854
|
dataStart = p;
|
|
25764
|
-
|
|
25855
|
+
const cnt = readU();
|
|
25765
25856
|
for (let i = 0; i < cnt; i++) {
|
|
25766
|
-
const st =
|
|
25767
|
-
const
|
|
25768
|
-
|
|
25769
|
-
if (mode === 2) {
|
|
25770
|
-
const [, m3] = readULEB2(buf, cp);
|
|
25771
|
-
cp = m3;
|
|
25772
|
-
}
|
|
25857
|
+
const st = cur - dataStart;
|
|
25858
|
+
const mode = readU();
|
|
25859
|
+
if (mode === 2) skipU();
|
|
25773
25860
|
if (mode === 0 || mode === 2) {
|
|
25774
|
-
const op = buf[
|
|
25775
|
-
if (op === 65 || op === 66)
|
|
25776
|
-
|
|
25777
|
-
|
|
25778
|
-
} else if (op === 35) {
|
|
25779
|
-
const [, m4] = readULEB2(buf, cp);
|
|
25780
|
-
cp = m4;
|
|
25781
|
-
}
|
|
25782
|
-
cp++;
|
|
25861
|
+
const op = buf[cur++];
|
|
25862
|
+
if (op === 65 || op === 66) skipS();
|
|
25863
|
+
else if (op === 35) skipU();
|
|
25864
|
+
cur++;
|
|
25783
25865
|
}
|
|
25784
|
-
const
|
|
25785
|
-
sPayloadStarts.push(
|
|
25786
|
-
|
|
25866
|
+
const dLen = readU();
|
|
25867
|
+
sPayloadStarts.push(cur - dataStart);
|
|
25868
|
+
cur += dLen;
|
|
25787
25869
|
sStarts.push(st);
|
|
25788
|
-
sEnds.push(
|
|
25870
|
+
sEnds.push(cur - dataStart);
|
|
25789
25871
|
}
|
|
25790
25872
|
} else if (id === 0) {
|
|
25791
|
-
const
|
|
25792
|
-
const name3 = rawBuf.toString("utf8",
|
|
25793
|
-
|
|
25873
|
+
const nLen = readU();
|
|
25874
|
+
const name3 = rawBuf.toString("utf8", cur, cur + nLen);
|
|
25875
|
+
cur += nLen;
|
|
25794
25876
|
if (name3 === "linking") {
|
|
25795
|
-
|
|
25796
|
-
while (
|
|
25797
|
-
const subId = buf[
|
|
25798
|
-
const
|
|
25799
|
-
const subEnd =
|
|
25877
|
+
skipU();
|
|
25878
|
+
while (cur < end) {
|
|
25879
|
+
const subId = buf[cur++];
|
|
25880
|
+
const subLen = readU();
|
|
25881
|
+
const subEnd = cur + subLen;
|
|
25800
25882
|
if (subId === 5) {
|
|
25801
|
-
const
|
|
25802
|
-
let cur = p2;
|
|
25883
|
+
const cnt = readU();
|
|
25803
25884
|
for (let i = 0; i < cnt; i++) {
|
|
25804
|
-
const
|
|
25805
|
-
segNames.push(rawBuf.toString("utf8",
|
|
25806
|
-
cur
|
|
25807
|
-
|
|
25808
|
-
|
|
25809
|
-
segFlags.push(fl);
|
|
25810
|
-
cur = s4;
|
|
25885
|
+
const sLen = readU();
|
|
25886
|
+
segNames.push(rawBuf.toString("utf8", cur, cur + sLen));
|
|
25887
|
+
cur += sLen;
|
|
25888
|
+
skipU();
|
|
25889
|
+
segFlags.push(readU());
|
|
25811
25890
|
}
|
|
25812
25891
|
} else if (subId === 6) {
|
|
25813
|
-
const
|
|
25814
|
-
let cur = p2;
|
|
25892
|
+
const cnt = readU();
|
|
25815
25893
|
for (let i = 0; i < cnt; i++) {
|
|
25816
|
-
|
|
25817
|
-
|
|
25818
|
-
initFuncs.push(symIdx);
|
|
25819
|
-
cur = s3;
|
|
25894
|
+
skipU();
|
|
25895
|
+
initFuncs.push(readU());
|
|
25820
25896
|
}
|
|
25821
25897
|
} else if (subId === 8) {
|
|
25822
|
-
const
|
|
25898
|
+
const cnt = readU();
|
|
25823
25899
|
symKind = new Uint8Array(cnt);
|
|
25824
25900
|
symFlags = new Uint32Array(cnt);
|
|
25825
25901
|
symElemIdx = new Int32Array(cnt).fill(-1);
|
|
25826
|
-
symOff = new Int32Array(cnt)
|
|
25827
|
-
symSz = new Int32Array(cnt)
|
|
25828
|
-
let cur = p2;
|
|
25902
|
+
symOff = new Int32Array(cnt);
|
|
25903
|
+
symSz = new Int32Array(cnt);
|
|
25829
25904
|
for (let i = 0; i < cnt; i++) {
|
|
25830
25905
|
const kind = buf[cur++];
|
|
25831
25906
|
if (symbolFlagOffsets) symbolFlagOffsets[i] = cur;
|
|
25832
|
-
const
|
|
25833
|
-
cur = c2;
|
|
25907
|
+
const fl = readU();
|
|
25834
25908
|
symKind[i] = kind;
|
|
25835
25909
|
symFlags[i] = fl;
|
|
25836
25910
|
const isUndef = (fl & 16) !== 0;
|
|
25837
25911
|
const isExplicitName = (fl & 64) !== 0;
|
|
25838
25912
|
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
25839
|
-
const
|
|
25840
|
-
cur = c3;
|
|
25913
|
+
const el = readU();
|
|
25841
25914
|
if (!isUndef && kind === 0) symElemIdx[i] = el;
|
|
25842
25915
|
let sName = "";
|
|
25843
25916
|
if (!isUndef || isExplicitName) {
|
|
25844
|
-
const
|
|
25845
|
-
sName = rawBuf.toString("utf8",
|
|
25846
|
-
cur
|
|
25917
|
+
const sLen = readU();
|
|
25918
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
25919
|
+
cur += sLen;
|
|
25847
25920
|
} else if (kind === 0) {
|
|
25848
25921
|
sName = importFuncNames[el] ?? "";
|
|
25849
25922
|
} else if (kind === 2) {
|
|
@@ -25857,33 +25930,28 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
25857
25930
|
hostImportNames.add(sName);
|
|
25858
25931
|
symNames.push(sName);
|
|
25859
25932
|
} else if (kind === 1) {
|
|
25860
|
-
const
|
|
25861
|
-
const sName = rawBuf.toString("utf8",
|
|
25862
|
-
cur
|
|
25933
|
+
const sLen = readU();
|
|
25934
|
+
const sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
25935
|
+
cur += sLen;
|
|
25863
25936
|
if (!isUndef) {
|
|
25864
|
-
|
|
25865
|
-
|
|
25866
|
-
|
|
25867
|
-
cur = c6;
|
|
25868
|
-
symElemIdx[i] = segIdx;
|
|
25869
|
-
symOff[i] = sOff;
|
|
25870
|
-
symSz[i] = sSz;
|
|
25937
|
+
symElemIdx[i] = readU();
|
|
25938
|
+
symOff[i] = readU();
|
|
25939
|
+
symSz[i] = readU();
|
|
25871
25940
|
}
|
|
25872
25941
|
symNames.push(sName);
|
|
25873
25942
|
} else if (kind === 3) {
|
|
25874
|
-
|
|
25875
|
-
cur = c3;
|
|
25943
|
+
skipU();
|
|
25876
25944
|
symNames.push("");
|
|
25877
25945
|
}
|
|
25878
25946
|
}
|
|
25879
25947
|
}
|
|
25880
|
-
|
|
25948
|
+
cur = subEnd;
|
|
25881
25949
|
}
|
|
25882
25950
|
} else if (name3 === "reloc.CODE" || name3 === "reloc.DATA") {
|
|
25883
|
-
|
|
25884
|
-
const
|
|
25951
|
+
skipU();
|
|
25952
|
+
const count = readU();
|
|
25885
25953
|
(name3 === "reloc.DATA" ? dataRelocSections : codeRelocSections).push({
|
|
25886
|
-
at,
|
|
25954
|
+
at: cur,
|
|
25887
25955
|
count
|
|
25888
25956
|
});
|
|
25889
25957
|
}
|
|
@@ -25936,40 +26004,63 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
25936
26004
|
segTopSyms.set(segIdx, dedupTop);
|
|
25937
26005
|
}
|
|
25938
26006
|
}
|
|
25939
|
-
const
|
|
25940
|
-
const
|
|
26007
|
+
const funcCount = fEnds.length;
|
|
26008
|
+
const funcRelocs = Array.from({ length: funcCount }, () => []);
|
|
26009
|
+
const rawCode = decodeRelocations(buf, funcCount > 0 ? codeRelocSections : []);
|
|
25941
26010
|
const codeRelocs = { ...rawCode, funcIdx: new Uint32Array(rawCode.count) };
|
|
26011
|
+
let fCursor = 0;
|
|
26012
|
+
let prevCodeRo = -1;
|
|
25942
26013
|
for (let i = 0; i < codeRelocs.count; i++) {
|
|
25943
26014
|
const ro = codeRelocs.ro[i];
|
|
25944
|
-
let lo
|
|
25945
|
-
|
|
25946
|
-
|
|
25947
|
-
|
|
25948
|
-
|
|
25949
|
-
|
|
26015
|
+
let lo;
|
|
26016
|
+
if (ro >= prevCodeRo) {
|
|
26017
|
+
while (fCursor < funcCount - 1 && fEnds[fCursor] <= ro) fCursor++;
|
|
26018
|
+
lo = fCursor;
|
|
26019
|
+
} else {
|
|
26020
|
+
lo = 0;
|
|
26021
|
+
let hi = funcCount - 1;
|
|
26022
|
+
while (lo < hi) {
|
|
26023
|
+
const mid = lo + hi >> 1;
|
|
26024
|
+
if (fEnds[mid] <= ro) lo = mid + 1;
|
|
26025
|
+
else hi = mid;
|
|
26026
|
+
}
|
|
26027
|
+
fCursor = lo;
|
|
25950
26028
|
}
|
|
26029
|
+
prevCodeRo = ro;
|
|
25951
26030
|
if (codeRelocs.bytes[codeRelocs.start[i]] !== 6)
|
|
25952
26031
|
funcRelocs[lo].push(codeRelocs.rs[i]);
|
|
25953
26032
|
codeRelocs.funcIdx[i] = lo;
|
|
25954
26033
|
}
|
|
25955
|
-
const
|
|
26034
|
+
const segCount = segNames.length;
|
|
26035
|
+
const segRelocs = Array.from({ length: segCount }, () => []);
|
|
25956
26036
|
const symDataRelocs = /* @__PURE__ */ new Map();
|
|
25957
26037
|
const rawData = decodeRelocations(buf, sEnds.length > 0 ? dataRelocSections : []);
|
|
25958
26038
|
const dataSegIdx = new Uint32Array(rawData.count);
|
|
25959
26039
|
const dataOffInSeg = new Int32Array(rawData.count);
|
|
25960
26040
|
const dataOwnerSymIdx = new Int32Array(rawData.count);
|
|
25961
26041
|
let kept = 0;
|
|
26042
|
+
let sCursor = 0;
|
|
26043
|
+
let prevDataRo = -1;
|
|
26044
|
+
const sEndLast = sEnds.length - 1;
|
|
25962
26045
|
for (let i = 0; i < rawData.count; i++) {
|
|
25963
26046
|
const ro = rawData.ro[i];
|
|
25964
26047
|
const rs = rawData.rs[i];
|
|
25965
|
-
let lo
|
|
25966
|
-
|
|
25967
|
-
|
|
25968
|
-
|
|
25969
|
-
|
|
25970
|
-
|
|
26048
|
+
let lo;
|
|
26049
|
+
if (ro >= prevDataRo) {
|
|
26050
|
+
while (sCursor < sEndLast && sEnds[sCursor] <= ro) sCursor++;
|
|
26051
|
+
lo = sCursor;
|
|
26052
|
+
} else {
|
|
26053
|
+
lo = 0;
|
|
26054
|
+
let hi = sEndLast;
|
|
26055
|
+
while (lo < hi) {
|
|
26056
|
+
const mid = lo + hi >> 1;
|
|
26057
|
+
if (sEnds[mid] <= ro) lo = mid + 1;
|
|
26058
|
+
else hi = mid;
|
|
26059
|
+
}
|
|
26060
|
+
sCursor = lo;
|
|
25971
26061
|
}
|
|
25972
|
-
|
|
26062
|
+
prevDataRo = ro;
|
|
26063
|
+
if (lo >= segCount) continue;
|
|
25973
26064
|
const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
|
|
25974
26065
|
let ownerSymIdx = -1;
|
|
25975
26066
|
const topList = segTopSyms.get(lo);
|
|
@@ -26116,74 +26207,78 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
26116
26207
|
const conformanceProtocols = /* @__PURE__ */ new Map();
|
|
26117
26208
|
const objcCategoryTargets = [];
|
|
26118
26209
|
if (isDist) {
|
|
26119
|
-
const relocAt = /* @__PURE__ */ new Map();
|
|
26120
|
-
for (let i = 0; i < dataRelocs.count; i++) {
|
|
26121
|
-
relocAt.set(`${dataRelocs.segIdx[i]}:${dataRelocs.offInSeg[i]}`, {
|
|
26122
|
-
rs: dataRelocs.rs[i],
|
|
26123
|
-
addend: dataRelocs.addend[i]
|
|
26124
|
-
});
|
|
26125
|
-
}
|
|
26126
26210
|
const confSegs = /* @__PURE__ */ new Set();
|
|
26127
26211
|
let hasCatsSeg = false;
|
|
26128
26212
|
for (let i = 0; i < segNames.length; i++) {
|
|
26129
26213
|
if (segNames[i] === "swift5_protocol_conformances") confSegs.add(i);
|
|
26130
26214
|
else if (segNames[i] === "__objc_cats") hasCatsSeg = true;
|
|
26131
26215
|
}
|
|
26132
|
-
if (confSegs.size > 0) {
|
|
26133
|
-
const
|
|
26134
|
-
|
|
26135
|
-
if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
|
|
26136
|
-
segOffToMpSym.set(`${symElemIdx[i]}:${symOff[i]}`, symNames[i]);
|
|
26137
|
-
}
|
|
26138
|
-
}
|
|
26139
|
-
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
26216
|
+
if (confSegs.size > 0 || hasCatsSeg) {
|
|
26217
|
+
const relocKey = (seg, off) => seg * 4294967296 + (off >>> 0);
|
|
26218
|
+
const relocAt = /* @__PURE__ */ new Map();
|
|
26140
26219
|
for (let i = 0; i < dataRelocs.count; i++) {
|
|
26141
|
-
|
|
26142
|
-
|
|
26143
|
-
|
|
26144
|
-
|
|
26220
|
+
relocAt.set(relocKey(dataRelocs.segIdx[i], dataRelocs.offInSeg[i]), i);
|
|
26221
|
+
}
|
|
26222
|
+
if (confSegs.size > 0) {
|
|
26223
|
+
const segOffToMpSym = /* @__PURE__ */ new Map();
|
|
26224
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
26225
|
+
if (symKind[i] === 1 && (symFlags[i] & 16) === 0 && symElemIdx[i] >= 0 && symNames[i].startsWith("$s") && symNames[i].endsWith("Mp")) {
|
|
26226
|
+
segOffToMpSym.set(relocKey(symElemIdx[i], symOff[i]), symNames[i]);
|
|
26227
|
+
}
|
|
26145
26228
|
}
|
|
26146
|
-
const
|
|
26147
|
-
|
|
26148
|
-
|
|
26149
|
-
|
|
26150
|
-
|
|
26151
|
-
|
|
26152
|
-
const stripped2 = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
|
|
26153
|
-
if (stripped2.startsWith("$s") && stripped2.endsWith("Mp")) {
|
|
26154
|
-
mp = stripped2;
|
|
26155
|
-
} else if (symKind[pr.rs] === 3 || stripped2 === "") {
|
|
26156
|
-
mp = segOffToMpSym.get(`${mcSeg}:${pr.addend}`) ?? "";
|
|
26229
|
+
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
26230
|
+
for (let i = 0; i < dataRelocs.count; i++) {
|
|
26231
|
+
if (!confSegs.has(dataRelocs.segIdx[i])) continue;
|
|
26232
|
+
const mcIdx = dataRelocs.rs[i];
|
|
26233
|
+
if (symKind[mcIdx] !== 1 || (symFlags[mcIdx] & 16) !== 0 || symElemIdx[mcIdx] < 0) {
|
|
26234
|
+
continue;
|
|
26157
26235
|
}
|
|
26158
|
-
|
|
26159
|
-
const
|
|
26160
|
-
|
|
26161
|
-
|
|
26162
|
-
|
|
26236
|
+
const mcSeg = symElemIdx[mcIdx];
|
|
26237
|
+
const mcOff = symOff[mcIdx];
|
|
26238
|
+
const prIdx = relocAt.get(relocKey(mcSeg, mcOff));
|
|
26239
|
+
let mp = "";
|
|
26240
|
+
if (prIdx !== void 0) {
|
|
26241
|
+
const prRs = dataRelocs.rs[prIdx];
|
|
26242
|
+
const raw2 = symNames[prRs];
|
|
26243
|
+
const stripped2 = raw2.startsWith(".Lgot.") ? raw2.slice(6) : raw2;
|
|
26244
|
+
if (stripped2.startsWith("$s") && stripped2.endsWith("Mp")) {
|
|
26245
|
+
mp = stripped2;
|
|
26246
|
+
} else if (symKind[prRs] === 3 || stripped2 === "") {
|
|
26247
|
+
mp = segOffToMpSym.get(relocKey(mcSeg, dataRelocs.addend[prIdx])) ?? "";
|
|
26248
|
+
}
|
|
26249
|
+
} else {
|
|
26250
|
+
const fileOff = dataStart + sPayloadStarts[mcSeg] + mcOff;
|
|
26251
|
+
if (fileOff + 4 <= buf.length) {
|
|
26252
|
+
const delta = dv.getInt32(fileOff, true);
|
|
26253
|
+
mp = segOffToMpSym.get(relocKey(mcSeg, mcOff + delta)) ?? segOffToMpSym.get(relocKey(mcSeg, mcOff + (delta & ~1))) ?? "";
|
|
26254
|
+
}
|
|
26163
26255
|
}
|
|
26256
|
+
if (mp) conformanceProtocols.set(mcIdx, mp);
|
|
26164
26257
|
}
|
|
26165
|
-
if (mp) conformanceProtocols.set(mcIdx, mp);
|
|
26166
26258
|
}
|
|
26167
|
-
|
|
26168
|
-
|
|
26169
|
-
|
|
26170
|
-
|
|
26171
|
-
|
|
26172
|
-
|
|
26173
|
-
|
|
26174
|
-
|
|
26175
|
-
|
|
26176
|
-
|
|
26177
|
-
|
|
26178
|
-
|
|
26179
|
-
|
|
26180
|
-
|
|
26181
|
-
|
|
26182
|
-
|
|
26183
|
-
|
|
26184
|
-
|
|
26185
|
-
|
|
26186
|
-
|
|
26259
|
+
if (hasCatsSeg) {
|
|
26260
|
+
const seenClasses = /* @__PURE__ */ new Set();
|
|
26261
|
+
for (let i = 0; i < symKind.length; i++) {
|
|
26262
|
+
if (symKind[i] !== 1 || (symFlags[i] & 16) !== 0 || symElemIdx[i] < 0 || segNames[symElemIdx[i]] !== "__objc_cats" || !symNames[i].startsWith(".objc_category_")) {
|
|
26263
|
+
continue;
|
|
26264
|
+
}
|
|
26265
|
+
const cSeg = symElemIdx[i];
|
|
26266
|
+
const cOff = symOff[i];
|
|
26267
|
+
const crIdx = relocAt.get(relocKey(cSeg, cOff + 8));
|
|
26268
|
+
if (crIdx !== void 0) {
|
|
26269
|
+
const crRs = dataRelocs.rs[crIdx];
|
|
26270
|
+
if (symKind[crRs] === 1 && (symFlags[crRs] & 16) === 0 && symElemIdx[crRs] >= 0) {
|
|
26271
|
+
const tSeg = symElemIdx[crRs];
|
|
26272
|
+
const strOff = dataStart + sPayloadStarts[tSeg] + symOff[crRs] + dataRelocs.addend[crIdx];
|
|
26273
|
+
let sEnd = strOff;
|
|
26274
|
+
while (sEnd < buf.length && buf[sEnd] !== 0) sEnd++;
|
|
26275
|
+
if (sEnd > strOff) {
|
|
26276
|
+
const clsName = rawBuf.toString("utf8", strOff, sEnd);
|
|
26277
|
+
if (!seenClasses.has(clsName)) {
|
|
26278
|
+
seenClasses.add(clsName);
|
|
26279
|
+
objcCategoryTargets.push(clsName);
|
|
26280
|
+
}
|
|
26281
|
+
}
|
|
26187
26282
|
}
|
|
26188
26283
|
}
|
|
26189
26284
|
}
|
|
@@ -27396,7 +27491,9 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
27396
27491
|
return true;
|
|
27397
27492
|
};
|
|
27398
27493
|
const writePrunedObject = (obj, outFile) => {
|
|
27399
|
-
const
|
|
27494
|
+
const cached2 = objectBytes.get(obj);
|
|
27495
|
+
const buf = cached2 ? new Uint8Array(cached2) : new Uint8Array(import_node_fs29.default.readFileSync(obj.file));
|
|
27496
|
+
const rawBuf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
27400
27497
|
const inputSha256 = link ? (0, import_node_crypto14.createHash)("sha256").update(buf).digest("hex") : "";
|
|
27401
27498
|
const fLive = liveFuncs.get(obj);
|
|
27402
27499
|
const sLive = liveSegs.get(obj);
|
|
@@ -27488,7 +27585,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
27488
27585
|
const end = p + sz;
|
|
27489
27586
|
if (id === 0) {
|
|
27490
27587
|
const [nLen, np] = readULEB2(buf, p);
|
|
27491
|
-
const name3 =
|
|
27588
|
+
const name3 = rawBuf.toString("utf8", np, np + nLen);
|
|
27492
27589
|
const cp = np + nLen;
|
|
27493
27590
|
if (name3 === "linking") {
|
|
27494
27591
|
const [, lpStart] = readULEB2(buf, cp);
|
|
@@ -27750,7 +27847,7 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
27750
27847
|
);
|
|
27751
27848
|
import_node_fs29.default.rmSync(rspPath, { force: true });
|
|
27752
27849
|
}
|
|
27753
|
-
var import_node_child_process16, import_node_crypto14, import_node_fs29, import_node_path28, 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;
|
|
27850
|
+
var import_node_child_process16, import_node_crypto14, import_node_fs29, import_node_path28, 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;
|
|
27754
27851
|
var init_swift_wasm_prune = __esm({
|
|
27755
27852
|
"src/swift-wasm-prune.ts"() {
|
|
27756
27853
|
"use strict";
|
|
@@ -27830,6 +27927,8 @@ var init_swift_wasm_prune = __esm({
|
|
|
27830
27927
|
"swift5_reflstr",
|
|
27831
27928
|
"swift5_typeref"
|
|
27832
27929
|
]);
|
|
27930
|
+
ADDEND_RELOC_MASK2 = 0;
|
|
27931
|
+
for (const type of ADDEND_RELOCATIONS) ADDEND_RELOC_MASK2 |= 1 << type;
|
|
27833
27932
|
relocationBytes = (relocs, i) => relocs.bytes.subarray(relocs.start[i], relocs.end[i]);
|
|
27834
27933
|
parsedObjectCache = /* @__PURE__ */ new Map();
|
|
27835
27934
|
PARSED_ROOTS = 2;
|
|
@@ -28337,7 +28436,7 @@ function llvmType(value) {
|
|
|
28337
28436
|
function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options2 = {}) {
|
|
28338
28437
|
if (!isWasmMagic(bytes)) throw new Error("expected wasm object");
|
|
28339
28438
|
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
28340
|
-
const { sdkLookupOnly, sdkProduct } = options2;
|
|
28439
|
+
const { sdkLookupOnly, sdkProduct, collectRewrittenSymbols } = options2;
|
|
28341
28440
|
const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
|
|
28342
28441
|
const rewrite = binding !== void 0;
|
|
28343
28442
|
const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
|
|
@@ -28346,6 +28445,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
28346
28445
|
const definitions = [];
|
|
28347
28446
|
const functionImports = /* @__PURE__ */ new Map();
|
|
28348
28447
|
const functionImportNames = [];
|
|
28448
|
+
const tableImportNames = [];
|
|
28449
|
+
const globalImportNames = [];
|
|
28450
|
+
const eventImportNames = [];
|
|
28349
28451
|
const functionSymbols = [];
|
|
28350
28452
|
const addressTaken = /* @__PURE__ */ new Set();
|
|
28351
28453
|
let usesDlsym = false;
|
|
@@ -28467,12 +28569,18 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
28467
28569
|
if (isDlsym) usesDlsym = true;
|
|
28468
28570
|
if (isDlerror) usesDlerror = true;
|
|
28469
28571
|
if (importWriter && binding) {
|
|
28572
|
+
const rewrittenName = isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3;
|
|
28470
28573
|
importWriter.string(module2);
|
|
28471
|
-
importWriter.string(
|
|
28472
|
-
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3
|
|
28473
|
-
);
|
|
28574
|
+
importWriter.string(rewrittenName);
|
|
28474
28575
|
importWriter.byte(kind);
|
|
28475
28576
|
importWriter.bytes(bytes, typeStart, offset);
|
|
28577
|
+
if (collectRewrittenSymbols) {
|
|
28578
|
+
if (kind === 0)
|
|
28579
|
+
functionImportNames[functionImportNames.length - 1] = rewrittenName;
|
|
28580
|
+
else if (kind === 1) tableImportNames.push(rewrittenName);
|
|
28581
|
+
else if (kind === 3) globalImportNames.push(rewrittenName);
|
|
28582
|
+
else if (kind === 4) eventImportNames.push(rewrittenName);
|
|
28583
|
+
}
|
|
28476
28584
|
}
|
|
28477
28585
|
}
|
|
28478
28586
|
if (offset !== end) throw new Error("invalid wasm import section");
|
|
@@ -28555,13 +28663,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
28555
28663
|
if (!rewrite && flags & 16 && symbolKind === 1 && alias)
|
|
28556
28664
|
usedSymbols.add(name3);
|
|
28557
28665
|
if (entryWriter && binding) {
|
|
28666
|
+
let rewrittenSym = name3;
|
|
28667
|
+
let addedCanonical;
|
|
28558
28668
|
if ((name3 === "dlsym" && usesDlsym || name3 === "dlerror" && usesDlerror) && flags & 16 && flags & 64 && symbolKind === 0) {
|
|
28669
|
+
rewrittenSym = name3 === "dlsym" ? callerAlias : dlerrorAlias;
|
|
28559
28670
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
28560
|
-
entryWriter.string(
|
|
28671
|
+
entryWriter.string(rewrittenSym);
|
|
28561
28672
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
28562
28673
|
} else if (flags & 16 && name3 !== "dlsym" && name3 !== "dlerror" && binding(name3) !== void 0) {
|
|
28674
|
+
rewrittenSym = binding(name3);
|
|
28563
28675
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
28564
|
-
entryWriter.string(
|
|
28676
|
+
entryWriter.string(rewrittenSym);
|
|
28565
28677
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
28566
28678
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
28567
28679
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
@@ -28575,7 +28687,9 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
28575
28687
|
extraWriter.string(alias);
|
|
28576
28688
|
extraWriter.bytes(bytes, nameEnd, offset);
|
|
28577
28689
|
added++;
|
|
28690
|
+
addedCanonical = alias;
|
|
28578
28691
|
} else {
|
|
28692
|
+
rewrittenSym = alias;
|
|
28579
28693
|
entryWriter.bytes(bytes, begin, nameStart);
|
|
28580
28694
|
entryWriter.string(alias);
|
|
28581
28695
|
entryWriter.bytes(bytes, nameEnd, offset);
|
|
@@ -28583,6 +28697,16 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
28583
28697
|
} else {
|
|
28584
28698
|
entryWriter.bytes(bytes, begin, offset);
|
|
28585
28699
|
}
|
|
28700
|
+
if (collectRewrittenSymbols) {
|
|
28701
|
+
if (flags & 16) {
|
|
28702
|
+
const resolved = flags & 64 || symbolKind === 1 ? rewrittenSym : symbolKind === 0 ? functionImportNames[index] ?? "" : symbolKind === 2 ? globalImportNames[index] ?? "" : symbolKind === 4 ? eventImportNames[index] ?? "" : symbolKind === 5 ? tableImportNames[index] ?? "" : "";
|
|
28703
|
+
if (resolved) collectRewrittenSymbols.referenced.add(resolved);
|
|
28704
|
+
} else if ((flags & 3) !== 2) {
|
|
28705
|
+
if (rewrittenSym) collectRewrittenSymbols.defined.add(rewrittenSym);
|
|
28706
|
+
if (addedCanonical)
|
|
28707
|
+
collectRewrittenSymbols.defined.add(addedCanonical);
|
|
28708
|
+
}
|
|
28709
|
+
}
|
|
28586
28710
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
28587
28711
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
28588
28712
|
throw new Error(`unsupported symbol ${name3}`);
|
|
@@ -28946,6 +29070,7 @@ function createGuestImageLedger(input) {
|
|
|
28946
29070
|
sdkGlobalBindings.set(name3, first.alias);
|
|
28947
29071
|
}
|
|
28948
29072
|
}
|
|
29073
|
+
const appSymbols = input.registerAppTables ? { referenced: /* @__PURE__ */ new Set(), defined: /* @__PURE__ */ new Set() } : void 0;
|
|
28949
29074
|
const objects = units.map(({ image, object: object8, aliases, functionImports }) => {
|
|
28950
29075
|
const shared = sharedLookupByImage.get(image);
|
|
28951
29076
|
const own2 = startup.get(object8.path);
|
|
@@ -28980,7 +29105,10 @@ function createGuestImageLedger(input) {
|
|
|
28980
29105
|
binding,
|
|
28981
29106
|
object8.instrumentDynamicLookups,
|
|
28982
29107
|
preserveCanonical,
|
|
28983
|
-
{
|
|
29108
|
+
{
|
|
29109
|
+
sdkProduct: object8.sdkProduct,
|
|
29110
|
+
collectRewrittenSymbols: object8.sdkProduct === void 0 ? appSymbols : void 0
|
|
29111
|
+
}
|
|
28984
29112
|
).bytes
|
|
28985
29113
|
};
|
|
28986
29114
|
});
|
|
@@ -29101,7 +29229,9 @@ function createGuestImageLedger(input) {
|
|
|
29101
29229
|
llvmIR: render2(false, lazy),
|
|
29102
29230
|
lazyFunctions: lazy,
|
|
29103
29231
|
appLLVMIR: appLazy && render2(true, appLazy),
|
|
29104
|
-
appLazyFunctions: appLazy
|
|
29232
|
+
appLazyFunctions: appLazy,
|
|
29233
|
+
appReferencedSymbols: appSymbols?.referenced,
|
|
29234
|
+
appDefinedSymbols: appSymbols?.defined
|
|
29105
29235
|
};
|
|
29106
29236
|
}
|
|
29107
29237
|
function guestLazyFunctionRuntime(count) {
|
|
@@ -29829,6 +29959,26 @@ function selectedGuestManifestInputs(plan, selection, identities, readSelected)
|
|
|
29829
29959
|
}
|
|
29830
29960
|
return images;
|
|
29831
29961
|
}
|
|
29962
|
+
function framedLinkOptions(options2) {
|
|
29963
|
+
const cached2 = framedLinkOptionsCache.get(options2);
|
|
29964
|
+
if (cached2) return cached2;
|
|
29965
|
+
const parts = new Array(options2.length * 2 + 2);
|
|
29966
|
+
const count = Buffer.from(String(options2.length), "utf8");
|
|
29967
|
+
const countSize = Buffer.allocUnsafe(8);
|
|
29968
|
+
countSize.writeBigUInt64BE(BigInt(count.byteLength));
|
|
29969
|
+
parts[0] = countSize;
|
|
29970
|
+
parts[1] = count;
|
|
29971
|
+
for (let i = 0; i < options2.length; i++) {
|
|
29972
|
+
const encoded = Buffer.from(options2[i], "utf8");
|
|
29973
|
+
const size2 = Buffer.allocUnsafe(8);
|
|
29974
|
+
size2.writeBigUInt64BE(BigInt(encoded.byteLength));
|
|
29975
|
+
parts[i * 2 + 2] = size2;
|
|
29976
|
+
parts[i * 2 + 3] = encoded;
|
|
29977
|
+
}
|
|
29978
|
+
const framed = Buffer.concat(parts);
|
|
29979
|
+
framedLinkOptionsCache.set(options2, framed);
|
|
29980
|
+
return framed;
|
|
29981
|
+
}
|
|
29832
29982
|
function createGuestImageManifest(image) {
|
|
29833
29983
|
const target = {
|
|
29834
29984
|
triple: SWIFT_WASM_TRIPLE,
|
|
@@ -29838,10 +29988,10 @@ function createGuestImageManifest(image) {
|
|
|
29838
29988
|
cpuSubtype: 0
|
|
29839
29989
|
};
|
|
29840
29990
|
const digest3 = (0, import_node_crypto18.createHash)("sha256");
|
|
29991
|
+
const sizeBuf = Buffer.allocUnsafe(8);
|
|
29841
29992
|
const add = (bytes) => {
|
|
29842
|
-
|
|
29843
|
-
|
|
29844
|
-
digest3.update(size2);
|
|
29993
|
+
sizeBuf.writeBigUInt64BE(BigInt(bytes.byteLength));
|
|
29994
|
+
digest3.update(sizeBuf);
|
|
29845
29995
|
digest3.update(bytes);
|
|
29846
29996
|
};
|
|
29847
29997
|
const text7 = (value) => add(Buffer.from(value, "utf8"));
|
|
@@ -29858,8 +30008,7 @@ function createGuestImageManifest(image) {
|
|
|
29858
30008
|
`${version2.platform}:${version2.minimum.major}:${version2.minimum.minor}:${version2.minimum.patch}`
|
|
29859
30009
|
);
|
|
29860
30010
|
text7(`${version2.sdk.major}:${version2.sdk.minor}:${version2.sdk.patch}`);
|
|
29861
|
-
|
|
29862
|
-
for (const option of image.linkOptions) text7(option);
|
|
30011
|
+
digest3.update(framedLinkOptions(image.linkOptions));
|
|
29863
30012
|
text7(String(image.inputs.length));
|
|
29864
30013
|
for (const input of image.inputs) {
|
|
29865
30014
|
text7(input.identity);
|
|
@@ -29880,7 +30029,7 @@ function createGuestImageManifest(image) {
|
|
|
29880
30029
|
regions: image.regions
|
|
29881
30030
|
};
|
|
29882
30031
|
}
|
|
29883
|
-
var import_node_crypto18, import_node_fs31;
|
|
30032
|
+
var import_node_crypto18, import_node_fs31, framedLinkOptionsCache;
|
|
29884
30033
|
var init_swift_guest_manifest = __esm({
|
|
29885
30034
|
"src/swift-guest-manifest.ts"() {
|
|
29886
30035
|
"use strict";
|
|
@@ -29889,6 +30038,7 @@ var init_swift_guest_manifest = __esm({
|
|
|
29889
30038
|
init_swift_guest_link_plan();
|
|
29890
30039
|
init_swift_wasm_prune();
|
|
29891
30040
|
init_swiftTargetContract();
|
|
30041
|
+
framedLinkOptionsCache = /* @__PURE__ */ new WeakMap();
|
|
29892
30042
|
}
|
|
29893
30043
|
});
|
|
29894
30044
|
|
|
@@ -31191,7 +31341,7 @@ var init_wasm_optimize = __esm({
|
|
|
31191
31341
|
];
|
|
31192
31342
|
BINARYEN_VERSION = binaryen_lock_default.version;
|
|
31193
31343
|
runBinaryen = (0, import_node_util3.promisify)(import_node_child_process18.execFile);
|
|
31194
|
-
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`;
|
|
31344
|
+
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`;
|
|
31195
31345
|
BINARYEN_RELEASES = new Map(Object.entries(binaryen_lock_default.platforms));
|
|
31196
31346
|
}
|
|
31197
31347
|
});
|
|
@@ -31636,6 +31786,7 @@ function linkGuestImages(options2) {
|
|
|
31636
31786
|
const ledgerObjects = new Map(ledger.objects.map((item) => [item.path, item]));
|
|
31637
31787
|
const appObjects = /* @__PURE__ */ new Map();
|
|
31638
31788
|
const sdkObjects = /* @__PURE__ */ new Map();
|
|
31789
|
+
const finalArchives = /* @__PURE__ */ new Map();
|
|
31639
31790
|
for (const [index, artifact] of plan.artifacts.entries()) {
|
|
31640
31791
|
const prefix = `${artifact.path}(`;
|
|
31641
31792
|
if (artifact.kind === "object") {
|
|
@@ -31657,7 +31808,10 @@ function linkGuestImages(options2) {
|
|
|
31657
31808
|
}
|
|
31658
31809
|
const members2 = archives.get(artifact.path);
|
|
31659
31810
|
if (!members2) continue;
|
|
31660
|
-
const
|
|
31811
|
+
const listing = (0, import_node_child_process19.execFileSync)(llvmAr, ["t", artifact.path], {
|
|
31812
|
+
encoding: "utf8"
|
|
31813
|
+
}).trimEnd();
|
|
31814
|
+
const listed = listing ? listing.split("\n") : [];
|
|
31661
31815
|
if (listed.length !== members2.length || new Set(listed).size !== listed.length || members2.some(
|
|
31662
31816
|
(member, i) => listed[i] !== member.name || import_node_path32.default.basename(member.name) !== member.name
|
|
31663
31817
|
))
|
|
@@ -31686,6 +31840,10 @@ function linkGuestImages(options2) {
|
|
|
31686
31840
|
const response = import_node_path32.default.join(memberDir, "members.rsp");
|
|
31687
31841
|
import_node_fs34.default.writeFileSync(response, inputs2.map((input) => JSON.stringify(input)).join(" "));
|
|
31688
31842
|
(0, import_node_child_process19.execFileSync)(llvmAr, ["rcs", output, `@${response}`], { stdio: "pipe" });
|
|
31843
|
+
finalArchives.set(
|
|
31844
|
+
output,
|
|
31845
|
+
members2.map((member) => ({ name: member.name, bytes: new Uint8Array(0) }))
|
|
31846
|
+
);
|
|
31689
31847
|
replacements.set(artifact.path, output);
|
|
31690
31848
|
}
|
|
31691
31849
|
const compileLedger = (name3, source) => {
|
|
@@ -31817,7 +31975,8 @@ function linkGuestImages(options2) {
|
|
|
31817
31975
|
remapGuestLinkPlan(plan, replacements),
|
|
31818
31976
|
finalArgs,
|
|
31819
31977
|
import_node_fs34.default.readFileSync(finalWhy, "utf8"),
|
|
31820
|
-
finalTrace
|
|
31978
|
+
finalTrace,
|
|
31979
|
+
finalArchives
|
|
31821
31980
|
);
|
|
31822
31981
|
const original = new Map([...replacements].map(([before2, after2]) => [after2, before2]));
|
|
31823
31982
|
const key2 = (item) => JSON.stringify([original.get(item.artifact) ?? item.artifact, item.member]);
|
|
@@ -31850,12 +32009,25 @@ ${changed.join("\n")}`
|
|
|
31850
32009
|
])
|
|
31851
32010
|
);
|
|
31852
32011
|
appObjects.set(appLedgerObject, options2.ledgerDataImage);
|
|
32012
|
+
let appReferencedSymbols;
|
|
32013
|
+
let appDefinedSymbols;
|
|
32014
|
+
if (ledger.appReferencedSymbols && ledger.appDefinedSymbols) {
|
|
32015
|
+
const referenced = new Set(ledger.appReferencedSymbols);
|
|
32016
|
+
const defined = new Set(ledger.appDefinedSymbols);
|
|
32017
|
+
const ledgerSyms = guestWasmSymbols(import_node_fs34.default.readFileSync(appLedgerObject));
|
|
32018
|
+
for (const name3 of ledgerSyms.undefined) referenced.add(name3);
|
|
32019
|
+
for (const name3 of ledgerSyms.defined) defined.add(name3);
|
|
32020
|
+
appReferencedSymbols = referenced;
|
|
32021
|
+
appDefinedSymbols = defined;
|
|
32022
|
+
}
|
|
31853
32023
|
options2.onSplitInputs({
|
|
31854
32024
|
appObjects,
|
|
31855
32025
|
appSections,
|
|
31856
32026
|
sdkObjects,
|
|
31857
32027
|
lazyFunctions: ledger.appLazyFunctions ?? [],
|
|
31858
|
-
dyldSymbols: ledger.dyldSymbols
|
|
32028
|
+
dyldSymbols: ledger.dyldSymbols,
|
|
32029
|
+
appReferencedSymbols,
|
|
32030
|
+
appDefinedSymbols
|
|
31859
32031
|
});
|
|
31860
32032
|
}
|
|
31861
32033
|
return selected;
|
|
@@ -32847,6 +33019,93 @@ function sourceGuestInputIdentities(graph, buildDirectory, objects) {
|
|
|
32847
33019
|
}
|
|
32848
33020
|
return identities;
|
|
32849
33021
|
}
|
|
33022
|
+
function wasmAutolinkEntries(bytes, out) {
|
|
33023
|
+
if (bytes.length < 8) return false;
|
|
33024
|
+
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) {
|
|
33025
|
+
for (const member of readArMembers(bytes)) {
|
|
33026
|
+
if (!wasmAutolinkEntries(member.bytes, out)) return false;
|
|
33027
|
+
}
|
|
33028
|
+
return true;
|
|
33029
|
+
}
|
|
33030
|
+
if (bytes[0] !== 0 || bytes[1] !== 97 || bytes[2] !== 115 || bytes[3] !== 109)
|
|
33031
|
+
return false;
|
|
33032
|
+
const raw2 = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
33033
|
+
let pos = 8;
|
|
33034
|
+
const len = bytes.length;
|
|
33035
|
+
while (pos < len) {
|
|
33036
|
+
const id = bytes[pos++];
|
|
33037
|
+
let sz = bytes[pos++];
|
|
33038
|
+
if (sz >= 128) {
|
|
33039
|
+
sz &= 127;
|
|
33040
|
+
let shift = 7;
|
|
33041
|
+
while (true) {
|
|
33042
|
+
const b = bytes[pos++];
|
|
33043
|
+
sz |= (b & 127) << shift;
|
|
33044
|
+
if (b < 128) break;
|
|
33045
|
+
shift += 7;
|
|
33046
|
+
}
|
|
33047
|
+
}
|
|
33048
|
+
const end = pos + sz;
|
|
33049
|
+
if (id === 0) {
|
|
33050
|
+
let nLen = bytes[pos++];
|
|
33051
|
+
if (nLen >= 128) {
|
|
33052
|
+
nLen &= 127;
|
|
33053
|
+
let shift = 7;
|
|
33054
|
+
while (true) {
|
|
33055
|
+
const b = bytes[pos++];
|
|
33056
|
+
nLen |= (b & 127) << shift;
|
|
33057
|
+
if (b < 128) break;
|
|
33058
|
+
shift += 7;
|
|
33059
|
+
}
|
|
33060
|
+
}
|
|
33061
|
+
if (nLen === 24 && raw2.toString("ascii", pos, pos + 24) === ".swift1_autolink_entries") {
|
|
33062
|
+
const payload = raw2.toString("utf8", pos + 24, end);
|
|
33063
|
+
for (const entry of payload.split("\0")) {
|
|
33064
|
+
const trimmed = entry.trim();
|
|
33065
|
+
if (trimmed.length > 0) out.push(trimmed);
|
|
33066
|
+
}
|
|
33067
|
+
}
|
|
33068
|
+
}
|
|
33069
|
+
pos = end;
|
|
33070
|
+
}
|
|
33071
|
+
return true;
|
|
33072
|
+
}
|
|
33073
|
+
function readAutolinkFlags(objects, toolchainBin, responsePath) {
|
|
33074
|
+
if (!objects.length) return [];
|
|
33075
|
+
const rawFlags = [];
|
|
33076
|
+
for (const file of objects) {
|
|
33077
|
+
if (!wasmAutolinkEntries((0, import_node_fs35.readFileSync)(file), rawFlags)) {
|
|
33078
|
+
(0, import_node_fs35.writeFileSync)(
|
|
33079
|
+
responsePath,
|
|
33080
|
+
objects.map((entry) => JSON.stringify(entry)).join("\n") + "\n"
|
|
33081
|
+
);
|
|
33082
|
+
return (0, import_node_child_process20.execFileSync)(
|
|
33083
|
+
import_node_path33.default.join(toolchainBin, "swift-autolink-extract"),
|
|
33084
|
+
[`@${responsePath}`, "-o", "-"],
|
|
33085
|
+
{ encoding: "utf8" }
|
|
33086
|
+
).split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
33087
|
+
}
|
|
33088
|
+
}
|
|
33089
|
+
const seen = /* @__PURE__ */ new Set();
|
|
33090
|
+
const flags = [];
|
|
33091
|
+
for (let i = 0; i < rawFlags.length; i++) {
|
|
33092
|
+
const flag = rawFlags[i];
|
|
33093
|
+
if ((flag === "-framework" || flag === "-weak_framework" || flag === "-l" || flag === "--library") && i + 1 < rawFlags.length) {
|
|
33094
|
+
const value = rawFlags[++i];
|
|
33095
|
+
const key2 = `${flag}\0${value}`;
|
|
33096
|
+
if (!seen.has(key2)) {
|
|
33097
|
+
seen.add(key2);
|
|
33098
|
+
flags.push(flag, value);
|
|
33099
|
+
}
|
|
33100
|
+
continue;
|
|
33101
|
+
}
|
|
33102
|
+
if (!seen.has(flag)) {
|
|
33103
|
+
seen.add(flag);
|
|
33104
|
+
flags.push(flag);
|
|
33105
|
+
}
|
|
33106
|
+
}
|
|
33107
|
+
return flags;
|
|
33108
|
+
}
|
|
32850
33109
|
function sourceGuestRuntimeLinks(options2) {
|
|
32851
33110
|
const aliases = /* @__PURE__ */ new Map();
|
|
32852
33111
|
const artifacts = /* @__PURE__ */ new Map();
|
|
@@ -32934,15 +33193,7 @@ function sourceGuestRuntimeLinks(options2) {
|
|
|
32934
33193
|
for (const image of options2.images) {
|
|
32935
33194
|
if (result.has(image.id)) throw new Error(`duplicate source image ${image.id}`);
|
|
32936
33195
|
const response = import_node_path33.default.join(options2.directory, `image-${image.id}-autolink.rsp`);
|
|
32937
|
-
(
|
|
32938
|
-
response,
|
|
32939
|
-
image.objects.map((file) => JSON.stringify(file)).join("\n") + "\n"
|
|
32940
|
-
);
|
|
32941
|
-
const autolink = image.objects.length ? (0, import_node_child_process20.execFileSync)(
|
|
32942
|
-
import_node_path33.default.join(options2.toolchainBin, "swift-autolink-extract"),
|
|
32943
|
-
[`@${response}`, "-o", "-"],
|
|
32944
|
-
{ encoding: "utf8" }
|
|
32945
|
-
).split("\n").map((line) => line.trim()).filter((line) => line.length > 0) : [];
|
|
33196
|
+
const autolink = readAutolinkFlags(image.objects, options2.toolchainBin, response);
|
|
32946
33197
|
const links = [];
|
|
32947
33198
|
const requests = [];
|
|
32948
33199
|
const optionGroups = [
|
|
@@ -33042,6 +33293,7 @@ var init_swift_guest_source_inputs = __esm({
|
|
|
33042
33293
|
init_forked_script_contract();
|
|
33043
33294
|
init_swift_guest_source_plan();
|
|
33044
33295
|
init_swift_runtime_products();
|
|
33296
|
+
init_swift_wasm_prune();
|
|
33045
33297
|
CLANG_TARGET_MODULE_WRAPPER = ".peach-clang";
|
|
33046
33298
|
PARALLEL_REPLAY = `
|
|
33047
33299
|
const { spawn } = require('node:child_process')
|
|
@@ -36129,24 +36381,26 @@ function setBoundedCache(cache, key2, value) {
|
|
|
36129
36381
|
return value;
|
|
36130
36382
|
}
|
|
36131
36383
|
function cached(directory2, key2) {
|
|
36132
|
-
const sdkInterfacePath = import_node_path41.default.join(directory2, INTERFACE_FILE);
|
|
36133
|
-
const image = import_node_path41.default.join(directory2, IMAGE_FILE);
|
|
36134
36384
|
const address = import_node_path41.default.join(directory2, IMAGE_DIGEST);
|
|
36135
|
-
if (!(0, import_node_fs43.existsSync)(
|
|
36385
|
+
if (!(0, import_node_fs43.existsSync)(import_node_path41.default.join(directory2, IMAGE_FILE)) || !(0, import_node_fs43.existsSync)(address) || !(0, import_node_fs43.existsSync)(import_node_path41.default.join(directory2, INTERFACE_FILE)) || !(0, import_node_fs43.existsSync)(import_node_path41.default.join(directory2, MANIFEST_FILE)) || !(0, import_node_fs43.existsSync)(import_node_path41.default.join(directory2, MANIFEST_DATA_FILE)))
|
|
36136
36386
|
return void 0;
|
|
36137
|
-
|
|
36387
|
+
return sdkImageAt(directory2, key2, (0, import_node_fs43.readFileSync)(address, "utf8"));
|
|
36388
|
+
}
|
|
36389
|
+
function sdkImageAt(directory2, key2, sha2565) {
|
|
36138
36390
|
const cacheKey = `${directory2}\0${sha2565}`;
|
|
36139
36391
|
let loadedInterface;
|
|
36140
36392
|
return {
|
|
36141
36393
|
key: key2,
|
|
36142
36394
|
directory: directory2,
|
|
36143
|
-
image,
|
|
36395
|
+
image: import_node_path41.default.join(directory2, IMAGE_FILE),
|
|
36144
36396
|
sha256: sha2565,
|
|
36145
36397
|
get sdkInterface() {
|
|
36146
36398
|
if (loadedInterface) return loadedInterface;
|
|
36147
36399
|
const memo2 = cachedSdkInterfaces.get(cacheKey);
|
|
36148
36400
|
if (memo2) return loadedInterface = memo2;
|
|
36149
|
-
const parsed2 = JSON.parse(
|
|
36401
|
+
const parsed2 = JSON.parse(
|
|
36402
|
+
(0, import_node_fs43.readFileSync)(import_node_path41.default.join(directory2, INTERFACE_FILE), "utf8")
|
|
36403
|
+
);
|
|
36150
36404
|
return loadedInterface = setBoundedCache(cachedSdkInterfaces, cacheKey, parsed2);
|
|
36151
36405
|
}
|
|
36152
36406
|
};
|
|
@@ -36199,7 +36453,7 @@ async function buildSwiftSdkImage(moduleRoot, scopedLookups = false, frameworkIm
|
|
|
36199
36453
|
throw new Error(`invalid published Swift SDK image ${key2}`);
|
|
36200
36454
|
(0, import_node_fs43.rmSync)(directory2, { recursive: true, force: true });
|
|
36201
36455
|
(0, import_node_fs43.renameSync)(stage, directory2);
|
|
36202
|
-
return
|
|
36456
|
+
return sdkImageAt(directory2, key2, image.sha256);
|
|
36203
36457
|
} finally {
|
|
36204
36458
|
(0, import_node_fs43.rmSync)(stage, { recursive: true, force: true });
|
|
36205
36459
|
}
|
|
@@ -36552,9 +36806,10 @@ function sdkHostExports(appRoot) {
|
|
|
36552
36806
|
if (!(byte & 128)) return value;
|
|
36553
36807
|
}
|
|
36554
36808
|
};
|
|
36809
|
+
const raw2 = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
36555
36810
|
for (let n = u(); n > 0; n--) {
|
|
36556
36811
|
const length = u();
|
|
36557
|
-
names.push(
|
|
36812
|
+
names.push(raw2.toString("utf8", at, at + length));
|
|
36558
36813
|
at += length + 1;
|
|
36559
36814
|
u();
|
|
36560
36815
|
}
|
|
@@ -36980,56 +37235,109 @@ function swiftAppModuleInputs(tokens2, buildRoot, sdkLibraries) {
|
|
|
36980
37235
|
}
|
|
36981
37236
|
return inputs2;
|
|
36982
37237
|
}
|
|
36983
|
-
|
|
37238
|
+
function llvmQuoted(value) {
|
|
37239
|
+
const bytes = Buffer.from(value, "utf8");
|
|
37240
|
+
let out = '"';
|
|
37241
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
37242
|
+
const b = bytes[i];
|
|
37243
|
+
if (b >= 32 && b <= 126 && b !== 34 && b !== 92) out += String.fromCharCode(b);
|
|
37244
|
+
else out += `\\${b.toString(16).toUpperCase().padStart(2, "0")}`;
|
|
37245
|
+
}
|
|
37246
|
+
return out + '"';
|
|
37247
|
+
}
|
|
37248
|
+
async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project2, readInput, precomputedSymbols) {
|
|
36984
37249
|
const { signatures, tls } = sdk2.sdkInterface;
|
|
36985
|
-
|
|
36986
|
-
|
|
36987
|
-
|
|
36988
|
-
|
|
36989
|
-
|
|
36990
|
-
|
|
36991
|
-
|
|
37250
|
+
let referenced;
|
|
37251
|
+
let defined;
|
|
37252
|
+
if (precomputedSymbols) {
|
|
37253
|
+
referenced = precomputedSymbols.referenced;
|
|
37254
|
+
defined = precomputedSymbols.defined;
|
|
37255
|
+
} else {
|
|
37256
|
+
const directories = inputs2.filter((input) => input.startsWith("-L")).map((input) => input.slice(2));
|
|
37257
|
+
const refSet = /* @__PURE__ */ new Set();
|
|
37258
|
+
const defSet = /* @__PURE__ */ new Set();
|
|
37259
|
+
const scan3 = (bytes) => {
|
|
37260
|
+
const symbols = guestWasmSymbols(bytes);
|
|
37261
|
+
for (const name3 of symbols.undefined) refSet.add(name3);
|
|
37262
|
+
for (const name3 of symbols.defined) defSet.add(name3);
|
|
37263
|
+
};
|
|
37264
|
+
for (const input of inputs2) {
|
|
37265
|
+
const file = input.startsWith("-l") ? directories.map((directory2) => import_node_path42.default.join(directory2, `lib${input.slice(2)}.a`)).find((candidate) => (0, import_node_fs44.existsSync)(candidate)) : input.startsWith("-") ? void 0 : input;
|
|
37266
|
+
if (!file) continue;
|
|
37267
|
+
const bytes = readInput(file);
|
|
37268
|
+
if (file.endsWith(".a"))
|
|
37269
|
+
for (const member of readArMembers(bytes)) scan3(member.bytes);
|
|
37270
|
+
else scan3(bytes);
|
|
37271
|
+
}
|
|
37272
|
+
referenced = refSet;
|
|
37273
|
+
defined = defSet;
|
|
37274
|
+
}
|
|
37275
|
+
const irType = {
|
|
37276
|
+
i: "i32",
|
|
37277
|
+
j: "i64",
|
|
37278
|
+
f: "float",
|
|
37279
|
+
d: "double"
|
|
37280
|
+
};
|
|
37281
|
+
const type = (kinds) => {
|
|
37282
|
+
const out = new Array(kinds.length);
|
|
37283
|
+
for (let i = 0; i < kinds.length; i++) {
|
|
37284
|
+
const kind = kinds[i];
|
|
37285
|
+
const name3 = irType[kind];
|
|
37286
|
+
if (!name3) throw new Error(`sdk signature kind ${kind}`);
|
|
37287
|
+
out[i] = name3;
|
|
37288
|
+
}
|
|
37289
|
+
return out;
|
|
36992
37290
|
};
|
|
36993
|
-
|
|
36994
|
-
|
|
36995
|
-
|
|
36996
|
-
const
|
|
36997
|
-
|
|
36998
|
-
|
|
36999
|
-
|
|
37000
|
-
|
|
37001
|
-
|
|
37002
|
-
|
|
37003
|
-
|
|
37004
|
-
return name3;
|
|
37005
|
-
});
|
|
37006
|
-
const literal3 = (name3) => JSON.stringify(name3);
|
|
37007
|
-
const lines = [];
|
|
37008
|
-
if (signatures.__objc_send_load_messages === ":")
|
|
37291
|
+
const lines = [`target triple = "${SWIFT_WASM_TRIPLE}"`];
|
|
37292
|
+
const attrs = [];
|
|
37293
|
+
const addImportAttr = (name3) => {
|
|
37294
|
+
const id = attrs.length;
|
|
37295
|
+
attrs.push(
|
|
37296
|
+
`attributes #${id} = { "wasm-import-module"="env" "wasm-import-name"=${llvmQuoted(name3)} }`
|
|
37297
|
+
);
|
|
37298
|
+
return id;
|
|
37299
|
+
};
|
|
37300
|
+
if (signatures.__objc_send_load_messages === ":") {
|
|
37301
|
+
const attr = addImportAttr("__objc_send_load_messages");
|
|
37009
37302
|
lines.push(
|
|
37010
|
-
|
|
37011
|
-
|
|
37303
|
+
"@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @send_app_load_messages, ptr null }]",
|
|
37304
|
+
`declare void @sdk_send_load_messages() #${attr}`,
|
|
37305
|
+
"define internal void @send_app_load_messages() {",
|
|
37306
|
+
" tail call void @sdk_send_load_messages()",
|
|
37307
|
+
" ret void",
|
|
37308
|
+
"}"
|
|
37012
37309
|
);
|
|
37310
|
+
}
|
|
37013
37311
|
const forwarders = /* @__PURE__ */ new Set();
|
|
37014
37312
|
let index = 0;
|
|
37015
37313
|
for (const name3 of referenced) {
|
|
37016
37314
|
const signature2 = signatures[name3];
|
|
37017
37315
|
if (signature2 === void 0 || defined.has(name3)) continue;
|
|
37018
|
-
const
|
|
37316
|
+
const colon = signature2.indexOf(":");
|
|
37317
|
+
const params = colon < 0 ? signature2 : signature2.slice(0, colon);
|
|
37318
|
+
const results = colon < 0 ? "" : signature2.slice(colon + 1);
|
|
37019
37319
|
if (results.length > 1) throw new Error(`sdk function ${name3} returns several values`);
|
|
37020
37320
|
const result = results ? type(results)[0] : "void";
|
|
37021
|
-
const
|
|
37022
|
-
const
|
|
37321
|
+
const paramTypes = type(params);
|
|
37322
|
+
const declParams = paramTypes.join(", ");
|
|
37323
|
+
const defParams = paramTypes.map((kind, at) => `${kind} %a${at}`).join(", ");
|
|
37324
|
+
const callArgs = paramTypes.map((kind, at) => `${kind} %a${at}`).join(", ");
|
|
37325
|
+
const attr = addImportAttr(name3);
|
|
37326
|
+
const quoted2 = llvmQuoted(name3);
|
|
37023
37327
|
lines.push(
|
|
37024
|
-
`
|
|
37025
|
-
`
|
|
37026
|
-
|
|
37328
|
+
`declare ${result} @i${index}(${declParams}) #${attr}`,
|
|
37329
|
+
`define weak hidden ${result} @${quoted2}(${defParams}) {`,
|
|
37330
|
+
result === "void" ? ` tail call void @i${index}(${callArgs})
|
|
37331
|
+
ret void` : ` %r = tail call ${result} @i${index}(${callArgs})
|
|
37332
|
+
ret ${result} %r`,
|
|
37333
|
+
"}"
|
|
37027
37334
|
);
|
|
37028
37335
|
forwarders.add(name3);
|
|
37029
37336
|
index++;
|
|
37030
37337
|
}
|
|
37031
37338
|
const errno = tls.errno;
|
|
37032
37339
|
let declaredErrno = false;
|
|
37340
|
+
const usedHelpers = [];
|
|
37033
37341
|
for (const name3 of referenced) {
|
|
37034
37342
|
const offset = tls[name3];
|
|
37035
37343
|
if (offset === void 0 || defined.has(name3)) continue;
|
|
@@ -37037,28 +37345,44 @@ async function compileSdkForwarders(inputs2, sdk2, toolchainBin, output, project
|
|
|
37037
37345
|
throw new Error("the sdk image has no errno to find its thread block by");
|
|
37038
37346
|
if (!declaredErrno) {
|
|
37039
37347
|
declaredErrno = true;
|
|
37348
|
+
const attr = addImportAttr("__errno_location");
|
|
37040
37349
|
lines.push(
|
|
37041
|
-
`
|
|
37350
|
+
`declare ptr @__peach_errno() #${attr}`,
|
|
37351
|
+
"declare ptr @llvm.wasm.tls.base()"
|
|
37042
37352
|
);
|
|
37043
37353
|
}
|
|
37354
|
+
const helper = `@${llvmQuoted(SDK_TLS_HELPER + name3)}`;
|
|
37355
|
+
const delta = `@${llvmQuoted(SDK_TLS_DELTA + name3)}`;
|
|
37356
|
+
usedHelpers.push(`ptr ${helper}`);
|
|
37044
37357
|
lines.push(
|
|
37045
|
-
|
|
37046
|
-
|
|
37047
|
-
`
|
|
37048
|
-
|
|
37358
|
+
`@${llvmQuoted(name3)} = weak hidden thread_local global i8 0, align 1`,
|
|
37359
|
+
`${delta} = external global i8, align 1`,
|
|
37360
|
+
`define hidden i64 ${helper}() {`,
|
|
37361
|
+
" %e = tail call ptr @__peach_errno()",
|
|
37362
|
+
" %ei = ptrtoint ptr %e to i64",
|
|
37363
|
+
` %di = ptrtoint ptr ${delta} to i64`,
|
|
37364
|
+
" %s = add i64 %ei, %di",
|
|
37365
|
+
" %b = tail call ptr @llvm.wasm.tls.base()",
|
|
37366
|
+
" %bi = ptrtoint ptr %b to i64",
|
|
37367
|
+
" %r = sub i64 %s, %bi",
|
|
37368
|
+
" ret i64 %r",
|
|
37369
|
+
"}"
|
|
37049
37370
|
);
|
|
37050
37371
|
index++;
|
|
37051
37372
|
}
|
|
37052
|
-
|
|
37053
|
-
|
|
37373
|
+
if (usedHelpers.length > 0) {
|
|
37374
|
+
lines.push(
|
|
37375
|
+
`@llvm.used = appending global [${usedHelpers.length} x ptr] [${usedHelpers.join(", ")}], section "llvm.metadata"`
|
|
37376
|
+
);
|
|
37377
|
+
}
|
|
37378
|
+
const source = `${output.slice(0, -2)}.ll`;
|
|
37379
|
+
(0, import_node_fs44.writeFileSync)(source, [...lines, ...attrs].join("\n") + "\n");
|
|
37054
37380
|
await run3(
|
|
37055
37381
|
import_node_path42.default.join(toolchainBin, "clang"),
|
|
37056
37382
|
[
|
|
37057
37383
|
`--target=${SWIFT_WASM_TRIPLE}`,
|
|
37058
|
-
"-O2",
|
|
37059
37384
|
"-matomics",
|
|
37060
37385
|
"-mbulk-memory",
|
|
37061
|
-
"-ffreestanding",
|
|
37062
37386
|
"-c",
|
|
37063
37387
|
source,
|
|
37064
37388
|
"-o",
|
|
@@ -37077,7 +37401,8 @@ async function linkSwiftAppModule(options2) {
|
|
|
37077
37401
|
toolchainBin,
|
|
37078
37402
|
forwarders,
|
|
37079
37403
|
options2.project,
|
|
37080
|
-
options2.readInput ?? import_node_fs44.readFileSync
|
|
37404
|
+
options2.readInput ?? import_node_fs44.readFileSync,
|
|
37405
|
+
options2.precomputedSymbols
|
|
37081
37406
|
);
|
|
37082
37407
|
const lazy = options2.lazyFunctions ?? [];
|
|
37083
37408
|
const lazyExports = import_node_path42.default.join(work, "lazy-exports.rsp");
|
|
@@ -38821,6 +39146,15 @@ async function compileGuestLink(options2) {
|
|
|
38821
39146
|
{ stdio: "pipe" }
|
|
38822
39147
|
);
|
|
38823
39148
|
}
|
|
39149
|
+
let precomputedSymbols;
|
|
39150
|
+
if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
|
|
39151
|
+
const referenced = new Set(splitInputs.appReferencedSymbols);
|
|
39152
|
+
const defined = new Set(splitInputs.appDefinedSymbols);
|
|
39153
|
+
const projSyms = guestWasmSymbols((0, import_node_fs45.readFileSync)(projectionObject));
|
|
39154
|
+
for (const name3 of projSyms.undefined) referenced.add(name3);
|
|
39155
|
+
for (const name3 of projSyms.defined) defined.add(name3);
|
|
39156
|
+
precomputedSymbols = { referenced, defined };
|
|
39157
|
+
}
|
|
38824
39158
|
for (; ; ) {
|
|
38825
39159
|
const link = await linkSwiftAppModule2({
|
|
38826
39160
|
objects: [...owners.keys()],
|
|
@@ -38832,6 +39166,7 @@ async function compileGuestLink(options2) {
|
|
|
38832
39166
|
optimize: options2.optimize,
|
|
38833
39167
|
layoutMap,
|
|
38834
39168
|
project: project2,
|
|
39169
|
+
precomputedSymbols,
|
|
38835
39170
|
loweringCache: project2 ? void 0 : {
|
|
38836
39171
|
file: import_node_path43.default.join(
|
|
38837
39172
|
options2.buildDirectory,
|
|
@@ -38956,6 +39291,7 @@ var init_swift_guest_compile = __esm({
|
|
|
38956
39291
|
init_swift_runtime_products();
|
|
38957
39292
|
init_swift_sdk_guest_lookups();
|
|
38958
39293
|
init_swift_toolchain();
|
|
39294
|
+
init_swift_wasm_prune();
|
|
38959
39295
|
init_swiftTargetContract();
|
|
38960
39296
|
init_wasm_optimize();
|
|
38961
39297
|
}
|
|
@@ -40437,7 +40773,25 @@ function swiftBuildJobs() {
|
|
|
40437
40773
|
return Math.min(cores, memoryJobs);
|
|
40438
40774
|
}
|
|
40439
40775
|
function swiftCompilerJobs() {
|
|
40440
|
-
return Math.min(
|
|
40776
|
+
return Math.min(32, swiftBuildJobs(), Math.max(1, Math.floor(import_node_os12.default.totalmem() / 2 ** 31)));
|
|
40777
|
+
}
|
|
40778
|
+
function swiftCompilerBaseEnv(toolchainBin, sourceEnv, includePeachHome = false) {
|
|
40779
|
+
const env = {};
|
|
40780
|
+
for (const key2 of SWIFT_COMPILER_ENV_KEYS) {
|
|
40781
|
+
const value = sourceEnv[key2];
|
|
40782
|
+
if (value !== void 0) env[key2] = value;
|
|
40783
|
+
}
|
|
40784
|
+
if (includePeachHome && sourceEnv.PEACH_HOME !== void 0)
|
|
40785
|
+
env.PEACH_HOME = sourceEnv.PEACH_HOME;
|
|
40786
|
+
if (process.platform === "linux") {
|
|
40787
|
+
env.LD_LIBRARY_PATH = [
|
|
40788
|
+
import_node_path53.default.resolve(toolchainBin, "../lib/swift/linux"),
|
|
40789
|
+
import_node_path53.default.resolve(toolchainBin, "../lib/swift/host"),
|
|
40790
|
+
sourceEnv.LD_LIBRARY_PATH
|
|
40791
|
+
].filter(Boolean).join(":");
|
|
40792
|
+
}
|
|
40793
|
+
env.PEACH_DEFER_WASM_LINK = "1";
|
|
40794
|
+
return env;
|
|
40441
40795
|
}
|
|
40442
40796
|
function assertSwiftBuildCores() {
|
|
40443
40797
|
const admitted = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
|
|
@@ -41626,10 +41980,22 @@ function emitSwiftPackageManifest(args) {
|
|
|
41626
41980
|
const available2 = distribution.objects.filter(
|
|
41627
41981
|
(object8) => !isProvider(object8) && !replacedObjects.has(object8)
|
|
41628
41982
|
);
|
|
41983
|
+
const targetNamesWithDash = targets.filter((target) => target.name.includes("-")).map((target) => `lib/${target.name}-`);
|
|
41984
|
+
const targetNameSet = new Set(targets.map((target) => target.name));
|
|
41985
|
+
const optionalSet = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...GAME_FAMILY, "PeachBox2D"]);
|
|
41986
|
+
const isTargetObject = (object8) => {
|
|
41987
|
+
const dash = object8.indexOf("-", 4);
|
|
41988
|
+
if (dash > 4 && targetNameSet.has(object8.slice(4, dash))) return true;
|
|
41989
|
+
return targetNamesWithDash.some((prefix) => object8.startsWith(prefix));
|
|
41990
|
+
};
|
|
41991
|
+
const isUnreachedOptional = (object8) => {
|
|
41992
|
+
const dash = object8.indexOf("-", 4);
|
|
41993
|
+
if (dash <= 4) return false;
|
|
41994
|
+
const name3 = object8.slice(4, dash);
|
|
41995
|
+
return optionalSet.has(name3) && !reachedFrameworks.has(name3);
|
|
41996
|
+
};
|
|
41629
41997
|
const objects = available2.filter(
|
|
41630
|
-
(object8) => !
|
|
41631
|
-
(name3) => !object8.startsWith(`lib/${name3}-`) || reachedFrameworks.has(name3)
|
|
41632
|
-
)
|
|
41998
|
+
(object8) => !isTargetObject(object8) && !isUnreachedOptional(object8)
|
|
41633
41999
|
);
|
|
41634
42000
|
const quoted2 = (object8) => `"${import_node_path53.default.join(moduleRoot, object8).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
41635
42001
|
const categoryObjects = new Set(
|
|
@@ -41710,18 +42076,53 @@ function emitSwiftPackageManifest(args) {
|
|
|
41710
42076
|
args.files.set(file, content);
|
|
41711
42077
|
return JSON.stringify([`@${file}`]);
|
|
41712
42078
|
};
|
|
41713
|
-
const
|
|
41714
|
-
|
|
41715
|
-
|
|
41716
|
-
const owner = args.targets.find((other) => other.name === dependency);
|
|
42079
|
+
const targetByName = new Map(targets.map((target) => [target.name, target]));
|
|
42080
|
+
const ownFrameworkDir = /* @__PURE__ */ new Map();
|
|
42081
|
+
for (const target of targets) {
|
|
41717
42082
|
const framework = /^(.*)\/[^/]+\.framework\/Modules$/.exec(
|
|
41718
|
-
|
|
42083
|
+
target.publicHeadersPath ?? ""
|
|
41719
42084
|
);
|
|
41720
|
-
|
|
41721
|
-
|
|
41722
|
-
|
|
41723
|
-
|
|
41724
|
-
|
|
42085
|
+
if (framework)
|
|
42086
|
+
ownFrameworkDir.set(
|
|
42087
|
+
target.name,
|
|
42088
|
+
import_node_path53.default.posix.join(args.root, target.path, framework[1])
|
|
42089
|
+
);
|
|
42090
|
+
}
|
|
42091
|
+
const frameworkDirectoriesCache = /* @__PURE__ */ new Map();
|
|
42092
|
+
const frameworkDirectories = (name3) => {
|
|
42093
|
+
if (ownFrameworkDir.size === 0) return [];
|
|
42094
|
+
const cached2 = frameworkDirectoriesCache.get(name3);
|
|
42095
|
+
if (cached2) return cached2;
|
|
42096
|
+
const dirs = [];
|
|
42097
|
+
const seen = /* @__PURE__ */ new Set();
|
|
42098
|
+
const visit3 = (current2) => {
|
|
42099
|
+
for (const dependency of siblings.get(current2) ?? []) {
|
|
42100
|
+
if (seen.has(dependency)) continue;
|
|
42101
|
+
seen.add(dependency);
|
|
42102
|
+
const dir = ownFrameworkDir.get(dependency);
|
|
42103
|
+
if (dir) dirs.push(dir);
|
|
42104
|
+
visit3(dependency);
|
|
42105
|
+
}
|
|
42106
|
+
};
|
|
42107
|
+
visit3(name3);
|
|
42108
|
+
frameworkDirectoriesCache.set(name3, dirs);
|
|
42109
|
+
return dirs;
|
|
42110
|
+
};
|
|
42111
|
+
const targetSwiftXccFlags = /* @__PURE__ */ new Map();
|
|
42112
|
+
for (const target of targets) {
|
|
42113
|
+
const flags = target.swiftFlags;
|
|
42114
|
+
if (!flags || flags.length === 0) continue;
|
|
42115
|
+
const xcc = [];
|
|
42116
|
+
for (let index = 1; index < flags.length; index++) {
|
|
42117
|
+
if (flags[index - 1] === "-Xcc")
|
|
42118
|
+
xcc.push(flags[index].replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root));
|
|
42119
|
+
}
|
|
42120
|
+
if (xcc.length > 0) targetSwiftXccFlags.set(target.name, xcc);
|
|
42121
|
+
}
|
|
42122
|
+
const binaryImports = args.binaryModules ? `, "-I", ${JSON.stringify(args.binaryModules)}` : "";
|
|
42123
|
+
const sharedImports = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
|
|
42124
|
+
providedModulesPath(args.root, distributionModules, args.moduleExcludes)
|
|
42125
|
+
)}${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("")}` : "");
|
|
41725
42126
|
const frameworkSearchFlags = (target, tool) => frameworkDirectories(target?.name ?? "").map((directory2) => ({
|
|
41726
42127
|
tool,
|
|
41727
42128
|
flags: ["-F", directory2]
|
|
@@ -41770,10 +42171,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
41770
42171
|
const upstream = (target.swiftFlags ?? []).map(
|
|
41771
42172
|
(flag) => `, ${JSON.stringify(flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root))}`
|
|
41772
42173
|
).join("");
|
|
41773
|
-
const
|
|
41774
|
-
const imports2 = binaryImports + (distributionModules ? `, "-Isystem", ${JSON.stringify(
|
|
41775
|
-
providedModulesPath(args.root, distributionModules, args.moduleExcludes)
|
|
41776
|
-
)}${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("")}` : "");
|
|
42174
|
+
const imports2 = sharedImports;
|
|
41777
42175
|
const nativeFlags = [
|
|
41778
42176
|
...args.nativeFlags?.get(target.name) ?? [],
|
|
41779
42177
|
...args.nativeHeaderFlags ?? []
|
|
@@ -41797,12 +42195,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
41797
42195
|
return map2 ? ["-fmodule-map-file=" + map2] : [];
|
|
41798
42196
|
}),
|
|
41799
42197
|
...[...importContext].flatMap((name3) => args.native?.get(name3)?.importFlags ?? []),
|
|
41800
|
-
...[...importContext].flatMap((name3) =>
|
|
41801
|
-
const flags = targets.find((target2) => target2.name === name3)?.swiftFlags ?? [];
|
|
41802
|
-
return flags.flatMap(
|
|
41803
|
-
(flag, index) => flags[index - 1] === "-Xcc" ? [flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, args.root)] : []
|
|
41804
|
-
);
|
|
41805
|
-
})
|
|
42198
|
+
...[...importContext].flatMap((name3) => targetSwiftXccFlags.get(name3) ?? [])
|
|
41806
42199
|
];
|
|
41807
42200
|
const nativeImportFlags = [
|
|
41808
42201
|
...frameworkDirectories(target.name).flatMap((directory2) => ["-F", directory2]),
|
|
@@ -41817,9 +42210,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
41817
42210
|
...native?.swiftFlags ?? [],
|
|
41818
42211
|
...args.objcImplementationModules?.has(target.name) ? ["-enable-experimental-feature", "ObjCImplementation"] : []
|
|
41819
42212
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("");
|
|
41820
|
-
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] ||
|
|
41821
|
-
(value) => value.late?.producers.includes(target.name)
|
|
41822
|
-
)) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path53.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
42213
|
+
const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || lateProducers.has(target.name)) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path53.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
|
|
41823
42214
|
const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
|
|
41824
42215
|
const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
|
|
41825
42216
|
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}]`)})]`;
|
|
@@ -41852,9 +42243,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
41852
42243
|
(dependency) => clang && // textual native headers can include one another without imposing
|
|
41853
42244
|
// an object build order. the executable already links every native
|
|
41854
42245
|
// target; only generated Swift headers require producer ordering.
|
|
41855
|
-
(args.native?.get(dependency)?.clang || [
|
|
41856
|
-
(value) => value.late?.producers.includes(dependency)
|
|
41857
|
-
)) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targets.some((candidate) => candidate.name === dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
|
|
42246
|
+
(args.native?.get(dependency)?.clang || lateProducers.has(dependency)) ? [] : OPTIONAL_FRAMEWORKS.has(dependency) && !targetNames.has(dependency) ? linkedObjects ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
|
|
41858
42247
|
),
|
|
41859
42248
|
// a swift importer still needs the producers its clang dependencies
|
|
41860
42249
|
// reached upstream, whose edges the clang targets above dropped.
|
|
@@ -41941,7 +42330,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
41941
42330
|
...args.nativeFlags?.get(name3) ?? [],
|
|
41942
42331
|
...args.nativeHeaderFlags ?? []
|
|
41943
42332
|
];
|
|
41944
|
-
const owner =
|
|
42333
|
+
const owner = targetByName.get(name3);
|
|
41945
42334
|
const context = /* @__PURE__ */ new Set();
|
|
41946
42335
|
const visit3 = (dependency) => {
|
|
41947
42336
|
if (context.has(dependency)) return;
|
|
@@ -42017,10 +42406,16 @@ ${declaration.replace(/,$/, "")}
|
|
|
42017
42406
|
""
|
|
42018
42407
|
].join("\n");
|
|
42019
42408
|
}
|
|
42020
|
-
function syncSwiftTree(base2, files2) {
|
|
42409
|
+
function syncSwiftTree(base2, files2, alreadySynced) {
|
|
42021
42410
|
(0, import_node_fs53.mkdirSync)(base2, { recursive: true });
|
|
42022
|
-
|
|
42023
|
-
|
|
42411
|
+
let kept;
|
|
42412
|
+
if (process.platform !== "linux") {
|
|
42413
|
+
kept = /* @__PURE__ */ new Set();
|
|
42414
|
+
for (const file of files2.keys()) {
|
|
42415
|
+
const stat = (0, import_node_fs53.statSync)(file, { throwIfNoEntry: false });
|
|
42416
|
+
if (stat) kept.add(stat.ino);
|
|
42417
|
+
}
|
|
42418
|
+
}
|
|
42024
42419
|
const walk4 = (dir) => {
|
|
42025
42420
|
for (const entry of (0, import_node_fs53.readdirSync)(dir, { withFileTypes: true })) {
|
|
42026
42421
|
const full = import_node_path53.default.join(dir, entry.name);
|
|
@@ -42029,12 +42424,13 @@ function syncSwiftTree(base2, files2) {
|
|
|
42029
42424
|
entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP))
|
|
42030
42425
|
continue;
|
|
42031
42426
|
if (entry.isDirectory()) walk4(full);
|
|
42032
|
-
else if (!files2.has(full) && !kept.has((0, import_node_fs53.lstatSync)(full).ino))
|
|
42427
|
+
else if (!files2.has(full) && (!kept || !kept.has((0, import_node_fs53.lstatSync)(full).ino)))
|
|
42033
42428
|
(0, import_node_fs53.rmSync)(full, { force: true });
|
|
42034
42429
|
}
|
|
42035
42430
|
};
|
|
42036
42431
|
walk4(base2);
|
|
42037
42432
|
for (const [full, contents2] of files2) {
|
|
42433
|
+
if (alreadySynced?.get(full) === contents2) continue;
|
|
42038
42434
|
writeBuildFile(full, contents2);
|
|
42039
42435
|
}
|
|
42040
42436
|
}
|
|
@@ -42142,25 +42538,59 @@ function swiftWasmCallGuards(source, unavailable2) {
|
|
|
42142
42538
|
out = out.slice(0, at) + replacement + out.slice(at + width);
|
|
42143
42539
|
return out;
|
|
42144
42540
|
}
|
|
42541
|
+
function matchesPathPrefixSet(file, set2) {
|
|
42542
|
+
if (set2.has(file)) return true;
|
|
42543
|
+
for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
|
|
42544
|
+
if (set2.has(file.slice(0, slash))) return true;
|
|
42545
|
+
}
|
|
42546
|
+
return false;
|
|
42547
|
+
}
|
|
42548
|
+
function indexTargetsByDirectory(targets) {
|
|
42549
|
+
const byDir = /* @__PURE__ */ new Map();
|
|
42550
|
+
for (const target of targets) {
|
|
42551
|
+
const key2 = target.path === "." ? "" : target.path.replace(/\/+$/, "");
|
|
42552
|
+
let list2 = byDir.get(key2);
|
|
42553
|
+
if (!list2) byDir.set(key2, list2 = []);
|
|
42554
|
+
list2.push(target);
|
|
42555
|
+
}
|
|
42556
|
+
return byDir;
|
|
42557
|
+
}
|
|
42558
|
+
function findTargetForFile(file, byDir, predicate) {
|
|
42559
|
+
for (let slash = file.lastIndexOf("/"); slash !== -1; slash = file.lastIndexOf("/", slash - 1)) {
|
|
42560
|
+
const candidates = byDir.get(file.slice(0, slash));
|
|
42561
|
+
if (!candidates) continue;
|
|
42562
|
+
const relative4 = file.slice(slash + 1);
|
|
42563
|
+
for (const target of candidates) if (predicate(target, relative4)) return target;
|
|
42564
|
+
}
|
|
42565
|
+
const rootCandidates = byDir.get("");
|
|
42566
|
+
if (rootCandidates) {
|
|
42567
|
+
for (const target of rootCandidates) if (predicate(target, file)) return target;
|
|
42568
|
+
}
|
|
42569
|
+
return void 0;
|
|
42570
|
+
}
|
|
42145
42571
|
function compiledSwiftSources(files2, targets, overlayFrameworks, headers, nativeSourceGlue = false) {
|
|
42146
42572
|
const ordered = [...targets].sort((a, b) => b.path.length - a.path.length);
|
|
42147
|
-
const
|
|
42148
|
-
|
|
42149
|
-
|
|
42150
|
-
|
|
42151
|
-
|
|
42152
|
-
|
|
42153
|
-
|
|
42154
|
-
|
|
42155
|
-
|
|
42156
|
-
|
|
42157
|
-
return
|
|
42158
|
-
})
|
|
42159
|
-
|
|
42573
|
+
const byDir = indexTargetsByDirectory(ordered);
|
|
42574
|
+
const excludeSets = /* @__PURE__ */ new Map();
|
|
42575
|
+
for (const target of ordered) {
|
|
42576
|
+
if (target.exclude?.length) excludeSets.set(target.name, new Set(target.exclude));
|
|
42577
|
+
}
|
|
42578
|
+
const owners = /* @__PURE__ */ new Map();
|
|
42579
|
+
for (const [file, source] of Object.entries(files2)) {
|
|
42580
|
+
if (!file.endsWith(".swift")) continue;
|
|
42581
|
+
const owner = findTargetForFile(file, byDir, (target, relative4) => {
|
|
42582
|
+
const excluded = excludeSets.get(target.name);
|
|
42583
|
+
return !excluded || !matchesPathPrefixSet(relative4, excluded);
|
|
42584
|
+
});
|
|
42585
|
+
owners.set(file, { source, owner });
|
|
42586
|
+
}
|
|
42160
42587
|
const swiftSources = /* @__PURE__ */ new Map();
|
|
42161
|
-
for (const { source, owner } of owners.values())
|
|
42162
|
-
if (owner)
|
|
42163
|
-
|
|
42588
|
+
for (const { source, owner } of owners.values()) {
|
|
42589
|
+
if (!owner) continue;
|
|
42590
|
+
let list2 = swiftSources.get(owner.name);
|
|
42591
|
+
if (!list2) swiftSources.set(owner.name, list2 = []);
|
|
42592
|
+
list2.push(source);
|
|
42593
|
+
}
|
|
42164
42594
|
const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
|
|
42165
42595
|
return new Map(
|
|
42166
42596
|
[...owners].map(([file, { source, owner }]) => {
|
|
@@ -42940,18 +43370,46 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
42940
43370
|
const bySourcePath = [...targets].sort(
|
|
42941
43371
|
(left, right) => right.path.length - left.path.length
|
|
42942
43372
|
);
|
|
43373
|
+
const targetsByDir = indexTargetsByDirectory(bySourcePath);
|
|
43374
|
+
const targetByName = new Map(targets.map((target) => [target.name, target]));
|
|
43375
|
+
const nativeTargets2 = input.nativeTargets ?? [];
|
|
43376
|
+
const nativeTargetByName = new Map(nativeTargets2.map((target) => [target.name, target]));
|
|
43377
|
+
const nativeTargetIndex = new Map(
|
|
43378
|
+
nativeTargets2.map((target, index) => [target.name, index])
|
|
43379
|
+
);
|
|
43380
|
+
const resourceTargetByName = new Map(
|
|
43381
|
+
resourceTargets.map((target) => [target.name, target])
|
|
43382
|
+
);
|
|
43383
|
+
const targetSourceSets = /* @__PURE__ */ new Map();
|
|
43384
|
+
const targetExcludeFullSets = /* @__PURE__ */ new Map();
|
|
43385
|
+
const targetExcludeExactSets = /* @__PURE__ */ new Map();
|
|
43386
|
+
for (const target of targets) {
|
|
43387
|
+
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
43388
|
+
if (target.sources !== void 0) {
|
|
43389
|
+
targetSourceSets.set(
|
|
43390
|
+
target.name,
|
|
43391
|
+
new Set(target.sources.map((source) => import_node_path53.default.posix.join(prefix, source)))
|
|
43392
|
+
);
|
|
43393
|
+
}
|
|
43394
|
+
if (target.exclude?.length) {
|
|
43395
|
+
targetExcludeFullSets.set(
|
|
43396
|
+
target.name,
|
|
43397
|
+
new Set(target.exclude.map((excluded) => `${prefix}${excluded}`))
|
|
43398
|
+
);
|
|
43399
|
+
targetExcludeExactSets.set(
|
|
43400
|
+
target.name,
|
|
43401
|
+
new Set(target.exclude.map((name3) => import_node_path53.default.posix.join(target.path, name3)))
|
|
43402
|
+
);
|
|
43403
|
+
}
|
|
43404
|
+
}
|
|
42943
43405
|
const swiftTargets = /* @__PURE__ */ new Set();
|
|
42944
43406
|
for (const file of Object.keys(input.files)) {
|
|
42945
43407
|
if (!file.endsWith(".swift")) continue;
|
|
42946
|
-
const target =
|
|
42947
|
-
|
|
42948
|
-
|
|
42949
|
-
|
|
42950
|
-
|
|
42951
|
-
);
|
|
42952
|
-
const excluded = target?.exclude?.some(
|
|
42953
|
-
(name3) => file === import_node_path53.default.posix.join(target.path, name3)
|
|
42954
|
-
);
|
|
43408
|
+
const target = findTargetForFile(file, targetsByDir, (candidate) => {
|
|
43409
|
+
const selected = targetSourceSets.get(candidate.name);
|
|
43410
|
+
return !selected || matchesPathPrefixSet(file, selected);
|
|
43411
|
+
});
|
|
43412
|
+
const excluded = target && targetExcludeExactSets.get(target.name)?.has(file);
|
|
42955
43413
|
if (target && !excluded) swiftTargets.add(target.name);
|
|
42956
43414
|
}
|
|
42957
43415
|
const importedModules = /* @__PURE__ */ new Set();
|
|
@@ -42989,7 +43447,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
42989
43447
|
checkedToolchain = swiftToolchain(pin2.release, swiftModuleSdk(moduleRoot));
|
|
42990
43448
|
return checkedToolchain;
|
|
42991
43449
|
};
|
|
42992
|
-
const deploymentTarget = (name3) =>
|
|
43450
|
+
const deploymentTarget = (name3) => nativeTargetByName.get(name3)?.deploymentTarget ?? targetByName.get(name3)?.iosDeploymentTarget ?? null;
|
|
42993
43451
|
const targetStagedFiles = /* @__PURE__ */ new Map();
|
|
42994
43452
|
const stageTargetFile = (target, file, contents2, options2) => {
|
|
42995
43453
|
const relative4 = import_node_path53.default.relative(layout2.root, file).split(import_node_path53.default.sep).join(import_node_path53.default.posix.sep);
|
|
@@ -43001,18 +43459,41 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
43001
43459
|
targetStagedFiles.set(target, staged);
|
|
43002
43460
|
files2.set(file, contents2);
|
|
43003
43461
|
};
|
|
43462
|
+
const entriesByPrefix = /* @__PURE__ */ new Map();
|
|
43463
|
+
for (const target of targets) {
|
|
43464
|
+
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
43465
|
+
if (!entriesByPrefix.has(prefix)) entriesByPrefix.set(prefix, []);
|
|
43466
|
+
}
|
|
43467
|
+
for (const entry of Object.entries(input.files)) {
|
|
43468
|
+
const [file] = entry;
|
|
43469
|
+
entriesByPrefix.get("")?.push(entry);
|
|
43470
|
+
for (let end = file.indexOf("/"); end !== -1; end = file.indexOf("/", end + 1)) {
|
|
43471
|
+
entriesByPrefix.get(file.slice(0, end + 1))?.push(entry);
|
|
43472
|
+
}
|
|
43473
|
+
}
|
|
43474
|
+
const targetEntriesCache = /* @__PURE__ */ new Map();
|
|
43004
43475
|
const targetEntries = (target) => {
|
|
43476
|
+
const cached2 = targetEntriesCache.get(target.name);
|
|
43477
|
+
if (cached2) return cached2;
|
|
43005
43478
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
43006
|
-
|
|
43007
|
-
|
|
43008
|
-
|
|
43009
|
-
|
|
43010
|
-
|
|
43011
|
-
(
|
|
43012
|
-
|
|
43013
|
-
|
|
43014
|
-
)
|
|
43015
|
-
|
|
43479
|
+
const selectedSources = targetSourceSets.get(target.name);
|
|
43480
|
+
const excludedPaths = targetExcludeFullSets.get(target.name);
|
|
43481
|
+
const nestedPrefixes = [];
|
|
43482
|
+
for (const candidate of targets) {
|
|
43483
|
+
if (candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix))
|
|
43484
|
+
nestedPrefixes.push(`${candidate.path}/`);
|
|
43485
|
+
}
|
|
43486
|
+
const matched = (entriesByPrefix.get(prefix) ?? []).filter(([file]) => {
|
|
43487
|
+
if (selectedSources !== void 0 && (file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) && !matchesPathPrefixSet(file, selectedSources))
|
|
43488
|
+
return false;
|
|
43489
|
+
if (excludedPaths !== void 0 && matchesPathPrefixSet(file, excludedPaths))
|
|
43490
|
+
return false;
|
|
43491
|
+
if (nestedPrefixes.length > 0 && nestedPrefixes.some((p) => file.startsWith(p)))
|
|
43492
|
+
return false;
|
|
43493
|
+
return true;
|
|
43494
|
+
});
|
|
43495
|
+
targetEntriesCache.set(target.name, matched);
|
|
43496
|
+
return matched;
|
|
43016
43497
|
};
|
|
43017
43498
|
const failTargetPreparation = (target, message) => {
|
|
43018
43499
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
@@ -43057,19 +43538,21 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
43057
43538
|
return value;
|
|
43058
43539
|
};
|
|
43059
43540
|
const podHeaders = /* @__PURE__ */ new Map();
|
|
43060
|
-
for (const settings of
|
|
43541
|
+
for (const settings of nativeTargets2)
|
|
43061
43542
|
for (const file of settings.headers) {
|
|
43062
43543
|
const owner = /\/Headers\/(?:Public|Private)\/([\w+-]+)\/(?:\1\/)?[^/]+\.h$/.exec(
|
|
43063
43544
|
file
|
|
43064
43545
|
)?.[1];
|
|
43065
|
-
if (owner)
|
|
43066
|
-
|
|
43067
|
-
|
|
43068
|
-
|
|
43069
|
-
]);
|
|
43546
|
+
if (owner) {
|
|
43547
|
+
const base2 = import_node_path53.default.basename(file);
|
|
43548
|
+
let list2 = podHeaders.get(base2);
|
|
43549
|
+
if (!list2) podHeaders.set(base2, list2 = []);
|
|
43550
|
+
list2.push({ owner, content: input.files[file] });
|
|
43551
|
+
}
|
|
43070
43552
|
}
|
|
43071
43553
|
const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(import_node_path53.default.basename(file))?.find((header) => header.content === content)?.owner;
|
|
43072
|
-
|
|
43554
|
+
const alreadySynced = /* @__PURE__ */ new Map();
|
|
43555
|
+
for (const settings of nativeTargets2) {
|
|
43073
43556
|
for (const file of settings.headers) {
|
|
43074
43557
|
const destination = import_node_path53.default.join(layout2.root, file);
|
|
43075
43558
|
if (files2.has(destination)) continue;
|
|
@@ -43086,10 +43569,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
43086
43569
|
`#import <${interfaceOwner}/${interfaceOwner}-Swift.h>`
|
|
43087
43570
|
) : rawContents;
|
|
43088
43571
|
writeBuildFile(destination, contents2);
|
|
43572
|
+
alreadySynced.set(destination, contents2);
|
|
43089
43573
|
files2.set(destination, contents2);
|
|
43090
43574
|
}
|
|
43091
43575
|
}
|
|
43092
|
-
const nativeTargets2 = input.nativeTargets ?? [];
|
|
43093
43576
|
const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? import_node_path53.default.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
|
|
43094
43577
|
const inRoot = `${layout2.root}${import_node_path53.default.sep}`;
|
|
43095
43578
|
const binaryTree = `${import_node_path53.default.sep}${SWIFT_BINARY_TREES_DIR}${import_node_path53.default.sep}`;
|
|
@@ -43154,12 +43637,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
43154
43637
|
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
43155
43638
|
const entries2 = targetEntries(target);
|
|
43156
43639
|
const units = entries2.filter(([file]) => isSwiftNativeTranslationUnit(file));
|
|
43157
|
-
|
|
43158
|
-
|
|
43159
|
-
)))
|
|
43640
|
+
const settings = nativeTargetByName.get(target.name);
|
|
43641
|
+
if (units.length === 0 && !(entries2.some(([file]) => file.endsWith(".swift")) && settings !== void 0 && (settings.publicHeaders.length > 0 || settings.bridgingHeader !== null)))
|
|
43160
43642
|
continue;
|
|
43161
43643
|
const includes = `${prefix}include/`;
|
|
43162
|
-
const settings = input.nativeTargets?.find((value) => value.name === target.name);
|
|
43163
43644
|
const searchRoots = [
|
|
43164
43645
|
...settings?.userHeaderSearchPaths ?? [],
|
|
43165
43646
|
...settings?.headerSearchPaths ?? [],
|
|
@@ -43190,7 +43671,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
43190
43671
|
...searchRoots.map((root) => import_node_path53.default.posix.join(root, include))
|
|
43191
43672
|
].find((candidate) => input.files[candidate] !== void 0);
|
|
43192
43673
|
if (local) {
|
|
43193
|
-
|
|
43674
|
+
let parents = reverse.get(local);
|
|
43675
|
+
if (!parents) reverse.set(local, parents = []);
|
|
43676
|
+
parents.push(file);
|
|
43194
43677
|
if (xcodeTarget && !seenHeaders.has(local)) {
|
|
43195
43678
|
seenHeaders.add(local);
|
|
43196
43679
|
searchEntries.push([local, input.files[local]]);
|
|
@@ -43236,9 +43719,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
43236
43719
|
const stageFlags = (flags2, sdkInclude2) => flags2.map(
|
|
43237
43720
|
(flag) => flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout2.root).replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude2)
|
|
43238
43721
|
);
|
|
43722
|
+
const settingsHeaderFlags = headerSearch.flags[nativeTargetIndex.get(settings.name)];
|
|
43239
43723
|
const originalFlags = [
|
|
43240
43724
|
...settings.flags,
|
|
43241
|
-
...
|
|
43725
|
+
...settingsHeaderFlags,
|
|
43242
43726
|
...search,
|
|
43243
43727
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
43244
43728
|
"-F",
|
|
@@ -43249,7 +43733,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
43249
43733
|
];
|
|
43250
43734
|
const importOriginalFlags = settings.flattensPublicHeaders ? [
|
|
43251
43735
|
...settings.importerFlags,
|
|
43252
|
-
...
|
|
43736
|
+
...settingsHeaderFlags,
|
|
43253
43737
|
...search,
|
|
43254
43738
|
...settings.frameworkSearchPaths.flatMap((dir) => [
|
|
43255
43739
|
"-F",
|
|
@@ -43274,7 +43758,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
43274
43758
|
}
|
|
43275
43759
|
return [
|
|
43276
43760
|
...kept,
|
|
43277
|
-
...
|
|
43761
|
+
...settingsHeaderFlags,
|
|
43278
43762
|
...search,
|
|
43279
43763
|
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
43280
43764
|
"-F",
|
|
@@ -43303,7 +43787,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
43303
43787
|
const bundleName = entries2.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
|
|
43304
43788
|
target: target.name,
|
|
43305
43789
|
path: target.path,
|
|
43306
|
-
resources:
|
|
43790
|
+
resources: resourceTargetByName.get(target.name)?.resources ?? false,
|
|
43307
43791
|
usesBundleMacro: entries2.some(
|
|
43308
43792
|
([file, contents2]) => (isSwiftNativeTranslationUnit(file) || /\.(?:h|hpp|hh|hxx)$/.test(file)) && /\bSWIFTPM_MODULE_BUNDLE\b/.test(contents2)
|
|
43309
43793
|
),
|
|
@@ -43456,10 +43940,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
43456
43940
|
.../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
|
|
43457
43941
|
...stageFlags(
|
|
43458
43942
|
[...objcCxx ? settings.cxxFlags : [], ...fileFlags],
|
|
43459
|
-
|
|
43460
|
-
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
43461
|
-
"darwin/usr/include"
|
|
43462
|
-
)
|
|
43943
|
+
sdkInclude
|
|
43463
43944
|
)
|
|
43464
43945
|
];
|
|
43465
43946
|
const moduleFlag = perFile.some((flag) => flag.startsWith("-fmodule-name=")) ? [] : [`-fmodule-name=${swiftTargetModuleName(target.name)}`];
|
|
@@ -43499,13 +43980,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
|
|
|
43499
43980
|
...flags,
|
|
43500
43981
|
...prefixHeader,
|
|
43501
43982
|
...accessorFlags,
|
|
43502
|
-
...stageFlags(
|
|
43503
|
-
cxx ? settings.cxxFlags : [],
|
|
43504
|
-
import_node_path53.default.join(
|
|
43505
|
-
swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
|
|
43506
|
-
"darwin/usr/include"
|
|
43507
|
-
)
|
|
43508
|
-
),
|
|
43983
|
+
...stageFlags(cxx ? settings.cxxFlags : [], sdkInclude),
|
|
43509
43984
|
...perFile,
|
|
43510
43985
|
...moduleFlag
|
|
43511
43986
|
]
|
|
@@ -43760,7 +44235,9 @@ module ${moduleName2}.Swift {
|
|
|
43760
44235
|
}
|
|
43761
44236
|
` : swiftObjCModuleMap(
|
|
43762
44237
|
moduleName2,
|
|
43763
|
-
(
|
|
44238
|
+
(nativeTargetByName.get(name3)?.publicHeaders ?? []).map(
|
|
44239
|
+
(header) => import_node_path53.default.join(layout2.root, header)
|
|
44240
|
+
),
|
|
43764
44241
|
submoduleImports2.get(moduleName2),
|
|
43765
44242
|
import_node_path53.default.join(headerDirectory, name3 + "-Swift.h")
|
|
43766
44243
|
)
|
|
@@ -44310,6 +44787,7 @@ ${entry}`);
|
|
|
44310
44787
|
files2.set(destination, Buffer.from(bytes, "base64"));
|
|
44311
44788
|
}
|
|
44312
44789
|
const targetToolset = nativeToolset || native.size > 0;
|
|
44790
|
+
let usesObjcPrebuilt = false;
|
|
44313
44791
|
if (targetToolset) {
|
|
44314
44792
|
const nativeToolsetFlags = [
|
|
44315
44793
|
...headerAliasFlags,
|
|
@@ -44330,6 +44808,7 @@ ${entry}`);
|
|
|
44330
44808
|
[...native.keys()],
|
|
44331
44809
|
objcPrebuiltStage
|
|
44332
44810
|
) : [];
|
|
44811
|
+
usesObjcPrebuilt = prebuiltCompiler.length > 0;
|
|
44333
44812
|
files2.set(
|
|
44334
44813
|
clangWrapper2,
|
|
44335
44814
|
[
|
|
@@ -44638,17 +45117,39 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
44638
45117
|
(name3) => !nativePrerequisiteSet.has(name3)
|
|
44639
45118
|
);
|
|
44640
45119
|
const nativeTargetUnitCount = /* @__PURE__ */ new Map();
|
|
45120
|
+
const nativeTargetSources = /* @__PURE__ */ new Map();
|
|
44641
45121
|
for (const target of manifestTargets)
|
|
44642
|
-
if (target.sources?.length)
|
|
45122
|
+
if (target.sources?.length) {
|
|
44643
45123
|
nativeTargetUnitCount.set(target.name, target.sources.length);
|
|
45124
|
+
nativeTargetSources.set(target.name, target.sources);
|
|
45125
|
+
}
|
|
44644
45126
|
for (const [name3, plan] of native) {
|
|
44645
|
-
if (!plan.mixed && plan.sources.length > 0)
|
|
44646
|
-
|
|
44647
|
-
|
|
45127
|
+
if (!plan.mixed && plan.sources.length > 0) {
|
|
45128
|
+
const sources = plan.clang?.sources ?? plan.sources;
|
|
45129
|
+
nativeTargetUnitCount.set(name3, sources.length);
|
|
45130
|
+
nativeTargetSources.set(name3, sources);
|
|
45131
|
+
}
|
|
45132
|
+
for (const group of plan.groups ?? []) {
|
|
44648
45133
|
nativeTargetUnitCount.set(group.name, group.sources.length);
|
|
44649
|
-
|
|
45134
|
+
nativeTargetSources.set(group.name, group.sources);
|
|
45135
|
+
}
|
|
45136
|
+
if (plan.late && !plan.groups?.length) {
|
|
44650
45137
|
nativeTargetUnitCount.set(plan.late.name, plan.sources.length);
|
|
45138
|
+
nativeTargetSources.set(plan.late.name, plan.lateSources);
|
|
45139
|
+
}
|
|
44651
45140
|
}
|
|
45141
|
+
const nativeStageObjects = /* @__PURE__ */ new Map();
|
|
45142
|
+
const recordStageObjects = (stageTarget, members2) => {
|
|
45143
|
+
const objects = [];
|
|
45144
|
+
for (const member of members2) {
|
|
45145
|
+
const sources = nativeTargetSources.get(member);
|
|
45146
|
+
if (!sources || sources.length === 0) return stageTarget;
|
|
45147
|
+
for (const source of sources)
|
|
45148
|
+
objects.push(import_node_path53.default.join(`${member}.build`, `${source}.o`));
|
|
45149
|
+
}
|
|
45150
|
+
nativeStageObjects.set(stageTarget, objects);
|
|
45151
|
+
return stageTarget;
|
|
45152
|
+
};
|
|
44652
45153
|
const MAX_NATIVE_STAGE_UNITS = 250;
|
|
44653
45154
|
const chunkNativeStageTargets = (prefix, names) => {
|
|
44654
45155
|
if (names.length === 0) return [];
|
|
@@ -44657,7 +45158,7 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
44657
45158
|
0
|
|
44658
45159
|
);
|
|
44659
45160
|
if (names.length === 1 || total <= MAX_NATIVE_STAGE_UNITS)
|
|
44660
|
-
return [buildProduct(prefix, names)];
|
|
45161
|
+
return [recordStageObjects(buildProduct(prefix, names), names)];
|
|
44661
45162
|
const chunks = [];
|
|
44662
45163
|
let current2 = [];
|
|
44663
45164
|
let count = 0;
|
|
@@ -44672,7 +45173,9 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
44672
45173
|
count += size2;
|
|
44673
45174
|
}
|
|
44674
45175
|
if (current2.length > 0) chunks.push(current2);
|
|
44675
|
-
return chunks.map(
|
|
45176
|
+
return chunks.map(
|
|
45177
|
+
(members2, index) => recordStageObjects(buildProduct(`${prefix}${index + 1}`, members2), members2)
|
|
45178
|
+
);
|
|
44676
45179
|
};
|
|
44677
45180
|
const nativePrerequisiteStageTargets = chunkNativeStageTargets(
|
|
44678
45181
|
"PeachHeaderNativePrereqs",
|
|
@@ -44683,7 +45186,7 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
44683
45186
|
remainingNativeBuildTargets
|
|
44684
45187
|
);
|
|
44685
45188
|
files2.set(manifestPath, manifest);
|
|
44686
|
-
syncSwiftTree(layout2.root, files2);
|
|
45189
|
+
syncSwiftTree(layout2.root, files2, alreadySynced);
|
|
44687
45190
|
if (layout2.multi)
|
|
44688
45191
|
for (const target of targets)
|
|
44689
45192
|
(0, import_node_fs53.mkdirSync)(import_node_path53.default.join(layout2.root, target.path), { recursive: true });
|
|
@@ -44698,7 +45201,9 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
|
|
|
44698
45201
|
targetFailures,
|
|
44699
45202
|
generatedOwners,
|
|
44700
45203
|
targetToolset,
|
|
44701
|
-
headerCompiler
|
|
45204
|
+
headerCompiler,
|
|
45205
|
+
usesObjcPrebuilt,
|
|
45206
|
+
nativeStageObjects
|
|
44702
45207
|
};
|
|
44703
45208
|
}
|
|
44704
45209
|
function streamText(value) {
|
|
@@ -45784,8 +46289,8 @@ ${cap}` : "";
|
|
|
45784
46289
|
work,
|
|
45785
46290
|
unoptimized
|
|
45786
46291
|
);
|
|
45787
|
-
const baseBuildEnv = {
|
|
45788
|
-
...options2.project
|
|
46292
|
+
const baseBuildEnv = options2.project?.env ? {
|
|
46293
|
+
...options2.project.env,
|
|
45789
46294
|
// shipped host plugins resolve against the selected compiler's runtime.
|
|
45790
46295
|
...process.platform === "linux" ? {
|
|
45791
46296
|
LD_LIBRARY_PATH: [
|
|
@@ -45795,7 +46300,7 @@ ${cap}` : "";
|
|
|
45795
46300
|
].filter(Boolean).join(":")
|
|
45796
46301
|
} : {},
|
|
45797
46302
|
PEACH_DEFER_WASM_LINK: "1"
|
|
45798
|
-
};
|
|
46303
|
+
} : swiftCompilerBaseEnv(options2.toolchainBin, process.env);
|
|
45799
46304
|
const {
|
|
45800
46305
|
frameworkRoot,
|
|
45801
46306
|
compileFrameworkRoot,
|
|
@@ -45939,7 +46444,11 @@ ${cap}` : "";
|
|
|
45939
46444
|
} : {
|
|
45940
46445
|
...buildOptions,
|
|
45941
46446
|
temporaryDirectory,
|
|
45942
|
-
env: {
|
|
46447
|
+
env: {
|
|
46448
|
+
...buildOptions.env,
|
|
46449
|
+
...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
|
|
46450
|
+
...compiler
|
|
46451
|
+
}
|
|
45943
46452
|
};
|
|
45944
46453
|
const unprepared = preparation.targetFailures.map(
|
|
45945
46454
|
(failure2) => `error: target ${failure2}`
|
|
@@ -45986,10 +46495,18 @@ ${cap}` : "";
|
|
|
45986
46495
|
// the mirror finds a changed sdk header's readers in their
|
|
45987
46496
|
// dependency files, which omit system headers by default
|
|
45988
46497
|
...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
|
|
45989
|
-
// the link strips debug info, so none is generated (as for the framework)
|
|
46498
|
+
// the link strips debug info, so none is generated (as for the framework).
|
|
46499
|
+
// keep -num-threads fixed across caller core caps so llbuild does not
|
|
46500
|
+
// rebuild every target when callers alternate --cores, and bound backend
|
|
46501
|
+
// fan-out under high -j.
|
|
45990
46502
|
"-Xswiftc",
|
|
45991
46503
|
"-gnone",
|
|
45992
|
-
...incrementalPreview ? [] : [
|
|
46504
|
+
...incrementalPreview ? [] : [
|
|
46505
|
+
"-Xswiftc",
|
|
46506
|
+
"-num-threads",
|
|
46507
|
+
"-Xswiftc",
|
|
46508
|
+
String(perFile ? 1 : Math.min(8, import_node_os12.default.availableParallelism()))
|
|
46509
|
+
],
|
|
45993
46510
|
...swiftReproducibleBuildFlags([
|
|
45994
46511
|
[import_node_path53.default.dirname(options2.toolchainBin), "toolchain"],
|
|
45995
46512
|
[compileFrameworkRoot, "framework"],
|
|
@@ -46164,7 +46681,18 @@ ${cap}` : "";
|
|
|
46164
46681
|
}))
|
|
46165
46682
|
];
|
|
46166
46683
|
const checkpoints = import_node_path53.default.join(root, ".build", "peach-product-checkpoints");
|
|
46684
|
+
const buildDbExists = (0, import_node_fs53.existsSync)(import_node_path53.default.join(root, ".build", "build.db"));
|
|
46685
|
+
const releaseDir = import_node_path53.default.dirname(linked);
|
|
46167
46686
|
for (const { target, producers } of stages) {
|
|
46687
|
+
if (!options2.project && producers.length === 0 && buildDbExists) {
|
|
46688
|
+
const expectedObjects = preparation.nativeStageObjects.get(target);
|
|
46689
|
+
if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
|
|
46690
|
+
(relative4) => (0, import_node_fs53.statSync)(import_node_path53.default.join(releaseDir, relative4), {
|
|
46691
|
+
throwIfNoEntry: false
|
|
46692
|
+
})?.isFile()
|
|
46693
|
+
))
|
|
46694
|
+
continue;
|
|
46695
|
+
}
|
|
46168
46696
|
const receipt = import_node_path53.default.join(
|
|
46169
46697
|
checkpoints,
|
|
46170
46698
|
(0, import_node_crypto32.createHash)("sha256").update(target).digest("hex")
|
|
@@ -46389,7 +46917,7 @@ ${cap}` : "";
|
|
|
46389
46917
|
options2.signal
|
|
46390
46918
|
);
|
|
46391
46919
|
}
|
|
46392
|
-
var import_node_child_process32, import_node_crypto32, import_node_fs53, import_node_os12, import_node_path53, 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;
|
|
46920
|
+
var import_node_child_process32, import_node_crypto32, import_node_fs53, import_node_os12, import_node_path53, 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;
|
|
46393
46921
|
var init_swift_compile = __esm({
|
|
46394
46922
|
"src/swift-compile.ts"() {
|
|
46395
46923
|
"use strict";
|
|
@@ -46442,6 +46970,29 @@ var init_swift_compile = __esm({
|
|
|
46442
46970
|
WASM_TRIPLE = SWIFT_WASM_TRIPLE;
|
|
46443
46971
|
SWIFTPM_PROGRESS = /^\[\d+\/\d+\] /;
|
|
46444
46972
|
SWIFTPM_NOISE = /^(?:\[\d+\/\d+\] |Building for production\.\.\.$|warning: '--build-system native' has been deprecated)/;
|
|
46973
|
+
SWIFT_COMPILER_ENV_KEYS = [
|
|
46974
|
+
"PATH",
|
|
46975
|
+
"HOME",
|
|
46976
|
+
"USER",
|
|
46977
|
+
"LOGNAME",
|
|
46978
|
+
"LANG",
|
|
46979
|
+
"LC_ALL",
|
|
46980
|
+
"LC_CTYPE",
|
|
46981
|
+
"TZ",
|
|
46982
|
+
"SDKROOT",
|
|
46983
|
+
"DEVELOPER_DIR",
|
|
46984
|
+
"DYLD_LIBRARY_PATH",
|
|
46985
|
+
"SYSTEMROOT",
|
|
46986
|
+
"COMSPEC",
|
|
46987
|
+
"SSL_CERT_FILE",
|
|
46988
|
+
"SSL_CERT_DIR",
|
|
46989
|
+
"HTTP_PROXY",
|
|
46990
|
+
"HTTPS_PROXY",
|
|
46991
|
+
"NO_PROXY",
|
|
46992
|
+
"http_proxy",
|
|
46993
|
+
"https_proxy",
|
|
46994
|
+
"no_proxy"
|
|
46995
|
+
];
|
|
46445
46996
|
distributionManifests = /* @__PURE__ */ new Map();
|
|
46446
46997
|
distributionCompileViews = /* @__PURE__ */ new WeakMap();
|
|
46447
46998
|
REACH_STAGED_FRAMEWORKS = /* @__PURE__ */ new Set(["React"]);
|
|
@@ -46637,7 +47188,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
46637
47188
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
46638
47189
|
MULTI_MANIFEST_VERSION = 76;
|
|
46639
47190
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
46640
|
-
compilerSourceDigest = true ? "
|
|
47191
|
+
compilerSourceDigest = true ? "4d55fa7cbb29586c08e4e51867226f96047bae2103c89f4fa59d9cf3ed3862fb" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
46641
47192
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
46642
47193
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
46643
47194
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
@@ -87084,7 +87635,7 @@ var init_swift_standin_digest = __esm({
|
|
|
87084
87635
|
STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
|
|
87085
87636
|
SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
87086
87637
|
standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
|
|
87087
|
-
STANDIN_SOURCE_DIGEST = true ? "
|
|
87638
|
+
STANDIN_SOURCE_DIGEST = true ? "803880cad876e27e4e621723b8eae85b3c486a882db0f0f745babaf80c070680" : standinSourceDigest();
|
|
87088
87639
|
}
|
|
87089
87640
|
});
|
|
87090
87641
|
|
|
@@ -103546,7 +104097,7 @@ var init_nitro_superset = __esm({
|
|
|
103546
104097
|
init_nitroContract();
|
|
103547
104098
|
init_swift_standin_digest();
|
|
103548
104099
|
NITRO_SUPERSET_ENTRY_NAME = "superset";
|
|
103549
|
-
NITRO_COMPILER_DIGEST = true ? "
|
|
104100
|
+
NITRO_COMPILER_DIGEST = true ? "e035fd2365cc4b70f472d1b90eb9d912a775ab289e281922a22092c6945c4f46" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
|
|
103550
104101
|
nitroSupersetLock = parseLock(nitro_superset_lock_default);
|
|
103551
104102
|
nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
|
|
103552
104103
|
published = /* @__PURE__ */ new Map();
|
|
@@ -104414,7 +104965,7 @@ var init_expo_eager_seam_contract = __esm({
|
|
|
104414
104965
|
|
|
104415
104966
|
// src/expo-native-compiler-digest.ts
|
|
104416
104967
|
function expoNativeCompilerDigestValue() {
|
|
104417
|
-
return true ? "
|
|
104968
|
+
return true ? "4e04e854647f1a1e167543007b405e6d43a936b2b02d7be227ac14a5bcb224f9" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
|
|
104418
104969
|
}
|
|
104419
104970
|
var import_node_crypto78;
|
|
104420
104971
|
var init_expo_native_compiler_digest = __esm({
|