peachsim 0.1.1881 → 0.1.1887
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/cli/commands/control.ts +11 -10
- package/cli/commands/reset.ts +1 -1
- package/cli/native-input.ts +1 -1
- package/cli/outbound-endpoints.ts +1 -1
- package/detox/index.ts +62 -1
- 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 +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +9079 -4305
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +35 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +8609 -3976
- package/dist-lib/expo-swift-metadata.cjs +5 -1
- package/dist-lib/expo-swift-metadata.mjs +5 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +9894 -5149
- package/dist-lib/host/fetch-proxy-handler.cjs +93 -13
- package/dist-lib/host/fetch-proxy-overrides.cjs +10 -2
- package/dist-lib/host/fetch-proxy-overrides.mjs +8 -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 +538 -120
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +536 -118
- package/dist-lib/native-app-identity-project.cjs +408 -72
- package/dist-lib/native-app-identity-project.mjs +739 -375
- package/dist-lib/native-app-identity.cjs +37 -1
- package/dist-lib/native-app-identity.mjs +36 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +61 -28
- package/dist-lib/public-origins-lib.json +250 -92
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- 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 +1 -1
- package/dist-lib/skills.cjs +16568 -11674
- package/dist-lib/swift-compile.cjs +6874 -2537
- package/dist-lib/swift-compile.mjs +6207 -1866
- package/dist-lib/swift-package.cjs +20 -3
- package/dist-lib/swift-package.mjs +20 -3
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +19 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +8753 -4124
- package/dist-lib/vite.cjs +93 -13
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/fontDataContract.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +11 -1
- package/dist-types/packages/peach-engine/src/render-worker/shell-tree-wire.d.ts +2 -1
- package/dist-types/packages/peach-globals/src/nodeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +10 -1
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/dist-types/packages/peach-kit/src/ui/popover-placement.d.ts +1 -1
- package/dist-types/packages/sootsim-swift/src/securityHostContract.d.ts +10 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHost.h +555 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +1 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +6 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSURLProtocol.h +0 -1
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Modules/module.modulemap +6 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBarButtonItemBadge.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBarMinimization.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIScrollView.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISearchTab.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITab.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITabAccessory.h +2 -2
- package/sdk/ios/usr/include/os/activity.h +534 -0
- package/sdk/ios/usr/include/os.modulemap +15 -0
- package/sdk/ios/wasm/include/fcntl.h +16 -0
- package/sdk/ios/wasm/include/string.h +5 -0
- package/sdk/native-hashes.json +1 -1
- package/src/dns-over-https.ts +61 -9
- package/src/expo-swift-bundle.ts +2 -7
- package/src/expo-swift-host.ts +11 -3
- package/src/host/fetch-proxy-handler.ts +51 -2
- package/src/host/fetch-proxy-overrides.ts +4 -0
- package/src/host/hostname-resolver.ts +9 -5
- package/src/native-app-identity-project.ts +13 -2
- package/src/native-app-identity.ts +47 -0
- package/src/nitro-adapter.lock.json +260 -260
- package/src/nitro-bundle.ts +7 -10
- package/src/nitro-superset.lock.json +4 -4
- package/src/podspec-sources.ts +20 -0
- package/src/storageSnapshotContract.ts +20 -1
- package/src/swift-compile.ts +409 -77
- package/src/swift-compiler-digest.ts +15 -0
- package/src/swift-coverage/xcode-packages.ts +3 -2
- package/src/swift-distribution.lock.json +12 -12
- package/src/swift-guest-archive.ts +153 -0
- package/src/swift-guest-compile.ts +449 -0
- package/src/swift-guest-image-ledger.ts +656 -0
- package/src/swift-guest-link-plan.ts +52 -0
- package/src/swift-guest-link.ts +1414 -0
- package/src/swift-guest-linked-spans.ts +338 -0
- package/src/swift-guest-manifest.ts +141 -0
- package/src/swift-guest-projection-storage.ts +310 -0
- package/src/swift-guest-projection.ts +252 -0
- package/src/swift-guest-runtime-plan.ts +834 -0
- package/src/swift-guest-source-inputs.ts +427 -0
- package/src/swift-guest-source-plan.ts +279 -0
- package/src/swift-host.ts +157 -36
- package/src/swift-icu.ts +60 -18
- package/src/swift-link-roots.ts +27 -50
- package/src/swift-package-manifest.ts +34 -18
- package/src/swift-package.ts +32 -2
- package/src/swift-packages.ts +138 -17
- package/src/swift-runtime-products.ts +73 -0
- package/src/swift-shared-sdk.ts +1 -1
- package/src/swift-submit.ts +15 -3
- package/src/swift-toolchain.ts +18 -0
- package/src/swift-wasm-prune.ts +313 -14
- package/src/swiftContract.ts +83 -0
- package/src/swiftRuntimeProductContract.ts +85 -45
- package/src/turbo-bundle.ts +1 -1
- package/src/turbo-codegen-intake.ts +10 -3
- package/src/turbo-runtime.lock.json +23 -23
- package/src/wasm-optimize.ts +16 -4
- package/src/xcode-project.ts +142 -14
|
@@ -21,6 +21,21 @@ export const SWIFT_DIGEST_SOURCES = [
|
|
|
21
21
|
'process-table.ts',
|
|
22
22
|
'swift-link-roots.ts',
|
|
23
23
|
'swift-wasm-prune.ts',
|
|
24
|
+
'swift-guest-image-ledger.ts',
|
|
25
|
+
'swift-guest-archive.ts',
|
|
26
|
+
'swift-guest-link-plan.ts',
|
|
27
|
+
'swift-guest-link.ts',
|
|
28
|
+
'swift-guest-compile.ts',
|
|
29
|
+
'swift-guest-linked-spans.ts',
|
|
30
|
+
'swift-guest-source-plan.ts',
|
|
31
|
+
'swift-guest-runtime-plan.ts',
|
|
32
|
+
'swift-guest-source-inputs.ts',
|
|
33
|
+
'swift-guest-manifest.ts',
|
|
34
|
+
'swift-guest-projection.ts',
|
|
35
|
+
'swift-guest-projection-storage.ts',
|
|
36
|
+
'swiftGuestImageContract.ts',
|
|
37
|
+
'swift-runtime-products.ts',
|
|
38
|
+
'swiftRuntimeProductContract.ts',
|
|
24
39
|
'swift-objc-import.ts',
|
|
25
40
|
'swiftContract.ts',
|
|
26
41
|
'swift-objc-platform.ts',
|
|
@@ -131,7 +131,7 @@ export function createSwiftModuleWalker(
|
|
|
131
131
|
reason: provider,
|
|
132
132
|
}
|
|
133
133
|
dependencyDir = provider.manifest.dir
|
|
134
|
-
const products = provider.manifest.products.get(dependency.name)
|
|
134
|
+
const products = provider.manifest.products.get(dependency.name)?.targets
|
|
135
135
|
if (!products)
|
|
136
136
|
return {
|
|
137
137
|
reason: `Package ${provider.manifest.name} declares no library product ${dependency.name}.`,
|
|
@@ -266,7 +266,8 @@ export function localPackageModules(app: App, root: string) {
|
|
|
266
266
|
return unknown(
|
|
267
267
|
`Package product ${product} names no library of a local package; its module remains unknown.`,
|
|
268
268
|
)
|
|
269
|
-
for (const target of walker.load(owner).manifest.products.get(product) ??
|
|
269
|
+
for (const target of walker.load(owner).manifest.products.get(product)?.targets ??
|
|
270
|
+
[]) {
|
|
270
271
|
const added = walker.addTarget(owner, target)
|
|
271
272
|
if (typeof added !== 'string') return unknown(added.reason)
|
|
272
273
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "254fdeb7cac228a5",
|
|
3
3
|
"release": "swift-6.4.0-RELEASE-custom-a560ff35bf882b5c",
|
|
4
|
-
"wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-
|
|
5
|
-
"wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-
|
|
6
|
-
"wasmSdkChecksum": "
|
|
7
|
-
"source": "
|
|
4
|
+
"wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-3b3aa5c2",
|
|
5
|
+
"wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-3b3aa5c2.artifactbundle.tar.gz",
|
|
6
|
+
"wasmSdkChecksum": "49fcbdbcb340a7ca89db0b8965bea0b1aced4a3f767a86a70b9db00ec55e067b",
|
|
7
|
+
"source": "247b45ce31848b067c4dae007217abdc4296cf83",
|
|
8
8
|
"targets": [
|
|
9
9
|
"ImagePlayground",
|
|
10
10
|
"QuickLookThumbnailing",
|
|
@@ -129,7 +129,6 @@
|
|
|
129
129
|
"CryptoTokenKit",
|
|
130
130
|
"TikTokBusinessSDK",
|
|
131
131
|
"nSure",
|
|
132
|
-
"Statsig",
|
|
133
132
|
"TOCropViewController",
|
|
134
133
|
"RiveRuntime",
|
|
135
134
|
"AVRouting",
|
|
@@ -227,20 +226,21 @@
|
|
|
227
226
|
"horizontalSizeClass": ["string:compact", "string:regular"],
|
|
228
227
|
"verticalSizeClass": ["string:compact", "string:regular"],
|
|
229
228
|
"accessibilityReduceMotion": ["bool"],
|
|
229
|
+
"vendorIdentifier": ["null", "string"],
|
|
230
230
|
"hinge": ["null", "object"]
|
|
231
231
|
},
|
|
232
232
|
"hosts": {
|
|
233
233
|
"darwin-arm64": {
|
|
234
|
-
"sha256": "
|
|
235
|
-
"size":
|
|
234
|
+
"sha256": "ffbd29ff0ca75fc07ba994d8b61695d24c880c208abf601df528fb1171a971c7",
|
|
235
|
+
"size": 98981850
|
|
236
236
|
},
|
|
237
237
|
"linux-x64": {
|
|
238
|
-
"sha256": "
|
|
239
|
-
"size":
|
|
238
|
+
"sha256": "ef79d939ba861e7c082ad66b3bd67b6abe1387ada6918bdc2f58b2dcc8d85739",
|
|
239
|
+
"size": 101700933
|
|
240
240
|
},
|
|
241
241
|
"linux-arm64": {
|
|
242
|
-
"sha256": "
|
|
243
|
-
"size":
|
|
242
|
+
"sha256": "e0b480b8f40500f0200d17a9c1e69b10cdd01c8d9a57cf370fa876329ad1320d",
|
|
243
|
+
"size": 101193434
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process'
|
|
2
|
+
import { createHash } from 'node:crypto'
|
|
3
|
+
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import { readArMembers } from './swift-wasm-prune'
|
|
6
|
+
import type { GuestLinkPlan, GuestLinkSelection } from './swift-guest-link-plan'
|
|
7
|
+
|
|
8
|
+
export interface GuestArchiveMemberAlias {
|
|
9
|
+
readonly alias: string
|
|
10
|
+
readonly name: string
|
|
11
|
+
readonly ordinal: number
|
|
12
|
+
readonly sha256: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AliasedGuestArchive {
|
|
16
|
+
readonly source: string
|
|
17
|
+
readonly archive: string
|
|
18
|
+
readonly members: readonly GuestArchiveMemberAlias[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Preserve archive order and bytes while giving every member an unambiguous linker name. */
|
|
22
|
+
export function aliasGuestArchive(options: {
|
|
23
|
+
readonly archive: string
|
|
24
|
+
readonly directory: string
|
|
25
|
+
readonly llvmAr: string
|
|
26
|
+
}): AliasedGuestArchive {
|
|
27
|
+
const original = readArMembers(readFileSync(options.archive))
|
|
28
|
+
const listed = execFileSync(options.llvmAr, ['t', options.archive], {
|
|
29
|
+
encoding: 'utf8',
|
|
30
|
+
})
|
|
31
|
+
.trimEnd()
|
|
32
|
+
.split('\n')
|
|
33
|
+
if (
|
|
34
|
+
!original.length ||
|
|
35
|
+
listed.length !== original.length ||
|
|
36
|
+
original.some((member, index) => member.name !== listed[index])
|
|
37
|
+
)
|
|
38
|
+
throw new Error(`unsupported guest archive ${options.archive}`)
|
|
39
|
+
mkdirSync(options.directory, { recursive: true })
|
|
40
|
+
const counts = new Map<string, number>()
|
|
41
|
+
const members = original.map((member, index) => {
|
|
42
|
+
const ordinal = (counts.get(member.name) ?? 0) + 1
|
|
43
|
+
counts.set(member.name, ordinal)
|
|
44
|
+
const alias = `member-${String(index).padStart(8, '0')}.o`
|
|
45
|
+
writeFileSync(path.join(options.directory, alias), member.bytes)
|
|
46
|
+
return {
|
|
47
|
+
alias,
|
|
48
|
+
name: member.name,
|
|
49
|
+
ordinal,
|
|
50
|
+
sha256: createHash('sha256').update(member.bytes).digest('hex'),
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
const response = path.join(options.directory, 'members.rsp')
|
|
54
|
+
writeFileSync(
|
|
55
|
+
response,
|
|
56
|
+
members
|
|
57
|
+
.map((member) => JSON.stringify(path.join(options.directory, member.alias)))
|
|
58
|
+
.join(' '),
|
|
59
|
+
)
|
|
60
|
+
const archive = path.join(options.directory, 'archive.a')
|
|
61
|
+
rmSync(archive, { force: true })
|
|
62
|
+
execFileSync(options.llvmAr, ['rcsD', archive, `@${response}`], { stdio: 'pipe' })
|
|
63
|
+
const rewritten = readArMembers(readFileSync(archive))
|
|
64
|
+
if (
|
|
65
|
+
rewritten.length !== members.length ||
|
|
66
|
+
rewritten.some(
|
|
67
|
+
(member, index) =>
|
|
68
|
+
member.name !== members[index]!.alias ||
|
|
69
|
+
createHash('sha256').update(member.bytes).digest('hex') !==
|
|
70
|
+
members[index]!.sha256,
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
throw new Error(`guest archive changed members ${options.archive}`)
|
|
74
|
+
return { source: options.archive, archive, members }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Translate selected linker aliases back to their exact original archive ordinal. */
|
|
78
|
+
export function originalGuestArchiveSelections(
|
|
79
|
+
selected: readonly GuestLinkSelection[],
|
|
80
|
+
archives: readonly AliasedGuestArchive[],
|
|
81
|
+
): {
|
|
82
|
+
readonly artifact: string
|
|
83
|
+
readonly member: string | null
|
|
84
|
+
readonly ordinal: number | null
|
|
85
|
+
}[] {
|
|
86
|
+
const aliases = new Map(
|
|
87
|
+
archives.map((archive) => [path.resolve(archive.archive), archive]),
|
|
88
|
+
)
|
|
89
|
+
if (aliases.size !== archives.length) throw new Error('duplicate aliased guest archive')
|
|
90
|
+
return selected.map((selection) => {
|
|
91
|
+
const archive = aliases.get(path.resolve(selection.artifact))
|
|
92
|
+
if (!archive) return { ...selection, ordinal: selection.member === null ? null : 1 }
|
|
93
|
+
if (selection.member === null)
|
|
94
|
+
throw new Error('aliased archive selected as an object')
|
|
95
|
+
const member = archive.members.find((entry) => entry.alias === selection.member)
|
|
96
|
+
if (!member) throw new Error(`unknown guest archive member alias ${selection.member}`)
|
|
97
|
+
return { artifact: archive.source, member: member.name, ordinal: member.ordinal }
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Keep producer ownership and original member identities on rewritten inputs. */
|
|
102
|
+
export function aliasGuestLinkPlan(
|
|
103
|
+
plan: GuestLinkPlan,
|
|
104
|
+
archives: readonly AliasedGuestArchive[],
|
|
105
|
+
): GuestLinkPlan {
|
|
106
|
+
const sources = new Map(
|
|
107
|
+
archives.map((archive) => [path.resolve(archive.source), archive]),
|
|
108
|
+
)
|
|
109
|
+
if (sources.size !== archives.length)
|
|
110
|
+
throw new Error('duplicate original guest archive')
|
|
111
|
+
return {
|
|
112
|
+
...plan,
|
|
113
|
+
artifacts: plan.artifacts.map((artifact) => {
|
|
114
|
+
const archive = sources.get(path.resolve(artifact.path))
|
|
115
|
+
if (!archive) return artifact
|
|
116
|
+
if (artifact.kind !== 'archive' || artifact.memberOrigins)
|
|
117
|
+
throw new Error(`invalid guest archive ownership ${artifact.path}`)
|
|
118
|
+
const memberImages = artifact.memberImages
|
|
119
|
+
? new Map(
|
|
120
|
+
archive.members.flatMap((member) => {
|
|
121
|
+
const image = artifact.memberImages!.get(member.name)
|
|
122
|
+
return image === undefined
|
|
123
|
+
? []
|
|
124
|
+
: [[member.alias, image] satisfies [string, number]]
|
|
125
|
+
}),
|
|
126
|
+
)
|
|
127
|
+
: undefined
|
|
128
|
+
return {
|
|
129
|
+
...artifact,
|
|
130
|
+
path: archive.archive,
|
|
131
|
+
memberImages,
|
|
132
|
+
memberOrigins: new Map(archive.members.map((member) => [member.alias, member])),
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Carry the source archive's logical identity to its linker-only copy. */
|
|
139
|
+
export function aliasGuestLinkIdentities(
|
|
140
|
+
identities: ReadonlyMap<string, string>,
|
|
141
|
+
archives: readonly AliasedGuestArchive[],
|
|
142
|
+
): Map<string, string> {
|
|
143
|
+
const result = new Map(identities)
|
|
144
|
+
for (const archive of archives) {
|
|
145
|
+
const identity = identities.get(archive.source)
|
|
146
|
+
if (identity === undefined)
|
|
147
|
+
throw new Error(`guest archive has no original identity ${archive.source}`)
|
|
148
|
+
if (result.has(archive.archive))
|
|
149
|
+
throw new Error(`duplicate guest archive identity ${archive.archive}`)
|
|
150
|
+
result.set(archive.archive, identity)
|
|
151
|
+
}
|
|
152
|
+
return result
|
|
153
|
+
}
|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process'
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { aliasGuestLinkIdentities } from './swift-guest-archive'
|
|
5
|
+
import {
|
|
6
|
+
linkPrunedGuestImages,
|
|
7
|
+
prepareGuestRuntimeInputs,
|
|
8
|
+
selectedGuestSymbolInputs,
|
|
9
|
+
verifyGuestSymbolScopes,
|
|
10
|
+
type GuestLinkProjection,
|
|
11
|
+
type GuestSdkLinkProducts,
|
|
12
|
+
} from './swift-guest-link'
|
|
13
|
+
import {
|
|
14
|
+
finalizeGuestProjectionStorage,
|
|
15
|
+
type ReservedGuestProjectionStorage,
|
|
16
|
+
} from './swift-guest-projection-storage'
|
|
17
|
+
import {
|
|
18
|
+
composeGuestRuntimeLinkPlan,
|
|
19
|
+
guestRuntimeInputIdentities,
|
|
20
|
+
readGuestRuntimeCatalogs,
|
|
21
|
+
} from './swift-guest-runtime-plan'
|
|
22
|
+
import {
|
|
23
|
+
logicalGuestLinkOptions,
|
|
24
|
+
sourceGuestClangLinkOptions,
|
|
25
|
+
sourceGuestInputIdentities,
|
|
26
|
+
sourceGuestRuntimeLinks,
|
|
27
|
+
} from './swift-guest-source-inputs'
|
|
28
|
+
import {
|
|
29
|
+
guestSourceImages,
|
|
30
|
+
guestSourceObjects,
|
|
31
|
+
libraryArchiveTarget,
|
|
32
|
+
planGuestSourceLink,
|
|
33
|
+
} from './swift-guest-source-plan'
|
|
34
|
+
import { frameworkRuntimeProductId } from './swift-runtime-products'
|
|
35
|
+
import { optimizeWasm } from './wasm-optimize'
|
|
36
|
+
import type { SwiftSourceLinkGraph } from './swiftContract'
|
|
37
|
+
import type { SwiftGuestImageManifest } from './swiftGuestImageContract'
|
|
38
|
+
|
|
39
|
+
function version(
|
|
40
|
+
value: string | null,
|
|
41
|
+
): SwiftGuestImageManifest['buildVersion']['minimum'] {
|
|
42
|
+
const match = value && /(?:^|[^0-9])(\d+)\.(\d+)(?:\.(\d+))?$/.exec(value)
|
|
43
|
+
if (!match) throw new Error(`unresolved guest build version ${value}`)
|
|
44
|
+
return {
|
|
45
|
+
major: Number(match[1]),
|
|
46
|
+
minor: Number(match[2]),
|
|
47
|
+
patch: Number(match[3] ?? 0),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** link a source graph to actual SDK products, then fill the post-opt image ranges. */
|
|
52
|
+
export async function compileGuestLink(options: {
|
|
53
|
+
readonly graph: SwiftSourceLinkGraph
|
|
54
|
+
readonly buildDirectory: string
|
|
55
|
+
readonly releaseDirectory: string
|
|
56
|
+
readonly moduleRoot: string
|
|
57
|
+
readonly toolchainBin: string
|
|
58
|
+
readonly sysroot: string
|
|
59
|
+
readonly sdk: { readonly wasmSdkId: string; readonly wasmSdkChecksum: string }
|
|
60
|
+
readonly staticClangTargets: readonly string[]
|
|
61
|
+
readonly generatedOwners: ReadonlyMap<string, string>
|
|
62
|
+
readonly output: string
|
|
63
|
+
readonly optimized: string
|
|
64
|
+
}): Promise<void> {
|
|
65
|
+
const directory = path.join(options.buildDirectory, '.peach-guest-link')
|
|
66
|
+
mkdirSync(directory, { recursive: true })
|
|
67
|
+
const sdkRoot = path.dirname(options.sysroot)
|
|
68
|
+
const catalogs = readGuestRuntimeCatalogs(sdkRoot, options.moduleRoot)
|
|
69
|
+
const sourceImages = guestSourceImages(options.graph)
|
|
70
|
+
const targets = new Map(options.graph.targets.map((target) => [target.id, target]))
|
|
71
|
+
const sourceFrameworks = new Set(
|
|
72
|
+
options.graph.targets.flatMap((target) =>
|
|
73
|
+
target.productName.endsWith('.framework') ? [target.productName.slice(0, -10)] : [],
|
|
74
|
+
),
|
|
75
|
+
)
|
|
76
|
+
const entry = targets.get(options.graph.entry)
|
|
77
|
+
if (!entry) throw new Error('guest source graph has no entry')
|
|
78
|
+
const imageBuildVersion = (value: typeof entry.buildVersion) => {
|
|
79
|
+
const platform =
|
|
80
|
+
value.platform === 'iphonesimulator' ? 7 : value.platform === 'iphoneos' ? 2 : null
|
|
81
|
+
if (platform === null) throw new Error(`unresolved guest platform ${value.platform}`)
|
|
82
|
+
return { platform, minimum: version(value.minimumOS), sdk: version(value.sdk) }
|
|
83
|
+
}
|
|
84
|
+
const buildVersion = imageBuildVersion(entry.buildVersion)
|
|
85
|
+
const clangOptions = [
|
|
86
|
+
'--target=wasm32-unknown-wasip1',
|
|
87
|
+
`--sysroot=${options.sysroot}`,
|
|
88
|
+
`-I${path.join(options.moduleRoot, 'include')}`,
|
|
89
|
+
]
|
|
90
|
+
const stubSource = path.join(directory, 'preselection-projection.c')
|
|
91
|
+
const stub = path.join(directory, 'preselection-projection.o')
|
|
92
|
+
writeFileSync(
|
|
93
|
+
stubSource,
|
|
94
|
+
'#include "guest-image-projection.h"\nconst struct peach_guest_image __peach_guest_images[] = {{0}};\nconst uint32_t __peach_guest_image_count = 0;\n',
|
|
95
|
+
)
|
|
96
|
+
execFileSync(
|
|
97
|
+
path.join(options.toolchainBin, 'clang'),
|
|
98
|
+
[...clangOptions, '-c', stubSource, '-o', stub],
|
|
99
|
+
{ stdio: 'pipe' },
|
|
100
|
+
)
|
|
101
|
+
let prepared: ReturnType<typeof prepareGuestRuntimeInputs> | undefined
|
|
102
|
+
let reserved: ReservedGuestProjectionStorage | undefined
|
|
103
|
+
let projectionObject = ''
|
|
104
|
+
let sourceObjects: ReturnType<typeof guestSourceObjects>['owned'] = []
|
|
105
|
+
let identities = new Map<string, string>()
|
|
106
|
+
let startupObjects = new Set<string>()
|
|
107
|
+
let systemProviders = new Set<string>()
|
|
108
|
+
let frameworkRequests: ReturnType<typeof sourceGuestRuntimeLinks>['frameworkRequests'] =
|
|
109
|
+
new Map()
|
|
110
|
+
let sdkFrameworkImages: ReadonlyMap<string, number> = new Map()
|
|
111
|
+
let selectedSourceByImage = new Map<number, string[]>()
|
|
112
|
+
let frameworkImage: number | undefined
|
|
113
|
+
let frameworkObjects = new Map<string, string>()
|
|
114
|
+
const imageMetadata = (products: GuestSdkLinkProducts) => {
|
|
115
|
+
const source: GuestLinkProjection['images'][number][] = sourceImages.map((image) => {
|
|
116
|
+
const target = targets.get(image.owner)!
|
|
117
|
+
const installName =
|
|
118
|
+
target.installName ?? (image.id === 0 ? target.productName : null)
|
|
119
|
+
if (!installName) throw new Error(`source image has no install name ${target.id}`)
|
|
120
|
+
return {
|
|
121
|
+
image: image.id,
|
|
122
|
+
id: target.id,
|
|
123
|
+
installName,
|
|
124
|
+
fileType: image.id === 0 ? 'executable' : 'dylib',
|
|
125
|
+
buildVersion: imageBuildVersion(target.buildVersion),
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
const runtime: GuestLinkProjection['images'][number][] = [...products.images].map(
|
|
129
|
+
([id, image]) => {
|
|
130
|
+
const product = products.products.find((item) => item.product.id === id)?.product
|
|
131
|
+
if (!product) throw new Error(`runtime image has no product ${id}`)
|
|
132
|
+
return {
|
|
133
|
+
image,
|
|
134
|
+
id,
|
|
135
|
+
installName: product.installName,
|
|
136
|
+
fileType: 'dylib',
|
|
137
|
+
buildVersion,
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
)
|
|
141
|
+
return [...source, ...runtime].sort((a, b) => a.image - b.image)
|
|
142
|
+
}
|
|
143
|
+
const result = linkPrunedGuestImages({
|
|
144
|
+
buildDirectory: options.buildDirectory,
|
|
145
|
+
toolchainBin: options.toolchainBin,
|
|
146
|
+
moduleRoot: options.moduleRoot,
|
|
147
|
+
staticClangTargets: options.staticClangTargets,
|
|
148
|
+
linkDirectory: directory,
|
|
149
|
+
mapPath: path.join(directory, 'guest.map'),
|
|
150
|
+
ledgerDataImage: 0,
|
|
151
|
+
framework: catalogs.framework,
|
|
152
|
+
sdkProducts: null,
|
|
153
|
+
prepareRuntime: (args, rewritten, sdk) => {
|
|
154
|
+
prepared = prepareGuestRuntimeInputs({
|
|
155
|
+
args,
|
|
156
|
+
directory: path.join(directory, 'preselection'),
|
|
157
|
+
wasmLd: path.join(options.toolchainBin, 'wasm-ld'),
|
|
158
|
+
llvmAr: path.join(options.toolchainBin, 'llvm-ar'),
|
|
159
|
+
discoveryObjects: [stub],
|
|
160
|
+
products: catalogs.products,
|
|
161
|
+
rewritten,
|
|
162
|
+
sdk,
|
|
163
|
+
firstImage: sourceImages.length,
|
|
164
|
+
containingImage: sourceImages.find((image) => image.owner === options.graph.entry)
|
|
165
|
+
?.id,
|
|
166
|
+
framework: catalogs.framework,
|
|
167
|
+
})
|
|
168
|
+
return prepared
|
|
169
|
+
},
|
|
170
|
+
plan: (_args, rewritten, sdk, products) => {
|
|
171
|
+
if (!prepared || !products)
|
|
172
|
+
throw new Error('guest runtime selection is unavailable')
|
|
173
|
+
const startup = catalogs.products.filter(
|
|
174
|
+
({ product }) => product.id === 'wasi/crt1-reactor.o',
|
|
175
|
+
)
|
|
176
|
+
if (
|
|
177
|
+
startup.length !== 1 ||
|
|
178
|
+
startup[0]!.product.linkOwnership !== 'containing-image'
|
|
179
|
+
)
|
|
180
|
+
throw new Error('missing catalogued WASI reactor startup product')
|
|
181
|
+
startupObjects = new Set(
|
|
182
|
+
startup[0]!.product.artifacts.map((artifact) => {
|
|
183
|
+
if (artifact.kind !== 'object')
|
|
184
|
+
throw new Error('invalid WASI reactor startup artifact')
|
|
185
|
+
const original = path.resolve(startup[0]!.root, artifact.path)
|
|
186
|
+
return rewritten.get(original) ?? original
|
|
187
|
+
}),
|
|
188
|
+
)
|
|
189
|
+
const original = new Map(
|
|
190
|
+
[...rewritten].map(([before, after]) => [
|
|
191
|
+
path.resolve(after),
|
|
192
|
+
path.resolve(before),
|
|
193
|
+
]),
|
|
194
|
+
)
|
|
195
|
+
// the products statically owned by the containing image supply libSystem:
|
|
196
|
+
// the C library, its Darwin records, the compiler runtime and ICU, which
|
|
197
|
+
// every native image links implicitly.
|
|
198
|
+
const systemArtifacts = new Set(
|
|
199
|
+
catalogs.products
|
|
200
|
+
.filter(({ product }) => product.linkOwnership === 'containing-image')
|
|
201
|
+
.flatMap(({ product, root }) =>
|
|
202
|
+
product.artifacts.map((artifact) => path.resolve(root, artifact.path)),
|
|
203
|
+
),
|
|
204
|
+
)
|
|
205
|
+
const isSystemArtifact = (artifact: string) =>
|
|
206
|
+
systemArtifacts.has(
|
|
207
|
+
original.get(path.resolve(artifact)) ?? path.resolve(artifact),
|
|
208
|
+
)
|
|
209
|
+
systemProviders = new Set([
|
|
210
|
+
...prepared.selected
|
|
211
|
+
.filter((item) => item.member === null && isSystemArtifact(item.artifact))
|
|
212
|
+
.map((item) => item.artifact),
|
|
213
|
+
...prepared.selected
|
|
214
|
+
.filter((item) => item.member !== null && isSystemArtifact(item.artifact))
|
|
215
|
+
.map((item) => `${item.artifact}(${item.member})`),
|
|
216
|
+
...prepared.archives
|
|
217
|
+
.filter((archive) => isSystemArtifact(archive.source))
|
|
218
|
+
.flatMap((archive) =>
|
|
219
|
+
archive.members.map((member) => `${archive.archive}(${member.alias})`),
|
|
220
|
+
),
|
|
221
|
+
])
|
|
222
|
+
const inputs = [
|
|
223
|
+
...new Set(
|
|
224
|
+
prepared.selected
|
|
225
|
+
.filter((item) => item.member === null || libraryArchiveTarget(item.artifact))
|
|
226
|
+
.map(
|
|
227
|
+
(item) =>
|
|
228
|
+
original.get(path.resolve(item.artifact)) ?? path.resolve(item.artifact),
|
|
229
|
+
),
|
|
230
|
+
),
|
|
231
|
+
]
|
|
232
|
+
sourceObjects = guestSourceObjects(
|
|
233
|
+
options.graph,
|
|
234
|
+
options.releaseDirectory,
|
|
235
|
+
inputs,
|
|
236
|
+
options.generatedOwners,
|
|
237
|
+
).owned
|
|
238
|
+
const source = planGuestSourceLink(
|
|
239
|
+
options.graph,
|
|
240
|
+
sourceImages,
|
|
241
|
+
[],
|
|
242
|
+
sourceObjects,
|
|
243
|
+
[],
|
|
244
|
+
)
|
|
245
|
+
const selected = new Set(
|
|
246
|
+
prepared.selected
|
|
247
|
+
.filter((item) => item.member === null)
|
|
248
|
+
.map((item) => path.resolve(item.artifact)),
|
|
249
|
+
)
|
|
250
|
+
const selectedSource = source.artifacts.filter((artifact) =>
|
|
251
|
+
selected.has(path.resolve(rewritten.get(artifact.path) ?? artifact.path)),
|
|
252
|
+
)
|
|
253
|
+
const clangOptions = sourceGuestClangLinkOptions({
|
|
254
|
+
buildDirectory: options.buildDirectory,
|
|
255
|
+
directory,
|
|
256
|
+
toolchainBin: options.toolchainBin,
|
|
257
|
+
objects: selectedSource.map((artifact) => artifact.path),
|
|
258
|
+
})
|
|
259
|
+
const links = sourceGuestRuntimeLinks({
|
|
260
|
+
toolchainBin: options.toolchainBin,
|
|
261
|
+
directory,
|
|
262
|
+
products: catalogs.products,
|
|
263
|
+
framework: catalogs.framework,
|
|
264
|
+
sdk: { ...options.sdk, root: sdkRoot },
|
|
265
|
+
images: sourceImages.map((image) => ({
|
|
266
|
+
id: image.id,
|
|
267
|
+
objects: selectedSource
|
|
268
|
+
.filter((artifact) => artifact.image === image.id)
|
|
269
|
+
.map((artifact) => artifact.path),
|
|
270
|
+
// a `-framework Name` for a framework the source graph builds links
|
|
271
|
+
// that framework's own image, which the plan already depends on
|
|
272
|
+
linkerFlags: image.members
|
|
273
|
+
.flatMap((id) => targets.get(id)!.linkerFlags)
|
|
274
|
+
.filter(
|
|
275
|
+
(flag, index, flags) =>
|
|
276
|
+
!sourceFrameworks.has(flags[index - 1] === '-framework' ? flag : '') &&
|
|
277
|
+
!(flag === '-framework' && sourceFrameworks.has(flags[index + 1] ?? '')),
|
|
278
|
+
),
|
|
279
|
+
clangLinkOptions: selectedSource
|
|
280
|
+
.filter((artifact) => artifact.image === image.id)
|
|
281
|
+
.map((artifact) => ({
|
|
282
|
+
object: path.resolve(rewritten.get(artifact.path) ?? artifact.path),
|
|
283
|
+
flags: clangOptions.get(path.resolve(artifact.path)) ?? [],
|
|
284
|
+
})),
|
|
285
|
+
})),
|
|
286
|
+
})
|
|
287
|
+
frameworkRequests = links.frameworkRequests
|
|
288
|
+
sdkFrameworkImages = products.images
|
|
289
|
+
frameworkImage = products.images.get(
|
|
290
|
+
frameworkRuntimeProductId(catalogs.framework.product),
|
|
291
|
+
)
|
|
292
|
+
selectedSourceByImage = new Map(
|
|
293
|
+
sourceImages.map((image) => [
|
|
294
|
+
image.id,
|
|
295
|
+
selectedSource
|
|
296
|
+
.filter((artifact) => artifact.image === image.id)
|
|
297
|
+
.map((artifact) =>
|
|
298
|
+
path.resolve(rewritten.get(artifact.path) ?? artifact.path),
|
|
299
|
+
),
|
|
300
|
+
]),
|
|
301
|
+
)
|
|
302
|
+
frameworkObjects = new Map(
|
|
303
|
+
catalogs.framework.product.objects.map((object) => {
|
|
304
|
+
const original = path.resolve(catalogs.framework.root, object.path)
|
|
305
|
+
return [path.resolve(rewritten.get(original) ?? original), object.target]
|
|
306
|
+
}),
|
|
307
|
+
)
|
|
308
|
+
identities = guestRuntimeInputIdentities({
|
|
309
|
+
sdkRoot,
|
|
310
|
+
distributionRoot: options.moduleRoot,
|
|
311
|
+
framework: catalogs.framework.product,
|
|
312
|
+
products: catalogs.products,
|
|
313
|
+
sdk,
|
|
314
|
+
})
|
|
315
|
+
for (const [file, identity] of sourceGuestInputIdentities(
|
|
316
|
+
options.graph,
|
|
317
|
+
options.releaseDirectory,
|
|
318
|
+
sourceObjects,
|
|
319
|
+
)) {
|
|
320
|
+
if (identities.has(file))
|
|
321
|
+
throw new Error(`source input has conflicting identity ${file}`)
|
|
322
|
+
identities.set(file, identity)
|
|
323
|
+
}
|
|
324
|
+
return composeGuestRuntimeLinkPlan(
|
|
325
|
+
source,
|
|
326
|
+
products.products.map((item) => item.product),
|
|
327
|
+
products.images,
|
|
328
|
+
links.links,
|
|
329
|
+
)
|
|
330
|
+
},
|
|
331
|
+
projection: (args, rewritten, _sdk, products) => {
|
|
332
|
+
if (!prepared || !products)
|
|
333
|
+
throw new Error('guest projection has no runtime selection')
|
|
334
|
+
const logical = new Map(identities)
|
|
335
|
+
for (const [before, after] of rewritten) {
|
|
336
|
+
const identity = logical.get(before)
|
|
337
|
+
if (identity !== undefined) logical.set(after, identity)
|
|
338
|
+
}
|
|
339
|
+
const withAliases = aliasGuestLinkIdentities(logical, prepared.archives)
|
|
340
|
+
const selected = new Set(
|
|
341
|
+
prepared.selected.map((item) => path.resolve(item.artifact)),
|
|
342
|
+
)
|
|
343
|
+
const selectedArgs = args.filter(
|
|
344
|
+
(arg) =>
|
|
345
|
+
arg.startsWith('-') ||
|
|
346
|
+
!/\.(?:o|obj|a)$/.test(arg) ||
|
|
347
|
+
selected.has(path.resolve(arg)),
|
|
348
|
+
)
|
|
349
|
+
return {
|
|
350
|
+
image: 0,
|
|
351
|
+
identities,
|
|
352
|
+
linkOptions: logicalGuestLinkOptions(selectedArgs, withAliases, [
|
|
353
|
+
{ path: options.buildDirectory, identity: 'build' },
|
|
354
|
+
{ path: options.moduleRoot, identity: 'distribution' },
|
|
355
|
+
{ path: sdkRoot, identity: 'sdk' },
|
|
356
|
+
{ path: options.toolchainBin, identity: 'toolchain' },
|
|
357
|
+
]),
|
|
358
|
+
images: imageMetadata(products),
|
|
359
|
+
memoryProtection: { initial: 3, maximum: 3 },
|
|
360
|
+
tableProtection: { initial: 5, maximum: 5 },
|
|
361
|
+
clangOptions,
|
|
362
|
+
onReserved: (value, object) => {
|
|
363
|
+
reserved = value
|
|
364
|
+
projectionObject = object
|
|
365
|
+
},
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
resolvePlan: (selected, plan) => {
|
|
369
|
+
if (!prepared) throw new Error('guest runtime selection is unavailable')
|
|
370
|
+
const scope = selectedGuestSymbolInputs(plan, selected)
|
|
371
|
+
const owners = new Map(scope.owners)
|
|
372
|
+
owners.set(path.join(directory, 'projection-discovery.o'), 0)
|
|
373
|
+
const frameworkProviders = new Map<string, Set<string>>()
|
|
374
|
+
for (const [image, requests] of frameworkRequests) {
|
|
375
|
+
for (const request of requests) {
|
|
376
|
+
const callers =
|
|
377
|
+
request.object === null
|
|
378
|
+
? (selectedSourceByImage.get(image) ?? [])
|
|
379
|
+
: [request.object]
|
|
380
|
+
for (const object of callers) {
|
|
381
|
+
if (scope.owners.get(object) !== image)
|
|
382
|
+
throw new Error(`framework request has no selected source owner ${object}`)
|
|
383
|
+
const allowed = frameworkProviders.get(object) ?? new Set<string>()
|
|
384
|
+
if (request.provider.kind === 'sdk') {
|
|
385
|
+
const owner = sdkFrameworkImages.get(request.provider.product)
|
|
386
|
+
if (owner !== undefined)
|
|
387
|
+
for (const [provider, image] of scope.owners)
|
|
388
|
+
if (image === owner) allowed.add(provider)
|
|
389
|
+
} else {
|
|
390
|
+
for (const [provider, target] of frameworkObjects) {
|
|
391
|
+
if (
|
|
392
|
+
!request.provider.targets.includes(target) ||
|
|
393
|
+
!scope.owners.has(provider)
|
|
394
|
+
)
|
|
395
|
+
continue
|
|
396
|
+
if (
|
|
397
|
+
frameworkImage === undefined ||
|
|
398
|
+
scope.owners.get(provider) !== frameworkImage
|
|
399
|
+
)
|
|
400
|
+
throw new Error(`framework provider has conflicting image ${provider}`)
|
|
401
|
+
allowed.add(provider)
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
frameworkProviders.set(object, allowed)
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
const verified = verifyGuestSymbolScopes({
|
|
409
|
+
args: prepared.args,
|
|
410
|
+
directory,
|
|
411
|
+
wasmLd: path.join(options.toolchainBin, 'wasm-ld'),
|
|
412
|
+
objects: [path.join(directory, 'projection-discovery.o')],
|
|
413
|
+
symbols: scope.symbols,
|
|
414
|
+
owners,
|
|
415
|
+
callers: plan.callers,
|
|
416
|
+
startupObjects,
|
|
417
|
+
weakReferences: scope.weakReferences,
|
|
418
|
+
weakDefinitions: scope.weakDefinitions,
|
|
419
|
+
definitionObjects: scope.definitionObjects,
|
|
420
|
+
frameworkProviders,
|
|
421
|
+
systemProviders,
|
|
422
|
+
hostImports: scope.hostImports,
|
|
423
|
+
})
|
|
424
|
+
return {
|
|
425
|
+
...plan,
|
|
426
|
+
symbols: scope.definitions,
|
|
427
|
+
directBindings: verified.directBindings,
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
})
|
|
431
|
+
if (!reserved || !projectionObject) throw new Error('guest projection was not reserved')
|
|
432
|
+
await optimizeWasm(options.output, options.optimized, [
|
|
433
|
+
'duplicate-function-elimination',
|
|
434
|
+
])
|
|
435
|
+
const map = readFileSync(result.mapPath, 'utf8')
|
|
436
|
+
// no linked code reads the image records, so the link dropped them and
|
|
437
|
+
// there is nothing to fill.
|
|
438
|
+
if (!/ __peach_guest_images$/m.test(map)) return
|
|
439
|
+
const finalized = finalizeGuestProjectionStorage({
|
|
440
|
+
map,
|
|
441
|
+
linked: readFileSync(options.output),
|
|
442
|
+
optimized: readFileSync(options.optimized),
|
|
443
|
+
owners: result.owners,
|
|
444
|
+
sectionOwners: result.generatedSectionOwners,
|
|
445
|
+
projectionObject,
|
|
446
|
+
reserved,
|
|
447
|
+
})
|
|
448
|
+
writeFileSync(options.optimized, finalized.wasm)
|
|
449
|
+
}
|