peachsim 0.1.2589 → 0.1.2591
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 +1490 -534
- 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-6FUOY6FX.mjs → acorn-EMX4WZ72.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-33SCXU3Y.mjs → chunk-4QHHRGO4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-Y4PV4HZB.mjs → chunk-7627LKJK.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-M4KUWGU3.mjs → chunk-AKKHSVJ4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MKSOJCRT.mjs → chunk-EGKH2L6J.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5EFD2VBY.mjs → chunk-ILWFGZWW.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-57FFWABF.mjs → chunk-J676B57D.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-JLOJZF2Y.mjs → chunk-JHXDM3YU.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-464CBA5U.mjs → chunk-MC6NMYWY.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CRIYVOMB.mjs → chunk-NX23AMX4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-EAIFG4MQ.mjs → chunk-Q4NA6PUR.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-47K4QPVA.mjs → chunk-QBMFX3J2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FQQ2DMXS.mjs → chunk-RKQZGWX2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5QWQDXXD.mjs → chunk-SOAYP72T.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-XTKKROVU.mjs → chunk-TFG4LZ5T.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-KFHCRS5K.mjs → chunk-UIVXVMS5.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-BSAAJR25.mjs → chunk-UYJXLDCG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FMWEI6OI.mjs → chunk-VD27WNCT.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-3VNUC4DT.mjs → chunk-VF5WVB3D.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WQ73RKJY.mjs → chunk-VRVXRZI4.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-L3OSVIGA.mjs → chunk-VYZ5DC3M.mjs} +1359 -487
- package/dist-lib/esm-chunks/{chunk-I22LAVD5.mjs → chunk-YR6DNV76.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PUBH3EXI.mjs → chunk-ZL5N6ENT.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-T5QIJTEV.mjs → metro-layout-parser-ANKZARNW.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-AWTZHPDM.mjs → swift-package-prebuilt-4N5CXBOZ.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-MGTJTVKU.mjs → swift-sdk-app-module-5IUSRXYA.mjs} +151 -67
- package/dist-lib/esm-chunks/{swift-sdk-image-JABGF3ZR.mjs → swift-sdk-image-7T2LMQS5.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-RJRJ3EFU.mjs → swift-sdk-image-producer-7QJ3BF6E.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +1489 -533
- 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 +1518 -557
- package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
- 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 +2 -2
- 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 +1520 -559
- package/dist-lib/swift-compile.cjs +1486 -530
- 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/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/src/swift-guest-compile.ts +43 -10
- package/src/swift-guest-dyld-table.ts +9 -2
- package/src/swift-guest-image-ledger.ts +403 -208
- package/src/swift-guest-link.ts +258 -113
- package/src/swift-guest-linked-spans.ts +217 -28
- package/src/swift-guest-manifest.ts +24 -13
- package/src/swift-guest-projection-storage.ts +6 -8
- package/src/swift-guest-projection.ts +7 -6
- package/src/swift-guest-source-inputs.ts +158 -30
- package/src/swift-sdk-app-module.ts +146 -59
- package/src/swift-sdk-image-map.ts +137 -35
- package/src/swift-wasm-prune.ts +263 -85
- package/src/swiftGuestImageContract.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2591 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
import {
|
|
3
3
|
SWIFT_AUTOLINK_LINKER,
|
|
4
4
|
SWIFT_CACHE_HOLD_MARKER,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
windowAdmission,
|
|
19
19
|
withSwiftRootLock,
|
|
20
20
|
writeSwiftAutolinkLinker
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-ILWFGZWW.mjs";
|
|
22
22
|
import {
|
|
23
23
|
SWIFT_BINARY_TREES_DIR,
|
|
24
24
|
SWIFT_NATIVE_INPUT_ROOT,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
isSwiftResourcePath,
|
|
34
34
|
isSwiftSourceLinkGraph,
|
|
35
35
|
swiftProjectFilesProblems
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-SOAYP72T.mjs";
|
|
37
37
|
import {
|
|
38
38
|
OBJC_RESOURCE_ACCESSOR_BODY,
|
|
39
39
|
OBJC_RESOURCE_ACCESSOR_HEADER,
|
|
@@ -57,16 +57,16 @@ import {
|
|
|
57
57
|
swiftPackagePartition,
|
|
58
58
|
swiftTargetModuleName,
|
|
59
59
|
withoutGlogModuleMap
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-YR6DNV76.mjs";
|
|
61
61
|
import {
|
|
62
62
|
rnxPublicBrand
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-JHXDM3YU.mjs";
|
|
64
64
|
import {
|
|
65
65
|
isRecord
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-EGKH2L6J.mjs";
|
|
67
67
|
import {
|
|
68
68
|
__publicField
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-4QHHRGO4.mjs";
|
|
70
70
|
|
|
71
71
|
// src/swift-compile.ts
|
|
72
72
|
import {
|
|
@@ -4776,24 +4776,56 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
4776
4776
|
const code = sections.get(10);
|
|
4777
4777
|
if (code) {
|
|
4778
4778
|
let pos = code[0];
|
|
4779
|
-
|
|
4780
|
-
|
|
4779
|
+
const codeStart = code[0];
|
|
4780
|
+
const codeEnd = code[1];
|
|
4781
|
+
let count = 0;
|
|
4782
|
+
{
|
|
4783
|
+
let shift = 0;
|
|
4784
|
+
for (; ; ) {
|
|
4785
|
+
if (pos >= codeEnd || shift > 28) throw new Error("invalid wasm integer");
|
|
4786
|
+
const byte = bytes[pos++];
|
|
4787
|
+
count += (byte & 127) * 2 ** shift;
|
|
4788
|
+
if (!(byte & 128)) break;
|
|
4789
|
+
shift += 7;
|
|
4790
|
+
}
|
|
4791
|
+
}
|
|
4781
4792
|
for (let i = 0; i < count; i++) {
|
|
4782
4793
|
const prefix = pos;
|
|
4783
|
-
let size;
|
|
4784
|
-
|
|
4785
|
-
|
|
4794
|
+
let size = 0;
|
|
4795
|
+
const b0 = bytes[pos++];
|
|
4796
|
+
if (b0 < 128) {
|
|
4797
|
+
size = b0;
|
|
4798
|
+
} else {
|
|
4799
|
+
size = b0 & 127;
|
|
4800
|
+
let shift = 7;
|
|
4801
|
+
for (; ; ) {
|
|
4802
|
+
if (pos >= codeEnd || shift > 28) throw new Error("invalid wasm integer");
|
|
4803
|
+
const byte = bytes[pos++];
|
|
4804
|
+
size += (byte & 127) * 2 ** shift;
|
|
4805
|
+
if (!(byte & 128)) break;
|
|
4806
|
+
shift += 7;
|
|
4807
|
+
}
|
|
4808
|
+
}
|
|
4809
|
+
functionsByCodeOffset.set(prefix - codeStart, imports + i);
|
|
4786
4810
|
if (imports + i === startFunction) startup = bytes.subarray(pos, pos + size);
|
|
4787
4811
|
pos += size;
|
|
4788
|
-
if (pos >
|
|
4812
|
+
if (pos > codeEnd) throw new Error("invalid wasm code");
|
|
4789
4813
|
}
|
|
4790
|
-
if (pos !==
|
|
4814
|
+
if (pos !== codeEnd) throw new Error("invalid wasm code section");
|
|
4791
4815
|
}
|
|
4792
4816
|
const functionsByTableSlot = /* @__PURE__ */ new Map();
|
|
4793
4817
|
const elements = sections.get(9);
|
|
4794
4818
|
if (elements) {
|
|
4795
4819
|
let pos = elements[0];
|
|
4820
|
+
const elemEnd = elements[1];
|
|
4796
4821
|
const read = () => {
|
|
4822
|
+
if (pos < elemEnd) {
|
|
4823
|
+
const b0 = bytes[pos];
|
|
4824
|
+
if (b0 < 128) {
|
|
4825
|
+
pos++;
|
|
4826
|
+
return b0;
|
|
4827
|
+
}
|
|
4828
|
+
}
|
|
4797
4829
|
const [value, next] = number2(bytes, pos);
|
|
4798
4830
|
pos = next;
|
|
4799
4831
|
return value;
|
|
@@ -4823,7 +4855,7 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
4823
4855
|
functionsByTableSlot.set(slot, read());
|
|
4824
4856
|
}
|
|
4825
4857
|
}
|
|
4826
|
-
if (pos !==
|
|
4858
|
+
if (pos !== elemEnd) throw new Error("invalid wasm element section");
|
|
4827
4859
|
}
|
|
4828
4860
|
const data = [];
|
|
4829
4861
|
const passive = /* @__PURE__ */ new Map();
|
|
@@ -4888,36 +4920,141 @@ function guestWasmDataSegments(bytes, requireExports = true) {
|
|
|
4888
4920
|
length: segment.bytes.length
|
|
4889
4921
|
}));
|
|
4890
4922
|
}
|
|
4891
|
-
function
|
|
4923
|
+
function isMapSpace(code) {
|
|
4924
|
+
return code === 32 || code >= 9 && code <= 13;
|
|
4925
|
+
}
|
|
4926
|
+
function isMapHex(code) {
|
|
4927
|
+
return code >= 48 && code <= 57 || code >= 97 && code <= 102;
|
|
4928
|
+
}
|
|
4929
|
+
function mapHexDigit(code) {
|
|
4930
|
+
return code <= 57 ? code - 48 : code - 87;
|
|
4931
|
+
}
|
|
4932
|
+
function* stringLines(text2) {
|
|
4933
|
+
let start = 0;
|
|
4934
|
+
for (let end = text2.indexOf("\n"); end !== -1; end = text2.indexOf("\n", start)) {
|
|
4935
|
+
yield text2.slice(start, end);
|
|
4936
|
+
start = end + 1;
|
|
4937
|
+
}
|
|
4938
|
+
yield text2.slice(start);
|
|
4939
|
+
}
|
|
4940
|
+
function guestLinkedSpans(map, before, after, owners, sectionOwners = /* @__PURE__ */ new Map(), importsLayout = false, extra) {
|
|
4892
4941
|
const unchanged = before === after;
|
|
4893
4942
|
const original = layout(before, !unchanged, !importsLayout);
|
|
4894
4943
|
const optimized = unchanged ? original : layout(after, true, !importsLayout);
|
|
4944
|
+
const collectSymbols = extra?.collectSymbols;
|
|
4945
|
+
const trackedObject = extra?.trackedObject;
|
|
4946
|
+
const trackedObjectOwner = extra?.trackedObjectOwner;
|
|
4947
|
+
const trackedLinearSpans = extra?.trackedLinearSpans;
|
|
4948
|
+
const hasSectionOwners = sectionOwners.size > 0;
|
|
4895
4949
|
let codeOffset;
|
|
4896
4950
|
let outputSection = "";
|
|
4897
4951
|
const codeOwners = /* @__PURE__ */ new Map();
|
|
4898
4952
|
const pieces = [];
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4953
|
+
const lines = typeof map === "string" ? stringLines(map) : map;
|
|
4954
|
+
for (const line of lines) {
|
|
4955
|
+
const lineLen = line.length;
|
|
4956
|
+
let pos = 0;
|
|
4957
|
+
let onlySpaces = true;
|
|
4958
|
+
while (pos < lineLen) {
|
|
4959
|
+
const ch = line.charCodeAt(pos);
|
|
4960
|
+
if (!isMapSpace(ch)) break;
|
|
4961
|
+
if (ch !== 32) onlySpaces = false;
|
|
4962
|
+
pos++;
|
|
4963
|
+
}
|
|
4964
|
+
const leadingSpaces = pos;
|
|
4965
|
+
if (pos >= lineLen) continue;
|
|
4966
|
+
const addrStart = pos;
|
|
4967
|
+
while (pos < lineLen && !isMapSpace(line.charCodeAt(pos))) pos++;
|
|
4968
|
+
const addrEnd = pos;
|
|
4969
|
+
if (pos >= lineLen) continue;
|
|
4970
|
+
const s1 = pos;
|
|
4971
|
+
while (pos < lineLen) {
|
|
4972
|
+
const ch = line.charCodeAt(pos);
|
|
4973
|
+
if (!isMapSpace(ch)) break;
|
|
4974
|
+
if (ch !== 32) onlySpaces = false;
|
|
4975
|
+
pos++;
|
|
4976
|
+
}
|
|
4977
|
+
if (pos === s1 || pos >= lineLen) continue;
|
|
4978
|
+
const offStart = pos;
|
|
4979
|
+
let offsetVal = 0;
|
|
4980
|
+
while (pos < lineLen && isMapHex(line.charCodeAt(pos))) {
|
|
4981
|
+
offsetVal = offsetVal * 16 + mapHexDigit(line.charCodeAt(pos++));
|
|
4982
|
+
}
|
|
4983
|
+
if (pos === offStart || pos >= lineLen) continue;
|
|
4984
|
+
const s2 = pos;
|
|
4985
|
+
while (pos < lineLen) {
|
|
4986
|
+
const ch = line.charCodeAt(pos);
|
|
4987
|
+
if (!isMapSpace(ch)) break;
|
|
4988
|
+
if (ch !== 32) onlySpaces = false;
|
|
4989
|
+
pos++;
|
|
4990
|
+
}
|
|
4991
|
+
if (pos === s2 || pos >= lineLen) continue;
|
|
4992
|
+
const sizeStart = pos;
|
|
4993
|
+
let sizeVal = 0;
|
|
4994
|
+
while (pos < lineLen && isMapHex(line.charCodeAt(pos))) {
|
|
4995
|
+
sizeVal = sizeVal * 16 + mapHexDigit(line.charCodeAt(pos++));
|
|
4996
|
+
}
|
|
4997
|
+
if (pos === sizeStart || pos >= lineLen) continue;
|
|
4998
|
+
const indentStart = pos;
|
|
4999
|
+
while (pos < lineLen && line.charCodeAt(pos) === 32) pos++;
|
|
5000
|
+
const indentLen = pos - indentStart;
|
|
5001
|
+
if (indentLen === 0 || pos >= lineLen) continue;
|
|
5002
|
+
const firstCh = line.charCodeAt(pos);
|
|
5003
|
+
if (isMapSpace(firstCh)) continue;
|
|
5004
|
+
const sourceStart = pos;
|
|
5005
|
+
if (collectSymbols && onlySpaces && leadingSpaces > 0 && indentLen >= 9 && firstCh !== 47 && firstCh !== 60) {
|
|
5006
|
+
let symEnd = sourceStart + 1;
|
|
5007
|
+
while (symEnd < lineLen && !isMapSpace(line.charCodeAt(symEnd))) symEnd++;
|
|
5008
|
+
collectSymbols.add(line.slice(sourceStart, symEnd));
|
|
5009
|
+
}
|
|
5010
|
+
const isDash = addrEnd - addrStart === 1 && line.charCodeAt(addrStart) === 45;
|
|
5011
|
+
if (isDash && indentLen === 1) {
|
|
5012
|
+
if (line.indexOf("\r", sourceStart) >= 0) continue;
|
|
5013
|
+
outputSection = line.slice(sourceStart);
|
|
5014
|
+
if (outputSection === "CODE") codeOffset = offsetVal;
|
|
4906
5015
|
continue;
|
|
4907
5016
|
}
|
|
4908
|
-
|
|
5017
|
+
if (sizeVal === 0) continue;
|
|
5018
|
+
const separator = line.indexOf(":(", sourceStart);
|
|
4909
5019
|
if (separator < 0) continue;
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
if (
|
|
4915
|
-
|
|
5020
|
+
if (line.indexOf("\r", sourceStart) >= 0) continue;
|
|
5021
|
+
let hasLineSep = false;
|
|
5022
|
+
for (let i = sourceStart; i < lineLen; i++) {
|
|
5023
|
+
const ch = line.charCodeAt(i);
|
|
5024
|
+
if (ch === 8232 || ch === 8233) {
|
|
5025
|
+
hasLineSep = true;
|
|
5026
|
+
break;
|
|
5027
|
+
}
|
|
5028
|
+
}
|
|
5029
|
+
if (hasLineSep) continue;
|
|
5030
|
+
const objectPath = line.slice(sourceStart, separator);
|
|
5031
|
+
let image = hasSectionOwners ? sectionOwners.get(line.slice(sourceStart)) : void 0;
|
|
5032
|
+
if (image === void 0) image = owners.get(objectPath);
|
|
5033
|
+
if (!isDash) {
|
|
5034
|
+
if (outputSection === "DATA") {
|
|
5035
|
+
let addressVal = 0;
|
|
5036
|
+
let allHex = true;
|
|
5037
|
+
for (let i = addrStart; i < addrEnd; i++) {
|
|
5038
|
+
const ch = line.charCodeAt(i);
|
|
5039
|
+
if (isMapHex(ch)) addressVal = addressVal * 16 + mapHexDigit(ch);
|
|
5040
|
+
else {
|
|
5041
|
+
allHex = false;
|
|
5042
|
+
break;
|
|
5043
|
+
}
|
|
5044
|
+
}
|
|
5045
|
+
if (!allHex) addressVal = parseInt(line.slice(addrStart, addrEnd), 16);
|
|
5046
|
+
pieces.push({
|
|
5047
|
+
image,
|
|
5048
|
+
address: addressVal,
|
|
5049
|
+
length: sizeVal,
|
|
5050
|
+
tracked: trackedObject !== void 0 && objectPath === trackedObject
|
|
5051
|
+
});
|
|
5052
|
+
}
|
|
4916
5053
|
continue;
|
|
4917
5054
|
}
|
|
4918
5055
|
if (image === void 0 || outputSection !== "CODE") continue;
|
|
4919
5056
|
if (codeOffset === void 0) throw new Error("link map has no code section");
|
|
4920
|
-
const index = original.functionsByCodeOffset.get(
|
|
5057
|
+
const index = original.functionsByCodeOffset.get(offsetVal - codeOffset);
|
|
4921
5058
|
if (index === void 0) throw new Error("link map function has no wasm body");
|
|
4922
5059
|
const existing = codeOwners.get(index);
|
|
4923
5060
|
if (existing !== void 0 && existing !== image)
|
|
@@ -4926,12 +5063,23 @@ function guestLinkedSpans(map, before, after, owners, sectionOwners = /* @__PURE
|
|
|
4926
5063
|
}
|
|
4927
5064
|
pieces.sort((a, b) => a.address - b.address);
|
|
4928
5065
|
const spans = [];
|
|
4929
|
-
for (
|
|
4930
|
-
|
|
5066
|
+
for (let index = 0; index < pieces.length; index++) {
|
|
5067
|
+
const piece = pieces[index];
|
|
5068
|
+
const { image, address, length, tracked } = piece;
|
|
5069
|
+
if (image === void 0 && !tracked) continue;
|
|
4931
5070
|
let next = index + 1;
|
|
4932
5071
|
while (next < pieces.length && pieces[next].address < address + length) next++;
|
|
4933
5072
|
const end = pieces[next]?.address ?? address + length;
|
|
4934
|
-
|
|
5073
|
+
const spanLength = end - address;
|
|
5074
|
+
if (image !== void 0)
|
|
5075
|
+
spans.push({ image, space: "linear-memory", address, length: spanLength });
|
|
5076
|
+
if (tracked && trackedLinearSpans && trackedObjectOwner !== void 0)
|
|
5077
|
+
trackedLinearSpans.push({
|
|
5078
|
+
image: trackedObjectOwner,
|
|
5079
|
+
space: "linear-memory",
|
|
5080
|
+
address,
|
|
5081
|
+
length: spanLength
|
|
5082
|
+
});
|
|
4935
5083
|
}
|
|
4936
5084
|
const optimizedOwners = /* @__PURE__ */ new Map();
|
|
4937
5085
|
const dataAt = (module, start, length) => {
|
|
@@ -4970,7 +5118,7 @@ function guestLinkedSpans(map, before, after, owners, sectionOwners = /* @__PURE
|
|
|
4970
5118
|
throw new Error(`optimization changed linked data at ${span.address}`);
|
|
4971
5119
|
}
|
|
4972
5120
|
let previous;
|
|
4973
|
-
for (const span of
|
|
5121
|
+
for (const span of spans) {
|
|
4974
5122
|
if (previous && span.address < previous.address + previous.length && span.image !== previous.image)
|
|
4975
5123
|
throw new Error("linked data belongs to multiple images");
|
|
4976
5124
|
if (!previous || span.address + span.length > previous.address + previous.length)
|
|
@@ -5157,6 +5305,20 @@ var PARTITIONED = [
|
|
|
5157
5305
|
];
|
|
5158
5306
|
var chunkKey = (chunk, symbol = chunk.symbols[0]?.name ?? "") => `${chunk.object}:${chunk.section}:${symbol}`;
|
|
5159
5307
|
var isPartitioned = (section2) => PARTITIONED.some((name) => section2 === name || section2.startsWith(`${name}.`));
|
|
5308
|
+
function isHexChar(code) {
|
|
5309
|
+
return code >= 48 && code <= 57 || code >= 97 && code <= 102;
|
|
5310
|
+
}
|
|
5311
|
+
function hexDigit(code) {
|
|
5312
|
+
return code <= 57 ? code - 48 : code - 87;
|
|
5313
|
+
}
|
|
5314
|
+
function hasLineBreak(line, from) {
|
|
5315
|
+
if (line.indexOf("\r", from) >= 0) return true;
|
|
5316
|
+
for (let i = from; i < line.length; i++) {
|
|
5317
|
+
const ch = line.charCodeAt(i);
|
|
5318
|
+
if (ch === 8232 || ch === 8233) return true;
|
|
5319
|
+
}
|
|
5320
|
+
return false;
|
|
5321
|
+
}
|
|
5160
5322
|
function readWasmLinkMap(file, partition) {
|
|
5161
5323
|
const segments = /* @__PURE__ */ new Map();
|
|
5162
5324
|
const data = [];
|
|
@@ -5164,48 +5326,117 @@ function readWasmLinkMap(file, partition) {
|
|
|
5164
5326
|
let kind = "";
|
|
5165
5327
|
let segment = "";
|
|
5166
5328
|
let previous;
|
|
5167
|
-
const hex = (value) => value === "-" ? -1 : parseInt(value, 16);
|
|
5168
5329
|
for (const line of guestLinkLines(file)) {
|
|
5169
|
-
const
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5330
|
+
const length = line.length;
|
|
5331
|
+
let pos = 0;
|
|
5332
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
5333
|
+
if (pos >= length) continue;
|
|
5334
|
+
const leadingSpaces = pos;
|
|
5335
|
+
let address = -1;
|
|
5336
|
+
if (line.charCodeAt(pos) === 45) {
|
|
5337
|
+
pos++;
|
|
5338
|
+
} else {
|
|
5339
|
+
const start = pos;
|
|
5340
|
+
let value = 0;
|
|
5341
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
5342
|
+
value = value * 16 + hexDigit(line.charCodeAt(pos++));
|
|
5343
|
+
}
|
|
5344
|
+
if (pos === start) continue;
|
|
5345
|
+
address = value;
|
|
5346
|
+
}
|
|
5347
|
+
const s1 = pos;
|
|
5348
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
5349
|
+
if (pos === s1 || pos >= length) continue;
|
|
5350
|
+
const offStart = pos;
|
|
5351
|
+
let offset = 0;
|
|
5352
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
5353
|
+
offset = offset * 16 + hexDigit(line.charCodeAt(pos++));
|
|
5354
|
+
}
|
|
5355
|
+
if (pos === offStart) continue;
|
|
5356
|
+
const s2 = pos;
|
|
5357
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
5358
|
+
if (pos === s2 || pos >= length) continue;
|
|
5359
|
+
const sizeStart = pos;
|
|
5360
|
+
let size = 0;
|
|
5361
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
5362
|
+
size = size * 16 + hexDigit(line.charCodeAt(pos++));
|
|
5363
|
+
}
|
|
5364
|
+
if (pos === sizeStart || pos >= length) continue;
|
|
5365
|
+
const indentStart = pos;
|
|
5366
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
5367
|
+
const indent = pos - indentStart;
|
|
5368
|
+
if (indent === 0 || pos >= length) continue;
|
|
5369
|
+
if (indent === 17) {
|
|
5370
|
+
if (previous) {
|
|
5371
|
+
const first = line.charCodeAt(pos);
|
|
5372
|
+
if (first > 32 && !hasLineBreak(line, pos)) {
|
|
5373
|
+
previous.symbols.push({
|
|
5374
|
+
name: line.slice(pos),
|
|
5375
|
+
address,
|
|
5376
|
+
size
|
|
5377
|
+
});
|
|
5378
|
+
}
|
|
5379
|
+
}
|
|
5176
5380
|
continue;
|
|
5177
5381
|
}
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5382
|
+
if (indent === 1) {
|
|
5383
|
+
let hasWhitespace = false;
|
|
5384
|
+
for (let i = pos; i < length; i++) {
|
|
5385
|
+
const ch = line.charCodeAt(i);
|
|
5386
|
+
if (ch <= 32) {
|
|
5387
|
+
hasWhitespace = true;
|
|
5388
|
+
break;
|
|
5389
|
+
}
|
|
5390
|
+
}
|
|
5391
|
+
if (hasWhitespace) continue;
|
|
5392
|
+
if (address < 0 && leadingSpaces > 0) {
|
|
5393
|
+
kind = line.slice(pos);
|
|
5394
|
+
} else if (kind === "DATA" && address >= 0) {
|
|
5395
|
+
segment = line.slice(pos);
|
|
5396
|
+
segments.set(segment, { address, size });
|
|
5397
|
+
}
|
|
5181
5398
|
continue;
|
|
5182
5399
|
}
|
|
5183
|
-
if (kind === "DATA") {
|
|
5184
|
-
const
|
|
5185
|
-
if (
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5400
|
+
if (indent === 9 && (kind === "DATA" || kind === "CODE")) {
|
|
5401
|
+
const first = line.charCodeAt(pos);
|
|
5402
|
+
if (first !== 47 && first !== 60) continue;
|
|
5403
|
+
if (hasLineBreak(line, pos)) continue;
|
|
5404
|
+
const name = line.slice(pos);
|
|
5405
|
+
let filePath = name;
|
|
5406
|
+
let section2 = "";
|
|
5407
|
+
if (name.charCodeAt(name.length - 1) === 41) {
|
|
5408
|
+
const splitAt = name.indexOf(":(");
|
|
5409
|
+
if (splitAt >= 0) {
|
|
5410
|
+
filePath = name.slice(0, splitAt);
|
|
5411
|
+
section2 = name.slice(splitAt + 2, -1);
|
|
5412
|
+
}
|
|
5413
|
+
}
|
|
5414
|
+
let objectName;
|
|
5415
|
+
if (filePath.charCodeAt(filePath.length - 1) === 41) {
|
|
5416
|
+
const open = filePath.lastIndexOf("(");
|
|
5417
|
+
if (open >= 0 && open + 1 < filePath.length - 1) {
|
|
5418
|
+
const close = filePath.indexOf(")", open + 1);
|
|
5419
|
+
if (close === filePath.length - 1) {
|
|
5420
|
+
objectName = filePath.slice(open + 1, -1);
|
|
5421
|
+
}
|
|
5422
|
+
}
|
|
5423
|
+
}
|
|
5424
|
+
if (objectName === void 0) objectName = basename(filePath);
|
|
5425
|
+
if (objectName.startsWith("lib") && objectName.includes("__")) {
|
|
5426
|
+
objectName = objectName.replace(/^lib\w*?__/, "");
|
|
5189
5427
|
}
|
|
5428
|
+
previous = {
|
|
5429
|
+
inputFile: filePath,
|
|
5430
|
+
segment,
|
|
5431
|
+
address,
|
|
5432
|
+
offset,
|
|
5433
|
+
size,
|
|
5434
|
+
object: objectName,
|
|
5435
|
+
section: section2,
|
|
5436
|
+
symbols: []
|
|
5437
|
+
};
|
|
5438
|
+
(kind === "DATA" ? data : code).push(previous);
|
|
5190
5439
|
}
|
|
5191
|
-
if (kind !== "DATA" && kind !== "CODE") continue;
|
|
5192
|
-
const input = /^ *([0-9a-f]+|-) +([0-9a-f]+) +([0-9a-f]+) {9}([/<].*)$/.exec(line);
|
|
5193
|
-
if (!input) continue;
|
|
5194
|
-
const name = input[4];
|
|
5195
|
-
const split = /^(.*?):\((.*)\)$/s.exec(name);
|
|
5196
|
-
const path33 = split ? split[1] : name;
|
|
5197
|
-
const member = /\(([^()]+)\)$/.exec(path33);
|
|
5198
|
-
previous = {
|
|
5199
|
-
inputFile: path33,
|
|
5200
|
-
segment,
|
|
5201
|
-
address: hex(input[1]),
|
|
5202
|
-
offset: parseInt(input[2], 16),
|
|
5203
|
-
size: parseInt(input[3], 16),
|
|
5204
|
-
object: (member ? member[1] : basename(path33)).replace(/^lib\w*?__/, ""),
|
|
5205
|
-
section: split ? split[2] : "",
|
|
5206
|
-
symbols: []
|
|
5207
|
-
};
|
|
5208
|
-
(kind === "DATA" ? data : code).push(previous);
|
|
5209
5440
|
}
|
|
5210
5441
|
return { segments, data: partition ? data.flatMap(symbolPieces) : data, code };
|
|
5211
5442
|
}
|
|
@@ -6375,6 +6606,7 @@ function patchSwiftrtObject(src) {
|
|
|
6375
6606
|
return buf;
|
|
6376
6607
|
}
|
|
6377
6608
|
function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
6609
|
+
const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
6378
6610
|
let pos = 8;
|
|
6379
6611
|
let numImportFuncs = 0;
|
|
6380
6612
|
let importsDlsym = false;
|
|
@@ -6410,10 +6642,10 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
6410
6642
|
let [cnt, cp] = readULEB2(buf, p);
|
|
6411
6643
|
for (let i = 0; i < cnt; i++) {
|
|
6412
6644
|
const [mLen, m2] = readULEB2(buf, cp);
|
|
6413
|
-
const mName =
|
|
6645
|
+
const mName = rawBuf.toString("utf8", m2, m2 + mLen);
|
|
6414
6646
|
cp = m2 + mLen;
|
|
6415
6647
|
const [fLen, f2] = readULEB2(buf, cp);
|
|
6416
|
-
const fName =
|
|
6648
|
+
const fName = rawBuf.toString("utf8", f2, f2 + fLen);
|
|
6417
6649
|
cp = f2 + fLen;
|
|
6418
6650
|
const kind = buf[cp++];
|
|
6419
6651
|
if (kind === 0) {
|
|
@@ -6493,7 +6725,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
6493
6725
|
}
|
|
6494
6726
|
} else if (id === 0) {
|
|
6495
6727
|
const [nLen, np] = readULEB2(buf, p);
|
|
6496
|
-
const name =
|
|
6728
|
+
const name = rawBuf.toString("utf8", np, np + nLen);
|
|
6497
6729
|
const cp = np + nLen;
|
|
6498
6730
|
if (name === "linking") {
|
|
6499
6731
|
let [, lp] = readULEB2(buf, cp);
|
|
@@ -6506,7 +6738,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
6506
6738
|
let cur = p2;
|
|
6507
6739
|
for (let i = 0; i < cnt; i++) {
|
|
6508
6740
|
const [sLen, s2] = readULEB2(buf, cur);
|
|
6509
|
-
segNames.push(
|
|
6741
|
+
segNames.push(rawBuf.toString("utf8", s2, s2 + sLen));
|
|
6510
6742
|
cur = s2 + sLen;
|
|
6511
6743
|
const [, s3] = readULEB2(buf, cur);
|
|
6512
6744
|
const [fl, s4] = readULEB2(buf, s3);
|
|
@@ -6546,7 +6778,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
6546
6778
|
let sName = "";
|
|
6547
6779
|
if (!isUndef || isExplicitName) {
|
|
6548
6780
|
const [sLen, c4] = readULEB2(buf, cur);
|
|
6549
|
-
sName =
|
|
6781
|
+
sName = rawBuf.toString("utf8", c4, c4 + sLen);
|
|
6550
6782
|
cur = c4 + sLen;
|
|
6551
6783
|
} else if (kind === 0) {
|
|
6552
6784
|
sName = importFuncNames[el] ?? "";
|
|
@@ -6562,7 +6794,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
6562
6794
|
symNames.push(sName);
|
|
6563
6795
|
} else if (kind === 1) {
|
|
6564
6796
|
const [sLen, c3] = readULEB2(buf, cur);
|
|
6565
|
-
const sName =
|
|
6797
|
+
const sName = rawBuf.toString("utf8", c3, c3 + sLen);
|
|
6566
6798
|
cur = c3 + sLen;
|
|
6567
6799
|
if (!isUndef) {
|
|
6568
6800
|
const [segIdx, c4] = readULEB2(buf, cur);
|
|
@@ -6677,9 +6909,21 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
6677
6909
|
const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
|
|
6678
6910
|
let ownerSymIdx = -1;
|
|
6679
6911
|
const topList = segTopSyms.get(lo);
|
|
6680
|
-
if (topList) {
|
|
6681
|
-
|
|
6682
|
-
|
|
6912
|
+
if (topList && topList.length > 0) {
|
|
6913
|
+
let tLo = 0;
|
|
6914
|
+
let tHi = topList.length - 1;
|
|
6915
|
+
while (tLo <= tHi) {
|
|
6916
|
+
const tMid = tLo + tHi >> 1;
|
|
6917
|
+
const top = topList[tMid];
|
|
6918
|
+
if (offInSeg < top.off) {
|
|
6919
|
+
tHi = tMid - 1;
|
|
6920
|
+
} else if (offInSeg >= top.end) {
|
|
6921
|
+
tLo = tMid + 1;
|
|
6922
|
+
} else {
|
|
6923
|
+
ownerSymIdx = top.symIdx;
|
|
6924
|
+
break;
|
|
6925
|
+
}
|
|
6926
|
+
}
|
|
6683
6927
|
}
|
|
6684
6928
|
if (ownerSymIdx !== -1) {
|
|
6685
6929
|
let list = symDataRelocs.get(ownerSymIdx);
|
|
@@ -6917,54 +7161,151 @@ function parseWasmObjectCached(file, isDist, entries2) {
|
|
|
6917
7161
|
return parsed;
|
|
6918
7162
|
}
|
|
6919
7163
|
function guestWasmSymbols(bytes) {
|
|
6920
|
-
const
|
|
7164
|
+
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
7165
|
+
let cur = 8;
|
|
7166
|
+
const readU = () => {
|
|
7167
|
+
const b0 = bytes[cur++];
|
|
7168
|
+
if (b0 < 128) return b0;
|
|
7169
|
+
let res = b0 & 127;
|
|
7170
|
+
let shift = 7;
|
|
7171
|
+
while (true) {
|
|
7172
|
+
const byte = bytes[cur++];
|
|
7173
|
+
res |= (byte & 127) << shift;
|
|
7174
|
+
if ((byte & 128) === 0) return res;
|
|
7175
|
+
shift += 7;
|
|
7176
|
+
}
|
|
7177
|
+
};
|
|
7178
|
+
let importsDlsym = false;
|
|
7179
|
+
const importFuncNames = [];
|
|
7180
|
+
const importFuncModules = [];
|
|
7181
|
+
const importGlobalNames = [];
|
|
7182
|
+
const importTableNames = [];
|
|
7183
|
+
const importEventNames = [];
|
|
7184
|
+
const undefinedSyms = /* @__PURE__ */ new Set();
|
|
7185
|
+
const tags = /* @__PURE__ */ new Set();
|
|
7186
|
+
const globals = /* @__PURE__ */ new Set();
|
|
7187
|
+
const hostImports = /* @__PURE__ */ new Set();
|
|
7188
|
+
const weakUndefined = /* @__PURE__ */ new Set();
|
|
7189
|
+
const defined = /* @__PURE__ */ new Set();
|
|
7190
|
+
const weakDefined = /* @__PURE__ */ new Set();
|
|
7191
|
+
while (cur < bytes.length) {
|
|
7192
|
+
const id = bytes[cur++];
|
|
7193
|
+
const sz = readU();
|
|
7194
|
+
const end = cur + sz;
|
|
7195
|
+
if (id === 2) {
|
|
7196
|
+
const cnt = readU();
|
|
7197
|
+
for (let i = 0; i < cnt; i++) {
|
|
7198
|
+
const mLen = readU();
|
|
7199
|
+
const mName = rawBuf.toString("utf8", cur, cur + mLen);
|
|
7200
|
+
cur += mLen;
|
|
7201
|
+
const fLen = readU();
|
|
7202
|
+
const fName = rawBuf.toString("utf8", cur, cur + fLen);
|
|
7203
|
+
cur += fLen;
|
|
7204
|
+
const kind = bytes[cur++];
|
|
7205
|
+
if (kind === 0) {
|
|
7206
|
+
readU();
|
|
7207
|
+
importFuncNames.push(fName);
|
|
7208
|
+
importFuncModules.push(mName);
|
|
7209
|
+
if (mName === "env" && fName === "dlsym") importsDlsym = true;
|
|
7210
|
+
} else if (kind === 1) {
|
|
7211
|
+
cur++;
|
|
7212
|
+
const fl = readU();
|
|
7213
|
+
readU();
|
|
7214
|
+
if (fl & 1) readU();
|
|
7215
|
+
importTableNames.push(fName);
|
|
7216
|
+
} else if (kind === 2) {
|
|
7217
|
+
const fl = readU();
|
|
7218
|
+
readU();
|
|
7219
|
+
if (fl & 1) readU();
|
|
7220
|
+
} else if (kind === 3) {
|
|
7221
|
+
cur += 2;
|
|
7222
|
+
importGlobalNames.push(fName);
|
|
7223
|
+
} else if (kind === 4) {
|
|
7224
|
+
cur++;
|
|
7225
|
+
readU();
|
|
7226
|
+
importEventNames.push(fName);
|
|
7227
|
+
}
|
|
7228
|
+
}
|
|
7229
|
+
} else if (id === 0) {
|
|
7230
|
+
const nLen = readU();
|
|
7231
|
+
if (nLen === 7 && bytes[cur] === 108 && rawBuf.toString("utf8", cur, cur + nLen) === "linking") {
|
|
7232
|
+
cur += nLen;
|
|
7233
|
+
readU();
|
|
7234
|
+
while (cur < end) {
|
|
7235
|
+
const subId = bytes[cur++];
|
|
7236
|
+
const subLen = readU();
|
|
7237
|
+
const subEnd = cur + subLen;
|
|
7238
|
+
if (subId === 8) {
|
|
7239
|
+
const cnt = readU();
|
|
7240
|
+
for (let i = 0; i < cnt; i++) {
|
|
7241
|
+
const kind = bytes[cur++];
|
|
7242
|
+
const fl = readU();
|
|
7243
|
+
const isUndef = (fl & 16) !== 0;
|
|
7244
|
+
const isExplicitName = (fl & 64) !== 0;
|
|
7245
|
+
let sName = "";
|
|
7246
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
7247
|
+
const el = readU();
|
|
7248
|
+
if (!isUndef || isExplicitName) {
|
|
7249
|
+
const sLen = readU();
|
|
7250
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
7251
|
+
cur += sLen;
|
|
7252
|
+
} else if (kind === 0) {
|
|
7253
|
+
sName = importFuncNames[el] ?? "";
|
|
7254
|
+
} else if (kind === 2) {
|
|
7255
|
+
sName = importGlobalNames[el] ?? "";
|
|
7256
|
+
} else if (kind === 4) {
|
|
7257
|
+
sName = importEventNames[el] ?? "";
|
|
7258
|
+
} else if (kind === 5) {
|
|
7259
|
+
sName = importTableNames[el] ?? "";
|
|
7260
|
+
}
|
|
7261
|
+
if (isUndef && kind === 0 && importFuncModules[el] !== "env")
|
|
7262
|
+
hostImports.add(sName);
|
|
7263
|
+
} else if (kind === 1) {
|
|
7264
|
+
const sLen = readU();
|
|
7265
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
7266
|
+
cur += sLen;
|
|
7267
|
+
if (!isUndef) {
|
|
7268
|
+
readU();
|
|
7269
|
+
readU();
|
|
7270
|
+
readU();
|
|
7271
|
+
}
|
|
7272
|
+
} else if (kind === 3) {
|
|
7273
|
+
readU();
|
|
7274
|
+
}
|
|
7275
|
+
if (sName) {
|
|
7276
|
+
if (isUndef) {
|
|
7277
|
+
undefinedSyms.add(sName);
|
|
7278
|
+
if ((fl & 19) === 17) weakUndefined.add(sName);
|
|
7279
|
+
} else if ((fl & 3) !== 2) {
|
|
7280
|
+
defined.add(sName);
|
|
7281
|
+
if ((fl & 19) === 1) weakDefined.add(sName);
|
|
7282
|
+
}
|
|
7283
|
+
if (kind === 4) tags.add(sName);
|
|
7284
|
+
else if (kind === 2 || kind === 5) globals.add(sName);
|
|
7285
|
+
}
|
|
7286
|
+
}
|
|
7287
|
+
break;
|
|
7288
|
+
}
|
|
7289
|
+
cur = subEnd;
|
|
7290
|
+
}
|
|
7291
|
+
break;
|
|
7292
|
+
}
|
|
7293
|
+
}
|
|
7294
|
+
cur = end;
|
|
7295
|
+
}
|
|
6921
7296
|
return {
|
|
6922
|
-
importsDlsym
|
|
6923
|
-
undefined: [
|
|
6924
|
-
...new Set(
|
|
6925
|
-
object2.symNames.filter(
|
|
6926
|
-
(name, index) => name && (object2.symFlags[index] & 16) !== 0
|
|
6927
|
-
)
|
|
6928
|
-
)
|
|
6929
|
-
],
|
|
7297
|
+
importsDlsym,
|
|
7298
|
+
undefined: [...undefinedSyms],
|
|
6930
7299
|
// a wasm tag is one module entity unified by name across the link, as the
|
|
6931
7300
|
// main module owns it for dynamic images, so no image scope applies.
|
|
6932
|
-
tags: [
|
|
6933
|
-
|
|
6934
|
-
object2.symNames.filter((name, index) => name && object2.symKind[index] === 4)
|
|
6935
|
-
)
|
|
6936
|
-
],
|
|
6937
|
-
globals: [
|
|
6938
|
-
...new Set(
|
|
6939
|
-
object2.symNames.filter(
|
|
6940
|
-
(name, index) => name && (object2.symKind[index] === 2 || object2.symKind[index] === 5)
|
|
6941
|
-
)
|
|
6942
|
-
)
|
|
6943
|
-
],
|
|
7301
|
+
tags: [...tags],
|
|
7302
|
+
globals: [...globals],
|
|
6944
7303
|
// an undefined function imported from a module other than env is supplied
|
|
6945
7304
|
// by the host, whatever linker symbol names it.
|
|
6946
|
-
hostImports: [...
|
|
6947
|
-
weakUndefined: [
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
(name, index) => name && (object2.symFlags[index] & 19) === 17
|
|
6951
|
-
)
|
|
6952
|
-
)
|
|
6953
|
-
],
|
|
6954
|
-
defined: [
|
|
6955
|
-
...new Set(
|
|
6956
|
-
object2.symNames.filter(
|
|
6957
|
-
(name, index) => name && (object2.symFlags[index] & 16) === 0 && (object2.symFlags[index] & 3) !== 2
|
|
6958
|
-
)
|
|
6959
|
-
)
|
|
6960
|
-
],
|
|
6961
|
-
weakDefined: [
|
|
6962
|
-
...new Set(
|
|
6963
|
-
object2.symNames.filter(
|
|
6964
|
-
(name, index) => name && (object2.symFlags[index] & 19) === 1
|
|
6965
|
-
)
|
|
6966
|
-
)
|
|
6967
|
-
]
|
|
7305
|
+
hostImports: [...hostImports],
|
|
7306
|
+
weakUndefined: [...weakUndefined],
|
|
7307
|
+
defined: [...defined],
|
|
7308
|
+
weakDefined: [...weakDefined]
|
|
6968
7309
|
};
|
|
6969
7310
|
}
|
|
6970
7311
|
function sdkObjectName(archive, member, ordinal) {
|
|
@@ -7495,9 +7836,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
7495
7836
|
for (const entry of waiting) tryActivateConformance(entry);
|
|
7496
7837
|
}
|
|
7497
7838
|
};
|
|
7839
|
+
const checkedProtocolTriggers = /* @__PURE__ */ new Set();
|
|
7498
7840
|
const checkProtocolTrigger = (rawSymName) => {
|
|
7499
7841
|
if (!rawSymName) return;
|
|
7500
7842
|
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
7843
|
+
if (checkedProtocolTriggers.has(sName)) return;
|
|
7844
|
+
checkedProtocolTriggers.add(sName);
|
|
7501
7845
|
if (knownProtocols.has(sName)) {
|
|
7502
7846
|
markProtocolLive(sName);
|
|
7503
7847
|
return;
|
|
@@ -7530,6 +7874,43 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
7530
7874
|
}
|
|
7531
7875
|
}
|
|
7532
7876
|
};
|
|
7877
|
+
const typeIndexes = /* @__PURE__ */ new Map();
|
|
7878
|
+
const getTypeIndex = (obj) => {
|
|
7879
|
+
let idx = typeIndexes.get(obj);
|
|
7880
|
+
if (idx) return idx;
|
|
7881
|
+
const mnByPrefix = /* @__PURE__ */ new Map();
|
|
7882
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
7883
|
+
const name = obj.symNames[i];
|
|
7884
|
+
if ((obj.symFlags[i] & 16) === 0 && name.startsWith("$s") && name.endsWith("Mn")) {
|
|
7885
|
+
const pref = name.slice(0, -2);
|
|
7886
|
+
let list = mnByPrefix.get(pref);
|
|
7887
|
+
if (!list) mnByPrefix.set(pref, list = []);
|
|
7888
|
+
list.push(i);
|
|
7889
|
+
}
|
|
7890
|
+
}
|
|
7891
|
+
const objcRegByPrefix = /* @__PURE__ */ new Map();
|
|
7892
|
+
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
7893
|
+
let list = objcRegByPrefix.get(p);
|
|
7894
|
+
if (!list) objcRegByPrefix.set(p, list = []);
|
|
7895
|
+
list.push(lf);
|
|
7896
|
+
}
|
|
7897
|
+
const objcClassByPrefix = /* @__PURE__ */ new Map();
|
|
7898
|
+
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
7899
|
+
if (!classSym.startsWith("._OBJC_CLASS_")) continue;
|
|
7900
|
+
let list = objcClassByPrefix.get(p);
|
|
7901
|
+
if (!list) objcClassByPrefix.set(p, list = []);
|
|
7902
|
+
list.push(classSym.slice("._OBJC_CLASS_".length));
|
|
7903
|
+
}
|
|
7904
|
+
let minPrefLen = Infinity;
|
|
7905
|
+
let maxPrefLen = 0;
|
|
7906
|
+
for (const p of obj.typePrefixesInObj) {
|
|
7907
|
+
if (p.length < minPrefLen) minPrefLen = p.length;
|
|
7908
|
+
if (p.length > maxPrefLen) maxPrefLen = p.length;
|
|
7909
|
+
}
|
|
7910
|
+
idx = { mnByPrefix, objcRegByPrefix, objcClassByPrefix, minPrefLen, maxPrefLen };
|
|
7911
|
+
typeIndexes.set(obj, idx);
|
|
7912
|
+
return idx;
|
|
7913
|
+
};
|
|
7533
7914
|
const markTypeLive = (obj, pref) => {
|
|
7534
7915
|
const set = liveTypes.get(obj);
|
|
7535
7916
|
if (set.has(pref)) return;
|
|
@@ -7543,22 +7924,10 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
7543
7924
|
const outer = pref.slice(0, n);
|
|
7544
7925
|
if (obj.typePrefixesInObj.has(outer)) markTypeLive(obj, outer);
|
|
7545
7926
|
}
|
|
7546
|
-
const
|
|
7547
|
-
for (
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
}
|
|
7551
|
-
}
|
|
7552
|
-
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
7553
|
-
if (p === pref) {
|
|
7554
|
-
markFuncLive(obj, lf);
|
|
7555
|
-
}
|
|
7556
|
-
}
|
|
7557
|
-
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
7558
|
-
if (p === pref && classSym.startsWith("._OBJC_CLASS_")) {
|
|
7559
|
-
markObjCClassLive(classSym.slice("._OBJC_CLASS_".length));
|
|
7560
|
-
}
|
|
7561
|
-
}
|
|
7927
|
+
const idx = getTypeIndex(obj);
|
|
7928
|
+
for (const i of idx.mnByPrefix.get(pref) ?? []) activateSymbolInObj(obj, i);
|
|
7929
|
+
for (const lf of idx.objcRegByPrefix.get(pref) ?? []) markFuncLive(obj, lf);
|
|
7930
|
+
for (const cls of idx.objcClassByPrefix.get(pref) ?? []) markObjCClassLive(cls);
|
|
7562
7931
|
};
|
|
7563
7932
|
const checkTypeTrigger = (obj, rawSymName) => {
|
|
7564
7933
|
if (!rawSymName) return;
|
|
@@ -7583,11 +7952,12 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
7583
7952
|
}
|
|
7584
7953
|
}
|
|
7585
7954
|
}
|
|
7586
|
-
if (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o")) {
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7955
|
+
if (obj.typePrefixesInObj.size > 0 && (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o"))) {
|
|
7956
|
+
const { minPrefLen, maxPrefLen } = getTypeIndex(obj);
|
|
7957
|
+
const hi = Math.min(sName.length, maxPrefLen);
|
|
7958
|
+
for (let n = minPrefLen; n <= hi; n++) {
|
|
7959
|
+
const cand = sName.slice(0, n);
|
|
7960
|
+
if (obj.typePrefixesInObj.has(cand)) markTypeLive(obj, cand);
|
|
7591
7961
|
}
|
|
7592
7962
|
}
|
|
7593
7963
|
};
|
|
@@ -7680,7 +8050,8 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
7680
8050
|
for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
|
|
7681
8051
|
for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
|
|
7682
8052
|
for (const name of obj.symNames) {
|
|
7683
|
-
|
|
8053
|
+
if (!name || !name.startsWith("_c_") || !name.endsWith("__load")) continue;
|
|
8054
|
+
const loaded = name.match(/^_c_(\w+)__load$/)?.[1];
|
|
7684
8055
|
if (!loaded) continue;
|
|
7685
8056
|
const classSym = obj.symNames.indexOf(`._OBJC_CLASS_${loaded}`);
|
|
7686
8057
|
if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
|
|
@@ -7828,14 +8199,30 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
|
|
|
7828
8199
|
const keepObjCClassesNamedInSegment = (obj, segIdx) => {
|
|
7829
8200
|
const range = obj.segPayloadRanges[segIdx];
|
|
7830
8201
|
if (!range) return;
|
|
8202
|
+
const [rangeStart, rangeEnd] = range;
|
|
8203
|
+
if (rangeEnd - rangeStart < 4) return;
|
|
7831
8204
|
let bytes = objectBytes.get(obj);
|
|
7832
8205
|
if (!bytes) objectBytes.set(obj, bytes = fs5.readFileSync(obj.file));
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
const
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
8206
|
+
let pos = rangeStart;
|
|
8207
|
+
while (pos < rangeEnd - 3) {
|
|
8208
|
+
const at = bytes.indexOf("So", pos);
|
|
8209
|
+
if (at < 0 || at >= rangeEnd - 2) break;
|
|
8210
|
+
let digitEnd = at + 2;
|
|
8211
|
+
let length = 0;
|
|
8212
|
+
while (digitEnd < rangeEnd) {
|
|
8213
|
+
const ch = bytes[digitEnd];
|
|
8214
|
+
if (ch < 48 || ch > 57) break;
|
|
8215
|
+
length = length * 10 + (ch - 48);
|
|
8216
|
+
digitEnd++;
|
|
8217
|
+
}
|
|
8218
|
+
if (digitEnd === at + 2) {
|
|
8219
|
+
pos = at + 2;
|
|
8220
|
+
continue;
|
|
8221
|
+
}
|
|
8222
|
+
pos = digitEnd;
|
|
8223
|
+
const nameEnd = digitEnd + length;
|
|
8224
|
+
if (nameEnd >= rangeEnd || bytes[nameEnd] !== 67) continue;
|
|
8225
|
+
const symbol = `._OBJC_CLASS_${bytes.toString("latin1", digitEnd, nameEnd)}`;
|
|
7839
8226
|
for (const provider of lazyProviders.get(symbol) ?? []) {
|
|
7840
8227
|
eagerDynamicObjects.add(provider);
|
|
7841
8228
|
extractObject(provider);
|
|
@@ -8646,7 +9033,62 @@ var NATIVE_DYLD_PACKS_SECTION = "peach.dyld-packs-v1";
|
|
|
8646
9033
|
|
|
8647
9034
|
// src/swift-guest-image-ledger.ts
|
|
8648
9035
|
import { createHash as createHash7 } from "node:crypto";
|
|
9036
|
+
var ByteWriter = class {
|
|
9037
|
+
constructor(initialCapacity = 256) {
|
|
9038
|
+
__publicField(this, "buf");
|
|
9039
|
+
__publicField(this, "pos", 0);
|
|
9040
|
+
this.buf = Buffer.allocUnsafe(Math.max(64, initialCapacity));
|
|
9041
|
+
}
|
|
9042
|
+
ensure(extra) {
|
|
9043
|
+
const needed = this.pos + extra;
|
|
9044
|
+
if (needed <= this.buf.length) return;
|
|
9045
|
+
let next = this.buf.length * 2;
|
|
9046
|
+
while (next < needed) next *= 2;
|
|
9047
|
+
const grown = Buffer.allocUnsafe(next);
|
|
9048
|
+
this.buf.copy(grown, 0, 0, this.pos);
|
|
9049
|
+
this.buf = grown;
|
|
9050
|
+
}
|
|
9051
|
+
byte(value) {
|
|
9052
|
+
this.ensure(1);
|
|
9053
|
+
this.buf[this.pos++] = value;
|
|
9054
|
+
}
|
|
9055
|
+
uleb(value) {
|
|
9056
|
+
this.ensure(10);
|
|
9057
|
+
let pos = this.pos;
|
|
9058
|
+
const buf = this.buf;
|
|
9059
|
+
do {
|
|
9060
|
+
let byte = value % 128;
|
|
9061
|
+
value = Math.floor(value / 128);
|
|
9062
|
+
if (value) byte |= 128;
|
|
9063
|
+
buf[pos++] = byte;
|
|
9064
|
+
} while (value);
|
|
9065
|
+
this.pos = pos;
|
|
9066
|
+
}
|
|
9067
|
+
bytes(source, start = 0, end = source.length) {
|
|
9068
|
+
const len = end - start;
|
|
9069
|
+
if (len <= 0) return;
|
|
9070
|
+
this.ensure(len);
|
|
9071
|
+
this.buf.set(source.subarray(start, end), this.pos);
|
|
9072
|
+
this.pos += len;
|
|
9073
|
+
}
|
|
9074
|
+
string(value) {
|
|
9075
|
+
const len = Buffer.byteLength(value, "utf8");
|
|
9076
|
+
this.uleb(len);
|
|
9077
|
+
if (len > 0) {
|
|
9078
|
+
this.ensure(len);
|
|
9079
|
+
this.buf.write(value, this.pos, len, "utf8");
|
|
9080
|
+
this.pos += len;
|
|
9081
|
+
}
|
|
9082
|
+
}
|
|
9083
|
+
finish() {
|
|
9084
|
+
return this.buf.subarray(0, this.pos);
|
|
9085
|
+
}
|
|
9086
|
+
};
|
|
8649
9087
|
function readNumber(bytes, position) {
|
|
9088
|
+
if (position < bytes.length) {
|
|
9089
|
+
const first = bytes[position];
|
|
9090
|
+
if (first < 128) return [first, position + 1];
|
|
9091
|
+
}
|
|
8650
9092
|
let value = 0;
|
|
8651
9093
|
let shift = 0;
|
|
8652
9094
|
for (; ; ) {
|
|
@@ -8658,6 +9100,7 @@ function readNumber(bytes, position) {
|
|
|
8658
9100
|
}
|
|
8659
9101
|
}
|
|
8660
9102
|
function encodeNumber(value) {
|
|
9103
|
+
if (value < 128) return Buffer.from([value]);
|
|
8661
9104
|
const bytes = [];
|
|
8662
9105
|
do {
|
|
8663
9106
|
let byte = value % 128;
|
|
@@ -8679,6 +9122,9 @@ function encodedString(value) {
|
|
|
8679
9122
|
const bytes = Buffer.from(value);
|
|
8680
9123
|
return Buffer.concat([encodeNumber(bytes.length), bytes]);
|
|
8681
9124
|
}
|
|
9125
|
+
function isWasmMagic(bytes) {
|
|
9126
|
+
return bytes.length >= 8 && bytes[0] === 0 && bytes[1] === 97 && bytes[2] === 115 && bytes[3] === 109 && bytes[4] === 1 && bytes[5] === 0 && bytes[6] === 0 && bytes[7] === 0;
|
|
9127
|
+
}
|
|
8682
9128
|
function llvmType(value) {
|
|
8683
9129
|
switch (value) {
|
|
8684
9130
|
case 127:
|
|
@@ -8696,11 +9142,12 @@ function llvmType(value) {
|
|
|
8696
9142
|
var OBJC_INIT_RECORD = ".objc_init";
|
|
8697
9143
|
var TABLE_INDEX_RELOCATIONS = /* @__PURE__ */ new Set([1, 2, 12, 18, 19, 24]);
|
|
8698
9144
|
function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options = {}) {
|
|
8699
|
-
if (
|
|
8700
|
-
|
|
9145
|
+
if (!isWasmMagic(bytes)) throw new Error("expected wasm object");
|
|
9146
|
+
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
8701
9147
|
const { sdkLookupOnly, sdkProduct } = options;
|
|
8702
9148
|
const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
|
|
8703
|
-
const
|
|
9149
|
+
const rewrite = binding !== void 0;
|
|
9150
|
+
const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
|
|
8704
9151
|
const types = [];
|
|
8705
9152
|
const functionTypes = [];
|
|
8706
9153
|
const definitions = [];
|
|
@@ -8714,45 +9161,74 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
8714
9161
|
const usedSymbols = /* @__PURE__ */ new Set();
|
|
8715
9162
|
let position = 8;
|
|
8716
9163
|
while (position < bytes.length) {
|
|
9164
|
+
const headerStart = position;
|
|
8717
9165
|
const id = bytes[position++];
|
|
8718
|
-
|
|
9166
|
+
let size = 0;
|
|
9167
|
+
if (position < bytes.length && bytes[position] < 128) {
|
|
9168
|
+
size = bytes[position++];
|
|
9169
|
+
} else {
|
|
9170
|
+
const [val, next] = readNumber(bytes, position);
|
|
9171
|
+
size = val;
|
|
9172
|
+
position = next;
|
|
9173
|
+
}
|
|
9174
|
+
const start = position;
|
|
8719
9175
|
const end = start + size;
|
|
8720
9176
|
if (end > bytes.length) throw new Error("invalid wasm section");
|
|
8721
9177
|
position = end;
|
|
8722
|
-
if (
|
|
8723
|
-
|
|
8724
|
-
|
|
9178
|
+
if (id > 3) {
|
|
9179
|
+
if (sections) sections.push(bytes.subarray(headerStart, end));
|
|
9180
|
+
continue;
|
|
9181
|
+
}
|
|
9182
|
+
let offset = start;
|
|
8725
9183
|
const number3 = () => {
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
9184
|
+
if (offset < end) {
|
|
9185
|
+
const first = bytes[offset];
|
|
9186
|
+
if (first < 128) {
|
|
9187
|
+
offset++;
|
|
9188
|
+
return first;
|
|
9189
|
+
}
|
|
9190
|
+
}
|
|
9191
|
+
let value = 0;
|
|
9192
|
+
let shift = 0;
|
|
9193
|
+
for (; ; ) {
|
|
9194
|
+
if (offset >= end || shift > 63) throw new Error("invalid wasm integer");
|
|
9195
|
+
const byte = bytes[offset++];
|
|
9196
|
+
value += (byte & 127) * 2 ** shift;
|
|
9197
|
+
if (!(byte & 128)) return value;
|
|
9198
|
+
shift += 7;
|
|
9199
|
+
}
|
|
8729
9200
|
};
|
|
8730
9201
|
const string2 = () => {
|
|
8731
|
-
const
|
|
8732
|
-
|
|
9202
|
+
const length = number3();
|
|
9203
|
+
const strEnd = offset + length;
|
|
9204
|
+
if (strEnd > end) throw new Error("invalid wasm string");
|
|
9205
|
+
const value = rawBuf.toString("utf8", offset, strEnd);
|
|
9206
|
+
offset = strEnd;
|
|
8733
9207
|
return value;
|
|
8734
9208
|
};
|
|
9209
|
+
let rewrittenSection;
|
|
8735
9210
|
if (id === 1) {
|
|
8736
9211
|
const count = number3();
|
|
8737
9212
|
for (let i = 0; i < count; i++) {
|
|
8738
|
-
if (
|
|
9213
|
+
if (bytes[offset++] !== 96) throw new Error("unsupported wasm type");
|
|
8739
9214
|
const parameterCount = number3();
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
9215
|
+
if (offset + parameterCount > end) throw new Error("invalid wasm type");
|
|
9216
|
+
const parameters = new Array(parameterCount);
|
|
9217
|
+
for (let p = 0; p < parameterCount; p++) parameters[p] = bytes[offset++];
|
|
8743
9218
|
const resultCount = number3();
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
9219
|
+
if (offset + resultCount > end) throw new Error("invalid wasm type");
|
|
9220
|
+
const results = new Array(resultCount);
|
|
9221
|
+
for (let r = 0; r < resultCount; r++) results[r] = bytes[offset++];
|
|
8747
9222
|
types.push({ parameters, results });
|
|
8748
9223
|
}
|
|
8749
9224
|
} else if (id === 2) {
|
|
8750
9225
|
const count = number3();
|
|
8751
|
-
const
|
|
9226
|
+
const importWriter = rewrite ? new ByteWriter(size + 64) : void 0;
|
|
9227
|
+
importWriter?.uleb(count);
|
|
8752
9228
|
for (let i = 0; i < count; i++) {
|
|
8753
9229
|
const module = string2();
|
|
8754
9230
|
const name = string2();
|
|
8755
|
-
const kind =
|
|
9231
|
+
const kind = bytes[offset++];
|
|
8756
9232
|
const typeStart = offset;
|
|
8757
9233
|
let functionType = -1;
|
|
8758
9234
|
if (kind === 0) {
|
|
@@ -8760,7 +9236,7 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
8760
9236
|
functionTypes.push(functionType);
|
|
8761
9237
|
functionImportNames.push(name);
|
|
8762
9238
|
} else if (kind === 1) {
|
|
8763
|
-
const referenceType =
|
|
9239
|
+
const referenceType = bytes[offset++];
|
|
8764
9240
|
if (referenceType !== 112 && referenceType !== 111)
|
|
8765
9241
|
throw new Error("unsupported table type");
|
|
8766
9242
|
const flags = number3();
|
|
@@ -8779,11 +9255,15 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
8779
9255
|
} else throw new Error("unsupported wasm import");
|
|
8780
9256
|
const isDlsym = instrumentDynamicLookups && module === "env" && name === "dlsym" && kind === 0;
|
|
8781
9257
|
const isDlerror = instrumentDynamicLookups && module === "env" && name === "dlerror" && kind === 0;
|
|
8782
|
-
if (
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
9258
|
+
if (!rewrite) {
|
|
9259
|
+
if (module === "env" && names.has(name)) {
|
|
9260
|
+
usedSymbols.add(name);
|
|
9261
|
+
if (kind === 0) {
|
|
9262
|
+
const type = types[functionType];
|
|
9263
|
+
if (!type) throw new Error(`missing import type for ${name}`);
|
|
9264
|
+
functionImports.set(name, type);
|
|
9265
|
+
}
|
|
9266
|
+
}
|
|
8787
9267
|
}
|
|
8788
9268
|
if (isDlsym || isDlerror) {
|
|
8789
9269
|
const type = types[functionType];
|
|
@@ -8793,17 +9273,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
8793
9273
|
}
|
|
8794
9274
|
if (isDlsym) usesDlsym = true;
|
|
8795
9275
|
if (isDlerror) usesDlerror = true;
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module === "env" && name !== "dlsym" && name !== "dlerror" ? binding
|
|
8800
|
-
)
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
9276
|
+
if (importWriter && binding) {
|
|
9277
|
+
importWriter.string(module);
|
|
9278
|
+
importWriter.string(
|
|
9279
|
+
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module === "env" && name !== "dlsym" && name !== "dlerror" ? binding(name) ?? name : name
|
|
9280
|
+
);
|
|
9281
|
+
importWriter.byte(kind);
|
|
9282
|
+
importWriter.bytes(bytes, typeStart, offset);
|
|
9283
|
+
}
|
|
8804
9284
|
}
|
|
8805
|
-
if (offset !==
|
|
8806
|
-
if (
|
|
9285
|
+
if (offset !== end) throw new Error("invalid wasm import section");
|
|
9286
|
+
if (importWriter) rewrittenSection = importWriter.finish();
|
|
8807
9287
|
} else if (id === 3) {
|
|
8808
9288
|
const count = number3();
|
|
8809
9289
|
for (let i = 0; i < count; i++) functionTypes.push(number3());
|
|
@@ -8812,43 +9292,40 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
8812
9292
|
if (sectionName === "linking") {
|
|
8813
9293
|
const version2 = number3();
|
|
8814
9294
|
if (version2 !== 2) throw new Error("unsupported wasm linking version");
|
|
8815
|
-
const subsections = [];
|
|
9295
|
+
const subsections = rewrite ? [] : void 0;
|
|
8816
9296
|
let objcLoader;
|
|
8817
|
-
while (offset <
|
|
8818
|
-
const kind =
|
|
9297
|
+
while (offset < end) {
|
|
9298
|
+
const kind = bytes[offset++];
|
|
8819
9299
|
const length = number3();
|
|
8820
9300
|
const stop = offset + length;
|
|
8821
|
-
if (stop >
|
|
8822
|
-
|
|
8823
|
-
if (kind === 7 && !sdkLookupOnly) {
|
|
8824
|
-
const
|
|
9301
|
+
if (stop > end) throw new Error("invalid linking subsection");
|
|
9302
|
+
const contentStart = offset;
|
|
9303
|
+
if (kind === 7 && rewrite && !sdkLookupOnly) {
|
|
9304
|
+
const comdatWriter = new ByteWriter(length + 64);
|
|
8825
9305
|
const count = number3();
|
|
8826
|
-
|
|
9306
|
+
comdatWriter.uleb(count);
|
|
8827
9307
|
for (let i = 0; i < count; i++) {
|
|
8828
9308
|
const group = string2();
|
|
8829
9309
|
const begin = offset;
|
|
8830
9310
|
number3();
|
|
8831
9311
|
const members = number3();
|
|
8832
9312
|
for (let member = 0; member < members * 2; member++) number3();
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
8836
|
-
),
|
|
8837
|
-
section2.subarray(begin, offset)
|
|
9313
|
+
comdatWriter.string(
|
|
9314
|
+
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
8838
9315
|
);
|
|
9316
|
+
comdatWriter.bytes(bytes, begin, offset);
|
|
8839
9317
|
}
|
|
8840
9318
|
if (offset !== stop) throw new Error("invalid comdat subsection");
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
if (kind === 8) {
|
|
8844
|
-
const
|
|
8845
|
-
|
|
9319
|
+
const buf = comdatWriter.finish();
|
|
9320
|
+
subsections.push({ kind, parts: [buf], byteLength: buf.length });
|
|
9321
|
+
} else if (kind === 8) {
|
|
9322
|
+
const entryWriter = rewrite ? new ByteWriter(length + 128) : void 0;
|
|
9323
|
+
let extraWriter;
|
|
8846
9324
|
const count = number3();
|
|
8847
|
-
entries2.push(encodeNumber(count));
|
|
8848
9325
|
let added = 0;
|
|
8849
9326
|
for (let i = 0; i < count; i++) {
|
|
8850
9327
|
const begin = offset;
|
|
8851
|
-
const symbolKind =
|
|
9328
|
+
const symbolKind = bytes[offset++];
|
|
8852
9329
|
const flags = number3();
|
|
8853
9330
|
const flagsEnd = offset;
|
|
8854
9331
|
let index = -1;
|
|
@@ -8876,25 +9353,43 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
8876
9353
|
}
|
|
8877
9354
|
} else if (symbolKind === 3) number3();
|
|
8878
9355
|
else throw new Error("unsupported wasm symbol kind");
|
|
8879
|
-
if (symbolKind === 0)
|
|
9356
|
+
if (!rewrite && symbolKind === 0)
|
|
8880
9357
|
functionSymbols[i] = name || functionImportNames[index];
|
|
8881
|
-
if (!sdkLookupOnly && name === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
9358
|
+
if (rewrite && !sdkLookupOnly && name === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
8882
9359
|
objcLoader = i;
|
|
8883
9360
|
}
|
|
8884
9361
|
const alias = names.get(name);
|
|
8885
|
-
if (flags & 16 && symbolKind === 1 && alias)
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
9362
|
+
if (!rewrite && flags & 16 && symbolKind === 1 && alias)
|
|
9363
|
+
usedSymbols.add(name);
|
|
9364
|
+
if (entryWriter && binding) {
|
|
9365
|
+
if ((name === "dlsym" && usesDlsym || name === "dlerror" && usesDlerror) && flags & 16 && flags & 64 && symbolKind === 0) {
|
|
9366
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
9367
|
+
entryWriter.string(name === "dlsym" ? callerAlias : dlerrorAlias);
|
|
9368
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
9369
|
+
} else if (flags & 16 && name !== "dlsym" && name !== "dlerror" && binding(name) !== void 0) {
|
|
9370
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
9371
|
+
entryWriter.string(binding(name));
|
|
9372
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
9373
|
+
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
9374
|
+
if (symbolKind !== 0 && symbolKind !== 1)
|
|
9375
|
+
throw new Error(`unsupported symbol ${name}`);
|
|
9376
|
+
if (preserveCanonical.has(name)) {
|
|
9377
|
+
entryWriter.bytes(bytes, begin, offset);
|
|
9378
|
+
extraWriter ?? (extraWriter = new ByteWriter(256));
|
|
9379
|
+
extraWriter.byte(bytes[begin]);
|
|
9380
|
+
extraWriter.uleb(flags & ~32);
|
|
9381
|
+
extraWriter.bytes(bytes, flagsEnd, nameStart);
|
|
9382
|
+
extraWriter.string(alias);
|
|
9383
|
+
extraWriter.bytes(bytes, nameEnd, offset);
|
|
9384
|
+
added++;
|
|
9385
|
+
} else {
|
|
9386
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
9387
|
+
entryWriter.string(alias);
|
|
9388
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
9389
|
+
}
|
|
9390
|
+
} else {
|
|
9391
|
+
entryWriter.bytes(bytes, begin, offset);
|
|
9392
|
+
}
|
|
8898
9393
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
8899
9394
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
8900
9395
|
throw new Error(`unsupported symbol ${name}`);
|
|
@@ -8908,63 +9403,73 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
8908
9403
|
hidden: (flags & 4) !== 0,
|
|
8909
9404
|
type
|
|
8910
9405
|
});
|
|
8911
|
-
|
|
8912
|
-
entries2.push(section2.subarray(begin, offset));
|
|
8913
|
-
extraEntries.push(
|
|
8914
|
-
section2.subarray(begin, begin + 1),
|
|
8915
|
-
encodeNumber(flags & ~32),
|
|
8916
|
-
section2.subarray(flagsEnd, nameStart),
|
|
8917
|
-
encodedString(alias),
|
|
8918
|
-
section2.subarray(nameEnd, offset)
|
|
8919
|
-
);
|
|
8920
|
-
added++;
|
|
8921
|
-
} else {
|
|
8922
|
-
entries2.push(
|
|
8923
|
-
section2.subarray(begin, nameStart),
|
|
8924
|
-
encodedString(alias),
|
|
8925
|
-
section2.subarray(nameEnd, offset)
|
|
8926
|
-
);
|
|
8927
|
-
}
|
|
8928
|
-
} else entries2.push(section2.subarray(begin, offset));
|
|
9406
|
+
}
|
|
8929
9407
|
}
|
|
8930
9408
|
if (offset !== stop) throw new Error("invalid symbol subsection");
|
|
8931
|
-
|
|
8932
|
-
|
|
9409
|
+
if (entryWriter) {
|
|
9410
|
+
const countBytes = encodeNumber(count + added);
|
|
9411
|
+
const entryBuf = entryWriter.finish();
|
|
9412
|
+
if (extraWriter) {
|
|
9413
|
+
const extraBuf = extraWriter.finish();
|
|
9414
|
+
subsections.push({
|
|
9415
|
+
kind,
|
|
9416
|
+
parts: [countBytes, entryBuf, extraBuf],
|
|
9417
|
+
byteLength: countBytes.length + entryBuf.length + extraBuf.length
|
|
9418
|
+
});
|
|
9419
|
+
} else {
|
|
9420
|
+
subsections.push({
|
|
9421
|
+
kind,
|
|
9422
|
+
parts: [countBytes, entryBuf],
|
|
9423
|
+
byteLength: countBytes.length + entryBuf.length
|
|
9424
|
+
});
|
|
9425
|
+
}
|
|
9426
|
+
}
|
|
9427
|
+
} else if (subsections) {
|
|
9428
|
+
subsections.push({
|
|
9429
|
+
kind,
|
|
9430
|
+
parts: [bytes.subarray(contentStart, stop)],
|
|
9431
|
+
byteLength: length
|
|
9432
|
+
});
|
|
8933
9433
|
}
|
|
8934
9434
|
offset = stop;
|
|
8935
|
-
subsections.push({ kind, content });
|
|
8936
9435
|
}
|
|
8937
|
-
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
const
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
content
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
9436
|
+
if (subsections) {
|
|
9437
|
+
const linkingWriter = new ByteWriter(size + 128);
|
|
9438
|
+
linkingWriter.string(sectionName);
|
|
9439
|
+
linkingWriter.uleb(version2);
|
|
9440
|
+
for (const subsection of subsections) {
|
|
9441
|
+
if (subsection.kind === 6 && objcLoader !== void 0) {
|
|
9442
|
+
const content = subsection.parts[0];
|
|
9443
|
+
const [count, entriesStart] = readNumber(content, 0);
|
|
9444
|
+
const initWriter = new ByteWriter(content.length + 16);
|
|
9445
|
+
initWriter.bytes(content, 0, entriesStart);
|
|
9446
|
+
let entryStart = entriesStart;
|
|
9447
|
+
for (let i = 0; i < count; i++) {
|
|
9448
|
+
const [, symbolStart] = readNumber(content, entryStart);
|
|
9449
|
+
const [symbol, entryEnd] = readNumber(content, symbolStart);
|
|
9450
|
+
if (symbol === objcLoader) {
|
|
9451
|
+
initWriter.uleb(1);
|
|
9452
|
+
initWriter.bytes(content, symbolStart, entryEnd);
|
|
9453
|
+
} else {
|
|
9454
|
+
initWriter.bytes(content, entryStart, entryEnd);
|
|
9455
|
+
}
|
|
9456
|
+
entryStart = entryEnd;
|
|
9457
|
+
}
|
|
9458
|
+
if (entryStart !== content.length)
|
|
9459
|
+
throw new Error("invalid init functions subsection");
|
|
9460
|
+
const initBuf = initWriter.finish();
|
|
9461
|
+
linkingWriter.byte(subsection.kind);
|
|
9462
|
+
linkingWriter.uleb(initBuf.length);
|
|
9463
|
+
linkingWriter.bytes(initBuf);
|
|
9464
|
+
} else {
|
|
9465
|
+
linkingWriter.byte(subsection.kind);
|
|
9466
|
+
linkingWriter.uleb(subsection.byteLength);
|
|
9467
|
+
for (const part of subsection.parts) linkingWriter.bytes(part);
|
|
8955
9468
|
}
|
|
8956
|
-
if (entryStart !== content.length)
|
|
8957
|
-
throw new Error("invalid init functions subsection");
|
|
8958
|
-
content = Buffer.concat(entries2);
|
|
8959
9469
|
}
|
|
8960
|
-
|
|
8961
|
-
Buffer.from([subsection.kind]),
|
|
8962
|
-
encodeNumber(content.length),
|
|
8963
|
-
content
|
|
8964
|
-
);
|
|
9470
|
+
rewrittenSection = linkingWriter.finish();
|
|
8965
9471
|
}
|
|
8966
|
-
|
|
8967
|
-
} else if (!sections && sectionName.startsWith("reloc.")) {
|
|
9472
|
+
} else if (!rewrite && sectionName.startsWith("reloc.")) {
|
|
8968
9473
|
number3();
|
|
8969
9474
|
for (let count = number3(); count > 0; count--) {
|
|
8970
9475
|
const type = number3();
|
|
@@ -8974,18 +9479,27 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
8974
9479
|
if (name !== void 0 && TABLE_INDEX_RELOCATIONS.has(type))
|
|
8975
9480
|
addressTaken.add(name);
|
|
8976
9481
|
}
|
|
8977
|
-
if (offset !==
|
|
8978
|
-
|
|
9482
|
+
if (offset !== end) throw new Error(`invalid relocation section ${sectionName}`);
|
|
9483
|
+
}
|
|
9484
|
+
}
|
|
9485
|
+
if (sections) {
|
|
9486
|
+
if (rewrittenSection) {
|
|
9487
|
+
sections.push(
|
|
9488
|
+
Buffer.from([id]),
|
|
9489
|
+
encodeNumber(rewrittenSection.length),
|
|
9490
|
+
rewrittenSection
|
|
9491
|
+
);
|
|
9492
|
+
} else {
|
|
9493
|
+
sections.push(bytes.subarray(headerStart, end));
|
|
8979
9494
|
}
|
|
8980
9495
|
}
|
|
8981
|
-
sections?.push(Buffer.from([id]), encodeNumber(section2.length), section2);
|
|
8982
9496
|
}
|
|
8983
9497
|
return {
|
|
8984
9498
|
bytes: sections ? Buffer.concat(sections) : bytes,
|
|
8985
9499
|
definitions,
|
|
8986
9500
|
functionImports,
|
|
8987
9501
|
usesDlsym,
|
|
8988
|
-
usedSymbols
|
|
9502
|
+
usedSymbols,
|
|
8989
9503
|
addressTaken: [...addressTaken]
|
|
8990
9504
|
};
|
|
8991
9505
|
}
|
|
@@ -9074,36 +9588,51 @@ function createGuestImageLedger(input) {
|
|
|
9074
9588
|
}
|
|
9075
9589
|
}
|
|
9076
9590
|
}
|
|
9077
|
-
|
|
9078
|
-
for (const definition of definitions)
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9591
|
+
let hasNonAscii = false;
|
|
9592
|
+
for (const definition of definitions) {
|
|
9593
|
+
const s = definition.name;
|
|
9594
|
+
for (let i = 0; i < s.length; i++) {
|
|
9595
|
+
if (s.charCodeAt(i) > 127) {
|
|
9596
|
+
hasNonAscii = true;
|
|
9597
|
+
break;
|
|
9598
|
+
}
|
|
9599
|
+
}
|
|
9600
|
+
if (hasNonAscii) break;
|
|
9601
|
+
}
|
|
9602
|
+
if (hasNonAscii) {
|
|
9603
|
+
const nameBytes = /* @__PURE__ */ new Map();
|
|
9604
|
+
for (const definition of definitions)
|
|
9605
|
+
if (!nameBytes.has(definition.name))
|
|
9606
|
+
nameBytes.set(definition.name, Buffer.from(definition.name));
|
|
9607
|
+
definitions.sort(
|
|
9608
|
+
(a, b) => Buffer.compare(nameBytes.get(a.name), nameBytes.get(b.name)) || a.image - b.image
|
|
9609
|
+
);
|
|
9610
|
+
} else {
|
|
9611
|
+
definitions.sort(
|
|
9612
|
+
(a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : a.image - b.image
|
|
9613
|
+
);
|
|
9614
|
+
}
|
|
9084
9615
|
const preserveCanonical = /* @__PURE__ */ new Set();
|
|
9085
9616
|
const definitionsByName = Map.groupBy(definitions, (definition) => definition.name);
|
|
9086
|
-
|
|
9617
|
+
if (symbolIndices.has("__cxa_throw")) {
|
|
9618
|
+
const name = "__cxa_throw";
|
|
9087
9619
|
const matching = definitionsByName.get(name) ?? [];
|
|
9088
|
-
if (new Set(matching.map((definition) => definition.image)).size
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
);
|
|
9103
|
-
if (uses && caller.image !== runtime.image && !caller.next.includes(runtime.image))
|
|
9104
|
-
throw new Error(`weak interposition scope excludes runtime for ${name}`);
|
|
9620
|
+
if (new Set(matching.map((definition) => definition.image)).size >= 2 && matching.some((definition) => definition.weak)) {
|
|
9621
|
+
const weak = matching.filter((definition) => definition.weak);
|
|
9622
|
+
const strong = matching.filter((definition) => !definition.weak);
|
|
9623
|
+
if (weak.length !== 1 || strong.length !== 1)
|
|
9624
|
+
throw new Error(`unsupported weak interposition for ${name}`);
|
|
9625
|
+
const [local] = weak;
|
|
9626
|
+
const [runtime] = strong;
|
|
9627
|
+
if (local.kind !== "function" || runtime.kind !== "function" || local.result !== runtime.result || local.parameters.join(",") !== runtime.parameters.join(","))
|
|
9628
|
+
throw new Error(`incompatible weak interposition for ${name}`);
|
|
9629
|
+
for (const caller of input.callers) {
|
|
9630
|
+
const uses = caller.image === local.image || units.some((unit) => unit.image === caller.image && unit.usedSymbols.has(name));
|
|
9631
|
+
if (uses && caller.image !== runtime.image && !caller.next.includes(runtime.image))
|
|
9632
|
+
throw new Error(`weak interposition scope excludes runtime for ${name}`);
|
|
9633
|
+
}
|
|
9634
|
+
preserveCanonical.add(name);
|
|
9105
9635
|
}
|
|
9106
|
-
preserveCanonical.add(name);
|
|
9107
9636
|
}
|
|
9108
9637
|
for (const name of [
|
|
9109
9638
|
"dlsym",
|
|
@@ -9115,40 +9644,76 @@ function createGuestImageLedger(input) {
|
|
|
9115
9644
|
])
|
|
9116
9645
|
preserveCanonical.add(name);
|
|
9117
9646
|
for (const name of input.commandLineSymbols ?? []) preserveCanonical.add(name);
|
|
9118
|
-
const
|
|
9119
|
-
const
|
|
9647
|
+
const imageAliases = /* @__PURE__ */ new Map();
|
|
9648
|
+
const imageWeakNames = /* @__PURE__ */ new Map();
|
|
9649
|
+
const singleOwnerByName = /* @__PURE__ */ new Map();
|
|
9650
|
+
for (const definition of definitions) {
|
|
9651
|
+
let aliases = imageAliases.get(definition.image);
|
|
9652
|
+
if (!aliases) imageAliases.set(definition.image, aliases = /* @__PURE__ */ new Map());
|
|
9653
|
+
const existing = aliases.get(definition.name);
|
|
9654
|
+
if (existing === void 0) {
|
|
9655
|
+
aliases.set(definition.name, definition.alias);
|
|
9656
|
+
if (definition.weak) {
|
|
9657
|
+
let weak = imageWeakNames.get(definition.image);
|
|
9658
|
+
if (!weak) imageWeakNames.set(definition.image, weak = /* @__PURE__ */ new Set());
|
|
9659
|
+
weak.add(definition.name);
|
|
9660
|
+
}
|
|
9661
|
+
const owner = singleOwnerByName.get(definition.name);
|
|
9662
|
+
if (owner === void 0)
|
|
9663
|
+
singleOwnerByName.set(definition.name, {
|
|
9664
|
+
image: definition.image,
|
|
9665
|
+
alias: definition.alias
|
|
9666
|
+
});
|
|
9667
|
+
else if (owner !== null && owner.image !== definition.image)
|
|
9668
|
+
singleOwnerByName.set(definition.name, null);
|
|
9669
|
+
} else if (!definition.weak && imageWeakNames.get(definition.image)?.has(definition.name)) {
|
|
9670
|
+
aliases.set(definition.name, definition.alias);
|
|
9671
|
+
imageWeakNames.get(definition.image).delete(definition.name);
|
|
9672
|
+
const owner = singleOwnerByName.get(definition.name);
|
|
9673
|
+
if (owner && owner.image === definition.image) owner.alias = definition.alias;
|
|
9674
|
+
}
|
|
9675
|
+
}
|
|
9676
|
+
const sharedLookupByImage = /* @__PURE__ */ new Map();
|
|
9120
9677
|
for (const caller of input.callers) {
|
|
9121
|
-
const bindings = /* @__PURE__ */ new Map();
|
|
9122
|
-
const seen = /* @__PURE__ */ new Map();
|
|
9123
9678
|
const scope = [caller.image, ...caller.next];
|
|
9124
9679
|
if (input.systemImage !== void 0 && !scope.includes(input.systemImage))
|
|
9125
9680
|
scope.push(input.systemImage);
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
|
|
9681
|
+
const scopeSet = new Set(scope);
|
|
9682
|
+
const scopeMaps = [];
|
|
9683
|
+
const seenImages = /* @__PURE__ */ new Set();
|
|
9684
|
+
for (const image of scope) {
|
|
9685
|
+
if (seenImages.has(image)) continue;
|
|
9686
|
+
seenImages.add(image);
|
|
9687
|
+
const aliases = imageAliases.get(image);
|
|
9688
|
+
if (aliases) scopeMaps.push(aliases);
|
|
9689
|
+
}
|
|
9690
|
+
const cache = /* @__PURE__ */ new Map();
|
|
9691
|
+
sharedLookupByImage.set(caller.image, (name) => {
|
|
9692
|
+
if (preserveCanonical.has(name)) return void 0;
|
|
9693
|
+
const single = singleOwnerByName.get(name);
|
|
9694
|
+
if (single === void 0) return void 0;
|
|
9695
|
+
if (single !== null) return scopeSet.has(single.image) ? single.alias : void 0;
|
|
9696
|
+
const hit = cache.get(name);
|
|
9697
|
+
if (hit !== void 0) return hit ?? void 0;
|
|
9698
|
+
for (const aliases of scopeMaps) {
|
|
9699
|
+
const alias = aliases.get(name);
|
|
9700
|
+
if (alias !== void 0) {
|
|
9701
|
+
cache.set(name, alias);
|
|
9702
|
+
return alias;
|
|
9141
9703
|
}
|
|
9142
9704
|
}
|
|
9143
|
-
|
|
9705
|
+
cache.set(name, null);
|
|
9706
|
+
return void 0;
|
|
9707
|
+
});
|
|
9144
9708
|
}
|
|
9145
9709
|
const startup = /* @__PURE__ */ new Map();
|
|
9710
|
+
const unitsByPath = new Map(units.map((unit) => [unit.object.path, unit]));
|
|
9146
9711
|
for (const binding of input.directBindings ?? []) {
|
|
9147
|
-
const unit =
|
|
9712
|
+
const unit = unitsByPath.get(binding.object);
|
|
9148
9713
|
const matches = (definitionsByName.get(binding.symbol) ?? []).filter(
|
|
9149
9714
|
(definition) => definition.object === binding.providerObject && definition.image === binding.providerImage
|
|
9150
9715
|
);
|
|
9151
|
-
if (!unit || !unit.usedSymbols.
|
|
9716
|
+
if (!unit || !unit.usedSymbols.has(binding.symbol) || matches.length !== 1)
|
|
9152
9717
|
throw new Error(`invalid startup binding ${binding.object} ${binding.symbol}`);
|
|
9153
9718
|
const bindings = startup.get(binding.object) ?? /* @__PURE__ */ new Map();
|
|
9154
9719
|
if (bindings.has(binding.symbol))
|
|
@@ -9189,11 +9754,11 @@ function createGuestImageLedger(input) {
|
|
|
9189
9754
|
}
|
|
9190
9755
|
}
|
|
9191
9756
|
const objects = units.map(({ image, object: object2, aliases, functionImports }) => {
|
|
9192
|
-
const shared =
|
|
9757
|
+
const shared = sharedLookupByImage.get(image);
|
|
9193
9758
|
const own = startup.get(object2.path);
|
|
9194
9759
|
const bindings = new Map(own);
|
|
9195
9760
|
const weak = input.sdkWeakReferences?.get(object2.path);
|
|
9196
|
-
const binding = (name) => bindings.get(name) ?? shared
|
|
9761
|
+
const binding = (name) => bindings.get(name) ?? shared(name) ?? (weak?.has(name) ? void 0 : sdkGlobalBindings.get(name));
|
|
9197
9762
|
for (const [name, type] of functionImports) {
|
|
9198
9763
|
const alias = binding(name);
|
|
9199
9764
|
const provider = alias === void 0 ? void 0 : definitionsByAlias.get(alias);
|
|
@@ -9885,8 +10450,11 @@ function moveGuestDyldTable(map, wasm, symbols, bindingValues = /* @__PURE__ */
|
|
|
9885
10450
|
function guestDyldValueRange(map) {
|
|
9886
10451
|
const suffix = `:(${GUEST_DYLD_VALUES_SECTION})`;
|
|
9887
10452
|
let found;
|
|
9888
|
-
for (
|
|
9889
|
-
|
|
10453
|
+
for (let at = map.indexOf(suffix); at !== -1; at = map.indexOf(suffix, at + suffix.length)) {
|
|
10454
|
+
const lineEnd = at + suffix.length;
|
|
10455
|
+
if (lineEnd < map.length && map.charCodeAt(lineEnd) !== 10) continue;
|
|
10456
|
+
const lineStart = map.lastIndexOf("\n", at) + 1;
|
|
10457
|
+
const line = map.slice(lineStart, lineEnd);
|
|
9890
10458
|
const match = /^\s*([\da-f]+)\s+[\da-f]+\s+([\da-f]+)\s/.exec(line);
|
|
9891
10459
|
if (!match) throw new Error("unreadable dyld values map line");
|
|
9892
10460
|
if (found) throw new Error("link map has several dyld value sections");
|
|
@@ -9913,7 +10481,7 @@ function selectedGuestInputImage(artifact, member) {
|
|
|
9913
10481
|
// src/swift-guest-manifest.ts
|
|
9914
10482
|
import { createHash as createHash9 } from "node:crypto";
|
|
9915
10483
|
import { readFileSync as readFileSync8 } from "node:fs";
|
|
9916
|
-
function selectedGuestManifestInputs(plan, selection, identities) {
|
|
10484
|
+
function selectedGuestManifestInputs(plan, selection, identities, readSelected) {
|
|
9917
10485
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
9918
10486
|
const archives = /* @__PURE__ */ new Map();
|
|
9919
10487
|
const images = /* @__PURE__ */ new Map();
|
|
@@ -9924,19 +10492,29 @@ function selectedGuestManifestInputs(plan, selection, identities) {
|
|
|
9924
10492
|
throw new Error(`selected input has no logical identity: ${item.artifact}`);
|
|
9925
10493
|
let bytes;
|
|
9926
10494
|
let memberIdentity = null;
|
|
9927
|
-
if (item.member === null)
|
|
9928
|
-
|
|
9929
|
-
|
|
9930
|
-
if (
|
|
9931
|
-
|
|
9932
|
-
|
|
10495
|
+
if (item.member === null) {
|
|
10496
|
+
bytes = readSelected ? readSelected(item) : readFileSync8(item.artifact);
|
|
10497
|
+
} else {
|
|
10498
|
+
if (readSelected) {
|
|
10499
|
+
bytes = readSelected(item);
|
|
10500
|
+
} else {
|
|
10501
|
+
let members = archives.get(item.artifact);
|
|
10502
|
+
if (!members) {
|
|
10503
|
+
members = /* @__PURE__ */ new Map();
|
|
10504
|
+
for (const member of readArMembers(readFileSync8(item.artifact))) {
|
|
10505
|
+
let list = members.get(member.name);
|
|
10506
|
+
if (!list) members.set(member.name, list = []);
|
|
10507
|
+
list.push(member.bytes);
|
|
10508
|
+
}
|
|
10509
|
+
archives.set(item.artifact, members);
|
|
10510
|
+
}
|
|
10511
|
+
const matching = members.get(item.member);
|
|
10512
|
+
if (!matching || matching.length !== 1)
|
|
10513
|
+
throw new Error(
|
|
10514
|
+
`selected archive member is ambiguous: ${item.artifact}(${item.member})`
|
|
10515
|
+
);
|
|
10516
|
+
bytes = matching[0];
|
|
9933
10517
|
}
|
|
9934
|
-
const matching = members.filter((member) => member.name === item.member);
|
|
9935
|
-
if (matching.length !== 1)
|
|
9936
|
-
throw new Error(
|
|
9937
|
-
`selected archive member is ambiguous: ${item.artifact}(${item.member})`
|
|
9938
|
-
);
|
|
9939
|
-
bytes = matching[0].bytes;
|
|
9940
10518
|
const origin = artifact.memberOrigins?.get(item.member);
|
|
9941
10519
|
if (artifact.memberOrigins && !origin)
|
|
9942
10520
|
throw new Error(
|
|
@@ -10017,7 +10595,7 @@ function createGuestImageManifest(image) {
|
|
|
10017
10595
|
function isSwiftGuestImageManifest(value) {
|
|
10018
10596
|
const uint = (value2, maximum) => typeof value2 === "number" && Number.isInteger(value2) && value2 >= 0 && value2 <= maximum;
|
|
10019
10597
|
const text2 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
10020
|
-
const name = (value2) => text2(value2) &&
|
|
10598
|
+
const name = (value2) => text2(value2) && Buffer.byteLength(value2, "utf8") <= 16;
|
|
10021
10599
|
const version2 = (value2) => isRecord(value2) && uint(value2.major, 65535) && uint(value2.minor, 255) && uint(value2.patch, 255);
|
|
10022
10600
|
if (!isRecord(value) || value.version !== 1 || !text2(value.id) || !text2(value.installName) || value.resourceBundlePath !== void 0 && !isSwiftBundlePath(value.resourceBundlePath) || value.fileType !== "executable" && value.fileType !== "dylib" || !isRecord(value.target) || value.target.triple !== SWIFT_WASM_TRIPLE || value.target.pointerWidth !== 64 || value.target.byteOrder !== "little" || value.target.cpuType !== -1 || value.target.cpuSubtype !== 0 || typeof value.inputsSha256 !== "string" || !/^[a-f0-9]{64}$/.test(value.inputsSha256) || value.uuid !== value.inputsSha256.slice(0, 32) || !isRecord(value.buildVersion) || !uint(value.buildVersion.platform, 4294967295) || !version2(value.buildVersion.minimum) || !version2(value.buildVersion.sdk) || !Array.isArray(value.regions))
|
|
10023
10601
|
return false;
|
|
@@ -10317,27 +10895,25 @@ function planGuestProjectionRegions(images, capacities, spans) {
|
|
|
10317
10895
|
function finalizeGuestProjectionStorage(options) {
|
|
10318
10896
|
const owner = options.owners.get(options.projectionObject);
|
|
10319
10897
|
if (owner === void 0) throw new Error("guest projection object has no image owner");
|
|
10898
|
+
const ranges = [];
|
|
10320
10899
|
const spans = guestLinkedSpans(
|
|
10321
10900
|
options.map,
|
|
10322
10901
|
options.linked,
|
|
10323
10902
|
options.optimized,
|
|
10324
10903
|
options.owners,
|
|
10325
10904
|
options.sectionOwners,
|
|
10326
|
-
options.sdkSpans !== void 0
|
|
10905
|
+
options.sdkSpans !== void 0,
|
|
10906
|
+
{
|
|
10907
|
+
trackedObject: options.projectionObject,
|
|
10908
|
+
trackedObjectOwner: owner,
|
|
10909
|
+
trackedLinearSpans: ranges
|
|
10910
|
+
}
|
|
10327
10911
|
);
|
|
10328
10912
|
const images = planGuestProjectionRegions(
|
|
10329
10913
|
options.reserved.images,
|
|
10330
10914
|
options.reserved.capacities,
|
|
10331
10915
|
options.sdkSpans ? [...spans, ...options.sdkSpans] : spans
|
|
10332
10916
|
);
|
|
10333
|
-
const ranges = guestLinkedSpans(
|
|
10334
|
-
options.map,
|
|
10335
|
-
options.linked,
|
|
10336
|
-
options.optimized,
|
|
10337
|
-
/* @__PURE__ */ new Map([[options.projectionObject, owner]]),
|
|
10338
|
-
void 0,
|
|
10339
|
-
options.sdkSpans !== void 0
|
|
10340
|
-
).filter((span) => span.space === "linear-memory");
|
|
10341
10917
|
const result = Buffer.from(options.optimized);
|
|
10342
10918
|
const data = guestWasmDataSegments(options.optimized, options.sdkSpans === void 0);
|
|
10343
10919
|
const locations = /* @__PURE__ */ new Map();
|
|
@@ -11670,7 +12246,7 @@ function occurrences(plan, args) {
|
|
|
11670
12246
|
throw new Error("guest plan does not match linker inputs");
|
|
11671
12247
|
return found;
|
|
11672
12248
|
}
|
|
11673
|
-
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
12249
|
+
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace, archiveCache) {
|
|
11674
12250
|
const rows = whyExtract.trimEnd().split("\n");
|
|
11675
12251
|
if (rows.shift() !== "reference extracted symbol")
|
|
11676
12252
|
throw new Error("invalid wasm-ld extraction report");
|
|
@@ -11685,8 +12261,38 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
11685
12261
|
for (const file of extracted)
|
|
11686
12262
|
if (!traced.has(file))
|
|
11687
12263
|
throw new Error(`extracted guest input is absent from link trace ${file}`);
|
|
12264
|
+
const foundOccurrences = occurrences(plan, args);
|
|
12265
|
+
const archivePaths = /* @__PURE__ */ new Set();
|
|
12266
|
+
for (const { artifact } of foundOccurrences)
|
|
12267
|
+
if (artifact.kind === "archive") archivePaths.add(artifact.path);
|
|
12268
|
+
const tracedMembers = /* @__PURE__ */ new Map();
|
|
12269
|
+
if (archivePaths.size > 0) {
|
|
12270
|
+
const archivePrefixes = [...archivePaths].map(
|
|
12271
|
+
(archivePath) => [archivePath, `${archivePath}(`]
|
|
12272
|
+
);
|
|
12273
|
+
for (const item of traced) {
|
|
12274
|
+
if (!item.endsWith(")")) continue;
|
|
12275
|
+
const open = item.lastIndexOf("(");
|
|
12276
|
+
if (open > 0) {
|
|
12277
|
+
const archivePath = item.slice(0, open);
|
|
12278
|
+
if (archivePaths.has(archivePath)) {
|
|
12279
|
+
let list = tracedMembers.get(archivePath);
|
|
12280
|
+
if (!list) tracedMembers.set(archivePath, list = []);
|
|
12281
|
+
list.push(item.slice(open + 1, -1));
|
|
12282
|
+
continue;
|
|
12283
|
+
}
|
|
12284
|
+
}
|
|
12285
|
+
for (const [archivePath, prefix] of archivePrefixes) {
|
|
12286
|
+
if (item.startsWith(prefix)) {
|
|
12287
|
+
let list = tracedMembers.get(archivePath);
|
|
12288
|
+
if (!list) tracedMembers.set(archivePath, list = []);
|
|
12289
|
+
list.push(item.slice(prefix.length, -1));
|
|
12290
|
+
}
|
|
12291
|
+
}
|
|
12292
|
+
}
|
|
12293
|
+
}
|
|
11688
12294
|
const result = [];
|
|
11689
|
-
for (const { artifact, lazy, whole } of
|
|
12295
|
+
for (const { artifact, lazy, whole } of foundOccurrences) {
|
|
11690
12296
|
if (artifact.kind === "object") {
|
|
11691
12297
|
if (!lazy && !traced.has(artifact.path))
|
|
11692
12298
|
throw new Error(`eager guest input is absent from link trace ${artifact.path}`);
|
|
@@ -11694,15 +12300,21 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
11694
12300
|
result.push({ artifact: artifact.path, member: null });
|
|
11695
12301
|
continue;
|
|
11696
12302
|
}
|
|
11697
|
-
const
|
|
11698
|
-
const
|
|
11699
|
-
|
|
12303
|
+
const names = tracedMembers.get(artifact.path) ?? [];
|
|
12304
|
+
const nameSet = new Set(names);
|
|
12305
|
+
let members = archiveCache?.get(artifact.path);
|
|
12306
|
+
if (!members) {
|
|
12307
|
+
members = readArMembers(fs9.readFileSync(artifact.path));
|
|
12308
|
+
archiveCache?.set(artifact.path, members);
|
|
12309
|
+
}
|
|
12310
|
+
const memberCounts = /* @__PURE__ */ new Map();
|
|
11700
12311
|
for (const member of members) {
|
|
11701
|
-
|
|
12312
|
+
memberCounts.set(member.name, (memberCounts.get(member.name) ?? 0) + 1);
|
|
12313
|
+
if (whole || nameSet.has(member.name))
|
|
11702
12314
|
result.push({ artifact: artifact.path, member: member.name });
|
|
11703
12315
|
}
|
|
11704
12316
|
for (const name of names)
|
|
11705
|
-
if (
|
|
12317
|
+
if (memberCounts.get(name) !== 1)
|
|
11706
12318
|
throw new Error(
|
|
11707
12319
|
`ambiguous or unsupported archive member ${artifact.path}(${name})`
|
|
11708
12320
|
);
|
|
@@ -11779,14 +12391,25 @@ function linkGuestImages(options) {
|
|
|
11779
12391
|
}
|
|
11780
12392
|
const archives = /* @__PURE__ */ new Map();
|
|
11781
12393
|
const memberBytes = /* @__PURE__ */ new Map();
|
|
12394
|
+
const objectBytes = /* @__PURE__ */ new Map();
|
|
11782
12395
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
11783
12396
|
const providerSymbol = "__peach_dlsym_from_image";
|
|
11784
12397
|
const readSelected = (item) => {
|
|
11785
|
-
if (item.member === null)
|
|
12398
|
+
if (item.member === null) {
|
|
12399
|
+
let bytes = objectBytes.get(item.artifact);
|
|
12400
|
+
if (!bytes) {
|
|
12401
|
+
bytes = fs9.readFileSync(item.artifact);
|
|
12402
|
+
objectBytes.set(item.artifact, bytes);
|
|
12403
|
+
}
|
|
12404
|
+
return bytes;
|
|
12405
|
+
}
|
|
11786
12406
|
let byName = memberBytes.get(item.artifact);
|
|
11787
12407
|
if (!byName) {
|
|
11788
|
-
|
|
11789
|
-
|
|
12408
|
+
let members = archives.get(item.artifact);
|
|
12409
|
+
if (!members) {
|
|
12410
|
+
members = readArMembers(fs9.readFileSync(item.artifact));
|
|
12411
|
+
archives.set(item.artifact, members);
|
|
12412
|
+
}
|
|
11790
12413
|
byName = /* @__PURE__ */ new Map();
|
|
11791
12414
|
for (const member of members)
|
|
11792
12415
|
if (!byName.has(member.name))
|
|
@@ -11810,7 +12433,13 @@ function linkGuestImages(options) {
|
|
|
11810
12433
|
`--why-extract=${whyPath}`,
|
|
11811
12434
|
`--Map=${mapPath}`
|
|
11812
12435
|
]);
|
|
11813
|
-
return selectedGuestLinkInputs(
|
|
12436
|
+
return selectedGuestLinkInputs(
|
|
12437
|
+
plan,
|
|
12438
|
+
args,
|
|
12439
|
+
fs9.readFileSync(whyPath, "utf8"),
|
|
12440
|
+
trace,
|
|
12441
|
+
archives
|
|
12442
|
+
);
|
|
11814
12443
|
};
|
|
11815
12444
|
const needsProvider = (item) => {
|
|
11816
12445
|
if (!artifacts.get(item.artifact).instrumentDynamicLookups) return false;
|
|
@@ -11850,7 +12479,7 @@ function linkGuestImages(options) {
|
|
|
11850
12479
|
)
|
|
11851
12480
|
]);
|
|
11852
12481
|
const originalOwnership = identity(plan);
|
|
11853
|
-
const resolved = options.resolvePlan(selected, plan);
|
|
12482
|
+
const resolved = options.resolvePlan(selected, plan, readSelected);
|
|
11854
12483
|
if (identity(resolved) !== originalOwnership)
|
|
11855
12484
|
throw new Error("resolved guest scopes changed input ownership");
|
|
11856
12485
|
plan = resolved;
|
|
@@ -11904,6 +12533,7 @@ function linkGuestImages(options) {
|
|
|
11904
12533
|
}
|
|
11905
12534
|
}
|
|
11906
12535
|
let discoveryRegions;
|
|
12536
|
+
let liveSymbols;
|
|
11907
12537
|
if (discoveryProjection && options.projection) {
|
|
11908
12538
|
const owners = /* @__PURE__ */ new Map([[discoveryProjection, options.projection.image]]);
|
|
11909
12539
|
for (const item of selected)
|
|
@@ -11912,10 +12542,15 @@ function linkGuestImages(options) {
|
|
|
11912
12542
|
selectedGuestInputImage(artifacts.get(item.artifact), item.member)
|
|
11913
12543
|
);
|
|
11914
12544
|
const wasm = fs9.readFileSync(discovery);
|
|
12545
|
+
liveSymbols = /* @__PURE__ */ new Set();
|
|
11915
12546
|
discoveryRegions = guestProjectionRegionCounts(
|
|
11916
12547
|
plan.images.length,
|
|
11917
|
-
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners
|
|
12548
|
+
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners, void 0, false, {
|
|
12549
|
+
collectSymbols: liveSymbols
|
|
12550
|
+
})
|
|
11918
12551
|
);
|
|
12552
|
+
} else {
|
|
12553
|
+
liveSymbols = linkedMapSymbols(guestLinkLines(mapPath));
|
|
11919
12554
|
}
|
|
11920
12555
|
const ledger = createGuestImageLedger({
|
|
11921
12556
|
images: plan.images.map((image) => ({
|
|
@@ -11924,7 +12559,7 @@ function linkGuestImages(options) {
|
|
|
11924
12559
|
})),
|
|
11925
12560
|
callers: plan.callers,
|
|
11926
12561
|
symbols: plan.symbols,
|
|
11927
|
-
liveSymbols
|
|
12562
|
+
liveSymbols,
|
|
11928
12563
|
commandLineSymbols: commandLineSymbols(args),
|
|
11929
12564
|
directBindings: plan.directBindings,
|
|
11930
12565
|
registerAppTables: sdkCallers !== void 0,
|
|
@@ -12056,7 +12691,8 @@ function linkGuestImages(options) {
|
|
|
12056
12691
|
const selectedInputs = selectedGuestManifestInputs(
|
|
12057
12692
|
plan,
|
|
12058
12693
|
selected,
|
|
12059
|
-
projection.identities
|
|
12694
|
+
projection.identities,
|
|
12695
|
+
readSelected
|
|
12060
12696
|
);
|
|
12061
12697
|
const images = projection.images.map(
|
|
12062
12698
|
(image) => createGuestImageManifest({
|
|
@@ -12066,6 +12702,9 @@ function linkGuestImages(options) {
|
|
|
12066
12702
|
regions: []
|
|
12067
12703
|
})
|
|
12068
12704
|
);
|
|
12705
|
+
objectBytes.clear();
|
|
12706
|
+
memberBytes.clear();
|
|
12707
|
+
archives.clear();
|
|
12069
12708
|
if (!discoveryRegions) throw new Error("guest projection layout object missing");
|
|
12070
12709
|
const regionsBefore = discoveryRegions;
|
|
12071
12710
|
const ledgerPieces = guestProjectionRegionCapacity([fs9.readFileSync(ledgerObject)], 0);
|
|
@@ -12091,6 +12730,7 @@ function linkGuestImages(options) {
|
|
|
12091
12730
|
{ stdio: "pipe" }
|
|
12092
12731
|
);
|
|
12093
12732
|
finalTrace = linkFinal(projectionObject, callerMap ? void 0 : layoutMap);
|
|
12733
|
+
if (sharedSdk) break;
|
|
12094
12734
|
const wasm = fs9.readFileSync(finalOutput);
|
|
12095
12735
|
const actual = guestProjectionRegionCounts(
|
|
12096
12736
|
images.length,
|
|
@@ -12159,10 +12799,47 @@ ${changed.join("\n")}`
|
|
|
12159
12799
|
}
|
|
12160
12800
|
function linkedMapSymbols(lines) {
|
|
12161
12801
|
const names = /* @__PURE__ */ new Set();
|
|
12162
|
-
const symbol = /^ +\S+ +[0-9a-f]+ +[0-9a-f]+ {9,}([^\s/<]\S*)/;
|
|
12163
12802
|
for (const line of lines) {
|
|
12164
|
-
const
|
|
12165
|
-
if (
|
|
12803
|
+
const length = line.length;
|
|
12804
|
+
if (length < 15 || line.charCodeAt(0) !== 32) continue;
|
|
12805
|
+
let pos = 1;
|
|
12806
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
12807
|
+
const c1 = pos;
|
|
12808
|
+
while (pos < length) {
|
|
12809
|
+
const ch = line.charCodeAt(pos);
|
|
12810
|
+
if (ch === 32 || ch >= 9 && ch <= 13) break;
|
|
12811
|
+
pos++;
|
|
12812
|
+
}
|
|
12813
|
+
if (pos === c1 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
12814
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
12815
|
+
const c2 = pos;
|
|
12816
|
+
while (pos < length) {
|
|
12817
|
+
const ch = line.charCodeAt(pos);
|
|
12818
|
+
if (!(ch >= 48 && ch <= 57 || ch >= 97 && ch <= 102)) break;
|
|
12819
|
+
pos++;
|
|
12820
|
+
}
|
|
12821
|
+
if (pos === c2 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
12822
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
12823
|
+
const c3 = pos;
|
|
12824
|
+
while (pos < length) {
|
|
12825
|
+
const ch = line.charCodeAt(pos);
|
|
12826
|
+
if (!(ch >= 48 && ch <= 57 || ch >= 97 && ch <= 102)) break;
|
|
12827
|
+
pos++;
|
|
12828
|
+
}
|
|
12829
|
+
if (pos === c3 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
12830
|
+
const sStart = pos;
|
|
12831
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
12832
|
+
if (pos - sStart < 9 || pos >= length) continue;
|
|
12833
|
+
const first = line.charCodeAt(pos);
|
|
12834
|
+
if (first === 47 || first === 60 || first === 32 || first >= 9 && first <= 13)
|
|
12835
|
+
continue;
|
|
12836
|
+
let end = pos + 1;
|
|
12837
|
+
while (end < length) {
|
|
12838
|
+
const ch = line.charCodeAt(end);
|
|
12839
|
+
if (ch === 32 || ch >= 9 && ch <= 13) break;
|
|
12840
|
+
end++;
|
|
12841
|
+
}
|
|
12842
|
+
names.add(line.slice(pos, end));
|
|
12166
12843
|
}
|
|
12167
12844
|
return names;
|
|
12168
12845
|
}
|
|
@@ -12261,7 +12938,7 @@ function discoverGuestLinkInputs(options) {
|
|
|
12261
12938
|
fs9.mkdirSync(options.directory, { recursive: true });
|
|
12262
12939
|
const why = path20.join(options.directory, "preselection-why.txt");
|
|
12263
12940
|
const response = path20.join(options.directory, "preselection.rsp");
|
|
12264
|
-
const output = path20.join(options.directory, "preselection.wasm");
|
|
12941
|
+
const output = process.platform !== "win32" ? "/dev/null" : path20.join(options.directory, "preselection.wasm");
|
|
12265
12942
|
const flags = [
|
|
12266
12943
|
...withOutput(args, output, true),
|
|
12267
12944
|
...options.objects,
|
|
@@ -12359,7 +13036,7 @@ function prepareGuestRuntimeInputs(options) {
|
|
|
12359
13036
|
});
|
|
12360
13037
|
return { args, selected, originalSelection, archives, sdkProducts, archiveArtifacts };
|
|
12361
13038
|
}
|
|
12362
|
-
function selectedGuestSymbolInputs(plan, selected) {
|
|
13039
|
+
function selectedGuestSymbolInputs(plan, selected, readSelected) {
|
|
12363
13040
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
12364
13041
|
const archives = /* @__PURE__ */ new Map();
|
|
12365
13042
|
const symbols = /* @__PURE__ */ new Set();
|
|
@@ -12375,22 +13052,27 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
12375
13052
|
if (!artifact) throw new Error(`selected symbol input has no owner ${item.artifact}`);
|
|
12376
13053
|
let bytes;
|
|
12377
13054
|
let name = item.artifact;
|
|
12378
|
-
if (item.member === null)
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
if (
|
|
12382
|
-
|
|
12383
|
-
|
|
12384
|
-
|
|
12385
|
-
)
|
|
12386
|
-
|
|
13055
|
+
if (item.member === null) {
|
|
13056
|
+
bytes = readSelected ? readSelected(item) : fs9.readFileSync(item.artifact);
|
|
13057
|
+
} else {
|
|
13058
|
+
if (readSelected) {
|
|
13059
|
+
bytes = readSelected(item);
|
|
13060
|
+
} else {
|
|
13061
|
+
let members = archives.get(item.artifact);
|
|
13062
|
+
if (!members) {
|
|
13063
|
+
members = Map.groupBy(
|
|
13064
|
+
readArMembers(fs9.readFileSync(item.artifact)),
|
|
13065
|
+
(member) => member.name
|
|
13066
|
+
);
|
|
13067
|
+
archives.set(item.artifact, members);
|
|
13068
|
+
}
|
|
13069
|
+
const matching = members.get(item.member) ?? [];
|
|
13070
|
+
if (matching.length !== 1)
|
|
13071
|
+
throw new Error(
|
|
13072
|
+
`ambiguous selected symbol input ${item.artifact}(${item.member})`
|
|
13073
|
+
);
|
|
13074
|
+
bytes = matching[0].bytes;
|
|
12387
13075
|
}
|
|
12388
|
-
const matching = members.get(item.member) ?? [];
|
|
12389
|
-
if (matching.length !== 1)
|
|
12390
|
-
throw new Error(
|
|
12391
|
-
`ambiguous selected symbol input ${item.artifact}(${item.member})`
|
|
12392
|
-
);
|
|
12393
|
-
bytes = matching[0].bytes;
|
|
12394
13076
|
name += `(${item.member})`;
|
|
12395
13077
|
}
|
|
12396
13078
|
if (owners.has(name)) throw new Error(`duplicate selected symbol input ${name}`);
|
|
@@ -12403,9 +13085,9 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
12403
13085
|
for (const symbol of names.tags) tags.add(symbol);
|
|
12404
13086
|
for (const symbol of names.defined) {
|
|
12405
13087
|
definitions.add(symbol);
|
|
12406
|
-
|
|
13088
|
+
let objects = definitionObjects.get(symbol);
|
|
13089
|
+
if (!objects) definitionObjects.set(symbol, objects = /* @__PURE__ */ new Set());
|
|
12407
13090
|
objects.add(name);
|
|
12408
|
-
definitionObjects.set(symbol, objects);
|
|
12409
13091
|
}
|
|
12410
13092
|
}
|
|
12411
13093
|
return {
|
|
@@ -12426,7 +13108,7 @@ function verifyGuestSymbolScopes(options) {
|
|
|
12426
13108
|
if (!symbols.length) return { bindings: [], directBindings: [] };
|
|
12427
13109
|
fs9.mkdirSync(options.directory, { recursive: true });
|
|
12428
13110
|
const response = path20.join(options.directory, "scope-trace.rsp");
|
|
12429
|
-
const output = path20.join(options.directory, "scope-trace.wasm");
|
|
13111
|
+
const output = process.platform !== "win32" ? "/dev/null" : path20.join(options.directory, "scope-trace.wasm");
|
|
12430
13112
|
const args = [
|
|
12431
13113
|
...withOutput(normalizedGuestLinkArgs(options.args), output, true),
|
|
12432
13114
|
...options.objects,
|
|
@@ -12444,55 +13126,76 @@ function verifyGuestSymbolScopes(options) {
|
|
|
12444
13126
|
fs9.closeSync(traceOutput);
|
|
12445
13127
|
}
|
|
12446
13128
|
const records = /* @__PURE__ */ new Map();
|
|
12447
|
-
const
|
|
12448
|
-
const
|
|
12449
|
-
|
|
12450
|
-
|
|
12451
|
-
|
|
12452
|
-
|
|
12453
|
-
const
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
|
|
12457
|
-
|
|
13129
|
+
for (const line of guestLinkLines(tracePath)) {
|
|
13130
|
+
const refSep = line.lastIndexOf(": reference to ");
|
|
13131
|
+
const defSep = line.lastIndexOf(": definition of ");
|
|
13132
|
+
if (refSep < 0 && defSep < 0) continue;
|
|
13133
|
+
const isRef = refSep > defSep;
|
|
13134
|
+
const sep = isRef ? refSep : defSep;
|
|
13135
|
+
const symbol = line.slice(sep + (isRef ? 15 : 16));
|
|
13136
|
+
if (!requested.has(symbol) || options.hostImports.has(symbol)) continue;
|
|
13137
|
+
let record = records.get(symbol);
|
|
13138
|
+
if (!record) {
|
|
13139
|
+
record = {
|
|
13140
|
+
references: /* @__PURE__ */ new Map(),
|
|
13141
|
+
providers: /* @__PURE__ */ new Map(),
|
|
13142
|
+
physicalModule: false
|
|
13143
|
+
};
|
|
13144
|
+
records.set(symbol, record);
|
|
13145
|
+
}
|
|
13146
|
+
const object2 = line.slice(0, sep);
|
|
12458
13147
|
if (object2 === "<internal>") {
|
|
12459
|
-
if (
|
|
13148
|
+
if (!isRef) record.physicalModule = true;
|
|
12460
13149
|
} else {
|
|
12461
13150
|
const image = options.owners.get(object2);
|
|
12462
13151
|
if (image === void 0)
|
|
12463
13152
|
throw new Error(`traced guest object has no owner ${object2}`);
|
|
12464
|
-
(
|
|
12465
|
-
object2,
|
|
12466
|
-
image
|
|
12467
|
-
);
|
|
13153
|
+
(isRef ? record.references : record.providers).set(object2, image);
|
|
12468
13154
|
}
|
|
12469
|
-
|
|
12470
|
-
};
|
|
12471
|
-
for (const line of guestLinkLines(tracePath)) consume(line);
|
|
13155
|
+
}
|
|
12472
13156
|
const callers = new Map(options.callers.map((caller) => [caller.image, caller.next]));
|
|
13157
|
+
const callerSets = new Map(
|
|
13158
|
+
options.callers.map((caller) => [caller.image, new Set(caller.next)])
|
|
13159
|
+
);
|
|
13160
|
+
const rootScope = callerSets.get(0);
|
|
12473
13161
|
const result = [];
|
|
12474
13162
|
const directBindings = [];
|
|
12475
13163
|
for (const symbol of symbols) {
|
|
12476
13164
|
const record = records.get(symbol);
|
|
12477
13165
|
if (!record || !record.references.size) continue;
|
|
12478
13166
|
if (!record.providers.size && options.hostImports.has(symbol)) continue;
|
|
12479
|
-
const startupReferences = [
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
const
|
|
12483
|
-
|
|
12484
|
-
|
|
13167
|
+
const startupReferences = [];
|
|
13168
|
+
const otherReferences = [];
|
|
13169
|
+
let allWeakRefs = true;
|
|
13170
|
+
for (const [object2, caller] of record.references) {
|
|
13171
|
+
const isWeakRef = options.weakReferences.get(object2)?.has(symbol) === true;
|
|
13172
|
+
if (!isWeakRef) allWeakRefs = false;
|
|
13173
|
+
if (isWeakRef && options.startupObjects.has(object2)) {
|
|
13174
|
+
startupReferences.push([object2, caller]);
|
|
13175
|
+
} else {
|
|
13176
|
+
otherReferences.push([object2, caller]);
|
|
13177
|
+
}
|
|
13178
|
+
}
|
|
12485
13179
|
for (const [, caller] of startupReferences)
|
|
12486
13180
|
if (!callers.has(caller))
|
|
12487
13181
|
throw new Error(`guest image has no caller scope ${caller}`);
|
|
12488
13182
|
if (startupReferences.length && !record.physicalModule) {
|
|
12489
|
-
const
|
|
12490
|
-
|
|
13183
|
+
const candidates2 = options.definitionObjects.get(symbol);
|
|
13184
|
+
const candidateSize = candidates2?.size ?? 0;
|
|
13185
|
+
if (candidateSize > 1 || record.providers.size > 1)
|
|
12491
13186
|
throw new Error(`ambiguous startup provider ${symbol}`);
|
|
12492
|
-
|
|
12493
|
-
|
|
13187
|
+
let unproven = candidateSize !== record.providers.size;
|
|
13188
|
+
if (!unproven && candidates2) {
|
|
13189
|
+
for (const object2 of record.providers.keys()) {
|
|
13190
|
+
if (!candidates2.has(object2)) {
|
|
13191
|
+
unproven = true;
|
|
13192
|
+
break;
|
|
13193
|
+
}
|
|
13194
|
+
}
|
|
13195
|
+
}
|
|
13196
|
+
if (unproven) throw new Error(`unproven startup provider ${symbol}`);
|
|
12494
13197
|
if (record.providers.size === 1) {
|
|
12495
|
-
const [providerObject, providerImage] =
|
|
13198
|
+
const [providerObject, providerImage] = record.providers.entries().next().value;
|
|
12496
13199
|
if (options.weakDefinitions.get(providerObject)?.has(symbol))
|
|
12497
13200
|
throw new Error(`weak startup provider ${symbol}`);
|
|
12498
13201
|
for (const [object2] of startupReferences)
|
|
@@ -12500,28 +13203,34 @@ function verifyGuestSymbolScopes(options) {
|
|
|
12500
13203
|
}
|
|
12501
13204
|
if (!otherReferences.length) continue;
|
|
12502
13205
|
}
|
|
12503
|
-
if (!record.providers.size && !record.physicalModule &&
|
|
12504
|
-
(object2) => options.weakReferences.get(object2)?.has(symbol)
|
|
12505
|
-
))
|
|
12506
|
-
continue;
|
|
13206
|
+
if (!record.providers.size && !record.physicalModule && allWeakRefs) continue;
|
|
12507
13207
|
const providerImages = new Set(record.providers.values());
|
|
12508
|
-
const
|
|
12509
|
-
|
|
13208
|
+
const candidates = options.definitionObjects.get(symbol);
|
|
13209
|
+
const copyImages = /* @__PURE__ */ new Set();
|
|
13210
|
+
const strongImages = /* @__PURE__ */ new Set();
|
|
13211
|
+
let weakDefinerImages;
|
|
13212
|
+
if (candidates) {
|
|
13213
|
+
for (const object2 of candidates) {
|
|
12510
13214
|
const image = options.owners.get(object2);
|
|
12511
|
-
|
|
13215
|
+
if (image === void 0) continue;
|
|
13216
|
+
copyImages.add(image);
|
|
13217
|
+
if (options.weakDefinitions.get(object2)?.has(symbol)) {
|
|
13218
|
+
;
|
|
13219
|
+
(weakDefinerImages ?? (weakDefinerImages = /* @__PURE__ */ new Set())).add(image);
|
|
13220
|
+
} else {
|
|
13221
|
+
strongImages.add(image);
|
|
13222
|
+
}
|
|
12512
13223
|
}
|
|
12513
|
-
|
|
12514
|
-
const copyImages = new Set(copies.map((copy) => copy.image));
|
|
12515
|
-
const strongImages = new Set(
|
|
12516
|
-
copies.filter((copy) => !copy.weak).map((copy) => copy.image)
|
|
12517
|
-
);
|
|
13224
|
+
}
|
|
12518
13225
|
const interposed = !record.physicalModule && copyImages.size > 1;
|
|
12519
13226
|
const providerCount = interposed ? 1 : providerImages.size + Number(record.physicalModule);
|
|
12520
13227
|
if (!providerCount) continue;
|
|
12521
13228
|
if (providerCount !== 1)
|
|
12522
13229
|
throw new Error(`guest symbol has ambiguous provider ${symbol}`);
|
|
12523
|
-
const scopedReferences = record.physicalModule ?
|
|
12524
|
-
const
|
|
13230
|
+
const scopedReferences = record.physicalModule ? record.references : otherReferences;
|
|
13231
|
+
const firstProviderImage = providerImages.values().next().value;
|
|
13232
|
+
const uniqueProvider = strongImages.size > 1 ? void 0 : strongImages.values().next().value ?? firstProviderImage;
|
|
13233
|
+
let interposedByCaller;
|
|
12525
13234
|
for (const [object2, caller] of scopedReferences) {
|
|
12526
13235
|
const scope = callers.get(caller);
|
|
12527
13236
|
if (!scope) throw new Error(`guest image has no caller scope ${caller}`);
|
|
@@ -12529,18 +13238,35 @@ function verifyGuestSymbolScopes(options) {
|
|
|
12529
13238
|
result.push({ symbol, caller, provider: { kind: "physical-module" } });
|
|
12530
13239
|
continue;
|
|
12531
13240
|
}
|
|
12532
|
-
|
|
13241
|
+
let provider;
|
|
13242
|
+
if (interposed) {
|
|
13243
|
+
if (interposedByCaller?.has(caller)) {
|
|
13244
|
+
provider = interposedByCaller.get(caller);
|
|
13245
|
+
} else {
|
|
13246
|
+
if (copyImages.has(caller)) {
|
|
13247
|
+
provider = caller;
|
|
13248
|
+
} else {
|
|
13249
|
+
for (const image of scope) {
|
|
13250
|
+
if (copyImages.has(image)) {
|
|
13251
|
+
provider = image;
|
|
13252
|
+
break;
|
|
13253
|
+
}
|
|
13254
|
+
}
|
|
13255
|
+
if (provider === void 0) provider = uniqueProvider;
|
|
13256
|
+
}
|
|
13257
|
+
;
|
|
13258
|
+
(interposedByCaller ?? (interposedByCaller = /* @__PURE__ */ new Map())).set(caller, provider);
|
|
13259
|
+
}
|
|
13260
|
+
} else {
|
|
13261
|
+
provider = firstProviderImage;
|
|
13262
|
+
}
|
|
12533
13263
|
if (provider === void 0) {
|
|
12534
13264
|
if (options.weakReferences.get(object2)?.has(symbol)) continue;
|
|
12535
13265
|
throw new Error(`guest scope ${caller} omits every provider of ${symbol}`);
|
|
12536
13266
|
}
|
|
12537
13267
|
if (caller === provider) continue;
|
|
12538
|
-
if (
|
|
12539
|
-
|
|
12540
|
-
))
|
|
12541
|
-
continue;
|
|
12542
|
-
if (!scope.includes(provider)) {
|
|
12543
|
-
const candidates = options.definitionObjects.get(symbol) ?? /* @__PURE__ */ new Set();
|
|
13268
|
+
if (weakDefinerImages?.has(caller)) continue;
|
|
13269
|
+
if (!callerSets.get(caller).has(provider)) {
|
|
12544
13270
|
const traced = [...record.providers.keys()];
|
|
12545
13271
|
const strongTraced = traced.filter(
|
|
12546
13272
|
(definer) => !options.weakDefinitions.get(definer)?.has(symbol)
|
|
@@ -12548,16 +13274,17 @@ function verifyGuestSymbolScopes(options) {
|
|
|
12548
13274
|
const providers = strongTraced.length === 1 ? strongTraced : traced;
|
|
12549
13275
|
if (options.weakReferences.get(object2)?.has(symbol) && !providers.some((provider2) => options.systemProviders.has(provider2)))
|
|
12550
13276
|
continue;
|
|
12551
|
-
const
|
|
13277
|
+
const candidateSet = candidates ?? /* @__PURE__ */ new Set();
|
|
13278
|
+
const equivalentCopies = providers.length === 1 && candidateSet.has(providers[0]) && [...candidateSet].every(
|
|
12552
13279
|
(definer) => options.weakDefinitions.get(definer)?.has(symbol)
|
|
12553
13280
|
);
|
|
12554
|
-
const strongCandidates = [...
|
|
13281
|
+
const strongCandidates = [...candidateSet].filter(
|
|
12555
13282
|
(definer) => !options.weakDefinitions.get(definer)?.has(symbol)
|
|
12556
13283
|
);
|
|
12557
|
-
const soleCandidate =
|
|
12558
|
-
if (!equivalentCopies && (!soleCandidate || providers.length !== 1 || !
|
|
13284
|
+
const soleCandidate = candidateSet.size === 1 || strongCandidates.length === 1 && strongCandidates[0] === providers[0];
|
|
13285
|
+
if (!equivalentCopies && (!soleCandidate || providers.length !== 1 || !candidateSet.has(providers[0]) || !(options.systemProviders.has(providers[0]) || // a strong undefined reference binds through the process global
|
|
12559
13286
|
// scope, the root image and its dependency closure, as in elf.
|
|
12560
|
-
provider === 0 ||
|
|
13287
|
+
provider === 0 || rootScope?.has(provider) || !options.weakReferences.get(object2)?.has(symbol) && options.frameworkProviders.get(object2)?.has(providers[0]))))
|
|
12561
13288
|
throw new Error(
|
|
12562
13289
|
`guest scope ${caller} omits traced provider ${provider} for ${symbol}`
|
|
12563
13290
|
);
|
|
@@ -12751,27 +13478,131 @@ function clangIrLinkOptions(ir) {
|
|
|
12751
13478
|
var CLANG_TARGET_MODULE_WRAPPER = ".peach-clang";
|
|
12752
13479
|
var PARALLEL_REPLAY = `
|
|
12753
13480
|
const { spawn } = require('node:child_process')
|
|
12754
|
-
const
|
|
13481
|
+
const fs = require('node:fs')
|
|
13482
|
+
const commands = JSON.parse(fs.readFileSync(process.env.PEACH_CLANG_REPLAYS, 'utf8'))
|
|
13483
|
+
const results = new Array(commands.length)
|
|
12755
13484
|
let next = 0
|
|
12756
13485
|
const run = () => {
|
|
12757
13486
|
if (next >= commands.length) return Promise.resolve()
|
|
12758
|
-
const
|
|
13487
|
+
const index = next++
|
|
13488
|
+
const [file, ...args] = commands[index]
|
|
12759
13489
|
return new Promise((resolve, reject) => {
|
|
12760
|
-
const child = spawn(file, args, { stdio: 'inherit' })
|
|
13490
|
+
const child = spawn(file, args, { stdio: ['ignore', 'pipe', 'inherit'] })
|
|
13491
|
+
const metadata = []
|
|
13492
|
+
let pending = ''
|
|
13493
|
+
child.stdout.setEncoding('utf8')
|
|
13494
|
+
child.stdout.on('data', (chunk) => {
|
|
13495
|
+
const text = pending + chunk
|
|
13496
|
+
let start = 0
|
|
13497
|
+
for (let nl = text.indexOf('\\n'); nl !== -1; nl = text.indexOf('\\n', start)) {
|
|
13498
|
+
if (text.charCodeAt(start) === 33) metadata.push(text.slice(start, nl))
|
|
13499
|
+
start = nl + 1
|
|
13500
|
+
}
|
|
13501
|
+
pending = text.slice(start)
|
|
13502
|
+
})
|
|
12761
13503
|
child.on('error', reject)
|
|
12762
|
-
child.on('close', (code) =>
|
|
13504
|
+
child.on('close', (code) => {
|
|
13505
|
+
if (pending.charCodeAt(0) === 33) metadata.push(pending)
|
|
13506
|
+
if (code === 0) {
|
|
13507
|
+
results[index] = metadata.join('\\n')
|
|
13508
|
+
resolve()
|
|
13509
|
+
} else reject(new Error('clang link replay failed: ' + file))
|
|
13510
|
+
})
|
|
12763
13511
|
}).then(run)
|
|
12764
13512
|
}
|
|
12765
13513
|
const jobs = Math.max(1, Number(process.env.PEACH_CLANG_JOBS) || 1)
|
|
12766
|
-
Promise.all(Array.from({ length: jobs }, run))
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
})
|
|
13514
|
+
Promise.all(Array.from({ length: jobs }, run))
|
|
13515
|
+
.then(() => {
|
|
13516
|
+
fs.writeFileSync(process.env.PEACH_CLANG_RESULTS, JSON.stringify(results))
|
|
13517
|
+
})
|
|
13518
|
+
.catch((error) => {
|
|
13519
|
+
console.error(error.message)
|
|
13520
|
+
process.exit(1)
|
|
13521
|
+
})
|
|
12770
13522
|
`;
|
|
12771
13523
|
function clangProducerStamp(file) {
|
|
12772
13524
|
const stat = statSync(file, { bigint: true });
|
|
12773
13525
|
return [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(":");
|
|
12774
13526
|
}
|
|
13527
|
+
function clangBinaryStamp(file) {
|
|
13528
|
+
const stat = statSync(file, { bigint: true });
|
|
13529
|
+
return [file, stat.size, stat.mtimeNs].join(":");
|
|
13530
|
+
}
|
|
13531
|
+
function clangWrapperStamp(file) {
|
|
13532
|
+
return createHash12("sha256").update(readFileSync11(file)).digest("hex");
|
|
13533
|
+
}
|
|
13534
|
+
function clangArgsNeedCwd(args) {
|
|
13535
|
+
const pathFlags = /* @__PURE__ */ new Set([
|
|
13536
|
+
"-I",
|
|
13537
|
+
"-isystem",
|
|
13538
|
+
"-iquote",
|
|
13539
|
+
"-F",
|
|
13540
|
+
"-iframework",
|
|
13541
|
+
"-isysroot",
|
|
13542
|
+
"-o",
|
|
13543
|
+
"-MF"
|
|
13544
|
+
]);
|
|
13545
|
+
const includeFlags = /* @__PURE__ */ new Set(["-include", "-imacros"]);
|
|
13546
|
+
const valueFlags = /* @__PURE__ */ new Set([
|
|
13547
|
+
"-x",
|
|
13548
|
+
"-target",
|
|
13549
|
+
"-MT",
|
|
13550
|
+
"-MQ",
|
|
13551
|
+
"-D",
|
|
13552
|
+
"-U",
|
|
13553
|
+
"-mllvm",
|
|
13554
|
+
"-Xclang",
|
|
13555
|
+
"-arch",
|
|
13556
|
+
"-std"
|
|
13557
|
+
]);
|
|
13558
|
+
const prefixFlags = [
|
|
13559
|
+
"-I",
|
|
13560
|
+
"-F",
|
|
13561
|
+
"-isystem",
|
|
13562
|
+
"-iquote",
|
|
13563
|
+
"--sysroot=",
|
|
13564
|
+
"-fmodule-map-file=",
|
|
13565
|
+
"-fmodules-cache-path="
|
|
13566
|
+
];
|
|
13567
|
+
const isRelativePath = (value) => value.length > 0 && !value.startsWith("/") && !value.startsWith("=/") && value !== "-";
|
|
13568
|
+
for (let i = 1; i < args.length; i++) {
|
|
13569
|
+
const arg = args[i];
|
|
13570
|
+
if (pathFlags.has(arg)) {
|
|
13571
|
+
if (isRelativePath(args[++i] ?? "")) return true;
|
|
13572
|
+
continue;
|
|
13573
|
+
}
|
|
13574
|
+
if (includeFlags.has(arg)) {
|
|
13575
|
+
const value = args[++i] ?? "";
|
|
13576
|
+
if (isRelativePath(value) && (value.includes("/") || existsSync4(value))) return true;
|
|
13577
|
+
continue;
|
|
13578
|
+
}
|
|
13579
|
+
if (valueFlags.has(arg)) {
|
|
13580
|
+
i++;
|
|
13581
|
+
continue;
|
|
13582
|
+
}
|
|
13583
|
+
if (arg.startsWith("@")) {
|
|
13584
|
+
if (isRelativePath(arg.slice(1))) return true;
|
|
13585
|
+
continue;
|
|
13586
|
+
}
|
|
13587
|
+
if (arg.startsWith("-")) {
|
|
13588
|
+
if (arg.startsWith("-include") && arg.length > 8) {
|
|
13589
|
+
const value = arg.slice(8);
|
|
13590
|
+
if (isRelativePath(value) && (value.includes("/") || existsSync4(value)))
|
|
13591
|
+
return true;
|
|
13592
|
+
continue;
|
|
13593
|
+
}
|
|
13594
|
+
for (const prefix of prefixFlags) {
|
|
13595
|
+
if (arg.startsWith(prefix) && arg.length > prefix.length) {
|
|
13596
|
+
if (isRelativePath(arg.slice(prefix.length))) return true;
|
|
13597
|
+
break;
|
|
13598
|
+
}
|
|
13599
|
+
}
|
|
13600
|
+
continue;
|
|
13601
|
+
}
|
|
13602
|
+
if (isRelativePath(arg)) return true;
|
|
13603
|
+
}
|
|
13604
|
+
return false;
|
|
13605
|
+
}
|
|
12775
13606
|
function validateClangLinkOptions(flags) {
|
|
12776
13607
|
for (let index = 0; index < flags.length; index++) {
|
|
12777
13608
|
const flag = flags[index];
|
|
@@ -12851,7 +13682,7 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
12851
13682
|
let clang;
|
|
12852
13683
|
let clangStamp;
|
|
12853
13684
|
let wrapperStamp;
|
|
12854
|
-
for (const
|
|
13685
|
+
for (const file of wanted) {
|
|
12855
13686
|
const command = commands.get(file);
|
|
12856
13687
|
if (!command) throw new Error(`missing source object producer ${file}`);
|
|
12857
13688
|
if (command.tool === "shell") {
|
|
@@ -12865,12 +13696,12 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
12865
13696
|
throw new Error(`unsupported source object producer ${file}`);
|
|
12866
13697
|
const key = createHash12("sha256").update(
|
|
12867
13698
|
JSON.stringify([
|
|
12868
|
-
"clang-link-options/
|
|
12869
|
-
process.cwd(),
|
|
13699
|
+
"clang-link-options/v2",
|
|
13700
|
+
clangArgsNeedCwd(command.args) ? process.cwd() : null,
|
|
12870
13701
|
driverEnvironment,
|
|
12871
13702
|
command.args,
|
|
12872
|
-
clangStamp ?? (clangStamp =
|
|
12873
|
-
compiler === clang ? null : wrapperStamp ?? (wrapperStamp =
|
|
13703
|
+
clangStamp ?? (clangStamp = clangBinaryStamp(clang)),
|
|
13704
|
+
compiler === clang ? null : wrapperStamp ?? (wrapperStamp = clangWrapperStamp(compiler)),
|
|
12874
13705
|
clangProducerStamp(file)
|
|
12875
13706
|
])
|
|
12876
13707
|
).digest("hex");
|
|
@@ -12885,31 +13716,44 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
12885
13716
|
continue;
|
|
12886
13717
|
}
|
|
12887
13718
|
result.set(file, []);
|
|
12888
|
-
const args = command.args.slice(1).filter((arg) => arg !== "-c");
|
|
12889
13719
|
const targetBuild = path21.relative(options.buildDirectory, file).split(path21.sep).findLast((part) => part !== ".build" && part.endsWith(".build"));
|
|
12890
|
-
const
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
)
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
|
|
13720
|
+
const args = [];
|
|
13721
|
+
let sawOutput = false;
|
|
13722
|
+
let explicitModuleName = false;
|
|
13723
|
+
for (let i = 1; i < command.args.length; i++) {
|
|
13724
|
+
const arg = command.args[i];
|
|
13725
|
+
if (arg === "-c" || arg === "-MD" || arg === "-MMD" || arg === "-MP") continue;
|
|
13726
|
+
if (arg === "-MF" || arg === "-MT" || arg === "-MQ") {
|
|
13727
|
+
if (i + 1 >= command.args.length)
|
|
13728
|
+
throw new Error(`missing clang ${arg} for ${file}`);
|
|
13729
|
+
i++;
|
|
13730
|
+
continue;
|
|
13731
|
+
}
|
|
13732
|
+
if (arg === "-o") {
|
|
13733
|
+
if (i + 1 >= command.args.length) throw new Error(`missing clang -o for ${file}`);
|
|
13734
|
+
i++;
|
|
13735
|
+
args.push("-o", "-");
|
|
13736
|
+
sawOutput = true;
|
|
13737
|
+
continue;
|
|
13738
|
+
}
|
|
13739
|
+
if (arg.startsWith("-fmodule-name=")) explicitModuleName = true;
|
|
13740
|
+
args.push(arg);
|
|
13741
|
+
}
|
|
13742
|
+
if (!sawOutput) throw new Error(`missing clang -o for ${file}`);
|
|
13743
|
+
if (compiler !== clang && targetBuild && !explicitModuleName) {
|
|
13744
|
+
args.unshift(`-fmodule-name=${targetBuild.slice(0, -".build".length)}`);
|
|
12901
13745
|
}
|
|
12902
13746
|
replays.push({
|
|
12903
13747
|
file,
|
|
12904
13748
|
compiler: command.args[0],
|
|
12905
13749
|
args: [...args, "-S", "-emit-llvm", "-Xclang", "-disable-llvm-passes"],
|
|
12906
|
-
output,
|
|
12907
13750
|
cacheFile,
|
|
12908
13751
|
key
|
|
12909
13752
|
});
|
|
12910
13753
|
}
|
|
12911
13754
|
if (replays.length === 0) return result;
|
|
12912
13755
|
const plan = path21.join(options.directory, "clang-link-replays.json");
|
|
13756
|
+
const resultsPath = path21.join(options.directory, "clang-link-results.json");
|
|
12913
13757
|
writeFileSync5(
|
|
12914
13758
|
plan,
|
|
12915
13759
|
JSON.stringify(replays.map(({ compiler, args }) => [compiler, ...args]))
|
|
@@ -12922,12 +13766,16 @@ function sourceGuestClangLinkOptions(options) {
|
|
|
12922
13766
|
...process.env,
|
|
12923
13767
|
[PEACH_FORKED_SCRIPT_ENV]: "1",
|
|
12924
13768
|
PEACH_CLANG_REPLAYS: plan,
|
|
13769
|
+
PEACH_CLANG_RESULTS: resultsPath,
|
|
12925
13770
|
PEACH_CLANG_JOBS: String(options.jobs)
|
|
12926
13771
|
}
|
|
12927
13772
|
});
|
|
13773
|
+
const replayMetadata = JSON.parse(readFileSync11(resultsPath, "utf8"));
|
|
13774
|
+
if (!Array.isArray(replayMetadata) || replayMetadata.length !== replays.length || !replayMetadata.every((item) => typeof item === "string"))
|
|
13775
|
+
throw new Error("invalid clang link replay results");
|
|
12928
13776
|
mkdirSync4(cacheDirectory, { recursive: true });
|
|
12929
|
-
for (const { file,
|
|
12930
|
-
const flags = clangIrLinkOptions(
|
|
13777
|
+
for (const [index, { file, cacheFile, key }] of replays.entries()) {
|
|
13778
|
+
const flags = clangIrLinkOptions(replayMetadata[index]);
|
|
12931
13779
|
validateClangLinkOptions(flags);
|
|
12932
13780
|
const temporary = `${cacheFile}.${process.pid}`;
|
|
12933
13781
|
writeFileSync5(temporary, JSON.stringify({ key, flags }));
|
|
@@ -13487,7 +14335,7 @@ async function compileGuestLink(options) {
|
|
|
13487
14335
|
};
|
|
13488
14336
|
const sdk = options.sdkImage;
|
|
13489
14337
|
const sdkCallers = sdk?.sdkInterface.guestCallers;
|
|
13490
|
-
const sdkObjects = sdk ? (await import("./swift-sdk-image-
|
|
14338
|
+
const sdkObjects = sdk ? (await import("./swift-sdk-image-7T2LMQS5.mjs")).readSwiftSdkManifestIndex(sdk).guestObjects : void 0;
|
|
13491
14339
|
if (sdk && (!sdkCallers || !sdkObjects))
|
|
13492
14340
|
throw new Error("the SDK image has no guest link manifest");
|
|
13493
14341
|
const result = linkPrunedGuestImages({
|
|
@@ -13585,13 +14433,19 @@ async function compileGuestLink(options) {
|
|
|
13585
14433
|
const selectedSource = source.artifacts.filter(
|
|
13586
14434
|
(artifact) => selected.has(path24.resolve(rewritten.get(artifact.path) ?? artifact.path))
|
|
13587
14435
|
);
|
|
14436
|
+
const admittedCores = Number(process.env.TM_EXEC_CPU_CORES);
|
|
14437
|
+
const linuxMemory = process.env.TM_EXEC_ADMITTED === "1" && process.env.LINUX_BUILD_SCOPE ? Number(process.env.TM_EXEC_LINUX_MEMORY_MAX) : NaN;
|
|
14438
|
+
const clangReplayJobs = Number.isInteger(admittedCores) && admittedCores > 0 ? Math.min(
|
|
14439
|
+
admittedCores,
|
|
14440
|
+
Number.isSafeInteger(linuxMemory) && linuxMemory > 0 ? Math.max(options.jobs, Math.floor(linuxMemory / (512 * 1024 ** 2))) : Math.max(options.jobs, admittedCores)
|
|
14441
|
+
) : options.jobs;
|
|
13588
14442
|
const clangOptions2 = sourceGuestClangLinkOptions({
|
|
13589
14443
|
buildDirectory: options.buildDirectory,
|
|
13590
14444
|
directory,
|
|
13591
14445
|
toolchainBin: options.toolchainBin,
|
|
13592
14446
|
swiftCompiler: options.swiftCompiler,
|
|
13593
14447
|
objects: selectedSource.map((artifact) => artifact.path),
|
|
13594
|
-
jobs:
|
|
14448
|
+
jobs: clangReplayJobs
|
|
13595
14449
|
});
|
|
13596
14450
|
const links = sourceGuestRuntimeLinks({
|
|
13597
14451
|
toolchainBin: options.toolchainBin,
|
|
@@ -13693,9 +14547,9 @@ async function compileGuestLink(options) {
|
|
|
13693
14547
|
}
|
|
13694
14548
|
};
|
|
13695
14549
|
},
|
|
13696
|
-
resolvePlan: (selected, plan) => {
|
|
14550
|
+
resolvePlan: (selected, plan, readSelected) => {
|
|
13697
14551
|
if (!prepared) throw new Error("guest runtime selection is unavailable");
|
|
13698
|
-
const scope = selectedGuestSymbolInputs(plan, selected);
|
|
14552
|
+
const scope = selectedGuestSymbolInputs(plan, selected, readSelected);
|
|
13699
14553
|
const owners = new Map(scope.owners);
|
|
13700
14554
|
owners.set(path24.join(directory, "projection-discovery.o"), 0);
|
|
13701
14555
|
const providersByImage = Map.groupBy(scope.owners, ([, image]) => image);
|
|
@@ -13773,8 +14627,9 @@ async function compileGuestLink(options) {
|
|
|
13773
14627
|
createSwiftSdkBinding,
|
|
13774
14628
|
finishSwiftAppModule,
|
|
13775
14629
|
linkSwiftAppModule,
|
|
13776
|
-
readSwiftSdkUsage
|
|
13777
|
-
|
|
14630
|
+
readSwiftSdkUsage,
|
|
14631
|
+
swiftSdkProjectionSpans
|
|
14632
|
+
} = await import("./swift-sdk-app-module-5IUSRXYA.mjs");
|
|
13778
14633
|
const project = options.project;
|
|
13779
14634
|
const work = project ? mkdtempSync2(path24.join(directory, "app-module-")) : path24.join(directory, "app-module");
|
|
13780
14635
|
if (project) chownSync(work, project.uid, project.gid);
|
|
@@ -13795,7 +14650,28 @@ async function compileGuestLink(options) {
|
|
|
13795
14650
|
}
|
|
13796
14651
|
const usage = readSwiftSdkUsage(result.mapPath, options.output, sdkObjectKeys);
|
|
13797
14652
|
const linkedModule = path24.join(work, "app.wasm");
|
|
14653
|
+
const sdkSpans = swiftSdkProjectionSpans(
|
|
14654
|
+
sdk,
|
|
14655
|
+
(object2, product) => sdkObjectImages.get(object2) ?? sdkProductImages.get(product)
|
|
14656
|
+
);
|
|
13798
14657
|
let storage = reserved;
|
|
14658
|
+
if (sdkSpans.length > 0) {
|
|
14659
|
+
const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans);
|
|
14660
|
+
storage = reserveGuestProjectionStorage(
|
|
14661
|
+
storage.images,
|
|
14662
|
+
storage.capacities.map((capacity, index) => ({
|
|
14663
|
+
...capacity,
|
|
14664
|
+
regions: capacity.regions + sdkCounts[index] + 16
|
|
14665
|
+
}))
|
|
14666
|
+
);
|
|
14667
|
+
const projectionSource = path24.join(work, "projection.c");
|
|
14668
|
+
writeFileSync6(projectionSource, storage.source);
|
|
14669
|
+
execFileSync10(
|
|
14670
|
+
path24.join(options.toolchainBin, "clang"),
|
|
14671
|
+
[...clangOptions, "-c", projectionSource, "-o", projectionObject],
|
|
14672
|
+
{ stdio: "pipe" }
|
|
14673
|
+
);
|
|
14674
|
+
}
|
|
13799
14675
|
for (; ; ) {
|
|
13800
14676
|
const link = await linkSwiftAppModule({
|
|
13801
14677
|
objects: [...owners.keys()],
|
|
@@ -13833,11 +14709,7 @@ async function compileGuestLink(options) {
|
|
|
13833
14709
|
bindingRows.set((address - values.address) / 8, value);
|
|
13834
14710
|
} else data.push(address, size, value);
|
|
13835
14711
|
}
|
|
13836
|
-
const
|
|
13837
|
-
const binding = createSwiftSdkBinding({ ...link.linkage, data }, sdk, usage, {
|
|
13838
|
-
imageFor: (object2, product) => sdkObjectImages.get(object2) ?? sdkProductImages.get(product),
|
|
13839
|
-
spans: sdkSpans
|
|
13840
|
-
});
|
|
14712
|
+
const binding = createSwiftSdkBinding({ ...link.linkage, data }, sdk, usage);
|
|
13841
14713
|
const linked = readFileSync13(
|
|
13842
14714
|
project ? projectOutputFile(work, linkedModule, project) : linkedModule
|
|
13843
14715
|
);
|
|
@@ -16334,7 +17206,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
|
|
|
16334
17206
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
16335
17207
|
var MULTI_MANIFEST_VERSION = 76;
|
|
16336
17208
|
var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
16337
|
-
var compilerSourceDigest = true ? "
|
|
17209
|
+
var compilerSourceDigest = true ? "d4cf22b53d08266bf9bd0238bffe899805f62daeb3d628664ee351830e496cda" : swiftCompilerSourceDigest(import.meta.dirname);
|
|
16338
17210
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
16339
17211
|
return swiftCompileInputHash(input, release).update(swiftModuleDigest(moduleRoot)).digest("hex");
|
|
16340
17212
|
}
|
|
@@ -20935,7 +21807,7 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
20935
21807
|
const distribution = swiftDistributionAt(moduleRoot);
|
|
20936
21808
|
const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
|
|
20937
21809
|
if (distribution) refreshSwiftCacheHold(moduleRoot);
|
|
20938
|
-
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-
|
|
21810
|
+
const input = distribution && !options.intermediates ? (await import("./swift-package-prebuilt-4N5CXBOZ.mjs")).useSwiftPackagePrebuilts(
|
|
20939
21811
|
sources,
|
|
20940
21812
|
moduleRoot,
|
|
20941
21813
|
options.toolchainBin
|
|
@@ -20949,7 +21821,7 @@ async function compileSwiftProjectOnce(sources, options) {
|
|
|
20949
21821
|
multi: compileTargets(input).length > 0
|
|
20950
21822
|
};
|
|
20951
21823
|
const sdkModule = options.sdkModule && !options.linkOnly;
|
|
20952
|
-
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-
|
|
21824
|
+
const sdkImage = sdkModule ? await (await import("./swift-sdk-image-7T2LMQS5.mjs")).buildSwiftSdkImage(
|
|
20953
21825
|
moduleRoot,
|
|
20954
21826
|
!!guestGraph,
|
|
20955
21827
|
distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
|
|
@@ -21606,7 +22478,7 @@ ${cap}` : "";
|
|
|
21606
22478
|
if (sdkImage && binding)
|
|
21607
22479
|
sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
|
|
21608
22480
|
} else if (sdkImage) {
|
|
21609
|
-
const { buildSwiftAppModule } = await import("./swift-sdk-app-module-
|
|
22481
|
+
const { buildSwiftAppModule } = await import("./swift-sdk-app-module-5IUSRXYA.mjs");
|
|
21610
22482
|
const binding = await buildSwiftAppModule({
|
|
21611
22483
|
buildRoot: root,
|
|
21612
22484
|
toolchainBin: options.toolchainBin,
|