peachsim 0.1.2592 → 0.1.2593
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 +1737 -1648
- 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-67PU73QE.mjs → acorn-DLENU3SM.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-L5T3HBPO.mjs → chunk-23D4W2EY.mjs} +240 -206
- package/dist-lib/esm-chunks/{chunk-D4LYKRRB.mjs → chunk-2MWUVSRW.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PITO2NI2.mjs → chunk-2UERF2EN.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-XSQH4R5E.mjs → chunk-4YJJKKKF.mjs} +69 -48
- package/dist-lib/esm-chunks/{chunk-FYXXFYML.mjs → chunk-6O2M4J2Y.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CF3MTPMY.mjs → chunk-BMKI4WBL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-EITX573K.mjs → chunk-DLSPHUHQ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5FTHILIE.mjs → chunk-E6OGMX3T.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-TJZPNFVF.mjs → chunk-GFMQ5PNX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-6DB5FR7S.mjs → chunk-IT4CC3HU.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-EWHA6X3Z.mjs → chunk-JPNUGMLE.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-XZ3FX3HW.mjs → chunk-KWMJUJJS.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DFF5XZ5M.mjs → chunk-LK3KQ4X3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-RV4ACE6R.mjs → chunk-LN7ZTBNS.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-EHRSWFTD.mjs → chunk-NIYJBFXV.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-M4QLI2SY.mjs → chunk-OIHSBING.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SW4PSSTF.mjs → chunk-P3A4MQHR.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GY6TE4B4.mjs → chunk-TXBZEHNH.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-R3WTQB5J.mjs → chunk-UM4DCXPA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GQ3EO2UV.mjs → chunk-UZPLSN2V.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-QSFWBVUO.mjs → chunk-XFFPOSW2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-KDI5YYQ6.mjs → chunk-ZT5ZXQC2.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-EX65MARK.mjs → metro-layout-parser-DHGC2DVE.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-3BPDQVA7.mjs → swift-package-prebuilt-ROIDLGLU.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-CRX6E3TR.mjs → swift-sdk-app-module-5VU63S56.mjs} +30 -20
- package/dist-lib/esm-chunks/{swift-sdk-image-EJD5TPQH.mjs → swift-sdk-image-SNFZVUQ3.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-QAZOSLTZ.mjs → swift-sdk-image-producer-5RQDIX53.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +324 -235
- 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 +421 -246
- package/dist-lib/host/fetch-proxy-handler.cjs +8 -7
- 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 +5 -5
- 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 +71 -71
- 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 +421 -246
- package/dist-lib/swift-compile.cjs +286 -230
- 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/binaryen.lock.json +3 -3
- package/src/one-native-controls-package.ts +95 -10
- package/src/one-sdk-preparation.ts +40 -2
- package/src/swift-guest-compile.ts +11 -2
- package/src/swift-guest-projection-storage.ts +45 -26
- package/src/swift-guest-runtime-plan.ts +1 -1
- package/src/swift-sdk-app-module.ts +15 -6
- package/src/swift-sdk-image-wasm.ts +5 -2
- package/src/swift-sdk-image.ts +69 -49
- package/src/swift-wasm-prune.ts +51 -34
- package/src/wasm-optimize.ts +146 -140
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2593 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -14521,252 +14521,1357 @@ var init_native_prebuilt = __esm({
|
|
|
14521
14521
|
}
|
|
14522
14522
|
});
|
|
14523
14523
|
|
|
14524
|
-
// src/
|
|
14525
|
-
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14539
|
-
|
|
14540
|
-
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
14544
|
-
|
|
14545
|
-
|
|
14546
|
-
|
|
14547
|
-
|
|
14548
|
-
|
|
14549
|
-
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
|
|
14556
|
-
);
|
|
14557
|
-
const result = JSON.parse(
|
|
14558
|
-
import_node_fs14.default.readFileSync(resultFile, "utf8")
|
|
14559
|
-
);
|
|
14560
|
-
return { generation: result.generation, files: new Map(result.files) };
|
|
14561
|
-
} finally {
|
|
14562
|
-
import_node_fs14.default.rmSync(directory2, { recursive: true, force: true });
|
|
14524
|
+
// src/swiftTargetContract.ts
|
|
14525
|
+
var SWIFT_WASM_TRIPLE, WASI_LIBC_TRIPLE, wasmThreadFlags, swiftWasmThreadFlags, wasmThreadLinkFlags;
|
|
14526
|
+
var init_swiftTargetContract = __esm({
|
|
14527
|
+
"src/swiftTargetContract.ts"() {
|
|
14528
|
+
"use strict";
|
|
14529
|
+
SWIFT_WASM_TRIPLE = "wasm64-unknown-wasip1-threads";
|
|
14530
|
+
WASI_LIBC_TRIPLE = "wasm64-wasip1-threads";
|
|
14531
|
+
wasmThreadFlags = [
|
|
14532
|
+
"-pthread",
|
|
14533
|
+
"-matomics",
|
|
14534
|
+
"-mbulk-memory",
|
|
14535
|
+
"-ftls-model=local-exec"
|
|
14536
|
+
];
|
|
14537
|
+
swiftWasmThreadFlags = wasmThreadFlags.flatMap((flag) => ["-Xcc", flag]);
|
|
14538
|
+
wasmThreadLinkFlags = [
|
|
14539
|
+
"--import-memory",
|
|
14540
|
+
"--export-memory",
|
|
14541
|
+
"--shared-memory",
|
|
14542
|
+
"--max-memory=4294967296",
|
|
14543
|
+
"--growable-table",
|
|
14544
|
+
"--export=__stack_pointer",
|
|
14545
|
+
"--export=__tls_base",
|
|
14546
|
+
"--export=__wasm_init_tls",
|
|
14547
|
+
"--export=__tls_size",
|
|
14548
|
+
"--export=__tls_align",
|
|
14549
|
+
"--export=__stack_low",
|
|
14550
|
+
"--export=__stack_high",
|
|
14551
|
+
"--export=__data_end",
|
|
14552
|
+
"--export=__heap_base",
|
|
14553
|
+
"--export-table",
|
|
14554
|
+
"--export=wasi_thread_start"
|
|
14555
|
+
];
|
|
14563
14556
|
}
|
|
14557
|
+
});
|
|
14558
|
+
|
|
14559
|
+
// src/swift-toolchain.ts
|
|
14560
|
+
function peachsimPackageRoot() {
|
|
14561
|
+
let dir = __sootsim_import_meta_dirname;
|
|
14562
|
+
while (!import_node_fs14.default.existsSync(import_node_path12.default.join(dir, "package.json")) && dir !== import_node_path12.default.dirname(dir))
|
|
14563
|
+
dir = import_node_path12.default.dirname(dir);
|
|
14564
|
+
return dir;
|
|
14564
14565
|
}
|
|
14565
|
-
|
|
14566
|
-
|
|
14567
|
-
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
14566
|
+
function sourceSwiftCheckout() {
|
|
14567
|
+
return import_node_path12.default.resolve(peachsimPackageRoot(), "../sootsim-swift");
|
|
14568
|
+
}
|
|
14569
|
+
function swiftSdkOptions() {
|
|
14570
|
+
return ["--swift-sdks-path", import_node_path12.default.resolve(peachSwiftSdksDir())];
|
|
14571
|
+
}
|
|
14572
|
+
function privateSwiftDistributionRoot() {
|
|
14573
|
+
const root = process.env[SWIFT_PRIVATE_DISTRIBUTION_ENV]?.trim();
|
|
14574
|
+
return root ? import_node_path12.default.resolve(root) : null;
|
|
14575
|
+
}
|
|
14576
|
+
function privateSwiftCompilerRelease() {
|
|
14577
|
+
return process.env.PEACH_SWIFT_PRIVATE_COMPILER_RELEASE?.trim() || null;
|
|
14578
|
+
}
|
|
14579
|
+
function privateSwiftRelease() {
|
|
14580
|
+
const compiler = privateSwiftCompilerRelease();
|
|
14581
|
+
if (compiler) return compiler;
|
|
14582
|
+
const root = privateSwiftDistributionRoot();
|
|
14583
|
+
if (!root) return null;
|
|
14584
|
+
const manifest = JSON.parse(
|
|
14585
|
+
import_node_fs14.default.readFileSync(import_node_path12.default.join(root, "distribution.json"), "utf8")
|
|
14586
|
+
);
|
|
14587
|
+
const release = manifest && typeof manifest === "object" && Reflect.get(manifest, "release");
|
|
14588
|
+
if (typeof release !== "string")
|
|
14589
|
+
throw new Error(`${root} holds no Swift distribution release`);
|
|
14590
|
+
return release;
|
|
14591
|
+
}
|
|
14592
|
+
function swiftLinuxRuntimeLib(arch = process.arch) {
|
|
14593
|
+
const lib = linuxRuntimeLibs[arch];
|
|
14594
|
+
if (!lib) throw new Error(`unsupported Swift Linux runtime host ${arch}`);
|
|
14595
|
+
return { ...lib };
|
|
14596
|
+
}
|
|
14597
|
+
function installSwiftLinuxRuntime(root, arch = process.arch) {
|
|
14598
|
+
const { url, checksum } = swiftLinuxRuntimeLib(arch);
|
|
14599
|
+
const dest = import_node_path12.default.join(root, "usr/lib/libxml2.so.2");
|
|
14600
|
+
const link = import_node_path12.default.join(root, "usr/lib/swift/linux/libxml2.so.2");
|
|
14601
|
+
import_node_fs14.default.mkdirSync(import_node_path12.default.dirname(dest), { recursive: true });
|
|
14602
|
+
import_node_fs14.default.mkdirSync(import_node_path12.default.dirname(link), { recursive: true });
|
|
14603
|
+
if (!import_node_fs14.default.existsSync(dest) || swiftFileChecksum(dest) !== checksum) {
|
|
14604
|
+
process.stderr.write(`peach: installing Linux runtime libxml2.so.2 into ${root}\u2026
|
|
14605
|
+
`);
|
|
14606
|
+
const download2 = `${dest}.${process.pid}.tmp`;
|
|
14607
|
+
try {
|
|
14608
|
+
(0, import_node_child_process9.execFileSync)(
|
|
14609
|
+
"curl",
|
|
14610
|
+
[
|
|
14611
|
+
"-fsSL",
|
|
14612
|
+
"--show-error",
|
|
14613
|
+
"--retry",
|
|
14614
|
+
"3",
|
|
14615
|
+
"--retry-all-errors",
|
|
14616
|
+
url,
|
|
14617
|
+
"-o",
|
|
14618
|
+
download2
|
|
14619
|
+
],
|
|
14620
|
+
{
|
|
14621
|
+
stdio: "inherit"
|
|
14622
|
+
}
|
|
14623
|
+
);
|
|
14624
|
+
if (swiftFileChecksum(download2) !== checksum)
|
|
14625
|
+
throw new Error("declared Linux runtime checksum mismatch");
|
|
14626
|
+
import_node_fs14.default.renameSync(download2, dest);
|
|
14627
|
+
} finally {
|
|
14628
|
+
import_node_fs14.default.rmSync(download2, { force: true });
|
|
14629
|
+
}
|
|
14574
14630
|
}
|
|
14575
|
-
const
|
|
14576
|
-
|
|
14577
|
-
|
|
14578
|
-
|
|
14579
|
-
|
|
14580
|
-
|
|
14581
|
-
|
|
14582
|
-
|
|
14583
|
-
|
|
14584
|
-
|
|
14585
|
-
|
|
14586
|
-
|
|
14587
|
-
|
|
14588
|
-
|
|
14589
|
-
|
|
14590
|
-
|
|
14591
|
-
|
|
14592
|
-
});
|
|
14593
|
-
for (const match of code.matchAll(
|
|
14594
|
-
/(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\s*\(\s*)['"](one(?:\/ios\/[A-Za-z_][A-Za-z0-9_]*)?)(?:\/[^'"]*)?['"]/g
|
|
14595
|
-
))
|
|
14596
|
-
imports2.add(match[1]);
|
|
14597
|
-
}
|
|
14631
|
+
const staged = `${link}.${process.pid}.tmp`;
|
|
14632
|
+
import_node_fs14.default.rmSync(staged, { force: true });
|
|
14633
|
+
import_node_fs14.default.symlinkSync("../../libxml2.so.2", staged);
|
|
14634
|
+
import_node_fs14.default.renameSync(staged, link);
|
|
14635
|
+
}
|
|
14636
|
+
function ensureSwiftLinuxRuntime(release) {
|
|
14637
|
+
if (process.platform !== "linux" || !release.includes("-custom-")) return;
|
|
14638
|
+
const root = import_node_path12.default.resolve(swiftToolchainBin(release), "../..");
|
|
14639
|
+
if (root !== import_node_path12.default.join(peachHome(), "swift", "toolchains", release) || !import_node_fs14.default.existsSync(root))
|
|
14640
|
+
return;
|
|
14641
|
+
installSwiftLinuxRuntime(root);
|
|
14642
|
+
for (const name3 of ["lib", "lib64"]) {
|
|
14643
|
+
try {
|
|
14644
|
+
import_node_fs14.default.symlinkSync(`usr/${name3}`, import_node_path12.default.join(root, name3));
|
|
14645
|
+
} catch (error) {
|
|
14646
|
+
if (!(error instanceof Error) || !("code" in error) || error.code !== "EEXIST")
|
|
14647
|
+
throw error;
|
|
14598
14648
|
}
|
|
14599
14649
|
}
|
|
14600
|
-
|
|
14601
|
-
if (!imports2.has("one") && !imports2.has("one/ios/UIKit")) return null;
|
|
14602
|
-
const generator = await import((0, import_node_url.pathToFileURL)(generatorFile).href);
|
|
14603
|
-
const frameworks = imports2.has("one") ? generator.importedFrameworks(appRoot).filter((name3) => name3 === "UIKit") : ["UIKit"];
|
|
14604
|
-
if (!frameworks.length) return null;
|
|
14605
|
-
const options2 = generator.appSdkOptions(appRoot);
|
|
14606
|
-
const selection = Object.fromEntries(
|
|
14607
|
-
frameworks.map((name3) => [
|
|
14608
|
-
name3,
|
|
14609
|
-
(0, import_node_crypto5.createHash)("sha256").update(
|
|
14610
|
-
JSON.stringify(
|
|
14611
|
-
options2.entries?.[name3] === void 0 ? null : [...new Set(options2.entries[name3])].sort((a, b) => a - b)
|
|
14612
|
-
)
|
|
14613
|
-
).digest("hex")
|
|
14614
|
-
])
|
|
14615
|
-
);
|
|
14616
|
-
return { one, generator, frameworks, options: options2, selection };
|
|
14650
|
+
linuxHostSdkRoot = root;
|
|
14617
14651
|
}
|
|
14618
|
-
function
|
|
14619
|
-
const
|
|
14620
|
-
|
|
14621
|
-
|
|
14622
|
-
|
|
14623
|
-
|
|
14624
|
-
|
|
14625
|
-
|
|
14626
|
-
|
|
14627
|
-
|
|
14628
|
-
|
|
14629
|
-
|
|
14652
|
+
function swiftHostCompilerPin(release) {
|
|
14653
|
+
const compiler = compilerArchives[release];
|
|
14654
|
+
if (!compiler) throw new Error(`unqualified host compiler ${release}`);
|
|
14655
|
+
return compiler;
|
|
14656
|
+
}
|
|
14657
|
+
function registerSwiftHostCompiler(release, pin2) {
|
|
14658
|
+
compilerArchives[release] = pin2;
|
|
14659
|
+
}
|
|
14660
|
+
function swiftHostCompilerArchive(release, host2 = `${process.platform}-${process.arch}`) {
|
|
14661
|
+
const compiler = swiftHostCompilerPin(release);
|
|
14662
|
+
const archive = compiler.hosts[host2];
|
|
14663
|
+
if (!archive) throw new Error(`unsupported Swift compiler host ${host2}`);
|
|
14664
|
+
return {
|
|
14665
|
+
...archive,
|
|
14666
|
+
identity: compiler.identity,
|
|
14667
|
+
archive: compiler.archive,
|
|
14668
|
+
url: `https://r2.sootsim.com/swift-host-compiler/${compiler.identity}/${archive.checksum}.${compiler.archive}`
|
|
14630
14669
|
};
|
|
14631
|
-
return { name: "bindings", inputs: inputs2, key: nativeEntryKey(inputs2) };
|
|
14632
14670
|
}
|
|
14633
|
-
|
|
14634
|
-
const
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
14671
|
+
function swiftHostCompilerTar(archive, url) {
|
|
14672
|
+
const file = import_node_fs14.default.createReadStream(archive);
|
|
14673
|
+
const decoder = url.endsWith(".tar.zst") ? import_node_zlib3.default.createZstdDecompress({ params: { [import_node_zlib3.default.constants.ZSTD_d_windowLogMax]: 30 } }) : import_node_zlib3.default.createGunzip();
|
|
14674
|
+
file.on("error", (error) => decoder.destroy(error));
|
|
14675
|
+
return file.pipe(decoder);
|
|
14676
|
+
}
|
|
14677
|
+
async function extractSwiftTar(archive, url, destination, options2 = []) {
|
|
14678
|
+
const tar = (0, import_node_child_process9.spawn)(
|
|
14679
|
+
"tar",
|
|
14680
|
+
["--ignore-zeros", "-xf", "-", "-C", destination, ...options2],
|
|
14681
|
+
{
|
|
14682
|
+
stdio: ["pipe", "inherit", "inherit"]
|
|
14683
|
+
}
|
|
14640
14684
|
);
|
|
14641
|
-
|
|
14642
|
-
|
|
14643
|
-
|
|
14644
|
-
|
|
14645
|
-
|
|
14646
|
-
|
|
14647
|
-
|
|
14648
|
-
|
|
14685
|
+
const exited = new Promise((resolve4, reject) => {
|
|
14686
|
+
tar.on("error", reject);
|
|
14687
|
+
tar.on("close", resolve4);
|
|
14688
|
+
});
|
|
14689
|
+
const [, code] = await Promise.all([
|
|
14690
|
+
(0, import_promises3.pipeline)(swiftHostCompilerTar(archive, url), tar.stdin),
|
|
14691
|
+
exited
|
|
14692
|
+
]);
|
|
14693
|
+
if (code !== 0) throw new Error(`tar exited with ${code} unpacking ${archive}`);
|
|
14694
|
+
}
|
|
14695
|
+
function swiftUpstreamRelease(release) {
|
|
14696
|
+
return release.replace(/-custom-[a-f0-9]{16}$/, "");
|
|
14697
|
+
}
|
|
14698
|
+
function swiftCompilerRelease(release) {
|
|
14699
|
+
return swiftUpstreamRelease(release).replace(
|
|
14700
|
+
/^swift-(\d+\.\d+)\.0-RELEASE$/,
|
|
14701
|
+
"swift-$1-RELEASE"
|
|
14702
|
+
);
|
|
14703
|
+
}
|
|
14704
|
+
function swiftToolchainBin(release) {
|
|
14705
|
+
if (process.platform === "darwin") {
|
|
14706
|
+
const dirs = [import_node_os5.default.homedir(), "/"].map(
|
|
14707
|
+
(base2) => import_node_path12.default.join(base2, `Library/Developer/Toolchains/${release}.xctoolchain/usr/bin`)
|
|
14649
14708
|
);
|
|
14650
|
-
|
|
14651
|
-
|
|
14652
|
-
|
|
14653
|
-
|
|
14654
|
-
|
|
14655
|
-
|
|
14656
|
-
|
|
14657
|
-
|
|
14658
|
-
|
|
14659
|
-
|
|
14709
|
+
const found = dirs.find((dir) => import_node_fs14.default.existsSync(import_node_path12.default.join(dir, "swift")));
|
|
14710
|
+
return found ? import_node_fs14.default.realpathSync(found) : dirs[0];
|
|
14711
|
+
}
|
|
14712
|
+
if (process.env.CONTRAST_SWIFT_TOOLCHAINS) {
|
|
14713
|
+
return import_node_path12.default.join(process.env.CONTRAST_SWIFT_TOOLCHAINS, release, "usr/bin");
|
|
14714
|
+
}
|
|
14715
|
+
const image = import_node_path12.default.join("/opt/swift", release, "usr/bin");
|
|
14716
|
+
if (import_node_fs14.default.existsSync(import_node_path12.default.join(image, "swift"))) return image;
|
|
14717
|
+
if (release.includes("-custom-"))
|
|
14718
|
+
return import_node_path12.default.join(peachHome(), "swift", "toolchains", release, "usr/bin");
|
|
14719
|
+
return (process.env.PATH ?? "").split(import_node_path12.default.delimiter).find((dir) => dir && import_node_fs14.default.existsSync(import_node_path12.default.join(dir, "swift"))) ?? image;
|
|
14720
|
+
}
|
|
14721
|
+
function writeSwiftAutolinkLinker(directory2, toolchainBin, omitLibraries = []) {
|
|
14722
|
+
const linker = import_node_path12.default.join(directory2, SWIFT_AUTOLINK_LINKER);
|
|
14723
|
+
const script = `#!/bin/sh
|
|
14724
|
+
set -eu
|
|
14725
|
+
for arg in "$@"; do
|
|
14726
|
+
case $arg in
|
|
14727
|
+
@*)
|
|
14728
|
+
rsp=\${arg#@}
|
|
14729
|
+
awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next }${omitLibraries.map((name3) => ` $0 == "\\"-l${name3}\\"" { next }`).join("")} $0 == "\\"-ObjC\\"" { next } { print }' "$rsp" > "$rsp.dedup"
|
|
14730
|
+
mv "$rsp.dedup" "$rsp"
|
|
14731
|
+
if [ "\${PEACH_DEFER_WASM_LINK:-}" = "1" ] && grep -q '"--start-lib"' "$rsp"; then
|
|
14732
|
+
cp "$rsp" ${JSON.stringify(import_node_path12.default.join(directory2, ".peach-link.rsp"))}
|
|
14733
|
+
out=$(awk 'BEGIN { RS = " " } prev == "\\"'-o'\\"" { gsub(/^"|"[[:space:]]*$/, ""); print; exit } { prev = $0 }' "$rsp")
|
|
14734
|
+
if [ -n "$out" ]; then
|
|
14735
|
+
printf '\\000asm\\001\\000\\000\\000' > "$out"
|
|
14736
|
+
exit 0
|
|
14737
|
+
fi
|
|
14738
|
+
fi
|
|
14739
|
+
;;
|
|
14740
|
+
esac
|
|
14741
|
+
done
|
|
14742
|
+
exec ${JSON.stringify(import_node_path12.default.join(toolchainBin, "wasm-ld"))} "$@"
|
|
14743
|
+
`;
|
|
14744
|
+
if (import_node_fs14.default.existsSync(linker) && import_node_fs14.default.readFileSync(linker, "utf8") === script) return linker;
|
|
14745
|
+
import_node_fs14.default.mkdirSync(directory2, { recursive: true });
|
|
14746
|
+
const next = `${linker}.${process.pid}`;
|
|
14747
|
+
import_node_fs14.default.writeFileSync(next, script, { mode: 493 });
|
|
14748
|
+
import_node_fs14.default.renameSync(next, linker);
|
|
14749
|
+
return linker;
|
|
14750
|
+
}
|
|
14751
|
+
function peachHome() {
|
|
14752
|
+
const override = process.env.PEACH_HOME;
|
|
14753
|
+
if (override) return import_node_path12.default.resolve(override);
|
|
14754
|
+
const home = import_node_path12.default.join(import_node_os5.default.homedir(), ".peach");
|
|
14755
|
+
return import_node_fs14.default.existsSync(home) ? import_node_fs14.default.realpathSync(home) : home;
|
|
14756
|
+
}
|
|
14757
|
+
function peachSwiftSdksDir() {
|
|
14758
|
+
return process.env.PEACH_SWIFT_SDKS_PATH ?? import_node_path12.default.join(peachHome(), "swift", "sdks");
|
|
14759
|
+
}
|
|
14760
|
+
function agentSharedCacheRoot() {
|
|
14761
|
+
if (process.platform !== "darwin" || !process.env.TM_SESSION) return null;
|
|
14762
|
+
if (agentBuildersRoot) return agentBuildersRoot;
|
|
14763
|
+
const policy = JSON.parse(
|
|
14764
|
+
(0, import_node_child_process9.execFileSync)("tm", ["machine", "policy", "--json"], {
|
|
14765
|
+
encoding: "utf8",
|
|
14766
|
+
timeout: 3e4
|
|
14767
|
+
})
|
|
14768
|
+
);
|
|
14769
|
+
const mounts = policy.storage_mounts ?? [];
|
|
14770
|
+
if (!Array.isArray(mounts)) throw new Error("storage_mounts must be a list");
|
|
14771
|
+
const isMount = (directory2) => {
|
|
14772
|
+
const lines = (0, import_node_child_process9.execFileSync)("/bin/df", ["-P", directory2], {
|
|
14773
|
+
encoding: "utf8",
|
|
14774
|
+
timeout: 3e4
|
|
14775
|
+
}).trim().split("\n");
|
|
14776
|
+
const fields = lines[lines.length - 1].trim().split(/\s+/);
|
|
14777
|
+
const mount = fields.slice(5).join(" ");
|
|
14778
|
+
if (!import_node_path12.default.isAbsolute(mount))
|
|
14779
|
+
throw new Error("filesystem mount identity is unavailable");
|
|
14780
|
+
return import_node_fs14.default.realpathSync(directory2) === import_node_fs14.default.realpathSync(mount);
|
|
14781
|
+
};
|
|
14782
|
+
for (const mount of mounts) {
|
|
14783
|
+
if (typeof mount !== "string" || !import_node_path12.default.isAbsolute(mount) || !isMount(mount))
|
|
14784
|
+
throw new Error(`configured storage is not mounted: ${mount}`);
|
|
14785
|
+
}
|
|
14786
|
+
const heavy = policy.heavy_data_dir;
|
|
14787
|
+
if (heavy == null) return agentBuildersRoot = import_node_path12.default.join(import_node_os5.default.homedir(), "builders");
|
|
14788
|
+
if (typeof heavy !== "string" || !import_node_path12.default.isAbsolute(heavy) || !import_node_fs14.default.statSync(heavy).isDirectory())
|
|
14789
|
+
throw new Error(`configured heavy_data_dir is unavailable: ${heavy}`);
|
|
14790
|
+
const mounted = isMount(heavy);
|
|
14791
|
+
if (import_node_path12.default.dirname(heavy) === "/Volumes" && !mounted)
|
|
14792
|
+
throw new Error(`configured storage is not mounted: ${heavy}`);
|
|
14793
|
+
return agentBuildersRoot = mounted && import_node_fs14.default.statSync(heavy).dev === import_node_fs14.default.statSync(import_node_os5.default.homedir()).dev ? import_node_path12.default.join(import_node_os5.default.homedir(), "builders") : import_node_path12.default.join(heavy, "builders");
|
|
14794
|
+
}
|
|
14795
|
+
function buildersRootEnv() {
|
|
14796
|
+
const root = process.env[BUILDERS_ROOT_ENV]?.trim();
|
|
14797
|
+
return root ? root : null;
|
|
14798
|
+
}
|
|
14799
|
+
function resolvedBuildersRoot() {
|
|
14800
|
+
return buildersRootEnv() ?? (process.env.PEACH_HOME ? null : agentSharedCacheRoot());
|
|
14801
|
+
}
|
|
14802
|
+
function swiftCacheDir() {
|
|
14803
|
+
const root = resolvedBuildersRoot();
|
|
14804
|
+
return root ? import_node_path12.default.join(root, "peach-cache") : import_node_path12.default.join(peachHome(), "cache");
|
|
14805
|
+
}
|
|
14806
|
+
function refreshSwiftCacheHold(directory2) {
|
|
14807
|
+
const cache = swiftCacheDir();
|
|
14808
|
+
if (!import_node_fs14.default.existsSync(cache)) return;
|
|
14809
|
+
const cacheRoot = import_node_fs14.default.realpathSync(cache);
|
|
14810
|
+
const relative4 = import_node_path12.default.relative(cacheRoot, import_node_fs14.default.realpathSync(directory2));
|
|
14811
|
+
const [kind, key2] = relative4.split(import_node_path12.default.sep);
|
|
14812
|
+
if (!key2 || kind === ".." || import_node_path12.default.isAbsolute(relative4)) return;
|
|
14813
|
+
const entry = import_node_path12.default.join(cacheRoot, kind, key2);
|
|
14814
|
+
if (!resolvedBuildersRoot()) {
|
|
14815
|
+
const now = /* @__PURE__ */ new Date();
|
|
14816
|
+
import_node_fs14.default.utimesSync(entry, now, now);
|
|
14660
14817
|
return;
|
|
14661
14818
|
}
|
|
14662
|
-
const
|
|
14663
|
-
|
|
14664
|
-
|
|
14665
|
-
|
|
14819
|
+
const marker = import_node_path12.default.join(entry, SWIFT_CACHE_HOLD_MARKER);
|
|
14820
|
+
const { O_WRONLY, O_CREAT, O_NOFOLLOW, O_NONBLOCK } = import_node_fs14.default.constants;
|
|
14821
|
+
const fd = import_node_fs14.default.openSync(marker, O_WRONLY | O_CREAT | O_NOFOLLOW | O_NONBLOCK, 420);
|
|
14822
|
+
try {
|
|
14823
|
+
if (!import_node_fs14.default.fstatSync(fd).isFile()) throw new Error(`invalid Swift cache hold: ${marker}`);
|
|
14824
|
+
const now = /* @__PURE__ */ new Date();
|
|
14825
|
+
import_node_fs14.default.futimesSync(fd, now, now);
|
|
14826
|
+
} finally {
|
|
14827
|
+
import_node_fs14.default.closeSync(fd);
|
|
14828
|
+
}
|
|
14829
|
+
}
|
|
14830
|
+
function sharedCacheDir(fallback) {
|
|
14831
|
+
const root = buildersRootEnv() ?? agentSharedCacheRoot();
|
|
14832
|
+
return root ? import_node_path12.default.join(root, "peach-cache") : fallback;
|
|
14833
|
+
}
|
|
14834
|
+
function swiftPackageCacheOptions() {
|
|
14835
|
+
const root = import_node_path12.default.join(swiftCacheDir(), "swiftpm");
|
|
14836
|
+
return [
|
|
14837
|
+
...["cache", "config", "security"].flatMap((name3) => [
|
|
14838
|
+
`--${name3}-path`,
|
|
14839
|
+
import_node_path12.default.join(root, name3)
|
|
14840
|
+
]),
|
|
14841
|
+
"--disable-keychain"
|
|
14842
|
+
];
|
|
14843
|
+
}
|
|
14844
|
+
function setSwiftLinuxLibraryPath(libraryPath) {
|
|
14845
|
+
linuxLibraryPath = libraryPath;
|
|
14846
|
+
}
|
|
14847
|
+
function confineSwiftScratch(root) {
|
|
14848
|
+
if (scratch) return;
|
|
14849
|
+
import_node_fs14.default.mkdirSync(root, { recursive: true });
|
|
14850
|
+
root = import_node_fs14.default.realpathSync(root);
|
|
14851
|
+
for (const name3 of import_node_fs14.default.readdirSync(root)) {
|
|
14852
|
+
const pid = Number(name3);
|
|
14853
|
+
if (Number.isInteger(pid) && pid > 0 && !processRuns(pid))
|
|
14854
|
+
import_node_fs14.default.rmSync(import_node_path12.default.join(root, name3), { recursive: true, force: true });
|
|
14855
|
+
}
|
|
14856
|
+
const dir = import_node_path12.default.join(root, String(process.pid));
|
|
14857
|
+
import_node_fs14.default.mkdirSync(dir, { recursive: true });
|
|
14858
|
+
const home = import_node_path12.default.join(root, "home");
|
|
14859
|
+
import_node_fs14.default.mkdirSync(home, { recursive: true });
|
|
14860
|
+
scratch = { directory: dir, home };
|
|
14861
|
+
process.once("exit", () => {
|
|
14862
|
+
import_node_fs14.default.rmSync(dir, { recursive: true, force: true });
|
|
14863
|
+
});
|
|
14864
|
+
}
|
|
14865
|
+
function processRuns(pid) {
|
|
14866
|
+
try {
|
|
14867
|
+
process.kill(pid, 0);
|
|
14868
|
+
return true;
|
|
14869
|
+
} catch (error) {
|
|
14870
|
+
return error instanceof Error && "code" in error && error.code === "EPERM";
|
|
14871
|
+
}
|
|
14872
|
+
}
|
|
14873
|
+
function withoutCoreDump(file, args) {
|
|
14874
|
+
return ["/bin/sh", ["-c", 'ulimit -c 0; exec "$@"', "sh", file, ...args]];
|
|
14875
|
+
}
|
|
14876
|
+
function swiftEnvironment(base2 = process.env) {
|
|
14877
|
+
return {
|
|
14878
|
+
...base2,
|
|
14879
|
+
...linuxHostSdkRoot ? { SDKROOT: linuxHostSdkRoot } : {},
|
|
14880
|
+
...linuxLibraryPath ? {
|
|
14881
|
+
LD_LIBRARY_PATH: [linuxLibraryPath, base2.LD_LIBRARY_PATH].filter(Boolean).join(":")
|
|
14882
|
+
} : {},
|
|
14883
|
+
...scratch ? {
|
|
14884
|
+
TMPDIR: scratch.directory,
|
|
14885
|
+
XDG_CONFIG_HOME: import_node_path12.default.join(scratch.home, ".config"),
|
|
14886
|
+
XDG_CACHE_HOME: import_node_path12.default.join(scratch.home, ".cache"),
|
|
14887
|
+
XDG_DATA_HOME: import_node_path12.default.join(scratch.home, ".local", "share"),
|
|
14888
|
+
...process.platform === "linux" ? { HOME: scratch.home } : {}
|
|
14889
|
+
} : {}
|
|
14890
|
+
};
|
|
14891
|
+
}
|
|
14892
|
+
function swiftSourceSdk(root) {
|
|
14893
|
+
const pin2 = JSON.parse(
|
|
14894
|
+
import_node_fs14.default.readFileSync(import_node_path12.default.join(root, "toolchain.json"), "utf8")
|
|
14666
14895
|
);
|
|
14667
|
-
if (
|
|
14668
|
-
throw new Error(
|
|
14669
|
-
|
|
14670
|
-
|
|
14671
|
-
|
|
14672
|
-
|
|
14673
|
-
const manifest = {
|
|
14674
|
-
generation,
|
|
14675
|
-
frameworks: selected.frameworks,
|
|
14676
|
-
selection: selected.selection,
|
|
14677
|
-
files: [...generated.files.keys()]
|
|
14896
|
+
if (!pin2 || typeof pin2 !== "object" || typeof Reflect.get(pin2, "wasmSdkId") !== "string" || typeof Reflect.get(pin2, "wasmSdkUrl") !== "string" || typeof Reflect.get(pin2, "wasmSdkChecksum") !== "string")
|
|
14897
|
+
throw new Error(`${root} pins no wasm SDK id, url and checksum`);
|
|
14898
|
+
return {
|
|
14899
|
+
wasmSdkId: String(Reflect.get(pin2, "wasmSdkId")),
|
|
14900
|
+
wasmSdkUrl: String(Reflect.get(pin2, "wasmSdkUrl")),
|
|
14901
|
+
wasmSdkChecksum: String(Reflect.get(pin2, "wasmSdkChecksum"))
|
|
14678
14902
|
};
|
|
14679
|
-
import_node_fs14.default.writeFileSync(import_node_path12.default.join(directory2, "manifest.json"), JSON.stringify(manifest));
|
|
14680
14903
|
}
|
|
14681
|
-
|
|
14682
|
-
|
|
14683
|
-
|
|
14684
|
-
|
|
14685
|
-
|
|
14686
|
-
|
|
14687
|
-
|
|
14688
|
-
|
|
14689
|
-
|
|
14690
|
-
|
|
14691
|
-
|
|
14692
|
-
import_sucrase = require("peachsim/vendor/sucrase");
|
|
14693
|
-
init_native_prebuilt();
|
|
14694
|
-
init_oneSdkContract();
|
|
14695
|
-
GENERATE_SCRIPT = `
|
|
14696
|
-
import { writeFileSync } from 'node:fs'
|
|
14697
|
-
import { pathToFileURL } from 'node:url'
|
|
14698
|
-
const [generatorFile, resultFile, frameworks, options] = process.argv.slice(1)
|
|
14699
|
-
const generator = await import(pathToFileURL(generatorFile).href)
|
|
14700
|
-
const { files, generation } = await generator.generateAppSdk(JSON.parse(frameworks), undefined, JSON.parse(options))
|
|
14701
|
-
writeFileSync(resultFile, JSON.stringify({ generation, files: [...files] }))
|
|
14702
|
-
`;
|
|
14904
|
+
function swiftToolchain(release, sdk2) {
|
|
14905
|
+
validateSwiftSdkIdentity(sdk2);
|
|
14906
|
+
let bin;
|
|
14907
|
+
try {
|
|
14908
|
+
bin = swiftCompiler(release);
|
|
14909
|
+
} catch (error) {
|
|
14910
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
14911
|
+
throw new Error(
|
|
14912
|
+
`Swift compiler ${release} is unavailable or differs from its pin: ${reason}
|
|
14913
|
+
${swiftInstallSteps(release, sdk2)}`
|
|
14914
|
+
);
|
|
14703
14915
|
}
|
|
14704
|
-
|
|
14705
|
-
|
|
14706
|
-
|
|
14707
|
-
|
|
14708
|
-
|
|
14709
|
-
|
|
14710
|
-
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
|
|
14714
|
-
|
|
14715
|
-
|
|
14716
|
-
(match) => match[1]
|
|
14916
|
+
const swift = import_node_path12.default.join(bin, "swift");
|
|
14917
|
+
const listed = [swift, sdk2.wasmSdkId, ...swiftSdkOptions()].join("\0");
|
|
14918
|
+
if (!listedSdks.has(listed)) {
|
|
14919
|
+
const sdks = (0, import_node_child_process9.execFileSync)(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
14920
|
+
encoding: "utf8",
|
|
14921
|
+
env: swiftEnvironment(),
|
|
14922
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
14923
|
+
});
|
|
14924
|
+
if (!sdks.split("\n").some((line) => line.trim() === sdk2.wasmSdkId)) {
|
|
14925
|
+
throw new Error(
|
|
14926
|
+
`peach compiles Swift with the ${sdk2.wasmSdkId} SDK, which ${swift} does not have.
|
|
14927
|
+
${swiftSdkInstallStep(release, sdk2)}`
|
|
14717
14928
|
);
|
|
14718
|
-
if (parts.length > 1) settings[key2] = parts;
|
|
14719
|
-
} else if (Array.isArray(value)) {
|
|
14720
|
-
if (value.length > 1 && arraySettings.has(stripped2)) continue;
|
|
14721
|
-
settings[key2] = value.map((item) => typeof item === "string" ? item : "").join(" ");
|
|
14722
14929
|
}
|
|
14930
|
+
listedSdks.add(listed);
|
|
14723
14931
|
}
|
|
14724
|
-
|
|
14725
|
-
|
|
14726
|
-
|
|
14727
|
-
const
|
|
14728
|
-
|
|
14729
|
-
|
|
14730
|
-
return `(
|
|
14731
|
-
${value.map((item) => `${indent2} ${write(item, depth + 1)},
|
|
14732
|
-
`).join("")}${indent2})`;
|
|
14733
|
-
const keys = Object.keys(value).sort(
|
|
14734
|
-
(a, b) => a === "isa" ? -1 : b === "isa" ? 1 : byBytes(a, b)
|
|
14735
|
-
);
|
|
14736
|
-
return `{
|
|
14737
|
-
${keys.map((key2) => `${indent2} ${quote(key2)} = ${write(value[key2], depth + 1)};
|
|
14738
|
-
`).join("")}${indent2}}`;
|
|
14739
|
-
};
|
|
14740
|
-
const byIsa = /* @__PURE__ */ new Map();
|
|
14741
|
-
for (const id of Object.keys(objects).sort(byBytes)) {
|
|
14742
|
-
const isa = String(objects[id].isa);
|
|
14743
|
-
byIsa.set(isa, [...byIsa.get(isa) ?? [], id]);
|
|
14932
|
+
try {
|
|
14933
|
+
verifySwiftSdk(swift, sdk2);
|
|
14934
|
+
} catch (error) {
|
|
14935
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
14936
|
+
throw new Error(`${reason}
|
|
14937
|
+
${swiftSdkInstallStep(release, sdk2)}`);
|
|
14744
14938
|
}
|
|
14745
|
-
|
|
14746
|
-
(isa) => `
|
|
14747
|
-
/* Begin ${isa} section */
|
|
14748
|
-
${byIsa.get(isa).map((id) => ` ${quote(id)} = ${write(objects[id], 2)};
|
|
14749
|
-
`).join("")}/* End ${isa} section */
|
|
14750
|
-
`
|
|
14751
|
-
);
|
|
14752
|
-
return `// !$*UTF8*$!
|
|
14753
|
-
{
|
|
14754
|
-
archiveVersion = 1;
|
|
14755
|
-
classes = {
|
|
14756
|
-
};
|
|
14757
|
-
objectVersion = ${objectVersion};
|
|
14758
|
-
objects = {
|
|
14759
|
-
${sections.join("")} };
|
|
14760
|
-
rootObject = ${quote(rootObject)};
|
|
14939
|
+
return bin;
|
|
14761
14940
|
}
|
|
14762
|
-
|
|
14941
|
+
function validateSwiftSdkIdentity(sdk2) {
|
|
14942
|
+
if (!/^[a-zA-Z0-9._-]+$/.test(sdk2.wasmSdkId) || !/^[a-f0-9]{64}$/.test(sdk2.wasmSdkChecksum))
|
|
14943
|
+
throw new Error("invalid Swift SDK identity or checksum");
|
|
14763
14944
|
}
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14945
|
+
function swiftSdkBundle(swift, id, options2) {
|
|
14946
|
+
const key2 = [swift, id, ...options2].join("\0");
|
|
14947
|
+
const known = sdkBundles.get(key2);
|
|
14948
|
+
if (known && import_node_fs14.default.existsSync(known)) return known;
|
|
14949
|
+
const configuration = (0, import_node_child_process9.execFileSync)(
|
|
14950
|
+
swift,
|
|
14951
|
+
["sdk", "configure", ...options2, "--show-configuration", id, SWIFT_WASM_TRIPLE],
|
|
14952
|
+
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
14953
|
+
);
|
|
14954
|
+
const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
|
|
14955
|
+
if (!sysroot || !import_node_path12.default.isAbsolute(sysroot))
|
|
14956
|
+
throw new Error(`Swift SDK ${id} reports no absolute sdkRootPath`);
|
|
14957
|
+
let bundle = sysroot;
|
|
14958
|
+
while (!bundle.endsWith(".artifactbundle")) {
|
|
14959
|
+
const parent = import_node_path12.default.dirname(bundle);
|
|
14960
|
+
if (parent === bundle)
|
|
14961
|
+
throw new Error(`Swift SDK ${id} is outside an artifact bundle`);
|
|
14962
|
+
bundle = parent;
|
|
14963
|
+
}
|
|
14964
|
+
const resolved = import_node_fs14.default.realpathSync(bundle);
|
|
14965
|
+
sdkBundles.set(key2, resolved);
|
|
14966
|
+
return resolved;
|
|
14967
|
+
}
|
|
14968
|
+
function swiftSdkPayloadChecksum(bundle) {
|
|
14969
|
+
const hash = (0, import_node_crypto5.createHash)("sha256");
|
|
14970
|
+
function visit3(relative4) {
|
|
14971
|
+
const file = import_node_path12.default.join(bundle, relative4);
|
|
14972
|
+
const stat = import_node_fs14.default.lstatSync(file, { bigint: true });
|
|
14973
|
+
if (stat.isSymbolicLink()) {
|
|
14974
|
+
const resolved = import_node_path12.default.relative(bundle, import_node_fs14.default.realpathSync(file));
|
|
14975
|
+
if (resolved === ".." || resolved.startsWith(`..${import_node_path12.default.sep}`) || import_node_path12.default.isAbsolute(resolved))
|
|
14976
|
+
throw new Error(`Swift SDK symlink escapes its bundle: ${relative4}`);
|
|
14977
|
+
hash.update(JSON.stringify([relative4, "link", import_node_fs14.default.readlinkSync(file)]) + "\n");
|
|
14978
|
+
} else if (stat.isDirectory()) {
|
|
14979
|
+
hash.update(JSON.stringify([relative4, "directory"]) + "\n");
|
|
14980
|
+
for (const name3 of import_node_fs14.default.readdirSync(file).sort()) visit3(import_node_path12.default.join(relative4, name3));
|
|
14981
|
+
} else if (stat.isFile()) {
|
|
14982
|
+
const stamp = [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(":");
|
|
14983
|
+
let cached2 = sdkFileHashes.get(file);
|
|
14984
|
+
if (cached2?.stamp !== stamp) {
|
|
14985
|
+
cached2 = { stamp, checksum: swiftFileChecksum(file) };
|
|
14986
|
+
sdkFileHashes.set(file, cached2);
|
|
14987
|
+
sdkFilesHashed++;
|
|
14988
|
+
}
|
|
14989
|
+
hash.update(
|
|
14990
|
+
JSON.stringify([relative4, "file", Number(stat.mode & 0o111n), cached2.checksum]) + "\n"
|
|
14991
|
+
);
|
|
14992
|
+
} else throw new Error(`unsupported Swift SDK payload entry: ${relative4}`);
|
|
14993
|
+
}
|
|
14994
|
+
visit3("");
|
|
14995
|
+
return hash.digest("hex");
|
|
14996
|
+
}
|
|
14997
|
+
function swiftSdkVerificationFile(bundle, sdk2) {
|
|
14998
|
+
return import_node_path12.default.join(
|
|
14999
|
+
import_node_path12.default.dirname(bundle),
|
|
15000
|
+
".peach-sdk-checksums",
|
|
15001
|
+
`${sdk2.wasmSdkId}-${sdk2.wasmSdkChecksum}.json`
|
|
15002
|
+
);
|
|
15003
|
+
}
|
|
15004
|
+
function verifySwiftSdk(swift, sdk2) {
|
|
15005
|
+
const bundle = swiftSdkBundle(swift, sdk2.wasmSdkId, swiftSdkOptions());
|
|
15006
|
+
const file = swiftSdkVerificationFile(bundle, sdk2);
|
|
15007
|
+
if (!import_node_fs14.default.existsSync(file))
|
|
15008
|
+
throw new Error(
|
|
15009
|
+
`Swift SDK ${sdk2.wasmSdkId} has no verified archive binding for ${sdk2.wasmSdkChecksum}. Hydrate it with installSwiftWasmSdk before compiling.`
|
|
15010
|
+
);
|
|
15011
|
+
const receipt = JSON.parse(import_node_fs14.default.readFileSync(file, "utf8"));
|
|
15012
|
+
const stamps = file.replace(/\.json$/, ".files.json");
|
|
15013
|
+
if (!loadedSdkHashFiles.has(stamps)) {
|
|
15014
|
+
loadedSdkHashFiles.add(stamps);
|
|
15015
|
+
const saved = import_node_fs14.default.existsSync(stamps) ? JSON.parse(import_node_fs14.default.readFileSync(stamps, "utf8")) : null;
|
|
15016
|
+
if (saved && typeof saved === "object") {
|
|
15017
|
+
for (const [entry, value] of Object.entries(saved))
|
|
15018
|
+
if (Array.isArray(value) && typeof value[0] === "string" && typeof value[1] === "string")
|
|
15019
|
+
sdkFileHashes.set(entry, { stamp: value[0], checksum: value[1] });
|
|
15020
|
+
}
|
|
15021
|
+
}
|
|
15022
|
+
const hashedBefore = sdkFilesHashed;
|
|
15023
|
+
if (!receipt || typeof receipt !== "object" || !("wasmSdkId" in receipt) || receipt.wasmSdkId !== sdk2.wasmSdkId || !("wasmSdkChecksum" in receipt) || receipt.wasmSdkChecksum !== sdk2.wasmSdkChecksum || !("payloadChecksum" in receipt) || receipt.payloadChecksum !== swiftSdkPayloadChecksum(bundle))
|
|
15024
|
+
throw new Error(
|
|
15025
|
+
`Swift SDK ${sdk2.wasmSdkId} installed payload differs from its verified archive ${sdk2.wasmSdkChecksum}`
|
|
15026
|
+
);
|
|
15027
|
+
if (sdkFilesHashed === hashedBefore) return;
|
|
15028
|
+
const temporary = `${stamps}.${process.pid}.tmp`;
|
|
15029
|
+
try {
|
|
15030
|
+
import_node_fs14.default.writeFileSync(
|
|
15031
|
+
temporary,
|
|
15032
|
+
JSON.stringify(
|
|
15033
|
+
Object.fromEntries(
|
|
15034
|
+
[...sdkFileHashes].filter(([entry]) => entry.startsWith(bundle + import_node_path12.default.sep)).map(([entry, { stamp, checksum }]) => [entry, [stamp, checksum]])
|
|
15035
|
+
)
|
|
15036
|
+
)
|
|
15037
|
+
);
|
|
15038
|
+
import_node_fs14.default.renameSync(temporary, stamps);
|
|
15039
|
+
} finally {
|
|
15040
|
+
import_node_fs14.default.rmSync(temporary, { force: true });
|
|
15041
|
+
}
|
|
15042
|
+
}
|
|
15043
|
+
async function installSwiftSdkArchive(swift, sdk2, archive) {
|
|
15044
|
+
validateSwiftSdkIdentity(sdk2);
|
|
15045
|
+
const staging = import_node_fs14.default.realpathSync(swiftSdkStagingDirectory("peach-sdk-verification-"));
|
|
15046
|
+
try {
|
|
15047
|
+
if (swiftFileChecksum(archive) !== sdk2.wasmSdkChecksum)
|
|
15048
|
+
throw new Error("declared Swift SDK archive checksum mismatch");
|
|
15049
|
+
const store = import_node_path12.default.join(staging, "sdks");
|
|
15050
|
+
import_node_fs14.default.mkdirSync(store);
|
|
15051
|
+
let source = archive;
|
|
15052
|
+
let checksumArgs = ["--checksum", sdk2.wasmSdkChecksum];
|
|
15053
|
+
if (sdk2.wasmSdkUrl.endsWith(".tar.zst")) {
|
|
15054
|
+
const extracted = import_node_path12.default.join(staging, "archive");
|
|
15055
|
+
import_node_fs14.default.mkdirSync(extracted);
|
|
15056
|
+
await extractSwiftTar(archive, sdk2.wasmSdkUrl, extracted);
|
|
15057
|
+
const [bundle2, extra] = import_node_fs14.default.readdirSync(extracted, { withFileTypes: true });
|
|
15058
|
+
if (!bundle2?.isDirectory() || !bundle2.name.endsWith(".artifactbundle") || extra)
|
|
15059
|
+
throw new Error("Swift SDK archive must contain one artifact bundle directory");
|
|
15060
|
+
source = import_node_path12.default.join(extracted, bundle2.name);
|
|
15061
|
+
checksumArgs = [];
|
|
15062
|
+
}
|
|
15063
|
+
(0, import_node_child_process9.execFileSync)(
|
|
15064
|
+
swift,
|
|
15065
|
+
["sdk", "install", source, ...checksumArgs, "--swift-sdks-path", store],
|
|
15066
|
+
{ env: swiftEnvironment(), stdio: "inherit" }
|
|
15067
|
+
);
|
|
15068
|
+
const stagedBundle = swiftSdkBundle(swift, sdk2.wasmSdkId, [
|
|
15069
|
+
"--swift-sdks-path",
|
|
15070
|
+
store
|
|
15071
|
+
]);
|
|
15072
|
+
const expected = swiftSdkPayloadChecksum(stagedBundle);
|
|
15073
|
+
const locks = import_node_path12.default.join(import_node_path12.default.resolve(peachSwiftSdksDir()), ".peach-locks");
|
|
15074
|
+
import_node_fs14.default.mkdirSync(locks, { recursive: true });
|
|
15075
|
+
(0, import_node_child_process9.execFileSync)(
|
|
15076
|
+
"perl",
|
|
15077
|
+
[
|
|
15078
|
+
"-e",
|
|
15079
|
+
'use Fcntl qw(:flock); my ($lock, $id, $bundle, $swift, @options) = @ARGV; open(my $fd, ">>", $lock) or die $!; flock($fd, LOCK_EX) or die $!; open(my $list, "-|", $swift, "sdk", "list", @options) or die $!; my $found = 0; while (<$list>) { s/^\\s+|\\s+$//g; $found = 1 if $_ eq $id; } close($list) or die "swift sdk list failed"; unless ($found) { system($swift, "sdk", "install", $bundle, @options); exit(($? & 127) ? 128 + ($? & 127) : $? >> 8); }',
|
|
15080
|
+
import_node_path12.default.join(locks, "wasm-sdk.lock"),
|
|
15081
|
+
sdk2.wasmSdkId,
|
|
15082
|
+
stagedBundle,
|
|
15083
|
+
swift,
|
|
15084
|
+
...swiftSdkOptions()
|
|
15085
|
+
],
|
|
15086
|
+
{ env: swiftEnvironment(), stdio: "inherit" }
|
|
15087
|
+
);
|
|
15088
|
+
const bundle = swiftSdkBundle(swift, sdk2.wasmSdkId, swiftSdkOptions());
|
|
15089
|
+
if (swiftSdkPayloadChecksum(bundle) !== expected)
|
|
15090
|
+
throw new SwiftSdkPayloadMismatch(
|
|
15091
|
+
`Swift SDK ${sdk2.wasmSdkId} already exists with different payload bytes; select a separate --swift-sdks-path. No installed SDK was replaced.`
|
|
15092
|
+
);
|
|
15093
|
+
const file = swiftSdkVerificationFile(bundle, sdk2);
|
|
15094
|
+
import_node_fs14.default.mkdirSync(import_node_path12.default.dirname(file), { recursive: true });
|
|
15095
|
+
const temporary = `${file}.${process.pid}.tmp`;
|
|
15096
|
+
try {
|
|
15097
|
+
import_node_fs14.default.writeFileSync(
|
|
15098
|
+
temporary,
|
|
15099
|
+
JSON.stringify({
|
|
15100
|
+
wasmSdkId: sdk2.wasmSdkId,
|
|
15101
|
+
wasmSdkChecksum: sdk2.wasmSdkChecksum,
|
|
15102
|
+
payloadChecksum: expected
|
|
15103
|
+
}) + "\n"
|
|
15104
|
+
);
|
|
15105
|
+
import_node_fs14.default.renameSync(temporary, file);
|
|
15106
|
+
} finally {
|
|
15107
|
+
import_node_fs14.default.rmSync(temporary, { force: true });
|
|
15108
|
+
}
|
|
15109
|
+
} finally {
|
|
15110
|
+
import_node_fs14.default.rmSync(staging, { recursive: true, force: true });
|
|
15111
|
+
for (const file of sdkFileHashes.keys())
|
|
15112
|
+
if (file.startsWith(staging + import_node_path12.default.sep)) sdkFileHashes.delete(file);
|
|
15113
|
+
}
|
|
15114
|
+
}
|
|
15115
|
+
function swiftSdkStagingDirectory(prefix) {
|
|
15116
|
+
const parent = scratch?.directory ?? import_node_os5.default.tmpdir();
|
|
15117
|
+
if (!import_node_fs14.default.existsSync(parent)) throw new Error(`Swift SDK install is missing ${parent}`);
|
|
15118
|
+
return import_node_fs14.default.mkdtempSync(import_node_path12.default.join(parent, prefix));
|
|
15119
|
+
}
|
|
15120
|
+
async function installSwiftWasmSdk(release, sdk2) {
|
|
15121
|
+
validateSwiftSdkIdentity(sdk2);
|
|
15122
|
+
ensureSwiftLinuxRuntime(release);
|
|
15123
|
+
try {
|
|
15124
|
+
swiftToolchain(release, sdk2);
|
|
15125
|
+
return;
|
|
15126
|
+
} catch {
|
|
15127
|
+
}
|
|
15128
|
+
const swift = import_node_path12.default.join(swiftCompiler(release), "swift");
|
|
15129
|
+
const staging = swiftSdkStagingDirectory("builder-swift-sdk-");
|
|
15130
|
+
const extension = sdk2.wasmSdkUrl.endsWith(".tar.zst") ? "zst" : "gz";
|
|
15131
|
+
const archive = import_node_path12.default.join(staging, `sdk.artifactbundle.tar.${extension}`);
|
|
15132
|
+
try {
|
|
15133
|
+
if (sdk2.wasmSdkUrl.startsWith("file:"))
|
|
15134
|
+
import_node_fs14.default.copyFileSync((0, import_node_url.fileURLToPath)(sdk2.wasmSdkUrl), archive);
|
|
15135
|
+
else
|
|
15136
|
+
(0, import_node_child_process9.execFileSync)(
|
|
15137
|
+
"curl",
|
|
15138
|
+
[
|
|
15139
|
+
"-fsSL",
|
|
15140
|
+
"--show-error",
|
|
15141
|
+
"--retry",
|
|
15142
|
+
"3",
|
|
15143
|
+
"--retry-all-errors",
|
|
15144
|
+
sdk2.wasmSdkUrl,
|
|
15145
|
+
"-o",
|
|
15146
|
+
archive
|
|
15147
|
+
],
|
|
15148
|
+
{
|
|
15149
|
+
stdio: "inherit"
|
|
15150
|
+
}
|
|
15151
|
+
);
|
|
15152
|
+
await installSwiftSdkArchive(swift, sdk2, archive);
|
|
15153
|
+
swiftToolchain(release, sdk2);
|
|
15154
|
+
} finally {
|
|
15155
|
+
import_node_fs14.default.rmSync(staging, { recursive: true, force: true });
|
|
15156
|
+
}
|
|
15157
|
+
}
|
|
15158
|
+
function swiftFileChecksum(file) {
|
|
15159
|
+
const hash = (0, import_node_crypto5.createHash)("sha256");
|
|
15160
|
+
const fd = import_node_fs14.default.openSync(file, "r");
|
|
15161
|
+
const buffer = Buffer.allocUnsafe(1024 * 1024);
|
|
15162
|
+
try {
|
|
15163
|
+
let size2 = import_node_fs14.default.readSync(fd, buffer, 0, buffer.length, null);
|
|
15164
|
+
while (size2 > 0) {
|
|
15165
|
+
hash.update(buffer.subarray(0, size2));
|
|
15166
|
+
size2 = import_node_fs14.default.readSync(fd, buffer, 0, buffer.length, null);
|
|
15167
|
+
}
|
|
15168
|
+
} finally {
|
|
15169
|
+
import_node_fs14.default.closeSync(fd);
|
|
15170
|
+
}
|
|
15171
|
+
return hash.digest("hex");
|
|
15172
|
+
}
|
|
15173
|
+
function swiftHostCompilerFiles(release, root) {
|
|
15174
|
+
const file = import_node_path12.default.join(root, "compiler.json");
|
|
15175
|
+
if (!import_node_fs14.default.existsSync(file))
|
|
15176
|
+
throw new Error(`Swift compiler ${release} is missing ${file}`);
|
|
15177
|
+
const privateCompiler = release === privateSwiftRelease();
|
|
15178
|
+
const pin2 = privateCompiler ? {
|
|
15179
|
+
identity: release.replace(/^.*-custom-/, ""),
|
|
15180
|
+
manifest: swiftFileChecksum(file)
|
|
15181
|
+
} : swiftHostCompilerArchive(release);
|
|
15182
|
+
if (swiftFileChecksum(file) !== pin2.manifest)
|
|
15183
|
+
throw new Error(`Swift compiler manifest mismatch at ${root}`);
|
|
15184
|
+
const manifest = JSON.parse(import_node_fs14.default.readFileSync(file, "utf8"));
|
|
15185
|
+
if (!manifest || typeof manifest !== "object" || !("identity" in manifest) || manifest.identity !== pin2.identity || !("host" in manifest) || manifest.host !== `${process.platform}-${process.arch}` || !("files" in manifest) || !manifest.files || typeof manifest.files !== "object") {
|
|
15186
|
+
throw new Error(`Swift compiler identity mismatch at ${root}`);
|
|
15187
|
+
}
|
|
15188
|
+
const files2 = Object.entries(manifest.files);
|
|
15189
|
+
const fileNames = Object.keys(manifest.files);
|
|
15190
|
+
const build2 = "compilerBuild" in manifest ? manifest.compilerBuild : null;
|
|
15191
|
+
const hasLinkerReceipt = build2 !== null && typeof build2 === "object" && typeof Reflect.get(build2, "lldSHA256") === "string";
|
|
15192
|
+
const hasSharedLLVM = build2 && typeof build2 === "object" && "hostLibraries" in build2;
|
|
15193
|
+
const llvmFiles = hasSharedLLVM ? process.platform === "darwin" ? 2 : 1 : 0;
|
|
15194
|
+
const hasLLVMFiles = process.platform === "darwin" ? fileNames.includes("usr/lib/libLLVM.dylib") && fileNames.includes("usr/lib/libLTO.dylib") : fileNames.some((file2) => /^usr\/lib\/libLLVM\.so\.\d+\.\d+$/.test(file2));
|
|
15195
|
+
const llvmTools = [
|
|
15196
|
+
"llvm-ar",
|
|
15197
|
+
"llvm-nm",
|
|
15198
|
+
"llvm-objcopy",
|
|
15199
|
+
"llvm-objdump",
|
|
15200
|
+
"llvm-symbolizer"
|
|
15201
|
+
];
|
|
15202
|
+
const expectedFiles = [
|
|
15203
|
+
"9f57741c6333ce5e",
|
|
15204
|
+
"139bc3bba3c4f73c",
|
|
15205
|
+
"cd5337e8ab49fd61"
|
|
15206
|
+
].includes(pin2.identity) ? 17 : hasLinkerReceipt || ["38af8a6bc3d9e72c", "17479c8af01737a3"].includes(pin2.identity) ? 18 : 16;
|
|
15207
|
+
if (files2.length !== expectedFiles + llvmFiles + (hasSharedLLVM ? llvmTools.length : 0) || hasSharedLLVM && (!hasLLVMFiles || !llvmTools.every((tool) => fileNames.includes(`usr/bin/${tool}`))) || expectedFiles >= 17 && !("usr/bin/lld" in manifest.files) || expectedFiles === 18 && !fileNames.some((file2) => /\/lib_InternalSwiftScan\.(so|dylib)$/.test(file2)))
|
|
15208
|
+
throw new Error("incomplete Swift compiler manifest");
|
|
15209
|
+
return files2.map(([relative4, checksum]) => {
|
|
15210
|
+
if (relative4.startsWith("/") || relative4.split("/").includes("..") || typeof checksum !== "string")
|
|
15211
|
+
throw new Error(`Swift compiler binary mismatch: ${relative4}`);
|
|
15212
|
+
const binary2 = import_node_path12.default.join(root, relative4);
|
|
15213
|
+
if (!import_node_fs14.default.existsSync(binary2))
|
|
15214
|
+
throw new Error(`Swift compiler ${release} is missing ${binary2}`);
|
|
15215
|
+
return [relative4, checksum];
|
|
15216
|
+
});
|
|
15217
|
+
}
|
|
15218
|
+
function verifySwiftHostCompiler(release, root) {
|
|
15219
|
+
for (const [relative4, checksum] of swiftHostCompilerFiles(release, root)) {
|
|
15220
|
+
if (swiftFileChecksum(import_node_path12.default.join(root, relative4)) !== checksum)
|
|
15221
|
+
throw new Error(`Swift compiler binary mismatch: ${relative4}`);
|
|
15222
|
+
}
|
|
15223
|
+
}
|
|
15224
|
+
async function swiftCompilerAsync(release, signal) {
|
|
15225
|
+
const cached2 = verifiedCompilers.get(release);
|
|
15226
|
+
if (cached2) return cached2;
|
|
15227
|
+
const bin = swiftToolchainBin(release);
|
|
15228
|
+
const binary2 = import_node_path12.default.join(bin, "swift");
|
|
15229
|
+
if (!import_node_fs14.default.existsSync(binary2))
|
|
15230
|
+
throw new Error(`Swift compiler ${release} is missing ${binary2}`);
|
|
15231
|
+
if (release.includes("-custom-")) {
|
|
15232
|
+
const root = import_node_path12.default.resolve(bin, "../..");
|
|
15233
|
+
for (const [relative4, checksum] of swiftHostCompilerFiles(release, root)) {
|
|
15234
|
+
const hash = (0, import_node_crypto5.createHash)("sha256");
|
|
15235
|
+
for await (const chunk of import_node_fs14.default.createReadStream(import_node_path12.default.join(root, relative4), {
|
|
15236
|
+
signal
|
|
15237
|
+
}))
|
|
15238
|
+
hash.update(chunk);
|
|
15239
|
+
if (hash.digest("hex") !== checksum)
|
|
15240
|
+
throw new Error(`Swift compiler binary mismatch: ${relative4}`);
|
|
15241
|
+
}
|
|
15242
|
+
}
|
|
15243
|
+
const { stdout } = await (0, import_node_util2.promisify)(import_node_child_process9.execFile)(binary2, ["--version"], {
|
|
15244
|
+
encoding: "utf8",
|
|
15245
|
+
env: swiftEnvironment(),
|
|
15246
|
+
signal
|
|
15247
|
+
});
|
|
15248
|
+
if (!stdout.includes(`(${swiftCompilerRelease(release)})`))
|
|
15249
|
+
throw new Error(`compiler release mismatch at ${bin}`);
|
|
15250
|
+
verifiedCompilers.set(release, bin);
|
|
15251
|
+
return bin;
|
|
15252
|
+
}
|
|
15253
|
+
function swiftCompiler(release, prepareHost) {
|
|
15254
|
+
const cached2 = verifiedCompilers.get(release);
|
|
15255
|
+
if (cached2) {
|
|
15256
|
+
prepareHost?.();
|
|
15257
|
+
return cached2;
|
|
15258
|
+
}
|
|
15259
|
+
const bin = swiftToolchainBin(release);
|
|
15260
|
+
const binary2 = import_node_path12.default.join(bin, "swift");
|
|
15261
|
+
if (!import_node_fs14.default.existsSync(binary2))
|
|
15262
|
+
throw new Error(`Swift compiler ${release} is missing ${binary2}`);
|
|
15263
|
+
if (release.includes("-custom-"))
|
|
15264
|
+
verifySwiftHostCompiler(release, import_node_path12.default.resolve(bin, "../.."));
|
|
15265
|
+
prepareHost?.();
|
|
15266
|
+
const version2 = (0, import_node_child_process9.execFileSync)(binary2, ["--version"], {
|
|
15267
|
+
encoding: "utf8",
|
|
15268
|
+
env: swiftEnvironment(),
|
|
15269
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
15270
|
+
});
|
|
15271
|
+
if (!version2.includes(`(${swiftCompilerRelease(release)})`))
|
|
15272
|
+
throw new Error(`compiler release mismatch at ${bin}`);
|
|
15273
|
+
verifiedCompilers.set(release, bin);
|
|
15274
|
+
return bin;
|
|
15275
|
+
}
|
|
15276
|
+
function swiftSdkInstallStep(release, wasmSdk) {
|
|
15277
|
+
return `install the pinned SDK:
|
|
15278
|
+
${swiftSdkInstallCommand(release, wasmSdk)}`;
|
|
15279
|
+
}
|
|
15280
|
+
function swiftSdkInstallCommand(release, wasmSdk) {
|
|
15281
|
+
const { wasmSdkId, wasmSdkUrl, wasmSdkChecksum } = wasmSdk;
|
|
15282
|
+
const program = `import { installSwiftWasmSdk } from "peachsim/swift-toolchain"; await installSwiftWasmSdk(${JSON.stringify(release)}, ${JSON.stringify({ wasmSdkId, wasmSdkUrl, wasmSdkChecksum })})`;
|
|
15283
|
+
const environment = `PEACH_SWIFT_SDKS_PATH='${import_node_path12.default.resolve(peachSwiftSdksDir()).replaceAll("'", "'\\''")}' `;
|
|
15284
|
+
return `${environment}node --input-type=module -e '${program.replaceAll("'", "'\\''")}'`;
|
|
15285
|
+
}
|
|
15286
|
+
function swiftInstallSteps(release, wasmSdk) {
|
|
15287
|
+
const { note, commands } = swiftCompilerInstall(release);
|
|
15288
|
+
return [
|
|
15289
|
+
`install the pinned compiler and SDK${note}:`,
|
|
15290
|
+
...[...commands, swiftSdkInstallCommand(release, wasmSdk)].map((line) => ` ${line}`)
|
|
15291
|
+
].join("\n");
|
|
15292
|
+
}
|
|
15293
|
+
function swiftCompilerInstallSteps(release) {
|
|
15294
|
+
const { note, commands } = swiftCompilerInstall(release);
|
|
15295
|
+
return [
|
|
15296
|
+
`install the pinned compiler${note}:`,
|
|
15297
|
+
...commands.map((line) => ` ${line}`)
|
|
15298
|
+
].join("\n");
|
|
15299
|
+
}
|
|
15300
|
+
function swiftCompilerInstall(release) {
|
|
15301
|
+
if (release === privateSwiftRelease())
|
|
15302
|
+
return { note: " (private: its builder installs it)", commands: [] };
|
|
15303
|
+
if (release.includes("-custom-")) {
|
|
15304
|
+
const archive = swiftHostCompilerArchive(release);
|
|
15305
|
+
const directory2 = import_node_path12.default.resolve(swiftToolchainBin(release), "../..");
|
|
15306
|
+
const file = `compiler.${archive.archive}`;
|
|
15307
|
+
return {
|
|
15308
|
+
note: "",
|
|
15309
|
+
commands: [
|
|
15310
|
+
`curl -fsSL ${archive.url} -o ${file}`,
|
|
15311
|
+
`echo '${archive.checksum} ${file}' | shasum -a 256 -c -`,
|
|
15312
|
+
`mkdir -p '${directory2}.partial'`,
|
|
15313
|
+
`tar -xf ${file} --strip-components=1 -C '${directory2}.partial' && mv '${directory2}.partial' '${directory2}'`
|
|
15314
|
+
]
|
|
15315
|
+
};
|
|
15316
|
+
}
|
|
15317
|
+
const version2 = release.replace(/^swift-/, "").toLowerCase();
|
|
15318
|
+
const downloads = `https://download.swift.org/swift-${version2}`;
|
|
15319
|
+
if (process.platform === "darwin") {
|
|
15320
|
+
return {
|
|
15321
|
+
note: "",
|
|
15322
|
+
commands: [
|
|
15323
|
+
`curl -fsSLO ${downloads}/xcode/${release}/${release}-osx.pkg`,
|
|
15324
|
+
`installer -pkg ${release}-osx.pkg -target CurrentUserHomeDirectory`
|
|
15325
|
+
]
|
|
15326
|
+
};
|
|
15327
|
+
}
|
|
15328
|
+
const platform2 = `debian12${process.arch === "arm64" ? "-aarch64" : ""}`;
|
|
15329
|
+
const name3 = `${release}-${platform2}`;
|
|
15330
|
+
return {
|
|
15331
|
+
note: " (Debian 12 shown; other distributions: https://www.swift.org/install/linux/)",
|
|
15332
|
+
commands: [
|
|
15333
|
+
`curl -fsSL ${downloads}/${platform2}/${release}/${name3}.tar.gz | tar -xz -C /opt`,
|
|
15334
|
+
`export PATH=/opt/${name3}/usr/bin:$PATH`
|
|
15335
|
+
]
|
|
15336
|
+
};
|
|
15337
|
+
}
|
|
15338
|
+
var import_node_child_process9, import_node_crypto5, import_node_fs14, import_node_os5, import_node_path12, import_promises3, import_node_url, import_node_util2, import_node_zlib3, compilerArchives, linuxRuntimeLibs, SWIFT_PRIVATE_DISTRIBUTION_ENV, SWIFT_AUTOLINK_LINKER, BUILDERS_ROOT_ENV, agentBuildersRoot, SWIFT_CACHE_HOLD_MARKER, SWIFT_CACHE_HOLD_MS, scratch, linuxLibraryPath, linuxHostSdkRoot, SwiftSdkPayloadMismatch, listedSdks, sdkBundles, sdkFileHashes, sdkFilesHashed, loadedSdkHashFiles, verifiedCompilers;
|
|
15339
|
+
var init_swift_toolchain = __esm({
|
|
15340
|
+
"src/swift-toolchain.ts"() {
|
|
15341
|
+
"use strict";
|
|
15342
|
+
import_node_child_process9 = require("node:child_process");
|
|
15343
|
+
import_node_crypto5 = require("node:crypto");
|
|
15344
|
+
import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
15345
|
+
import_node_os5 = __toESM(require("node:os"), 1);
|
|
15346
|
+
import_node_path12 = __toESM(require("node:path"), 1);
|
|
15347
|
+
import_promises3 = require("node:stream/promises");
|
|
15348
|
+
import_node_url = require("node:url");
|
|
15349
|
+
import_node_util2 = require("node:util");
|
|
15350
|
+
import_node_zlib3 = __toESM(require("node:zlib"), 1);
|
|
15351
|
+
init_swiftTargetContract();
|
|
15352
|
+
compilerArchives = {
|
|
15353
|
+
"swift-6.4.0-RELEASE-custom-77d2c2623ec68c0c": {
|
|
15354
|
+
identity: "77d2c2623ec68c0c",
|
|
15355
|
+
archive: "tar.zst",
|
|
15356
|
+
hosts: {
|
|
15357
|
+
"darwin-arm64": {
|
|
15358
|
+
checksum: "0245c2f6593751cf29ce5920b9686f12097d0d76174c9f242e8d15dfb7ad049a",
|
|
15359
|
+
manifest: "07739120bd00b8fc9270f652ee66599cc45deb80bcc5cd7d45a452567fe6ba9d"
|
|
15360
|
+
},
|
|
15361
|
+
"linux-x64": {
|
|
15362
|
+
checksum: "75fc76f1a683bc52c402c0e969f7ba5c774717d7df571d2b59d0c0e81fa2a75e",
|
|
15363
|
+
manifest: "89c3dee81d47bcbbad10a57ef110f10463e792fb9d5d450463084ccf8d1d5623"
|
|
15364
|
+
},
|
|
15365
|
+
"linux-arm64": {
|
|
15366
|
+
checksum: "2bc4425b7092c74bb7a03a319b41824a295ee5a81f4dbb4e769598dd656a6777",
|
|
15367
|
+
manifest: "4b46e0f2fd8458a9a18f9a5114db616340838108fb476fb55ed5fc9d265fdd09"
|
|
15368
|
+
}
|
|
15369
|
+
}
|
|
15370
|
+
},
|
|
15371
|
+
"swift-6.4.0-RELEASE-custom-34da2e3307f11598": {
|
|
15372
|
+
identity: "34da2e3307f11598",
|
|
15373
|
+
archive: "tar.zst",
|
|
15374
|
+
hosts: {
|
|
15375
|
+
"darwin-arm64": {
|
|
15376
|
+
checksum: "f8f6ded1943979fbd4add8a43940485cb3b36f4dd293aa76b0c17f72d9e1c233",
|
|
15377
|
+
manifest: "7e0e74025935a64f66b9ea5e6a8aee1e730a908227c12686364fa83b665fbb44"
|
|
15378
|
+
},
|
|
15379
|
+
"linux-x64": {
|
|
15380
|
+
checksum: "8761203ffde1721bbd10820ac0dc68ec5d48e034672ba738261e509b1757c160",
|
|
15381
|
+
manifest: "61fe6dcee0f6cc0c895ff511478a264c43b89a14b39bc90c6de8b873ba2f14a6"
|
|
15382
|
+
},
|
|
15383
|
+
"linux-arm64": {
|
|
15384
|
+
checksum: "d0f5312eb032068e38bcdc8dacf12fcf4375ba789a1ee434d31d5e9a24554126",
|
|
15385
|
+
manifest: "9e3218d197c9784e3c434883a21f975222a662523a1ae78a38519e53c3a0385c"
|
|
15386
|
+
}
|
|
15387
|
+
}
|
|
15388
|
+
},
|
|
15389
|
+
"swift-6.4.0-RELEASE-custom-0ebff005f47d6148": {
|
|
15390
|
+
identity: "0ebff005f47d6148",
|
|
15391
|
+
archive: "tar.zst",
|
|
15392
|
+
hosts: {
|
|
15393
|
+
"darwin-arm64": {
|
|
15394
|
+
checksum: "2ddf2c544a17e5ba04c0c2cafd6b49394d9417e8c8d2d1c380846dc003436e10",
|
|
15395
|
+
manifest: "fd7527a60ba728e275afcaf19babf5565f096cd1bcbac9c3d65e238f869df105"
|
|
15396
|
+
},
|
|
15397
|
+
"linux-x64": {
|
|
15398
|
+
checksum: "08f0ad4175b81116842cdb752b34f92fa28133befa81e1813371ba25144b958e",
|
|
15399
|
+
manifest: "f89425fdbe1137005f59875542e2aa9637c5e586f6ae9a107375c4633ff6d425"
|
|
15400
|
+
},
|
|
15401
|
+
"linux-arm64": {
|
|
15402
|
+
checksum: "11b3368e45f8baf5d3fcffe12168744457695757f64c74de0443aac95fcb963b",
|
|
15403
|
+
manifest: "f889ea5d5d6da59af0a278208349e889e5d755571abf6ef4b59f6cf49fa21e0b"
|
|
15404
|
+
}
|
|
15405
|
+
}
|
|
15406
|
+
},
|
|
15407
|
+
"swift-6.4.0-RELEASE-custom-17479c8af01737a3": {
|
|
15408
|
+
identity: "17479c8af01737a3",
|
|
15409
|
+
archive: "tar.zst",
|
|
15410
|
+
hosts: {
|
|
15411
|
+
"darwin-arm64": {
|
|
15412
|
+
checksum: "b41a24b8d9b2ae13e9d6fe3935df69625e2a01cc742056049239415497e99ffb",
|
|
15413
|
+
manifest: "e824fa7f4333aa4307410899987e42863de087db43b2c70b96d4e67de0b0a843"
|
|
15414
|
+
},
|
|
15415
|
+
"linux-x64": {
|
|
15416
|
+
checksum: "fdd6e4ef39698d3a254b4d4967018cf468fdd3b6c6af461719de4c3b3ca126dc",
|
|
15417
|
+
manifest: "a15dc88910eaa012849604b0a866ab028072e526b4f00e611d29762b0cf41c9a"
|
|
15418
|
+
},
|
|
15419
|
+
"linux-arm64": {
|
|
15420
|
+
checksum: "3bfda70b772e13e4751e8ea8ca656e4382b66bc668a0ec4b1ed9740992d4bf50",
|
|
15421
|
+
manifest: "4c069a442d09fe4f92aee7d2d6b40a63a8ea5928c922879e0c4d2a9ac21d65f9"
|
|
15422
|
+
}
|
|
15423
|
+
}
|
|
15424
|
+
},
|
|
15425
|
+
"swift-6.4.0-RELEASE-custom-38af8a6bc3d9e72c": {
|
|
15426
|
+
identity: "38af8a6bc3d9e72c",
|
|
15427
|
+
archive: "tar.zst",
|
|
15428
|
+
hosts: {
|
|
15429
|
+
"darwin-arm64": {
|
|
15430
|
+
checksum: "1a7be355f9763f43e4b9e092a6917e071cbdfd2b6eaf1ba29f33893d2140a952",
|
|
15431
|
+
manifest: "4ea4a563012de05be738cd9d89cd5797408813277ae07a7b7221c22fe16dacbb"
|
|
15432
|
+
},
|
|
15433
|
+
"linux-x64": {
|
|
15434
|
+
checksum: "1daa88ea2c31d2b815414da981df9def4799b8290ba2bd4347a56e73cbce5b68",
|
|
15435
|
+
manifest: "9b2b771a1b8bcf28a5bb52a4c299b94b509cee71ac825feccaff438ad29cc812"
|
|
15436
|
+
},
|
|
15437
|
+
"linux-arm64": {
|
|
15438
|
+
checksum: "3a30617cba08bc5474c0ef24fdecc13ee7759f90c3ce847e00e3bcdb05c0315a",
|
|
15439
|
+
manifest: "f3074c4a2d80641e1a620f52161473de193def016b477cda85c7584b3cfbfd7b"
|
|
15440
|
+
}
|
|
15441
|
+
}
|
|
15442
|
+
},
|
|
15443
|
+
"swift-6.4.0-RELEASE-custom-cd5337e8ab49fd61": {
|
|
15444
|
+
identity: "cd5337e8ab49fd61",
|
|
15445
|
+
archive: "tar.zst",
|
|
15446
|
+
hosts: {
|
|
15447
|
+
"darwin-arm64": {
|
|
15448
|
+
checksum: "a95b73d196daebc342020ecce50ee468c1e5664398825aee79dcb700a10c86b1",
|
|
15449
|
+
manifest: "9b1d49ac08f6a9e710656e9a762d144ec45b142c8ec9ad90bab819a78dd45502"
|
|
15450
|
+
},
|
|
15451
|
+
"linux-x64": {
|
|
15452
|
+
checksum: "fa141d23c542c050bad77805517f9c277bd403b6ca0f4a271354329aaa5d09e6",
|
|
15453
|
+
manifest: "5cd9d1430b61dbe38c728425abd27cd51a8b99256ba026dbf335afb36655c9e4"
|
|
15454
|
+
},
|
|
15455
|
+
"linux-arm64": {
|
|
15456
|
+
checksum: "5b0ee093ff97d1e48b276535ceca35704608fbb10be219bd89cf89226a83d3da",
|
|
15457
|
+
manifest: "177390f9963958d71f5414efa077d728ae728cb0f61e21e3287a989dc939f235"
|
|
15458
|
+
}
|
|
15459
|
+
}
|
|
15460
|
+
},
|
|
15461
|
+
"swift-6.4.0-RELEASE-custom-139bc3bba3c4f73c": {
|
|
15462
|
+
identity: "139bc3bba3c4f73c",
|
|
15463
|
+
archive: "tar.zst",
|
|
15464
|
+
hosts: {
|
|
15465
|
+
"darwin-arm64": {
|
|
15466
|
+
checksum: "4c35af19e099a956f38932e94aa7ea31ee6e8ccf2497a7922b9784e4adba9c4e",
|
|
15467
|
+
manifest: "48753338f405766388e3556e66fbe592ff5af16089f0f577ad91bff267923dae"
|
|
15468
|
+
},
|
|
15469
|
+
"linux-x64": {
|
|
15470
|
+
checksum: "601ba7161cdc2d8fb07701aeb7e81b2bf5368aae23643e56286ff0798f25be9c",
|
|
15471
|
+
manifest: "9b3371f99d5f21b8758abc3497a8ade10e0a49d6373e9979b57eb21edc927b3f"
|
|
15472
|
+
},
|
|
15473
|
+
"linux-arm64": {
|
|
15474
|
+
checksum: "6e8931db639655525acaeb1ab8fffd76e836d2a28b5d9ba384d00f1d2e6da3ed",
|
|
15475
|
+
manifest: "5bfebf5e544c9b8a5e3405923ce57c887c6b87cae7d8891cd25e9ad251e2bc5d"
|
|
15476
|
+
}
|
|
15477
|
+
}
|
|
15478
|
+
},
|
|
15479
|
+
"swift-6.4.0-RELEASE-custom-9f57741c6333ce5e": {
|
|
15480
|
+
identity: "9f57741c6333ce5e",
|
|
15481
|
+
archive: "tar.zst",
|
|
15482
|
+
hosts: {
|
|
15483
|
+
"darwin-arm64": {
|
|
15484
|
+
checksum: "97c80de3caaa961be2f2649a839eb69cec376e8b5aa68a9a1191fcf312eaa002",
|
|
15485
|
+
manifest: "8177dea4013ba47bc0c0e14f5bb3d407a4a94636906e6c8273ef974d93d905b8"
|
|
15486
|
+
},
|
|
15487
|
+
"linux-x64": {
|
|
15488
|
+
checksum: "08bf59a5899990395aa1acc764d312e91c75844a4748a4dcd51061bc0ffbc153",
|
|
15489
|
+
manifest: "8e68a4780c7b29e1b3b43f473518138dc9a6ef63ed8f0fdb2ac3b5a9b487c7f2"
|
|
15490
|
+
},
|
|
15491
|
+
"linux-arm64": {
|
|
15492
|
+
checksum: "aa8a5b2023badafbd910bddd90f702a94338f2e83f5f62f4de17e4e20e240b0e",
|
|
15493
|
+
manifest: "4d0781f9a3648795e9f063c45643dc4f2c1d7bf7b766eee7cd99c726e5f73187"
|
|
15494
|
+
}
|
|
15495
|
+
}
|
|
15496
|
+
},
|
|
15497
|
+
"swift-6.4.0-RELEASE-custom-cbd9cef4b408cc96": {
|
|
15498
|
+
identity: "cbd9cef4b408cc96",
|
|
15499
|
+
archive: "tar.zst",
|
|
15500
|
+
hosts: {
|
|
15501
|
+
"darwin-arm64": {
|
|
15502
|
+
checksum: "97ed2a6b10ae85e73422656fe7b44fdbd5e2343d7082ef2cb39476847988e615",
|
|
15503
|
+
manifest: "49c8002809ba90b16e2619653994bc776b5bc7ef26b98796233d8b425515b734"
|
|
15504
|
+
},
|
|
15505
|
+
"linux-x64": {
|
|
15506
|
+
checksum: "b404cffaa55b783098056cce0ef568d864bc92910dafa89dd0650d0e9d019918",
|
|
15507
|
+
manifest: "19c333d87f2ffc5c716e0561b3bcb0c2a6c6015ccd4a404a739099c6aa3b898f"
|
|
15508
|
+
},
|
|
15509
|
+
"linux-arm64": {
|
|
15510
|
+
checksum: "47d8572b0438f100494edaeb4c7b24fbf5c627d7d02a09fcd68a95c6d2d780f5",
|
|
15511
|
+
manifest: "b27a2bccb5a8a0988414951b3b4a4cd9d3acc315694f59ae4c166c2f41282171"
|
|
15512
|
+
}
|
|
15513
|
+
}
|
|
15514
|
+
},
|
|
15515
|
+
"swift-6.4.0-RELEASE-custom-fb42d2535739dfd2": {
|
|
15516
|
+
identity: "fb42d2535739dfd2",
|
|
15517
|
+
archive: "tar.zst",
|
|
15518
|
+
hosts: {
|
|
15519
|
+
"darwin-arm64": {
|
|
15520
|
+
checksum: "5e417d415ca74a435755e298a1d2d19ec47637fd03479de7a7d958eb382941f1",
|
|
15521
|
+
manifest: "eb5a0356aebabe89c7b2780f8809e13d6e2ad6f342fed87cf99f9a5834344363"
|
|
15522
|
+
},
|
|
15523
|
+
"linux-arm64": {
|
|
15524
|
+
checksum: "8ac7ad97f3d68bf485423001d1ce3cd92a8d4625313c47c8071867a9aeed3af9",
|
|
15525
|
+
manifest: "6126266dd65b43c43d719e4dc4d33c4ea6a3267f99f34e3638637439a995af2e"
|
|
15526
|
+
},
|
|
15527
|
+
"linux-x64": {
|
|
15528
|
+
checksum: "7d76463079619ba822123d250601bd35f6744ed5f8054a657ce472ce4dac76c8",
|
|
15529
|
+
manifest: "f1a6c0c61d15eddb2ecfa4c3a72a5154621881ac2f0c413162ff1d0f4343bd0e"
|
|
15530
|
+
}
|
|
15531
|
+
}
|
|
15532
|
+
},
|
|
15533
|
+
"swift-6.4.0-RELEASE-custom-11345d60dca47496": {
|
|
15534
|
+
identity: "11345d60dca47496",
|
|
15535
|
+
archive: "tar.zst",
|
|
15536
|
+
hosts: {
|
|
15537
|
+
"darwin-arm64": {
|
|
15538
|
+
checksum: "3df74a95c6f3ffa45aaa412027b390c99f9af81f6f6a41bf6d58a1a3079b5b02",
|
|
15539
|
+
manifest: "8e5ed4be6adc967e4c7d955eff004c96d5dc050a589d50e1b3e694b70f9afd63"
|
|
15540
|
+
},
|
|
15541
|
+
"linux-x64": {
|
|
15542
|
+
checksum: "a80e46add069932114bacc18640dc2e6a1a8f2a3ea7306a8ea8614d5cdf6e0e7",
|
|
15543
|
+
manifest: "662d8869534f3cce827b1205973db1f9a1e1d92027005a5bdb6893f9c2a0b39d"
|
|
15544
|
+
},
|
|
15545
|
+
"linux-arm64": {
|
|
15546
|
+
checksum: "4ca69bbc284fc7d54be57c80b744b88cce997d470ff23048795db54e7a6fbcba",
|
|
15547
|
+
manifest: "85df84da2f814b6a71c264b37b83a81965ac33b5d2b465443d60c08cc7bc5dc3"
|
|
15548
|
+
}
|
|
15549
|
+
}
|
|
15550
|
+
},
|
|
15551
|
+
"swift-6.4.0-RELEASE-custom-81b2c791c27276bf": {
|
|
15552
|
+
identity: "81b2c791c27276bf",
|
|
15553
|
+
archive: "tar.gz",
|
|
15554
|
+
hosts: {
|
|
15555
|
+
"darwin-arm64": {
|
|
15556
|
+
checksum: "bc51b83d9e2e01c9873875326544734486d3ff3a868d650379c304045e8838d3",
|
|
15557
|
+
manifest: "a26eb9cb4fbd1dbd7faac20cced1ec5e67745bd358aa1180cc4abc1a0d21d6e6"
|
|
15558
|
+
},
|
|
15559
|
+
"linux-x64": {
|
|
15560
|
+
checksum: "ea63bbdecae14ff8e9e3f535b521fedc65d51b31521c5d10cc332cb91882d058",
|
|
15561
|
+
manifest: "b22b321ce3eb3fe044fa2122484a15c061f262c45d88a05b3fbace0a5bf038b6"
|
|
15562
|
+
},
|
|
15563
|
+
"linux-arm64": {
|
|
15564
|
+
checksum: "3eef4ed57830908515d8def2882e312f7cabeea57ccda5b2a7585401ef98cc48",
|
|
15565
|
+
manifest: "cfab342b8090fa83a697a391a7563cba14b771c24f07e1f8e19977f913ac88be"
|
|
15566
|
+
}
|
|
15567
|
+
}
|
|
15568
|
+
}
|
|
15569
|
+
};
|
|
15570
|
+
linuxRuntimeLibs = {
|
|
15571
|
+
x64: {
|
|
15572
|
+
url: "https://r2.sootsim.com/swift-linux-runtime/libxml2-2.9.14/x64/libxml2.so.2",
|
|
15573
|
+
checksum: "ae1982f7614096bdbd42301e7acc5f74be2aca295eb603cc81ad55d00ddde763"
|
|
15574
|
+
},
|
|
15575
|
+
arm64: {
|
|
15576
|
+
url: "https://r2.sootsim.com/swift-linux-runtime/libxml2-2.9.14/arm64/libxml2.so.2",
|
|
15577
|
+
checksum: "70acdc2a54328159fdff4ec39f5e75bda7b8301af60698b88d8fa99766252b4b"
|
|
15578
|
+
}
|
|
15579
|
+
};
|
|
15580
|
+
SWIFT_PRIVATE_DISTRIBUTION_ENV = "PEACH_SWIFT_PRIVATE_DISTRIBUTION";
|
|
15581
|
+
SWIFT_AUTOLINK_LINKER = ".peach-wasm-ld";
|
|
15582
|
+
BUILDERS_ROOT_ENV = "CONTRAST_BUILDERS_ROOT";
|
|
15583
|
+
SWIFT_CACHE_HOLD_MARKER = ".tm-hold";
|
|
15584
|
+
SWIFT_CACHE_HOLD_MS = 7 * 24 * 36e5;
|
|
15585
|
+
SwiftSdkPayloadMismatch = class extends Error {
|
|
15586
|
+
};
|
|
15587
|
+
listedSdks = /* @__PURE__ */ new Set();
|
|
15588
|
+
sdkBundles = /* @__PURE__ */ new Map();
|
|
15589
|
+
sdkFileHashes = /* @__PURE__ */ new Map();
|
|
15590
|
+
sdkFilesHashed = 0;
|
|
15591
|
+
loadedSdkHashFiles = /* @__PURE__ */ new Set();
|
|
15592
|
+
verifiedCompilers = /* @__PURE__ */ new Map();
|
|
15593
|
+
}
|
|
15594
|
+
});
|
|
15595
|
+
|
|
15596
|
+
// src/one-sdk-preparation.ts
|
|
15597
|
+
async function generateAppSdkInChild(generatorFile, frameworks, options2) {
|
|
15598
|
+
const directory2 = import_node_fs15.default.mkdtempSync(import_node_path13.default.join(import_node_os6.default.tmpdir(), "peach-one-sdk-"));
|
|
15599
|
+
const resultFile = import_node_path13.default.join(directory2, "result.json");
|
|
15600
|
+
try {
|
|
15601
|
+
const child = (0, import_node_child_process10.spawn)(
|
|
15602
|
+
"node",
|
|
15603
|
+
[
|
|
15604
|
+
"--input-type=module",
|
|
15605
|
+
"-e",
|
|
15606
|
+
GENERATE_SCRIPT,
|
|
15607
|
+
generatorFile,
|
|
15608
|
+
resultFile,
|
|
15609
|
+
JSON.stringify(frameworks),
|
|
15610
|
+
JSON.stringify(options2)
|
|
15611
|
+
],
|
|
15612
|
+
{ stdio: ["ignore", "ignore", "pipe"] }
|
|
15613
|
+
);
|
|
15614
|
+
let stderr = "";
|
|
15615
|
+
child.stderr.setEncoding("utf8");
|
|
15616
|
+
child.stderr.on("data", (chunk) => {
|
|
15617
|
+
stderr += chunk;
|
|
15618
|
+
});
|
|
15619
|
+
const [status, signal] = await new Promise(
|
|
15620
|
+
(resolve4, reject) => {
|
|
15621
|
+
child.once("error", reject);
|
|
15622
|
+
child.once("close", (code, closeSignal) => resolve4([code, closeSignal]));
|
|
15623
|
+
}
|
|
15624
|
+
);
|
|
15625
|
+
if (status !== 0)
|
|
15626
|
+
throw new Error(
|
|
15627
|
+
`One SDK source generation failed (${signal ?? `exit ${status}`})${stderr ? `: ${stderr.trim().slice(-2e3)}` : ""}`
|
|
15628
|
+
);
|
|
15629
|
+
const result = JSON.parse(
|
|
15630
|
+
import_node_fs15.default.readFileSync(resultFile, "utf8")
|
|
15631
|
+
);
|
|
15632
|
+
return { generation: result.generation, files: new Map(result.files) };
|
|
15633
|
+
} finally {
|
|
15634
|
+
import_node_fs15.default.rmSync(directory2, { recursive: true, force: true });
|
|
15635
|
+
}
|
|
15636
|
+
}
|
|
15637
|
+
async function selectOneSDK(appRoot) {
|
|
15638
|
+
const require2 = (0, import_node_module2.createRequire)(import_node_path13.default.join(appRoot, "package.json"));
|
|
15639
|
+
let onePackage;
|
|
15640
|
+
try {
|
|
15641
|
+
onePackage = require2.resolve("one/package.json");
|
|
15642
|
+
} catch (error) {
|
|
15643
|
+
if (error instanceof Error && "code" in error && error.code === "MODULE_NOT_FOUND")
|
|
15644
|
+
return null;
|
|
15645
|
+
throw error;
|
|
15646
|
+
}
|
|
15647
|
+
const one = import_node_path13.default.dirname(onePackage);
|
|
15648
|
+
const generatorFile = import_node_path13.default.join(one, "dist/sdk/app.mjs");
|
|
15649
|
+
if (!import_node_fs15.default.existsSync(generatorFile)) return null;
|
|
15650
|
+
const imports2 = /* @__PURE__ */ new Set();
|
|
15651
|
+
const skipped = /* @__PURE__ */ new Set(["node_modules", "ios", "android", "dist", "build", "types"]);
|
|
15652
|
+
async function scan3(directory2) {
|
|
15653
|
+
if (imports2.has("one")) return;
|
|
15654
|
+
for (const entry of import_node_fs15.default.readdirSync(directory2, { withFileTypes: true })) {
|
|
15655
|
+
if (imports2.has("one")) return;
|
|
15656
|
+
if (entry.name.startsWith(".") || skipped.has(entry.name)) continue;
|
|
15657
|
+
const file = import_node_path13.default.join(directory2, entry.name);
|
|
15658
|
+
if (entry.isDirectory()) await scan3(file);
|
|
15659
|
+
else if (/\.[cm]?[jt]sx?$/.test(entry.name) && !/\.d\.[cm]?ts$/.test(entry.name)) {
|
|
15660
|
+
const source = import_node_fs15.default.readFileSync(file, "utf8");
|
|
15661
|
+
if (!/['"]one(?:\/ios\/|['"])/.test(source)) continue;
|
|
15662
|
+
const { code } = (0, import_sucrase.transform)(source, {
|
|
15663
|
+
transforms: ["typescript", "jsx"],
|
|
15664
|
+
filePath: file,
|
|
15665
|
+
disableESTransforms: true
|
|
15666
|
+
});
|
|
15667
|
+
for (const match of code.matchAll(
|
|
15668
|
+
/(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\s*\(\s*)['"](one(?:\/ios\/[A-Za-z_][A-Za-z0-9_]*)?)(?:\/[^'"]*)?['"]/g
|
|
15669
|
+
)) {
|
|
15670
|
+
imports2.add(match[1]);
|
|
15671
|
+
if (match[1] === "one") return;
|
|
15672
|
+
}
|
|
15673
|
+
}
|
|
15674
|
+
}
|
|
15675
|
+
}
|
|
15676
|
+
await scan3(appRoot);
|
|
15677
|
+
if (!imports2.has("one") && !imports2.has("one/ios/UIKit")) return null;
|
|
15678
|
+
const generator = await import((0, import_node_url2.pathToFileURL)(generatorFile).href);
|
|
15679
|
+
const frameworks = imports2.has("one") ? generator.importedFrameworks(appRoot).filter((name3) => name3 === "UIKit") : ["UIKit"];
|
|
15680
|
+
if (!frameworks.length) return null;
|
|
15681
|
+
const options2 = generator.appSdkOptions(appRoot);
|
|
15682
|
+
const selection = Object.fromEntries(
|
|
15683
|
+
frameworks.map((name3) => [
|
|
15684
|
+
name3,
|
|
15685
|
+
(0, import_node_crypto6.createHash)("sha256").update(
|
|
15686
|
+
JSON.stringify(
|
|
15687
|
+
options2.entries?.[name3] === void 0 ? null : [...new Set(options2.entries[name3])].sort((a, b) => a - b)
|
|
15688
|
+
)
|
|
15689
|
+
).digest("hex")
|
|
15690
|
+
])
|
|
15691
|
+
);
|
|
15692
|
+
return { one, generator, frameworks, options: options2, selection };
|
|
15693
|
+
}
|
|
15694
|
+
function oneSDKSourceEntry(one, frameworks, selection) {
|
|
15695
|
+
const digest3 = (file) => (0, import_node_crypto6.createHash)("sha256").update(import_node_fs15.default.readFileSync(import_node_path13.default.join(one, file))).digest("hex");
|
|
15696
|
+
const inputs2 = {
|
|
15697
|
+
generator: digest3("dist/sdk/app.mjs"),
|
|
15698
|
+
manifest: digest3("ios-bindings/manifest.json"),
|
|
15699
|
+
facades: (0, import_node_crypto6.createHash)("sha256").update(
|
|
15700
|
+
frameworks.map((name3) => `${name3}\0${digest3(`ios-bindings/${name3}.ts`)}`).join("\n")
|
|
15701
|
+
).digest("hex"),
|
|
15702
|
+
frameworks: JSON.stringify(frameworks),
|
|
15703
|
+
selection: JSON.stringify(
|
|
15704
|
+
Object.fromEntries(frameworks.map((name3) => [name3, selection[name3]]))
|
|
15705
|
+
)
|
|
15706
|
+
};
|
|
15707
|
+
return { name: "bindings", inputs: inputs2, key: nativeEntryKey(inputs2) };
|
|
15708
|
+
}
|
|
15709
|
+
async function prepareOneSDKSources(appRoot, output) {
|
|
15710
|
+
const selected = await selectOneSDK(appRoot);
|
|
15711
|
+
if (!selected) return;
|
|
15712
|
+
const entry = oneSDKSourceEntry(selected.one, selected.frameworks, selected.selection);
|
|
15713
|
+
const directory2 = output ?? import_node_path13.default.join(appRoot, ONE_SDK_SOURCE_DIRECTORY);
|
|
15714
|
+
const { generation } = JSON.parse(
|
|
15715
|
+
import_node_fs15.default.readFileSync(import_node_path13.default.join(selected.one, "ios-bindings/manifest.json"), "utf8")
|
|
15716
|
+
);
|
|
15717
|
+
if (process.platform !== "darwin") {
|
|
15718
|
+
const published3 = fetchNativeEntry("one-sdk", entry.name, entry.key);
|
|
15719
|
+
if (!published3)
|
|
15720
|
+
throw new Error(
|
|
15721
|
+
`One SDK bindings ${entry.key} are not published for this One version. Run peach upgrade after its native bindings are published.`
|
|
15722
|
+
);
|
|
15723
|
+
const manifest2 = readOneSDKSourceManifest(
|
|
15724
|
+
JSON.parse(import_node_fs15.default.readFileSync(import_node_path13.default.join(published3, "manifest.json"), "utf8"))
|
|
15725
|
+
);
|
|
15726
|
+
if (manifest2.generation !== generation || JSON.stringify(manifest2.frameworks) !== JSON.stringify(selected.frameworks) || selected.frameworks.some(
|
|
15727
|
+
(name3) => manifest2.selection[name3] !== selected.selection[name3]
|
|
15728
|
+
))
|
|
15729
|
+
throw new Error(
|
|
15730
|
+
"published One SDK sources differ from the installed facades or app imports"
|
|
15731
|
+
);
|
|
15732
|
+
import_node_fs15.default.rmSync(directory2, { recursive: true, force: true });
|
|
15733
|
+
import_node_fs15.default.mkdirSync(directory2, { recursive: true });
|
|
15734
|
+
for (const name3 of [...manifest2.files, "manifest.json"])
|
|
15735
|
+
import_node_fs15.default.copyFileSync(import_node_path13.default.join(published3, name3), import_node_path13.default.join(directory2, name3));
|
|
15736
|
+
return;
|
|
15737
|
+
}
|
|
15738
|
+
const localCache = import_node_path13.default.join(swiftCacheDir(), "one-sdk-sources", entry.key);
|
|
15739
|
+
const localManifestPath = import_node_path13.default.join(localCache, "manifest.json");
|
|
15740
|
+
if (import_node_fs15.default.existsSync(localManifestPath)) {
|
|
15741
|
+
const manifest2 = readOneSDKSourceManifest(
|
|
15742
|
+
JSON.parse(import_node_fs15.default.readFileSync(localManifestPath, "utf8"))
|
|
15743
|
+
);
|
|
15744
|
+
if (manifest2.generation === generation && JSON.stringify(manifest2.frameworks) === JSON.stringify(selected.frameworks) && selected.frameworks.every(
|
|
15745
|
+
(name3) => manifest2.selection[name3] === selected.selection[name3]
|
|
15746
|
+
) && manifest2.files.every((name3) => import_node_fs15.default.existsSync(import_node_path13.default.join(localCache, name3)))) {
|
|
15747
|
+
import_node_fs15.default.rmSync(directory2, { recursive: true, force: true });
|
|
15748
|
+
import_node_fs15.default.mkdirSync(directory2, { recursive: true });
|
|
15749
|
+
for (const name3 of [...manifest2.files, "manifest.json"])
|
|
15750
|
+
import_node_fs15.default.copyFileSync(import_node_path13.default.join(localCache, name3), import_node_path13.default.join(directory2, name3));
|
|
15751
|
+
return;
|
|
15752
|
+
}
|
|
15753
|
+
}
|
|
15754
|
+
const generated = await generateAppSdkInChild(
|
|
15755
|
+
import_node_path13.default.join(selected.one, "dist/sdk/app.mjs"),
|
|
15756
|
+
selected.frameworks,
|
|
15757
|
+
selected.options
|
|
15758
|
+
);
|
|
15759
|
+
if (generated.generation !== generation)
|
|
15760
|
+
throw new Error("One SDK source generation differs from the installed facades");
|
|
15761
|
+
import_node_fs15.default.rmSync(directory2, { recursive: true, force: true });
|
|
15762
|
+
import_node_fs15.default.mkdirSync(directory2, { recursive: true });
|
|
15763
|
+
for (const [name3, from] of generated.files)
|
|
15764
|
+
import_node_fs15.default.copyFileSync(from, import_node_path13.default.join(directory2, name3));
|
|
15765
|
+
const manifest = {
|
|
15766
|
+
generation,
|
|
15767
|
+
frameworks: selected.frameworks,
|
|
15768
|
+
selection: selected.selection,
|
|
15769
|
+
files: [...generated.files.keys()]
|
|
15770
|
+
};
|
|
15771
|
+
const manifestJson = JSON.stringify(manifest);
|
|
15772
|
+
import_node_fs15.default.writeFileSync(import_node_path13.default.join(directory2, "manifest.json"), manifestJson);
|
|
15773
|
+
import_node_fs15.default.mkdirSync(import_node_path13.default.dirname(localCache), { recursive: true });
|
|
15774
|
+
const staging = import_node_fs15.default.mkdtempSync(`${localCache}.tmp-`);
|
|
15775
|
+
try {
|
|
15776
|
+
for (const [name3, from] of generated.files)
|
|
15777
|
+
import_node_fs15.default.copyFileSync(from, import_node_path13.default.join(staging, name3));
|
|
15778
|
+
import_node_fs15.default.writeFileSync(import_node_path13.default.join(staging, "manifest.json"), manifestJson);
|
|
15779
|
+
import_node_fs15.default.renameSync(staging, localCache);
|
|
15780
|
+
} catch (error) {
|
|
15781
|
+
import_node_fs15.default.rmSync(staging, { recursive: true, force: true });
|
|
15782
|
+
if (!import_node_fs15.default.existsSync(localManifestPath)) throw error;
|
|
15783
|
+
}
|
|
15784
|
+
}
|
|
15785
|
+
var import_node_child_process10, import_node_crypto6, import_node_fs15, import_node_module2, import_node_os6, import_node_path13, import_node_url2, import_sucrase, GENERATE_SCRIPT;
|
|
15786
|
+
var init_one_sdk_preparation = __esm({
|
|
15787
|
+
"src/one-sdk-preparation.ts"() {
|
|
15788
|
+
"use strict";
|
|
15789
|
+
import_node_child_process10 = require("node:child_process");
|
|
15790
|
+
import_node_crypto6 = require("node:crypto");
|
|
15791
|
+
import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
15792
|
+
import_node_module2 = require("node:module");
|
|
15793
|
+
import_node_os6 = __toESM(require("node:os"), 1);
|
|
15794
|
+
import_node_path13 = __toESM(require("node:path"), 1);
|
|
15795
|
+
import_node_url2 = require("node:url");
|
|
15796
|
+
import_sucrase = require("peachsim/vendor/sucrase");
|
|
15797
|
+
init_native_prebuilt();
|
|
15798
|
+
init_oneSdkContract();
|
|
15799
|
+
init_swift_toolchain();
|
|
15800
|
+
GENERATE_SCRIPT = `
|
|
15801
|
+
import { writeFileSync } from 'node:fs'
|
|
15802
|
+
import { pathToFileURL } from 'node:url'
|
|
15803
|
+
const [generatorFile, resultFile, frameworks, options] = process.argv.slice(1)
|
|
15804
|
+
const generator = await import(pathToFileURL(generatorFile).href)
|
|
15805
|
+
const { files, generation } = await generator.generateAppSdk(JSON.parse(frameworks), undefined, JSON.parse(options))
|
|
15806
|
+
writeFileSync(resultFile, JSON.stringify({ generation, files: [...files] }))
|
|
15807
|
+
`;
|
|
15808
|
+
}
|
|
15809
|
+
});
|
|
15810
|
+
|
|
15811
|
+
// src/pbx-table.ts
|
|
15812
|
+
function normalizeArraySettings(settings, objectVersion) {
|
|
15813
|
+
const arraySettings = Number(objectVersion) >= 50 ? ARRAY_SETTINGS : LEGACY_ARRAY_SETTINGS;
|
|
15814
|
+
for (const key2 of Object.keys(settings)) {
|
|
15815
|
+
const value = settings[key2];
|
|
15816
|
+
if (!value) continue;
|
|
15817
|
+
const stripped2 = key2.replace(/\[[^\]]+\]$/, "");
|
|
15818
|
+
if (typeof value === "string") {
|
|
15819
|
+
if (!arraySettings.has(stripped2)) continue;
|
|
15820
|
+
const parts = [...value.matchAll(/ *((['"]?).*?[^\\]\2)(?= |(?![\s\S]))/g)].map(
|
|
15821
|
+
(match) => match[1]
|
|
15822
|
+
);
|
|
15823
|
+
if (parts.length > 1) settings[key2] = parts;
|
|
15824
|
+
} else if (Array.isArray(value)) {
|
|
15825
|
+
if (value.length > 1 && arraySettings.has(stripped2)) continue;
|
|
15826
|
+
settings[key2] = value.map((item) => typeof item === "string" ? item : "").join(" ");
|
|
15827
|
+
}
|
|
15828
|
+
}
|
|
15829
|
+
}
|
|
15830
|
+
function serializePbxproj(objects, rootObject, objectVersion) {
|
|
15831
|
+
const write = (value, depth) => {
|
|
15832
|
+
const indent2 = " ".repeat(depth);
|
|
15833
|
+
if (typeof value === "string") return quote(value);
|
|
15834
|
+
if (Array.isArray(value))
|
|
15835
|
+
return `(
|
|
15836
|
+
${value.map((item) => `${indent2} ${write(item, depth + 1)},
|
|
15837
|
+
`).join("")}${indent2})`;
|
|
15838
|
+
const keys = Object.keys(value).sort(
|
|
15839
|
+
(a, b) => a === "isa" ? -1 : b === "isa" ? 1 : byBytes(a, b)
|
|
15840
|
+
);
|
|
15841
|
+
return `{
|
|
15842
|
+
${keys.map((key2) => `${indent2} ${quote(key2)} = ${write(value[key2], depth + 1)};
|
|
15843
|
+
`).join("")}${indent2}}`;
|
|
15844
|
+
};
|
|
15845
|
+
const byIsa = /* @__PURE__ */ new Map();
|
|
15846
|
+
for (const id of Object.keys(objects).sort(byBytes)) {
|
|
15847
|
+
const isa = String(objects[id].isa);
|
|
15848
|
+
byIsa.set(isa, [...byIsa.get(isa) ?? [], id]);
|
|
15849
|
+
}
|
|
15850
|
+
const sections = [...byIsa.keys()].sort(byBytes).map(
|
|
15851
|
+
(isa) => `
|
|
15852
|
+
/* Begin ${isa} section */
|
|
15853
|
+
${byIsa.get(isa).map((id) => ` ${quote(id)} = ${write(objects[id], 2)};
|
|
15854
|
+
`).join("")}/* End ${isa} section */
|
|
15855
|
+
`
|
|
15856
|
+
);
|
|
15857
|
+
return `// !$*UTF8*$!
|
|
15858
|
+
{
|
|
15859
|
+
archiveVersion = 1;
|
|
15860
|
+
classes = {
|
|
15861
|
+
};
|
|
15862
|
+
objectVersion = ${objectVersion};
|
|
15863
|
+
objects = {
|
|
15864
|
+
${sections.join("")} };
|
|
15865
|
+
rootObject = ${quote(rootObject)};
|
|
15866
|
+
}
|
|
15867
|
+
`;
|
|
15868
|
+
}
|
|
15869
|
+
var import_node_crypto7, isIdList, PbxTable, ARRAY_SETTINGS, LEGACY_ARRAY_SETTINGS, PLAIN_STRING, STRING_ESCAPES, quote, byBytes;
|
|
15870
|
+
var init_pbx_table = __esm({
|
|
15871
|
+
"src/pbx-table.ts"() {
|
|
15872
|
+
"use strict";
|
|
15873
|
+
import_node_crypto7 = require("node:crypto");
|
|
15874
|
+
init_openstep_plist();
|
|
14770
15875
|
isIdList = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
14771
15876
|
PbxTable = class {
|
|
14772
15877
|
constructor(objects = {}, rootObject = "") {
|
|
@@ -14775,9 +15880,9 @@ var init_pbx_table = __esm({
|
|
|
14775
15880
|
}
|
|
14776
15881
|
/** adds `object` under an id derived from `seed`, which names it among the objects. */
|
|
14777
15882
|
add(seed, object8) {
|
|
14778
|
-
let id = (0,
|
|
15883
|
+
let id = (0, import_node_crypto7.createHash)("sha1").update(seed).digest("hex").slice(0, 24).toUpperCase();
|
|
14779
15884
|
for (let n = 1; this.objects[id]; n++)
|
|
14780
|
-
id = (0,
|
|
15885
|
+
id = (0, import_node_crypto7.createHash)("sha1").update(`${seed}#${n}`).digest("hex").slice(0, 24).toUpperCase();
|
|
14781
15886
|
this.objects[id] = object8;
|
|
14782
15887
|
return id;
|
|
14783
15888
|
}
|
|
@@ -14889,16 +15994,16 @@ var init_pbx_table = __esm({
|
|
|
14889
15994
|
|
|
14890
15995
|
// src/pod-graph-specifications.ts
|
|
14891
15996
|
function readPodGraphSpecifications(file) {
|
|
14892
|
-
const value = JSON.parse(
|
|
15997
|
+
const value = JSON.parse(import_node_fs16.default.readFileSync(file, "utf8"));
|
|
14893
15998
|
if (!isRecord(value) || !Object.values(value).every((item) => typeof item === "string"))
|
|
14894
15999
|
throw new Error(`${file}: invalid pod graph specifications`);
|
|
14895
16000
|
return new Map(Object.entries(value).map(([name3, json]) => [name3, String(json)]));
|
|
14896
16001
|
}
|
|
14897
|
-
var
|
|
16002
|
+
var import_node_fs16, POD_GRAPH_SPECIFICATIONS;
|
|
14898
16003
|
var init_pod_graph_specifications = __esm({
|
|
14899
16004
|
"src/pod-graph-specifications.ts"() {
|
|
14900
16005
|
"use strict";
|
|
14901
|
-
|
|
16006
|
+
import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
14902
16007
|
init_is_record();
|
|
14903
16008
|
POD_GRAPH_SPECIFICATIONS = ".peach-podspecs.json";
|
|
14904
16009
|
}
|
|
@@ -16950,1210 +18055,138 @@ var init_swift_c_predefines = __esm({
|
|
|
16950
18055
|
__unsafe_unretained: "__attribute__((objc_ownership(none)))",
|
|
16951
18056
|
__weak: "__attribute__((objc_ownership(weak)))"
|
|
16952
18057
|
}
|
|
16953
|
-
}
|
|
16954
|
-
};
|
|
16955
|
-
}
|
|
16956
|
-
});
|
|
16957
|
-
|
|
16958
|
-
// src/process-liveness.ts
|
|
16959
|
-
function isProcessRunning(pid) {
|
|
16960
|
-
if (process.platform === "linux") {
|
|
16961
|
-
try {
|
|
16962
|
-
const stat = (0, import_node_fs16.readFileSync)(`/proc/${pid}/stat`, "utf8");
|
|
16963
|
-
const state = stat.charAt(stat.lastIndexOf(")") + 2);
|
|
16964
|
-
return state !== "Z" && state !== "X";
|
|
16965
|
-
} catch {
|
|
16966
|
-
return false;
|
|
16967
|
-
}
|
|
16968
|
-
}
|
|
16969
|
-
try {
|
|
16970
|
-
process.kill(pid, 0);
|
|
16971
|
-
return true;
|
|
16972
|
-
} catch (error) {
|
|
16973
|
-
return error instanceof Error && Reflect.get(error, "code") === "EPERM";
|
|
16974
|
-
}
|
|
16975
|
-
}
|
|
16976
|
-
var import_node_fs16;
|
|
16977
|
-
var init_process_liveness = __esm({
|
|
16978
|
-
"src/process-liveness.ts"() {
|
|
16979
|
-
"use strict";
|
|
16980
|
-
import_node_fs16 = require("node:fs");
|
|
16981
|
-
}
|
|
16982
|
-
});
|
|
16983
|
-
|
|
16984
|
-
// src/retired-cache-directory.ts
|
|
16985
|
-
function removeRetiredDirectory(directory2) {
|
|
16986
|
-
void (0, import_promises3.rm)(directory2, { recursive: true, force: true, maxRetries: 3 }).catch(
|
|
16987
|
-
(error) => console.warn(
|
|
16988
|
-
`[peach] retired cache directory ${directory2} stays for a later prune: ${error}`
|
|
16989
|
-
)
|
|
16990
|
-
);
|
|
16991
|
-
}
|
|
16992
|
-
function reapRetiredCacheDirectory(parent, name3) {
|
|
16993
|
-
const owner = /^\.retired-(\d+)-/.exec(name3);
|
|
16994
|
-
if (!owner || isProcessRunning(Number(owner[1]))) return;
|
|
16995
|
-
const directory2 = import_node_path13.default.join(parent, name3);
|
|
16996
|
-
const claimed = import_node_path13.default.join(parent, `.retired-${process.pid}-${(0, import_node_crypto7.randomUUID)()}`);
|
|
16997
|
-
try {
|
|
16998
|
-
(0, import_node_fs17.renameSync)(directory2, claimed);
|
|
16999
|
-
} catch (error) {
|
|
17000
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") return;
|
|
17001
|
-
throw error;
|
|
17002
|
-
}
|
|
17003
|
-
removeRetiredDirectory(claimed);
|
|
17004
|
-
}
|
|
17005
|
-
var import_node_crypto7, import_node_fs17, import_promises3, import_node_path13;
|
|
17006
|
-
var init_retired_cache_directory = __esm({
|
|
17007
|
-
"src/retired-cache-directory.ts"() {
|
|
17008
|
-
"use strict";
|
|
17009
|
-
import_node_crypto7 = require("node:crypto");
|
|
17010
|
-
import_node_fs17 = require("node:fs");
|
|
17011
|
-
import_promises3 = require("node:fs/promises");
|
|
17012
|
-
import_node_path13 = __toESM(require("node:path"), 1);
|
|
17013
|
-
init_process_liveness();
|
|
17014
|
-
}
|
|
17015
|
-
});
|
|
17016
|
-
|
|
17017
|
-
// src/swift-compile-budget.ts
|
|
17018
|
-
function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
|
|
17019
|
-
return SWIFT_LOCK_WAIT_TIMEOUT_MS + (compileTimeoutMs ?? SWIFT_COMPILE_TIMEOUT_MS) + SWIFT_TRANSPORT_MARGIN_MS;
|
|
17020
|
-
}
|
|
17021
|
-
async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
|
|
17022
|
-
const deadline = new AbortController();
|
|
17023
|
-
const combined = signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal;
|
|
17024
|
-
let timer = setTimeout(
|
|
17025
|
-
() => deadline.abort(new Error("Swift build lock wait timed out")),
|
|
17026
|
-
SWIFT_LOCK_WAIT_TIMEOUT_MS
|
|
17027
|
-
);
|
|
17028
|
-
try {
|
|
17029
|
-
combined.throwIfAborted();
|
|
17030
|
-
const result = await work({
|
|
17031
|
-
signal: combined,
|
|
17032
|
-
startCompile() {
|
|
17033
|
-
combined.throwIfAborted();
|
|
17034
|
-
clearTimeout(timer);
|
|
17035
|
-
timer = setTimeout(
|
|
17036
|
-
() => deadline.abort(new Error("Swift compilation timed out")),
|
|
17037
|
-
compileTimeoutMs ?? SWIFT_COMPILE_TIMEOUT_MS
|
|
17038
|
-
);
|
|
17039
|
-
}
|
|
17040
|
-
});
|
|
17041
|
-
combined.throwIfAborted();
|
|
17042
|
-
return result;
|
|
17043
|
-
} finally {
|
|
17044
|
-
clearTimeout(timer);
|
|
17045
|
-
}
|
|
17046
|
-
}
|
|
17047
|
-
var SWIFT_COMPILE_TIMEOUT_MS, SWIFT_LOCK_WAIT_TIMEOUT_MS, SWIFT_TRANSPORT_MARGIN_MS;
|
|
17048
|
-
var init_swift_compile_budget = __esm({
|
|
17049
|
-
"src/swift-compile-budget.ts"() {
|
|
17050
|
-
"use strict";
|
|
17051
|
-
SWIFT_COMPILE_TIMEOUT_MS = 18e5;
|
|
17052
|
-
SWIFT_LOCK_WAIT_TIMEOUT_MS = 36e5;
|
|
17053
|
-
SWIFT_TRANSPORT_MARGIN_MS = 3e5;
|
|
17054
|
-
}
|
|
17055
|
-
});
|
|
17056
|
-
|
|
17057
|
-
// src/swift-objc-sdk-tree.ts
|
|
17058
|
-
function readIosSdkTree(root) {
|
|
17059
|
-
return (0, import_node_fs18.readdirSync)(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => {
|
|
17060
|
-
const file = import_node_path14.default.join(entry.parentPath, entry.name);
|
|
17061
|
-
return [
|
|
17062
|
-
import_node_path14.default.relative(root, file).split(import_node_path14.default.sep).join("/"),
|
|
17063
|
-
(0, import_node_fs18.readFileSync)(file, "utf8")
|
|
17064
|
-
];
|
|
17065
|
-
}).sort(([a], [b]) => a < b ? -1 : 1);
|
|
17066
|
-
}
|
|
17067
|
-
var import_node_fs18, import_node_path14;
|
|
17068
|
-
var init_swift_objc_sdk_tree = __esm({
|
|
17069
|
-
"src/swift-objc-sdk-tree.ts"() {
|
|
17070
|
-
"use strict";
|
|
17071
|
-
import_node_fs18 = require("node:fs");
|
|
17072
|
-
import_node_path14 = __toESM(require("node:path"), 1);
|
|
17073
|
-
}
|
|
17074
|
-
});
|
|
17075
|
-
|
|
17076
|
-
// src/swift-compiler-digest.ts
|
|
17077
|
-
var import_node_crypto8, import_node_fs19, import_node_path15;
|
|
17078
|
-
var init_swift_compiler_digest = __esm({
|
|
17079
|
-
"src/swift-compiler-digest.ts"() {
|
|
17080
|
-
"use strict";
|
|
17081
|
-
import_node_crypto8 = require("node:crypto");
|
|
17082
|
-
import_node_fs19 = require("node:fs");
|
|
17083
|
-
import_node_path15 = __toESM(require("node:path"), 1);
|
|
17084
|
-
init_swift_objc_sdk_tree();
|
|
17085
|
-
}
|
|
17086
|
-
});
|
|
17087
|
-
|
|
17088
|
-
// src/swiftTargetContract.ts
|
|
17089
|
-
var SWIFT_WASM_TRIPLE, WASI_LIBC_TRIPLE, wasmThreadFlags, swiftWasmThreadFlags, wasmThreadLinkFlags;
|
|
17090
|
-
var init_swiftTargetContract = __esm({
|
|
17091
|
-
"src/swiftTargetContract.ts"() {
|
|
17092
|
-
"use strict";
|
|
17093
|
-
SWIFT_WASM_TRIPLE = "wasm64-unknown-wasip1-threads";
|
|
17094
|
-
WASI_LIBC_TRIPLE = "wasm64-wasip1-threads";
|
|
17095
|
-
wasmThreadFlags = [
|
|
17096
|
-
"-pthread",
|
|
17097
|
-
"-matomics",
|
|
17098
|
-
"-mbulk-memory",
|
|
17099
|
-
"-ftls-model=local-exec"
|
|
17100
|
-
];
|
|
17101
|
-
swiftWasmThreadFlags = wasmThreadFlags.flatMap((flag) => ["-Xcc", flag]);
|
|
17102
|
-
wasmThreadLinkFlags = [
|
|
17103
|
-
"--import-memory",
|
|
17104
|
-
"--export-memory",
|
|
17105
|
-
"--shared-memory",
|
|
17106
|
-
"--max-memory=4294967296",
|
|
17107
|
-
"--growable-table",
|
|
17108
|
-
"--export=__stack_pointer",
|
|
17109
|
-
"--export=__tls_base",
|
|
17110
|
-
"--export=__wasm_init_tls",
|
|
17111
|
-
"--export=__tls_size",
|
|
17112
|
-
"--export=__tls_align",
|
|
17113
|
-
"--export=__stack_low",
|
|
17114
|
-
"--export=__stack_high",
|
|
17115
|
-
"--export=__data_end",
|
|
17116
|
-
"--export=__heap_base",
|
|
17117
|
-
"--export-table",
|
|
17118
|
-
"--export=wasi_thread_start"
|
|
17119
|
-
];
|
|
17120
|
-
}
|
|
17121
|
-
});
|
|
17122
|
-
|
|
17123
|
-
// src/swift-toolchain.ts
|
|
17124
|
-
function peachsimPackageRoot() {
|
|
17125
|
-
let dir = __sootsim_import_meta_dirname;
|
|
17126
|
-
while (!import_node_fs20.default.existsSync(import_node_path16.default.join(dir, "package.json")) && dir !== import_node_path16.default.dirname(dir))
|
|
17127
|
-
dir = import_node_path16.default.dirname(dir);
|
|
17128
|
-
return dir;
|
|
17129
|
-
}
|
|
17130
|
-
function sourceSwiftCheckout() {
|
|
17131
|
-
return import_node_path16.default.resolve(peachsimPackageRoot(), "../sootsim-swift");
|
|
17132
|
-
}
|
|
17133
|
-
function swiftSdkOptions() {
|
|
17134
|
-
return ["--swift-sdks-path", import_node_path16.default.resolve(peachSwiftSdksDir())];
|
|
17135
|
-
}
|
|
17136
|
-
function privateSwiftDistributionRoot() {
|
|
17137
|
-
const root = process.env[SWIFT_PRIVATE_DISTRIBUTION_ENV]?.trim();
|
|
17138
|
-
return root ? import_node_path16.default.resolve(root) : null;
|
|
17139
|
-
}
|
|
17140
|
-
function privateSwiftCompilerRelease() {
|
|
17141
|
-
return process.env.PEACH_SWIFT_PRIVATE_COMPILER_RELEASE?.trim() || null;
|
|
17142
|
-
}
|
|
17143
|
-
function privateSwiftRelease() {
|
|
17144
|
-
const compiler = privateSwiftCompilerRelease();
|
|
17145
|
-
if (compiler) return compiler;
|
|
17146
|
-
const root = privateSwiftDistributionRoot();
|
|
17147
|
-
if (!root) return null;
|
|
17148
|
-
const manifest = JSON.parse(
|
|
17149
|
-
import_node_fs20.default.readFileSync(import_node_path16.default.join(root, "distribution.json"), "utf8")
|
|
17150
|
-
);
|
|
17151
|
-
const release = manifest && typeof manifest === "object" && Reflect.get(manifest, "release");
|
|
17152
|
-
if (typeof release !== "string")
|
|
17153
|
-
throw new Error(`${root} holds no Swift distribution release`);
|
|
17154
|
-
return release;
|
|
17155
|
-
}
|
|
17156
|
-
function swiftLinuxRuntimeLib(arch = process.arch) {
|
|
17157
|
-
const lib = linuxRuntimeLibs[arch];
|
|
17158
|
-
if (!lib) throw new Error(`unsupported Swift Linux runtime host ${arch}`);
|
|
17159
|
-
return { ...lib };
|
|
17160
|
-
}
|
|
17161
|
-
function installSwiftLinuxRuntime(root, arch = process.arch) {
|
|
17162
|
-
const { url, checksum } = swiftLinuxRuntimeLib(arch);
|
|
17163
|
-
const dest = import_node_path16.default.join(root, "usr/lib/libxml2.so.2");
|
|
17164
|
-
const link = import_node_path16.default.join(root, "usr/lib/swift/linux/libxml2.so.2");
|
|
17165
|
-
import_node_fs20.default.mkdirSync(import_node_path16.default.dirname(dest), { recursive: true });
|
|
17166
|
-
import_node_fs20.default.mkdirSync(import_node_path16.default.dirname(link), { recursive: true });
|
|
17167
|
-
if (!import_node_fs20.default.existsSync(dest) || swiftFileChecksum(dest) !== checksum) {
|
|
17168
|
-
process.stderr.write(`peach: installing Linux runtime libxml2.so.2 into ${root}\u2026
|
|
17169
|
-
`);
|
|
17170
|
-
const download2 = `${dest}.${process.pid}.tmp`;
|
|
17171
|
-
try {
|
|
17172
|
-
(0, import_node_child_process10.execFileSync)(
|
|
17173
|
-
"curl",
|
|
17174
|
-
[
|
|
17175
|
-
"-fsSL",
|
|
17176
|
-
"--show-error",
|
|
17177
|
-
"--retry",
|
|
17178
|
-
"3",
|
|
17179
|
-
"--retry-all-errors",
|
|
17180
|
-
url,
|
|
17181
|
-
"-o",
|
|
17182
|
-
download2
|
|
17183
|
-
],
|
|
17184
|
-
{
|
|
17185
|
-
stdio: "inherit"
|
|
17186
|
-
}
|
|
17187
|
-
);
|
|
17188
|
-
if (swiftFileChecksum(download2) !== checksum)
|
|
17189
|
-
throw new Error("declared Linux runtime checksum mismatch");
|
|
17190
|
-
import_node_fs20.default.renameSync(download2, dest);
|
|
17191
|
-
} finally {
|
|
17192
|
-
import_node_fs20.default.rmSync(download2, { force: true });
|
|
17193
|
-
}
|
|
17194
|
-
}
|
|
17195
|
-
const staged = `${link}.${process.pid}.tmp`;
|
|
17196
|
-
import_node_fs20.default.rmSync(staged, { force: true });
|
|
17197
|
-
import_node_fs20.default.symlinkSync("../../libxml2.so.2", staged);
|
|
17198
|
-
import_node_fs20.default.renameSync(staged, link);
|
|
17199
|
-
}
|
|
17200
|
-
function ensureSwiftLinuxRuntime(release) {
|
|
17201
|
-
if (process.platform !== "linux" || !release.includes("-custom-")) return;
|
|
17202
|
-
const root = import_node_path16.default.resolve(swiftToolchainBin(release), "../..");
|
|
17203
|
-
if (root !== import_node_path16.default.join(peachHome(), "swift", "toolchains", release) || !import_node_fs20.default.existsSync(root))
|
|
17204
|
-
return;
|
|
17205
|
-
installSwiftLinuxRuntime(root);
|
|
17206
|
-
for (const name3 of ["lib", "lib64"]) {
|
|
17207
|
-
try {
|
|
17208
|
-
import_node_fs20.default.symlinkSync(`usr/${name3}`, import_node_path16.default.join(root, name3));
|
|
17209
|
-
} catch (error) {
|
|
17210
|
-
if (!(error instanceof Error) || !("code" in error) || error.code !== "EEXIST")
|
|
17211
|
-
throw error;
|
|
17212
|
-
}
|
|
18058
|
+
}
|
|
18059
|
+
};
|
|
17213
18060
|
}
|
|
17214
|
-
|
|
17215
|
-
|
|
17216
|
-
|
|
17217
|
-
|
|
17218
|
-
if (
|
|
17219
|
-
|
|
17220
|
-
}
|
|
17221
|
-
|
|
17222
|
-
|
|
17223
|
-
}
|
|
17224
|
-
|
|
17225
|
-
const compiler = swiftHostCompilerPin(release);
|
|
17226
|
-
const archive = compiler.hosts[host2];
|
|
17227
|
-
if (!archive) throw new Error(`unsupported Swift compiler host ${host2}`);
|
|
17228
|
-
return {
|
|
17229
|
-
...archive,
|
|
17230
|
-
identity: compiler.identity,
|
|
17231
|
-
archive: compiler.archive,
|
|
17232
|
-
url: `https://r2.sootsim.com/swift-host-compiler/${compiler.identity}/${archive.checksum}.${compiler.archive}`
|
|
17233
|
-
};
|
|
17234
|
-
}
|
|
17235
|
-
function swiftHostCompilerTar(archive, url) {
|
|
17236
|
-
const file = import_node_fs20.default.createReadStream(archive);
|
|
17237
|
-
const decoder = url.endsWith(".tar.zst") ? import_node_zlib3.default.createZstdDecompress({ params: { [import_node_zlib3.default.constants.ZSTD_d_windowLogMax]: 30 } }) : import_node_zlib3.default.createGunzip();
|
|
17238
|
-
file.on("error", (error) => decoder.destroy(error));
|
|
17239
|
-
return file.pipe(decoder);
|
|
17240
|
-
}
|
|
17241
|
-
async function extractSwiftTar(archive, url, destination, options2 = []) {
|
|
17242
|
-
const tar = (0, import_node_child_process10.spawn)(
|
|
17243
|
-
"tar",
|
|
17244
|
-
["--ignore-zeros", "-xf", "-", "-C", destination, ...options2],
|
|
17245
|
-
{
|
|
17246
|
-
stdio: ["pipe", "inherit", "inherit"]
|
|
18061
|
+
});
|
|
18062
|
+
|
|
18063
|
+
// src/process-liveness.ts
|
|
18064
|
+
function isProcessRunning(pid) {
|
|
18065
|
+
if (process.platform === "linux") {
|
|
18066
|
+
try {
|
|
18067
|
+
const stat = (0, import_node_fs17.readFileSync)(`/proc/${pid}/stat`, "utf8");
|
|
18068
|
+
const state = stat.charAt(stat.lastIndexOf(")") + 2);
|
|
18069
|
+
return state !== "Z" && state !== "X";
|
|
18070
|
+
} catch {
|
|
18071
|
+
return false;
|
|
17247
18072
|
}
|
|
17248
|
-
);
|
|
17249
|
-
const exited = new Promise((resolve4, reject) => {
|
|
17250
|
-
tar.on("error", reject);
|
|
17251
|
-
tar.on("close", resolve4);
|
|
17252
|
-
});
|
|
17253
|
-
const [, code] = await Promise.all([
|
|
17254
|
-
(0, import_promises4.pipeline)(swiftHostCompilerTar(archive, url), tar.stdin),
|
|
17255
|
-
exited
|
|
17256
|
-
]);
|
|
17257
|
-
if (code !== 0) throw new Error(`tar exited with ${code} unpacking ${archive}`);
|
|
17258
|
-
}
|
|
17259
|
-
function swiftUpstreamRelease(release) {
|
|
17260
|
-
return release.replace(/-custom-[a-f0-9]{16}$/, "");
|
|
17261
|
-
}
|
|
17262
|
-
function swiftCompilerRelease(release) {
|
|
17263
|
-
return swiftUpstreamRelease(release).replace(
|
|
17264
|
-
/^swift-(\d+\.\d+)\.0-RELEASE$/,
|
|
17265
|
-
"swift-$1-RELEASE"
|
|
17266
|
-
);
|
|
17267
|
-
}
|
|
17268
|
-
function swiftToolchainBin(release) {
|
|
17269
|
-
if (process.platform === "darwin") {
|
|
17270
|
-
const dirs = [import_node_os6.default.homedir(), "/"].map(
|
|
17271
|
-
(base2) => import_node_path16.default.join(base2, `Library/Developer/Toolchains/${release}.xctoolchain/usr/bin`)
|
|
17272
|
-
);
|
|
17273
|
-
const found = dirs.find((dir) => import_node_fs20.default.existsSync(import_node_path16.default.join(dir, "swift")));
|
|
17274
|
-
return found ? import_node_fs20.default.realpathSync(found) : dirs[0];
|
|
17275
|
-
}
|
|
17276
|
-
if (process.env.CONTRAST_SWIFT_TOOLCHAINS) {
|
|
17277
|
-
return import_node_path16.default.join(process.env.CONTRAST_SWIFT_TOOLCHAINS, release, "usr/bin");
|
|
17278
|
-
}
|
|
17279
|
-
const image = import_node_path16.default.join("/opt/swift", release, "usr/bin");
|
|
17280
|
-
if (import_node_fs20.default.existsSync(import_node_path16.default.join(image, "swift"))) return image;
|
|
17281
|
-
if (release.includes("-custom-"))
|
|
17282
|
-
return import_node_path16.default.join(peachHome(), "swift", "toolchains", release, "usr/bin");
|
|
17283
|
-
return (process.env.PATH ?? "").split(import_node_path16.default.delimiter).find((dir) => dir && import_node_fs20.default.existsSync(import_node_path16.default.join(dir, "swift"))) ?? image;
|
|
17284
|
-
}
|
|
17285
|
-
function writeSwiftAutolinkLinker(directory2, toolchainBin, omitLibraries = []) {
|
|
17286
|
-
const linker = import_node_path16.default.join(directory2, SWIFT_AUTOLINK_LINKER);
|
|
17287
|
-
const script = `#!/bin/sh
|
|
17288
|
-
set -eu
|
|
17289
|
-
for arg in "$@"; do
|
|
17290
|
-
case $arg in
|
|
17291
|
-
@*)
|
|
17292
|
-
rsp=\${arg#@}
|
|
17293
|
-
awk 'BEGIN { RS = " "; ORS = " " } /^"-l/ { if (seen[$0]++) next }${omitLibraries.map((name3) => ` $0 == "\\"-l${name3}\\"" { next }`).join("")} $0 == "\\"-ObjC\\"" { next } { print }' "$rsp" > "$rsp.dedup"
|
|
17294
|
-
mv "$rsp.dedup" "$rsp"
|
|
17295
|
-
if [ "\${PEACH_DEFER_WASM_LINK:-}" = "1" ] && grep -q '"--start-lib"' "$rsp"; then
|
|
17296
|
-
cp "$rsp" ${JSON.stringify(import_node_path16.default.join(directory2, ".peach-link.rsp"))}
|
|
17297
|
-
out=$(awk 'BEGIN { RS = " " } prev == "\\"'-o'\\"" { gsub(/^"|"[[:space:]]*$/, ""); print; exit } { prev = $0 }' "$rsp")
|
|
17298
|
-
if [ -n "$out" ]; then
|
|
17299
|
-
printf '\\000asm\\001\\000\\000\\000' > "$out"
|
|
17300
|
-
exit 0
|
|
17301
|
-
fi
|
|
17302
|
-
fi
|
|
17303
|
-
;;
|
|
17304
|
-
esac
|
|
17305
|
-
done
|
|
17306
|
-
exec ${JSON.stringify(import_node_path16.default.join(toolchainBin, "wasm-ld"))} "$@"
|
|
17307
|
-
`;
|
|
17308
|
-
if (import_node_fs20.default.existsSync(linker) && import_node_fs20.default.readFileSync(linker, "utf8") === script) return linker;
|
|
17309
|
-
import_node_fs20.default.mkdirSync(directory2, { recursive: true });
|
|
17310
|
-
const next = `${linker}.${process.pid}`;
|
|
17311
|
-
import_node_fs20.default.writeFileSync(next, script, { mode: 493 });
|
|
17312
|
-
import_node_fs20.default.renameSync(next, linker);
|
|
17313
|
-
return linker;
|
|
17314
|
-
}
|
|
17315
|
-
function peachHome() {
|
|
17316
|
-
const override = process.env.PEACH_HOME;
|
|
17317
|
-
if (override) return import_node_path16.default.resolve(override);
|
|
17318
|
-
const home = import_node_path16.default.join(import_node_os6.default.homedir(), ".peach");
|
|
17319
|
-
return import_node_fs20.default.existsSync(home) ? import_node_fs20.default.realpathSync(home) : home;
|
|
17320
|
-
}
|
|
17321
|
-
function peachSwiftSdksDir() {
|
|
17322
|
-
return process.env.PEACH_SWIFT_SDKS_PATH ?? import_node_path16.default.join(peachHome(), "swift", "sdks");
|
|
17323
|
-
}
|
|
17324
|
-
function agentSharedCacheRoot() {
|
|
17325
|
-
if (process.platform !== "darwin" || !process.env.TM_SESSION) return null;
|
|
17326
|
-
if (agentBuildersRoot) return agentBuildersRoot;
|
|
17327
|
-
const policy = JSON.parse(
|
|
17328
|
-
(0, import_node_child_process10.execFileSync)("tm", ["machine", "policy", "--json"], {
|
|
17329
|
-
encoding: "utf8",
|
|
17330
|
-
timeout: 3e4
|
|
17331
|
-
})
|
|
17332
|
-
);
|
|
17333
|
-
const mounts = policy.storage_mounts ?? [];
|
|
17334
|
-
if (!Array.isArray(mounts)) throw new Error("storage_mounts must be a list");
|
|
17335
|
-
const isMount = (directory2) => {
|
|
17336
|
-
const lines = (0, import_node_child_process10.execFileSync)("/bin/df", ["-P", directory2], {
|
|
17337
|
-
encoding: "utf8",
|
|
17338
|
-
timeout: 3e4
|
|
17339
|
-
}).trim().split("\n");
|
|
17340
|
-
const fields = lines[lines.length - 1].trim().split(/\s+/);
|
|
17341
|
-
const mount = fields.slice(5).join(" ");
|
|
17342
|
-
if (!import_node_path16.default.isAbsolute(mount))
|
|
17343
|
-
throw new Error("filesystem mount identity is unavailable");
|
|
17344
|
-
return import_node_fs20.default.realpathSync(directory2) === import_node_fs20.default.realpathSync(mount);
|
|
17345
|
-
};
|
|
17346
|
-
for (const mount of mounts) {
|
|
17347
|
-
if (typeof mount !== "string" || !import_node_path16.default.isAbsolute(mount) || !isMount(mount))
|
|
17348
|
-
throw new Error(`configured storage is not mounted: ${mount}`);
|
|
17349
|
-
}
|
|
17350
|
-
const heavy = policy.heavy_data_dir;
|
|
17351
|
-
if (heavy == null) return agentBuildersRoot = import_node_path16.default.join(import_node_os6.default.homedir(), "builders");
|
|
17352
|
-
if (typeof heavy !== "string" || !import_node_path16.default.isAbsolute(heavy) || !import_node_fs20.default.statSync(heavy).isDirectory())
|
|
17353
|
-
throw new Error(`configured heavy_data_dir is unavailable: ${heavy}`);
|
|
17354
|
-
const mounted = isMount(heavy);
|
|
17355
|
-
if (import_node_path16.default.dirname(heavy) === "/Volumes" && !mounted)
|
|
17356
|
-
throw new Error(`configured storage is not mounted: ${heavy}`);
|
|
17357
|
-
return agentBuildersRoot = mounted && import_node_fs20.default.statSync(heavy).dev === import_node_fs20.default.statSync(import_node_os6.default.homedir()).dev ? import_node_path16.default.join(import_node_os6.default.homedir(), "builders") : import_node_path16.default.join(heavy, "builders");
|
|
17358
|
-
}
|
|
17359
|
-
function buildersRootEnv() {
|
|
17360
|
-
const root = process.env[BUILDERS_ROOT_ENV]?.trim();
|
|
17361
|
-
return root ? root : null;
|
|
17362
|
-
}
|
|
17363
|
-
function resolvedBuildersRoot() {
|
|
17364
|
-
return buildersRootEnv() ?? (process.env.PEACH_HOME ? null : agentSharedCacheRoot());
|
|
17365
|
-
}
|
|
17366
|
-
function swiftCacheDir() {
|
|
17367
|
-
const root = resolvedBuildersRoot();
|
|
17368
|
-
return root ? import_node_path16.default.join(root, "peach-cache") : import_node_path16.default.join(peachHome(), "cache");
|
|
17369
|
-
}
|
|
17370
|
-
function refreshSwiftCacheHold(directory2) {
|
|
17371
|
-
const cache = swiftCacheDir();
|
|
17372
|
-
if (!import_node_fs20.default.existsSync(cache)) return;
|
|
17373
|
-
const cacheRoot = import_node_fs20.default.realpathSync(cache);
|
|
17374
|
-
const relative4 = import_node_path16.default.relative(cacheRoot, import_node_fs20.default.realpathSync(directory2));
|
|
17375
|
-
const [kind, key2] = relative4.split(import_node_path16.default.sep);
|
|
17376
|
-
if (!key2 || kind === ".." || import_node_path16.default.isAbsolute(relative4)) return;
|
|
17377
|
-
const entry = import_node_path16.default.join(cacheRoot, kind, key2);
|
|
17378
|
-
if (!resolvedBuildersRoot()) {
|
|
17379
|
-
const now = /* @__PURE__ */ new Date();
|
|
17380
|
-
import_node_fs20.default.utimesSync(entry, now, now);
|
|
17381
|
-
return;
|
|
17382
|
-
}
|
|
17383
|
-
const marker = import_node_path16.default.join(entry, SWIFT_CACHE_HOLD_MARKER);
|
|
17384
|
-
const { O_WRONLY, O_CREAT, O_NOFOLLOW, O_NONBLOCK } = import_node_fs20.default.constants;
|
|
17385
|
-
const fd = import_node_fs20.default.openSync(marker, O_WRONLY | O_CREAT | O_NOFOLLOW | O_NONBLOCK, 420);
|
|
17386
|
-
try {
|
|
17387
|
-
if (!import_node_fs20.default.fstatSync(fd).isFile()) throw new Error(`invalid Swift cache hold: ${marker}`);
|
|
17388
|
-
const now = /* @__PURE__ */ new Date();
|
|
17389
|
-
import_node_fs20.default.futimesSync(fd, now, now);
|
|
17390
|
-
} finally {
|
|
17391
|
-
import_node_fs20.default.closeSync(fd);
|
|
17392
|
-
}
|
|
17393
|
-
}
|
|
17394
|
-
function sharedCacheDir(fallback) {
|
|
17395
|
-
const root = buildersRootEnv() ?? agentSharedCacheRoot();
|
|
17396
|
-
return root ? import_node_path16.default.join(root, "peach-cache") : fallback;
|
|
17397
|
-
}
|
|
17398
|
-
function swiftPackageCacheOptions() {
|
|
17399
|
-
const root = import_node_path16.default.join(swiftCacheDir(), "swiftpm");
|
|
17400
|
-
return [
|
|
17401
|
-
...["cache", "config", "security"].flatMap((name3) => [
|
|
17402
|
-
`--${name3}-path`,
|
|
17403
|
-
import_node_path16.default.join(root, name3)
|
|
17404
|
-
]),
|
|
17405
|
-
"--disable-keychain"
|
|
17406
|
-
];
|
|
17407
|
-
}
|
|
17408
|
-
function setSwiftLinuxLibraryPath(libraryPath) {
|
|
17409
|
-
linuxLibraryPath = libraryPath;
|
|
17410
|
-
}
|
|
17411
|
-
function confineSwiftScratch(root) {
|
|
17412
|
-
if (scratch) return;
|
|
17413
|
-
import_node_fs20.default.mkdirSync(root, { recursive: true });
|
|
17414
|
-
root = import_node_fs20.default.realpathSync(root);
|
|
17415
|
-
for (const name3 of import_node_fs20.default.readdirSync(root)) {
|
|
17416
|
-
const pid = Number(name3);
|
|
17417
|
-
if (Number.isInteger(pid) && pid > 0 && !processRuns(pid))
|
|
17418
|
-
import_node_fs20.default.rmSync(import_node_path16.default.join(root, name3), { recursive: true, force: true });
|
|
17419
18073
|
}
|
|
17420
|
-
const dir = import_node_path16.default.join(root, String(process.pid));
|
|
17421
|
-
import_node_fs20.default.mkdirSync(dir, { recursive: true });
|
|
17422
|
-
const home = import_node_path16.default.join(root, "home");
|
|
17423
|
-
import_node_fs20.default.mkdirSync(home, { recursive: true });
|
|
17424
|
-
scratch = { directory: dir, home };
|
|
17425
|
-
process.once("exit", () => {
|
|
17426
|
-
import_node_fs20.default.rmSync(dir, { recursive: true, force: true });
|
|
17427
|
-
});
|
|
17428
|
-
}
|
|
17429
|
-
function processRuns(pid) {
|
|
17430
18074
|
try {
|
|
17431
18075
|
process.kill(pid, 0);
|
|
17432
18076
|
return true;
|
|
17433
18077
|
} catch (error) {
|
|
17434
|
-
return error instanceof Error && "code"
|
|
17435
|
-
}
|
|
17436
|
-
}
|
|
17437
|
-
function withoutCoreDump(file, args) {
|
|
17438
|
-
return ["/bin/sh", ["-c", 'ulimit -c 0; exec "$@"', "sh", file, ...args]];
|
|
17439
|
-
}
|
|
17440
|
-
function swiftEnvironment(base2 = process.env) {
|
|
17441
|
-
return {
|
|
17442
|
-
...base2,
|
|
17443
|
-
...linuxHostSdkRoot ? { SDKROOT: linuxHostSdkRoot } : {},
|
|
17444
|
-
...linuxLibraryPath ? {
|
|
17445
|
-
LD_LIBRARY_PATH: [linuxLibraryPath, base2.LD_LIBRARY_PATH].filter(Boolean).join(":")
|
|
17446
|
-
} : {},
|
|
17447
|
-
...scratch ? {
|
|
17448
|
-
TMPDIR: scratch.directory,
|
|
17449
|
-
XDG_CONFIG_HOME: import_node_path16.default.join(scratch.home, ".config"),
|
|
17450
|
-
XDG_CACHE_HOME: import_node_path16.default.join(scratch.home, ".cache"),
|
|
17451
|
-
XDG_DATA_HOME: import_node_path16.default.join(scratch.home, ".local", "share"),
|
|
17452
|
-
...process.platform === "linux" ? { HOME: scratch.home } : {}
|
|
17453
|
-
} : {}
|
|
17454
|
-
};
|
|
17455
|
-
}
|
|
17456
|
-
function swiftSourceSdk(root) {
|
|
17457
|
-
const pin2 = JSON.parse(
|
|
17458
|
-
import_node_fs20.default.readFileSync(import_node_path16.default.join(root, "toolchain.json"), "utf8")
|
|
17459
|
-
);
|
|
17460
|
-
if (!pin2 || typeof pin2 !== "object" || typeof Reflect.get(pin2, "wasmSdkId") !== "string" || typeof Reflect.get(pin2, "wasmSdkUrl") !== "string" || typeof Reflect.get(pin2, "wasmSdkChecksum") !== "string")
|
|
17461
|
-
throw new Error(`${root} pins no wasm SDK id, url and checksum`);
|
|
17462
|
-
return {
|
|
17463
|
-
wasmSdkId: String(Reflect.get(pin2, "wasmSdkId")),
|
|
17464
|
-
wasmSdkUrl: String(Reflect.get(pin2, "wasmSdkUrl")),
|
|
17465
|
-
wasmSdkChecksum: String(Reflect.get(pin2, "wasmSdkChecksum"))
|
|
17466
|
-
};
|
|
17467
|
-
}
|
|
17468
|
-
function swiftToolchain(release, sdk2) {
|
|
17469
|
-
validateSwiftSdkIdentity(sdk2);
|
|
17470
|
-
let bin;
|
|
17471
|
-
try {
|
|
17472
|
-
bin = swiftCompiler(release);
|
|
17473
|
-
} catch (error) {
|
|
17474
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
17475
|
-
throw new Error(
|
|
17476
|
-
`Swift compiler ${release} is unavailable or differs from its pin: ${reason}
|
|
17477
|
-
${swiftInstallSteps(release, sdk2)}`
|
|
17478
|
-
);
|
|
17479
|
-
}
|
|
17480
|
-
const swift = import_node_path16.default.join(bin, "swift");
|
|
17481
|
-
const listed = [swift, sdk2.wasmSdkId, ...swiftSdkOptions()].join("\0");
|
|
17482
|
-
if (!listedSdks.has(listed)) {
|
|
17483
|
-
const sdks = (0, import_node_child_process10.execFileSync)(swift, ["sdk", "list", ...swiftSdkOptions()], {
|
|
17484
|
-
encoding: "utf8",
|
|
17485
|
-
env: swiftEnvironment(),
|
|
17486
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
17487
|
-
});
|
|
17488
|
-
if (!sdks.split("\n").some((line) => line.trim() === sdk2.wasmSdkId)) {
|
|
17489
|
-
throw new Error(
|
|
17490
|
-
`peach compiles Swift with the ${sdk2.wasmSdkId} SDK, which ${swift} does not have.
|
|
17491
|
-
${swiftSdkInstallStep(release, sdk2)}`
|
|
17492
|
-
);
|
|
17493
|
-
}
|
|
17494
|
-
listedSdks.add(listed);
|
|
17495
|
-
}
|
|
17496
|
-
try {
|
|
17497
|
-
verifySwiftSdk(swift, sdk2);
|
|
17498
|
-
} catch (error) {
|
|
17499
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
17500
|
-
throw new Error(`${reason}
|
|
17501
|
-
${swiftSdkInstallStep(release, sdk2)}`);
|
|
17502
|
-
}
|
|
17503
|
-
return bin;
|
|
17504
|
-
}
|
|
17505
|
-
function validateSwiftSdkIdentity(sdk2) {
|
|
17506
|
-
if (!/^[a-zA-Z0-9._-]+$/.test(sdk2.wasmSdkId) || !/^[a-f0-9]{64}$/.test(sdk2.wasmSdkChecksum))
|
|
17507
|
-
throw new Error("invalid Swift SDK identity or checksum");
|
|
17508
|
-
}
|
|
17509
|
-
function swiftSdkBundle(swift, id, options2) {
|
|
17510
|
-
const key2 = [swift, id, ...options2].join("\0");
|
|
17511
|
-
const known = sdkBundles.get(key2);
|
|
17512
|
-
if (known && import_node_fs20.default.existsSync(known)) return known;
|
|
17513
|
-
const configuration = (0, import_node_child_process10.execFileSync)(
|
|
17514
|
-
swift,
|
|
17515
|
-
["sdk", "configure", ...options2, "--show-configuration", id, SWIFT_WASM_TRIPLE],
|
|
17516
|
-
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
17517
|
-
);
|
|
17518
|
-
const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim();
|
|
17519
|
-
if (!sysroot || !import_node_path16.default.isAbsolute(sysroot))
|
|
17520
|
-
throw new Error(`Swift SDK ${id} reports no absolute sdkRootPath`);
|
|
17521
|
-
let bundle = sysroot;
|
|
17522
|
-
while (!bundle.endsWith(".artifactbundle")) {
|
|
17523
|
-
const parent = import_node_path16.default.dirname(bundle);
|
|
17524
|
-
if (parent === bundle)
|
|
17525
|
-
throw new Error(`Swift SDK ${id} is outside an artifact bundle`);
|
|
17526
|
-
bundle = parent;
|
|
17527
|
-
}
|
|
17528
|
-
const resolved = import_node_fs20.default.realpathSync(bundle);
|
|
17529
|
-
sdkBundles.set(key2, resolved);
|
|
17530
|
-
return resolved;
|
|
17531
|
-
}
|
|
17532
|
-
function swiftSdkPayloadChecksum(bundle) {
|
|
17533
|
-
const hash = (0, import_node_crypto9.createHash)("sha256");
|
|
17534
|
-
function visit3(relative4) {
|
|
17535
|
-
const file = import_node_path16.default.join(bundle, relative4);
|
|
17536
|
-
const stat = import_node_fs20.default.lstatSync(file, { bigint: true });
|
|
17537
|
-
if (stat.isSymbolicLink()) {
|
|
17538
|
-
const resolved = import_node_path16.default.relative(bundle, import_node_fs20.default.realpathSync(file));
|
|
17539
|
-
if (resolved === ".." || resolved.startsWith(`..${import_node_path16.default.sep}`) || import_node_path16.default.isAbsolute(resolved))
|
|
17540
|
-
throw new Error(`Swift SDK symlink escapes its bundle: ${relative4}`);
|
|
17541
|
-
hash.update(JSON.stringify([relative4, "link", import_node_fs20.default.readlinkSync(file)]) + "\n");
|
|
17542
|
-
} else if (stat.isDirectory()) {
|
|
17543
|
-
hash.update(JSON.stringify([relative4, "directory"]) + "\n");
|
|
17544
|
-
for (const name3 of import_node_fs20.default.readdirSync(file).sort()) visit3(import_node_path16.default.join(relative4, name3));
|
|
17545
|
-
} else if (stat.isFile()) {
|
|
17546
|
-
const stamp = [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(":");
|
|
17547
|
-
let cached2 = sdkFileHashes.get(file);
|
|
17548
|
-
if (cached2?.stamp !== stamp) {
|
|
17549
|
-
cached2 = { stamp, checksum: swiftFileChecksum(file) };
|
|
17550
|
-
sdkFileHashes.set(file, cached2);
|
|
17551
|
-
sdkFilesHashed++;
|
|
17552
|
-
}
|
|
17553
|
-
hash.update(
|
|
17554
|
-
JSON.stringify([relative4, "file", Number(stat.mode & 0o111n), cached2.checksum]) + "\n"
|
|
17555
|
-
);
|
|
17556
|
-
} else throw new Error(`unsupported Swift SDK payload entry: ${relative4}`);
|
|
17557
|
-
}
|
|
17558
|
-
visit3("");
|
|
17559
|
-
return hash.digest("hex");
|
|
17560
|
-
}
|
|
17561
|
-
function swiftSdkVerificationFile(bundle, sdk2) {
|
|
17562
|
-
return import_node_path16.default.join(
|
|
17563
|
-
import_node_path16.default.dirname(bundle),
|
|
17564
|
-
".peach-sdk-checksums",
|
|
17565
|
-
`${sdk2.wasmSdkId}-${sdk2.wasmSdkChecksum}.json`
|
|
17566
|
-
);
|
|
17567
|
-
}
|
|
17568
|
-
function verifySwiftSdk(swift, sdk2) {
|
|
17569
|
-
const bundle = swiftSdkBundle(swift, sdk2.wasmSdkId, swiftSdkOptions());
|
|
17570
|
-
const file = swiftSdkVerificationFile(bundle, sdk2);
|
|
17571
|
-
if (!import_node_fs20.default.existsSync(file))
|
|
17572
|
-
throw new Error(
|
|
17573
|
-
`Swift SDK ${sdk2.wasmSdkId} has no verified archive binding for ${sdk2.wasmSdkChecksum}. Hydrate it with installSwiftWasmSdk before compiling.`
|
|
17574
|
-
);
|
|
17575
|
-
const receipt = JSON.parse(import_node_fs20.default.readFileSync(file, "utf8"));
|
|
17576
|
-
const stamps = file.replace(/\.json$/, ".files.json");
|
|
17577
|
-
if (!loadedSdkHashFiles.has(stamps)) {
|
|
17578
|
-
loadedSdkHashFiles.add(stamps);
|
|
17579
|
-
const saved = import_node_fs20.default.existsSync(stamps) ? JSON.parse(import_node_fs20.default.readFileSync(stamps, "utf8")) : null;
|
|
17580
|
-
if (saved && typeof saved === "object") {
|
|
17581
|
-
for (const [entry, value] of Object.entries(saved))
|
|
17582
|
-
if (Array.isArray(value) && typeof value[0] === "string" && typeof value[1] === "string")
|
|
17583
|
-
sdkFileHashes.set(entry, { stamp: value[0], checksum: value[1] });
|
|
17584
|
-
}
|
|
17585
|
-
}
|
|
17586
|
-
const hashedBefore = sdkFilesHashed;
|
|
17587
|
-
if (!receipt || typeof receipt !== "object" || !("wasmSdkId" in receipt) || receipt.wasmSdkId !== sdk2.wasmSdkId || !("wasmSdkChecksum" in receipt) || receipt.wasmSdkChecksum !== sdk2.wasmSdkChecksum || !("payloadChecksum" in receipt) || receipt.payloadChecksum !== swiftSdkPayloadChecksum(bundle))
|
|
17588
|
-
throw new Error(
|
|
17589
|
-
`Swift SDK ${sdk2.wasmSdkId} installed payload differs from its verified archive ${sdk2.wasmSdkChecksum}`
|
|
17590
|
-
);
|
|
17591
|
-
if (sdkFilesHashed === hashedBefore) return;
|
|
17592
|
-
const temporary = `${stamps}.${process.pid}.tmp`;
|
|
17593
|
-
try {
|
|
17594
|
-
import_node_fs20.default.writeFileSync(
|
|
17595
|
-
temporary,
|
|
17596
|
-
JSON.stringify(
|
|
17597
|
-
Object.fromEntries(
|
|
17598
|
-
[...sdkFileHashes].filter(([entry]) => entry.startsWith(bundle + import_node_path16.default.sep)).map(([entry, { stamp, checksum }]) => [entry, [stamp, checksum]])
|
|
17599
|
-
)
|
|
17600
|
-
)
|
|
17601
|
-
);
|
|
17602
|
-
import_node_fs20.default.renameSync(temporary, stamps);
|
|
17603
|
-
} finally {
|
|
17604
|
-
import_node_fs20.default.rmSync(temporary, { force: true });
|
|
17605
|
-
}
|
|
17606
|
-
}
|
|
17607
|
-
async function installSwiftSdkArchive(swift, sdk2, archive) {
|
|
17608
|
-
validateSwiftSdkIdentity(sdk2);
|
|
17609
|
-
const staging = import_node_fs20.default.realpathSync(swiftSdkStagingDirectory("peach-sdk-verification-"));
|
|
17610
|
-
try {
|
|
17611
|
-
if (swiftFileChecksum(archive) !== sdk2.wasmSdkChecksum)
|
|
17612
|
-
throw new Error("declared Swift SDK archive checksum mismatch");
|
|
17613
|
-
const store = import_node_path16.default.join(staging, "sdks");
|
|
17614
|
-
import_node_fs20.default.mkdirSync(store);
|
|
17615
|
-
let source = archive;
|
|
17616
|
-
let checksumArgs = ["--checksum", sdk2.wasmSdkChecksum];
|
|
17617
|
-
if (sdk2.wasmSdkUrl.endsWith(".tar.zst")) {
|
|
17618
|
-
const extracted = import_node_path16.default.join(staging, "archive");
|
|
17619
|
-
import_node_fs20.default.mkdirSync(extracted);
|
|
17620
|
-
await extractSwiftTar(archive, sdk2.wasmSdkUrl, extracted);
|
|
17621
|
-
const [bundle2, extra] = import_node_fs20.default.readdirSync(extracted, { withFileTypes: true });
|
|
17622
|
-
if (!bundle2?.isDirectory() || !bundle2.name.endsWith(".artifactbundle") || extra)
|
|
17623
|
-
throw new Error("Swift SDK archive must contain one artifact bundle directory");
|
|
17624
|
-
source = import_node_path16.default.join(extracted, bundle2.name);
|
|
17625
|
-
checksumArgs = [];
|
|
17626
|
-
}
|
|
17627
|
-
(0, import_node_child_process10.execFileSync)(
|
|
17628
|
-
swift,
|
|
17629
|
-
["sdk", "install", source, ...checksumArgs, "--swift-sdks-path", store],
|
|
17630
|
-
{ env: swiftEnvironment(), stdio: "inherit" }
|
|
17631
|
-
);
|
|
17632
|
-
const stagedBundle = swiftSdkBundle(swift, sdk2.wasmSdkId, [
|
|
17633
|
-
"--swift-sdks-path",
|
|
17634
|
-
store
|
|
17635
|
-
]);
|
|
17636
|
-
const expected = swiftSdkPayloadChecksum(stagedBundle);
|
|
17637
|
-
const locks = import_node_path16.default.join(import_node_path16.default.resolve(peachSwiftSdksDir()), ".peach-locks");
|
|
17638
|
-
import_node_fs20.default.mkdirSync(locks, { recursive: true });
|
|
17639
|
-
(0, import_node_child_process10.execFileSync)(
|
|
17640
|
-
"perl",
|
|
17641
|
-
[
|
|
17642
|
-
"-e",
|
|
17643
|
-
'use Fcntl qw(:flock); my ($lock, $id, $bundle, $swift, @options) = @ARGV; open(my $fd, ">>", $lock) or die $!; flock($fd, LOCK_EX) or die $!; open(my $list, "-|", $swift, "sdk", "list", @options) or die $!; my $found = 0; while (<$list>) { s/^\\s+|\\s+$//g; $found = 1 if $_ eq $id; } close($list) or die "swift sdk list failed"; unless ($found) { system($swift, "sdk", "install", $bundle, @options); exit(($? & 127) ? 128 + ($? & 127) : $? >> 8); }',
|
|
17644
|
-
import_node_path16.default.join(locks, "wasm-sdk.lock"),
|
|
17645
|
-
sdk2.wasmSdkId,
|
|
17646
|
-
stagedBundle,
|
|
17647
|
-
swift,
|
|
17648
|
-
...swiftSdkOptions()
|
|
17649
|
-
],
|
|
17650
|
-
{ env: swiftEnvironment(), stdio: "inherit" }
|
|
17651
|
-
);
|
|
17652
|
-
const bundle = swiftSdkBundle(swift, sdk2.wasmSdkId, swiftSdkOptions());
|
|
17653
|
-
if (swiftSdkPayloadChecksum(bundle) !== expected)
|
|
17654
|
-
throw new SwiftSdkPayloadMismatch(
|
|
17655
|
-
`Swift SDK ${sdk2.wasmSdkId} already exists with different payload bytes; select a separate --swift-sdks-path. No installed SDK was replaced.`
|
|
17656
|
-
);
|
|
17657
|
-
const file = swiftSdkVerificationFile(bundle, sdk2);
|
|
17658
|
-
import_node_fs20.default.mkdirSync(import_node_path16.default.dirname(file), { recursive: true });
|
|
17659
|
-
const temporary = `${file}.${process.pid}.tmp`;
|
|
17660
|
-
try {
|
|
17661
|
-
import_node_fs20.default.writeFileSync(
|
|
17662
|
-
temporary,
|
|
17663
|
-
JSON.stringify({
|
|
17664
|
-
wasmSdkId: sdk2.wasmSdkId,
|
|
17665
|
-
wasmSdkChecksum: sdk2.wasmSdkChecksum,
|
|
17666
|
-
payloadChecksum: expected
|
|
17667
|
-
}) + "\n"
|
|
17668
|
-
);
|
|
17669
|
-
import_node_fs20.default.renameSync(temporary, file);
|
|
17670
|
-
} finally {
|
|
17671
|
-
import_node_fs20.default.rmSync(temporary, { force: true });
|
|
17672
|
-
}
|
|
17673
|
-
} finally {
|
|
17674
|
-
import_node_fs20.default.rmSync(staging, { recursive: true, force: true });
|
|
17675
|
-
for (const file of sdkFileHashes.keys())
|
|
17676
|
-
if (file.startsWith(staging + import_node_path16.default.sep)) sdkFileHashes.delete(file);
|
|
17677
|
-
}
|
|
17678
|
-
}
|
|
17679
|
-
function swiftSdkStagingDirectory(prefix) {
|
|
17680
|
-
const parent = scratch?.directory ?? import_node_os6.default.tmpdir();
|
|
17681
|
-
if (!import_node_fs20.default.existsSync(parent)) throw new Error(`Swift SDK install is missing ${parent}`);
|
|
17682
|
-
return import_node_fs20.default.mkdtempSync(import_node_path16.default.join(parent, prefix));
|
|
17683
|
-
}
|
|
17684
|
-
async function installSwiftWasmSdk(release, sdk2) {
|
|
17685
|
-
validateSwiftSdkIdentity(sdk2);
|
|
17686
|
-
ensureSwiftLinuxRuntime(release);
|
|
17687
|
-
try {
|
|
17688
|
-
swiftToolchain(release, sdk2);
|
|
17689
|
-
return;
|
|
17690
|
-
} catch {
|
|
17691
|
-
}
|
|
17692
|
-
const swift = import_node_path16.default.join(swiftCompiler(release), "swift");
|
|
17693
|
-
const staging = swiftSdkStagingDirectory("builder-swift-sdk-");
|
|
17694
|
-
const extension = sdk2.wasmSdkUrl.endsWith(".tar.zst") ? "zst" : "gz";
|
|
17695
|
-
const archive = import_node_path16.default.join(staging, `sdk.artifactbundle.tar.${extension}`);
|
|
17696
|
-
try {
|
|
17697
|
-
if (sdk2.wasmSdkUrl.startsWith("file:"))
|
|
17698
|
-
import_node_fs20.default.copyFileSync((0, import_node_url2.fileURLToPath)(sdk2.wasmSdkUrl), archive);
|
|
17699
|
-
else
|
|
17700
|
-
(0, import_node_child_process10.execFileSync)(
|
|
17701
|
-
"curl",
|
|
17702
|
-
[
|
|
17703
|
-
"-fsSL",
|
|
17704
|
-
"--show-error",
|
|
17705
|
-
"--retry",
|
|
17706
|
-
"3",
|
|
17707
|
-
"--retry-all-errors",
|
|
17708
|
-
sdk2.wasmSdkUrl,
|
|
17709
|
-
"-o",
|
|
17710
|
-
archive
|
|
17711
|
-
],
|
|
17712
|
-
{
|
|
17713
|
-
stdio: "inherit"
|
|
17714
|
-
}
|
|
17715
|
-
);
|
|
17716
|
-
await installSwiftSdkArchive(swift, sdk2, archive);
|
|
17717
|
-
swiftToolchain(release, sdk2);
|
|
17718
|
-
} finally {
|
|
17719
|
-
import_node_fs20.default.rmSync(staging, { recursive: true, force: true });
|
|
17720
|
-
}
|
|
17721
|
-
}
|
|
17722
|
-
function swiftFileChecksum(file) {
|
|
17723
|
-
const hash = (0, import_node_crypto9.createHash)("sha256");
|
|
17724
|
-
const fd = import_node_fs20.default.openSync(file, "r");
|
|
17725
|
-
const buffer = Buffer.allocUnsafe(1024 * 1024);
|
|
17726
|
-
try {
|
|
17727
|
-
let size2 = import_node_fs20.default.readSync(fd, buffer, 0, buffer.length, null);
|
|
17728
|
-
while (size2 > 0) {
|
|
17729
|
-
hash.update(buffer.subarray(0, size2));
|
|
17730
|
-
size2 = import_node_fs20.default.readSync(fd, buffer, 0, buffer.length, null);
|
|
17731
|
-
}
|
|
17732
|
-
} finally {
|
|
17733
|
-
import_node_fs20.default.closeSync(fd);
|
|
17734
|
-
}
|
|
17735
|
-
return hash.digest("hex");
|
|
17736
|
-
}
|
|
17737
|
-
function swiftHostCompilerFiles(release, root) {
|
|
17738
|
-
const file = import_node_path16.default.join(root, "compiler.json");
|
|
17739
|
-
if (!import_node_fs20.default.existsSync(file))
|
|
17740
|
-
throw new Error(`Swift compiler ${release} is missing ${file}`);
|
|
17741
|
-
const privateCompiler = release === privateSwiftRelease();
|
|
17742
|
-
const pin2 = privateCompiler ? {
|
|
17743
|
-
identity: release.replace(/^.*-custom-/, ""),
|
|
17744
|
-
manifest: swiftFileChecksum(file)
|
|
17745
|
-
} : swiftHostCompilerArchive(release);
|
|
17746
|
-
if (swiftFileChecksum(file) !== pin2.manifest)
|
|
17747
|
-
throw new Error(`Swift compiler manifest mismatch at ${root}`);
|
|
17748
|
-
const manifest = JSON.parse(import_node_fs20.default.readFileSync(file, "utf8"));
|
|
17749
|
-
if (!manifest || typeof manifest !== "object" || !("identity" in manifest) || manifest.identity !== pin2.identity || !("host" in manifest) || manifest.host !== `${process.platform}-${process.arch}` || !("files" in manifest) || !manifest.files || typeof manifest.files !== "object") {
|
|
17750
|
-
throw new Error(`Swift compiler identity mismatch at ${root}`);
|
|
17751
|
-
}
|
|
17752
|
-
const files2 = Object.entries(manifest.files);
|
|
17753
|
-
const fileNames = Object.keys(manifest.files);
|
|
17754
|
-
const build2 = "compilerBuild" in manifest ? manifest.compilerBuild : null;
|
|
17755
|
-
const hasLinkerReceipt = build2 !== null && typeof build2 === "object" && typeof Reflect.get(build2, "lldSHA256") === "string";
|
|
17756
|
-
const hasSharedLLVM = build2 && typeof build2 === "object" && "hostLibraries" in build2;
|
|
17757
|
-
const llvmFiles = hasSharedLLVM ? process.platform === "darwin" ? 2 : 1 : 0;
|
|
17758
|
-
const hasLLVMFiles = process.platform === "darwin" ? fileNames.includes("usr/lib/libLLVM.dylib") && fileNames.includes("usr/lib/libLTO.dylib") : fileNames.some((file2) => /^usr\/lib\/libLLVM\.so\.\d+\.\d+$/.test(file2));
|
|
17759
|
-
const llvmTools = [
|
|
17760
|
-
"llvm-ar",
|
|
17761
|
-
"llvm-nm",
|
|
17762
|
-
"llvm-objcopy",
|
|
17763
|
-
"llvm-objdump",
|
|
17764
|
-
"llvm-symbolizer"
|
|
17765
|
-
];
|
|
17766
|
-
const expectedFiles = [
|
|
17767
|
-
"9f57741c6333ce5e",
|
|
17768
|
-
"139bc3bba3c4f73c",
|
|
17769
|
-
"cd5337e8ab49fd61"
|
|
17770
|
-
].includes(pin2.identity) ? 17 : hasLinkerReceipt || ["38af8a6bc3d9e72c", "17479c8af01737a3"].includes(pin2.identity) ? 18 : 16;
|
|
17771
|
-
if (files2.length !== expectedFiles + llvmFiles + (hasSharedLLVM ? llvmTools.length : 0) || hasSharedLLVM && (!hasLLVMFiles || !llvmTools.every((tool) => fileNames.includes(`usr/bin/${tool}`))) || expectedFiles >= 17 && !("usr/bin/lld" in manifest.files) || expectedFiles === 18 && !fileNames.some((file2) => /\/lib_InternalSwiftScan\.(so|dylib)$/.test(file2)))
|
|
17772
|
-
throw new Error("incomplete Swift compiler manifest");
|
|
17773
|
-
return files2.map(([relative4, checksum]) => {
|
|
17774
|
-
if (relative4.startsWith("/") || relative4.split("/").includes("..") || typeof checksum !== "string")
|
|
17775
|
-
throw new Error(`Swift compiler binary mismatch: ${relative4}`);
|
|
17776
|
-
const binary2 = import_node_path16.default.join(root, relative4);
|
|
17777
|
-
if (!import_node_fs20.default.existsSync(binary2))
|
|
17778
|
-
throw new Error(`Swift compiler ${release} is missing ${binary2}`);
|
|
17779
|
-
return [relative4, checksum];
|
|
17780
|
-
});
|
|
17781
|
-
}
|
|
17782
|
-
function verifySwiftHostCompiler(release, root) {
|
|
17783
|
-
for (const [relative4, checksum] of swiftHostCompilerFiles(release, root)) {
|
|
17784
|
-
if (swiftFileChecksum(import_node_path16.default.join(root, relative4)) !== checksum)
|
|
17785
|
-
throw new Error(`Swift compiler binary mismatch: ${relative4}`);
|
|
17786
|
-
}
|
|
17787
|
-
}
|
|
17788
|
-
async function swiftCompilerAsync(release, signal) {
|
|
17789
|
-
const cached2 = verifiedCompilers.get(release);
|
|
17790
|
-
if (cached2) return cached2;
|
|
17791
|
-
const bin = swiftToolchainBin(release);
|
|
17792
|
-
const binary2 = import_node_path16.default.join(bin, "swift");
|
|
17793
|
-
if (!import_node_fs20.default.existsSync(binary2))
|
|
17794
|
-
throw new Error(`Swift compiler ${release} is missing ${binary2}`);
|
|
17795
|
-
if (release.includes("-custom-")) {
|
|
17796
|
-
const root = import_node_path16.default.resolve(bin, "../..");
|
|
17797
|
-
for (const [relative4, checksum] of swiftHostCompilerFiles(release, root)) {
|
|
17798
|
-
const hash = (0, import_node_crypto9.createHash)("sha256");
|
|
17799
|
-
for await (const chunk of import_node_fs20.default.createReadStream(import_node_path16.default.join(root, relative4), {
|
|
17800
|
-
signal
|
|
17801
|
-
}))
|
|
17802
|
-
hash.update(chunk);
|
|
17803
|
-
if (hash.digest("hex") !== checksum)
|
|
17804
|
-
throw new Error(`Swift compiler binary mismatch: ${relative4}`);
|
|
17805
|
-
}
|
|
18078
|
+
return error instanceof Error && Reflect.get(error, "code") === "EPERM";
|
|
17806
18079
|
}
|
|
17807
|
-
const { stdout } = await (0, import_node_util2.promisify)(import_node_child_process10.execFile)(binary2, ["--version"], {
|
|
17808
|
-
encoding: "utf8",
|
|
17809
|
-
env: swiftEnvironment(),
|
|
17810
|
-
signal
|
|
17811
|
-
});
|
|
17812
|
-
if (!stdout.includes(`(${swiftCompilerRelease(release)})`))
|
|
17813
|
-
throw new Error(`compiler release mismatch at ${bin}`);
|
|
17814
|
-
verifiedCompilers.set(release, bin);
|
|
17815
|
-
return bin;
|
|
17816
18080
|
}
|
|
17817
|
-
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
17821
|
-
|
|
18081
|
+
var import_node_fs17;
|
|
18082
|
+
var init_process_liveness = __esm({
|
|
18083
|
+
"src/process-liveness.ts"() {
|
|
18084
|
+
"use strict";
|
|
18085
|
+
import_node_fs17 = require("node:fs");
|
|
17822
18086
|
}
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
17831
|
-
|
|
17832
|
-
env: swiftEnvironment(),
|
|
17833
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
17834
|
-
});
|
|
17835
|
-
if (!version2.includes(`(${swiftCompilerRelease(release)})`))
|
|
17836
|
-
throw new Error(`compiler release mismatch at ${bin}`);
|
|
17837
|
-
verifiedCompilers.set(release, bin);
|
|
17838
|
-
return bin;
|
|
17839
|
-
}
|
|
17840
|
-
function swiftSdkInstallStep(release, wasmSdk) {
|
|
17841
|
-
return `install the pinned SDK:
|
|
17842
|
-
${swiftSdkInstallCommand(release, wasmSdk)}`;
|
|
17843
|
-
}
|
|
17844
|
-
function swiftSdkInstallCommand(release, wasmSdk) {
|
|
17845
|
-
const { wasmSdkId, wasmSdkUrl, wasmSdkChecksum } = wasmSdk;
|
|
17846
|
-
const program = `import { installSwiftWasmSdk } from "peachsim/swift-toolchain"; await installSwiftWasmSdk(${JSON.stringify(release)}, ${JSON.stringify({ wasmSdkId, wasmSdkUrl, wasmSdkChecksum })})`;
|
|
17847
|
-
const environment = `PEACH_SWIFT_SDKS_PATH='${import_node_path16.default.resolve(peachSwiftSdksDir()).replaceAll("'", "'\\''")}' `;
|
|
17848
|
-
return `${environment}node --input-type=module -e '${program.replaceAll("'", "'\\''")}'`;
|
|
18087
|
+
});
|
|
18088
|
+
|
|
18089
|
+
// src/retired-cache-directory.ts
|
|
18090
|
+
function removeRetiredDirectory(directory2) {
|
|
18091
|
+
void (0, import_promises4.rm)(directory2, { recursive: true, force: true, maxRetries: 3 }).catch(
|
|
18092
|
+
(error) => console.warn(
|
|
18093
|
+
`[peach] retired cache directory ${directory2} stays for a later prune: ${error}`
|
|
18094
|
+
)
|
|
18095
|
+
);
|
|
17849
18096
|
}
|
|
17850
|
-
function
|
|
17851
|
-
const
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
18097
|
+
function reapRetiredCacheDirectory(parent, name3) {
|
|
18098
|
+
const owner = /^\.retired-(\d+)-/.exec(name3);
|
|
18099
|
+
if (!owner || isProcessRunning(Number(owner[1]))) return;
|
|
18100
|
+
const directory2 = import_node_path14.default.join(parent, name3);
|
|
18101
|
+
const claimed = import_node_path14.default.join(parent, `.retired-${process.pid}-${(0, import_node_crypto8.randomUUID)()}`);
|
|
18102
|
+
try {
|
|
18103
|
+
(0, import_node_fs18.renameSync)(directory2, claimed);
|
|
18104
|
+
} catch (error) {
|
|
18105
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return;
|
|
18106
|
+
throw error;
|
|
18107
|
+
}
|
|
18108
|
+
removeRetiredDirectory(claimed);
|
|
17856
18109
|
}
|
|
17857
|
-
|
|
17858
|
-
|
|
17859
|
-
|
|
17860
|
-
|
|
17861
|
-
|
|
17862
|
-
|
|
18110
|
+
var import_node_crypto8, import_node_fs18, import_promises4, import_node_path14;
|
|
18111
|
+
var init_retired_cache_directory = __esm({
|
|
18112
|
+
"src/retired-cache-directory.ts"() {
|
|
18113
|
+
"use strict";
|
|
18114
|
+
import_node_crypto8 = require("node:crypto");
|
|
18115
|
+
import_node_fs18 = require("node:fs");
|
|
18116
|
+
import_promises4 = require("node:fs/promises");
|
|
18117
|
+
import_node_path14 = __toESM(require("node:path"), 1);
|
|
18118
|
+
init_process_liveness();
|
|
18119
|
+
}
|
|
18120
|
+
});
|
|
18121
|
+
|
|
18122
|
+
// src/swift-compile-budget.ts
|
|
18123
|
+
function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
|
|
18124
|
+
return SWIFT_LOCK_WAIT_TIMEOUT_MS + (compileTimeoutMs ?? SWIFT_COMPILE_TIMEOUT_MS) + SWIFT_TRANSPORT_MARGIN_MS;
|
|
17863
18125
|
}
|
|
17864
|
-
function
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
|
|
17868
|
-
|
|
17869
|
-
|
|
17870
|
-
|
|
17871
|
-
|
|
17872
|
-
|
|
17873
|
-
|
|
17874
|
-
|
|
17875
|
-
|
|
17876
|
-
|
|
17877
|
-
|
|
17878
|
-
|
|
17879
|
-
|
|
18126
|
+
async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
|
|
18127
|
+
const deadline = new AbortController();
|
|
18128
|
+
const combined = signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal;
|
|
18129
|
+
let timer = setTimeout(
|
|
18130
|
+
() => deadline.abort(new Error("Swift build lock wait timed out")),
|
|
18131
|
+
SWIFT_LOCK_WAIT_TIMEOUT_MS
|
|
18132
|
+
);
|
|
18133
|
+
try {
|
|
18134
|
+
combined.throwIfAborted();
|
|
18135
|
+
const result = await work({
|
|
18136
|
+
signal: combined,
|
|
18137
|
+
startCompile() {
|
|
18138
|
+
combined.throwIfAborted();
|
|
18139
|
+
clearTimeout(timer);
|
|
18140
|
+
timer = setTimeout(
|
|
18141
|
+
() => deadline.abort(new Error("Swift compilation timed out")),
|
|
18142
|
+
compileTimeoutMs ?? SWIFT_COMPILE_TIMEOUT_MS
|
|
18143
|
+
);
|
|
18144
|
+
}
|
|
18145
|
+
});
|
|
18146
|
+
combined.throwIfAborted();
|
|
18147
|
+
return result;
|
|
18148
|
+
} finally {
|
|
18149
|
+
clearTimeout(timer);
|
|
17880
18150
|
}
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
|
|
17885
|
-
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
]
|
|
17890
|
-
};
|
|
18151
|
+
}
|
|
18152
|
+
var SWIFT_COMPILE_TIMEOUT_MS, SWIFT_LOCK_WAIT_TIMEOUT_MS, SWIFT_TRANSPORT_MARGIN_MS;
|
|
18153
|
+
var init_swift_compile_budget = __esm({
|
|
18154
|
+
"src/swift-compile-budget.ts"() {
|
|
18155
|
+
"use strict";
|
|
18156
|
+
SWIFT_COMPILE_TIMEOUT_MS = 18e5;
|
|
18157
|
+
SWIFT_LOCK_WAIT_TIMEOUT_MS = 36e5;
|
|
18158
|
+
SWIFT_TRANSPORT_MARGIN_MS = 3e5;
|
|
17891
18159
|
}
|
|
17892
|
-
|
|
17893
|
-
|
|
17894
|
-
|
|
17895
|
-
|
|
17896
|
-
|
|
17897
|
-
|
|
17898
|
-
|
|
17899
|
-
|
|
17900
|
-
|
|
18160
|
+
});
|
|
18161
|
+
|
|
18162
|
+
// src/swift-objc-sdk-tree.ts
|
|
18163
|
+
function readIosSdkTree(root) {
|
|
18164
|
+
return (0, import_node_fs19.readdirSync)(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => {
|
|
18165
|
+
const file = import_node_path15.default.join(entry.parentPath, entry.name);
|
|
18166
|
+
return [
|
|
18167
|
+
import_node_path15.default.relative(root, file).split(import_node_path15.default.sep).join("/"),
|
|
18168
|
+
(0, import_node_fs19.readFileSync)(file, "utf8")
|
|
18169
|
+
];
|
|
18170
|
+
}).sort(([a], [b]) => a < b ? -1 : 1);
|
|
17901
18171
|
}
|
|
17902
|
-
var
|
|
17903
|
-
var
|
|
17904
|
-
"src/swift-
|
|
18172
|
+
var import_node_fs19, import_node_path15;
|
|
18173
|
+
var init_swift_objc_sdk_tree = __esm({
|
|
18174
|
+
"src/swift-objc-sdk-tree.ts"() {
|
|
18175
|
+
"use strict";
|
|
18176
|
+
import_node_fs19 = require("node:fs");
|
|
18177
|
+
import_node_path15 = __toESM(require("node:path"), 1);
|
|
18178
|
+
}
|
|
18179
|
+
});
|
|
18180
|
+
|
|
18181
|
+
// src/swift-compiler-digest.ts
|
|
18182
|
+
var import_node_crypto9, import_node_fs20, import_node_path16;
|
|
18183
|
+
var init_swift_compiler_digest = __esm({
|
|
18184
|
+
"src/swift-compiler-digest.ts"() {
|
|
17905
18185
|
"use strict";
|
|
17906
|
-
import_node_child_process10 = require("node:child_process");
|
|
17907
18186
|
import_node_crypto9 = require("node:crypto");
|
|
17908
|
-
import_node_fs20 =
|
|
17909
|
-
import_node_os6 = __toESM(require("node:os"), 1);
|
|
18187
|
+
import_node_fs20 = require("node:fs");
|
|
17910
18188
|
import_node_path16 = __toESM(require("node:path"), 1);
|
|
17911
|
-
|
|
17912
|
-
import_node_url2 = require("node:url");
|
|
17913
|
-
import_node_util2 = require("node:util");
|
|
17914
|
-
import_node_zlib3 = __toESM(require("node:zlib"), 1);
|
|
17915
|
-
init_swiftTargetContract();
|
|
17916
|
-
compilerArchives = {
|
|
17917
|
-
"swift-6.4.0-RELEASE-custom-77d2c2623ec68c0c": {
|
|
17918
|
-
identity: "77d2c2623ec68c0c",
|
|
17919
|
-
archive: "tar.zst",
|
|
17920
|
-
hosts: {
|
|
17921
|
-
"darwin-arm64": {
|
|
17922
|
-
checksum: "0245c2f6593751cf29ce5920b9686f12097d0d76174c9f242e8d15dfb7ad049a",
|
|
17923
|
-
manifest: "07739120bd00b8fc9270f652ee66599cc45deb80bcc5cd7d45a452567fe6ba9d"
|
|
17924
|
-
},
|
|
17925
|
-
"linux-x64": {
|
|
17926
|
-
checksum: "75fc76f1a683bc52c402c0e969f7ba5c774717d7df571d2b59d0c0e81fa2a75e",
|
|
17927
|
-
manifest: "89c3dee81d47bcbbad10a57ef110f10463e792fb9d5d450463084ccf8d1d5623"
|
|
17928
|
-
},
|
|
17929
|
-
"linux-arm64": {
|
|
17930
|
-
checksum: "2bc4425b7092c74bb7a03a319b41824a295ee5a81f4dbb4e769598dd656a6777",
|
|
17931
|
-
manifest: "4b46e0f2fd8458a9a18f9a5114db616340838108fb476fb55ed5fc9d265fdd09"
|
|
17932
|
-
}
|
|
17933
|
-
}
|
|
17934
|
-
},
|
|
17935
|
-
"swift-6.4.0-RELEASE-custom-34da2e3307f11598": {
|
|
17936
|
-
identity: "34da2e3307f11598",
|
|
17937
|
-
archive: "tar.zst",
|
|
17938
|
-
hosts: {
|
|
17939
|
-
"darwin-arm64": {
|
|
17940
|
-
checksum: "f8f6ded1943979fbd4add8a43940485cb3b36f4dd293aa76b0c17f72d9e1c233",
|
|
17941
|
-
manifest: "7e0e74025935a64f66b9ea5e6a8aee1e730a908227c12686364fa83b665fbb44"
|
|
17942
|
-
},
|
|
17943
|
-
"linux-x64": {
|
|
17944
|
-
checksum: "8761203ffde1721bbd10820ac0dc68ec5d48e034672ba738261e509b1757c160",
|
|
17945
|
-
manifest: "61fe6dcee0f6cc0c895ff511478a264c43b89a14b39bc90c6de8b873ba2f14a6"
|
|
17946
|
-
},
|
|
17947
|
-
"linux-arm64": {
|
|
17948
|
-
checksum: "d0f5312eb032068e38bcdc8dacf12fcf4375ba789a1ee434d31d5e9a24554126",
|
|
17949
|
-
manifest: "9e3218d197c9784e3c434883a21f975222a662523a1ae78a38519e53c3a0385c"
|
|
17950
|
-
}
|
|
17951
|
-
}
|
|
17952
|
-
},
|
|
17953
|
-
"swift-6.4.0-RELEASE-custom-0ebff005f47d6148": {
|
|
17954
|
-
identity: "0ebff005f47d6148",
|
|
17955
|
-
archive: "tar.zst",
|
|
17956
|
-
hosts: {
|
|
17957
|
-
"darwin-arm64": {
|
|
17958
|
-
checksum: "2ddf2c544a17e5ba04c0c2cafd6b49394d9417e8c8d2d1c380846dc003436e10",
|
|
17959
|
-
manifest: "fd7527a60ba728e275afcaf19babf5565f096cd1bcbac9c3d65e238f869df105"
|
|
17960
|
-
},
|
|
17961
|
-
"linux-x64": {
|
|
17962
|
-
checksum: "08f0ad4175b81116842cdb752b34f92fa28133befa81e1813371ba25144b958e",
|
|
17963
|
-
manifest: "f89425fdbe1137005f59875542e2aa9637c5e586f6ae9a107375c4633ff6d425"
|
|
17964
|
-
},
|
|
17965
|
-
"linux-arm64": {
|
|
17966
|
-
checksum: "11b3368e45f8baf5d3fcffe12168744457695757f64c74de0443aac95fcb963b",
|
|
17967
|
-
manifest: "f889ea5d5d6da59af0a278208349e889e5d755571abf6ef4b59f6cf49fa21e0b"
|
|
17968
|
-
}
|
|
17969
|
-
}
|
|
17970
|
-
},
|
|
17971
|
-
"swift-6.4.0-RELEASE-custom-17479c8af01737a3": {
|
|
17972
|
-
identity: "17479c8af01737a3",
|
|
17973
|
-
archive: "tar.zst",
|
|
17974
|
-
hosts: {
|
|
17975
|
-
"darwin-arm64": {
|
|
17976
|
-
checksum: "b41a24b8d9b2ae13e9d6fe3935df69625e2a01cc742056049239415497e99ffb",
|
|
17977
|
-
manifest: "e824fa7f4333aa4307410899987e42863de087db43b2c70b96d4e67de0b0a843"
|
|
17978
|
-
},
|
|
17979
|
-
"linux-x64": {
|
|
17980
|
-
checksum: "fdd6e4ef39698d3a254b4d4967018cf468fdd3b6c6af461719de4c3b3ca126dc",
|
|
17981
|
-
manifest: "a15dc88910eaa012849604b0a866ab028072e526b4f00e611d29762b0cf41c9a"
|
|
17982
|
-
},
|
|
17983
|
-
"linux-arm64": {
|
|
17984
|
-
checksum: "3bfda70b772e13e4751e8ea8ca656e4382b66bc668a0ec4b1ed9740992d4bf50",
|
|
17985
|
-
manifest: "4c069a442d09fe4f92aee7d2d6b40a63a8ea5928c922879e0c4d2a9ac21d65f9"
|
|
17986
|
-
}
|
|
17987
|
-
}
|
|
17988
|
-
},
|
|
17989
|
-
"swift-6.4.0-RELEASE-custom-38af8a6bc3d9e72c": {
|
|
17990
|
-
identity: "38af8a6bc3d9e72c",
|
|
17991
|
-
archive: "tar.zst",
|
|
17992
|
-
hosts: {
|
|
17993
|
-
"darwin-arm64": {
|
|
17994
|
-
checksum: "1a7be355f9763f43e4b9e092a6917e071cbdfd2b6eaf1ba29f33893d2140a952",
|
|
17995
|
-
manifest: "4ea4a563012de05be738cd9d89cd5797408813277ae07a7b7221c22fe16dacbb"
|
|
17996
|
-
},
|
|
17997
|
-
"linux-x64": {
|
|
17998
|
-
checksum: "1daa88ea2c31d2b815414da981df9def4799b8290ba2bd4347a56e73cbce5b68",
|
|
17999
|
-
manifest: "9b2b771a1b8bcf28a5bb52a4c299b94b509cee71ac825feccaff438ad29cc812"
|
|
18000
|
-
},
|
|
18001
|
-
"linux-arm64": {
|
|
18002
|
-
checksum: "3a30617cba08bc5474c0ef24fdecc13ee7759f90c3ce847e00e3bcdb05c0315a",
|
|
18003
|
-
manifest: "f3074c4a2d80641e1a620f52161473de193def016b477cda85c7584b3cfbfd7b"
|
|
18004
|
-
}
|
|
18005
|
-
}
|
|
18006
|
-
},
|
|
18007
|
-
"swift-6.4.0-RELEASE-custom-cd5337e8ab49fd61": {
|
|
18008
|
-
identity: "cd5337e8ab49fd61",
|
|
18009
|
-
archive: "tar.zst",
|
|
18010
|
-
hosts: {
|
|
18011
|
-
"darwin-arm64": {
|
|
18012
|
-
checksum: "a95b73d196daebc342020ecce50ee468c1e5664398825aee79dcb700a10c86b1",
|
|
18013
|
-
manifest: "9b1d49ac08f6a9e710656e9a762d144ec45b142c8ec9ad90bab819a78dd45502"
|
|
18014
|
-
},
|
|
18015
|
-
"linux-x64": {
|
|
18016
|
-
checksum: "fa141d23c542c050bad77805517f9c277bd403b6ca0f4a271354329aaa5d09e6",
|
|
18017
|
-
manifest: "5cd9d1430b61dbe38c728425abd27cd51a8b99256ba026dbf335afb36655c9e4"
|
|
18018
|
-
},
|
|
18019
|
-
"linux-arm64": {
|
|
18020
|
-
checksum: "5b0ee093ff97d1e48b276535ceca35704608fbb10be219bd89cf89226a83d3da",
|
|
18021
|
-
manifest: "177390f9963958d71f5414efa077d728ae728cb0f61e21e3287a989dc939f235"
|
|
18022
|
-
}
|
|
18023
|
-
}
|
|
18024
|
-
},
|
|
18025
|
-
"swift-6.4.0-RELEASE-custom-139bc3bba3c4f73c": {
|
|
18026
|
-
identity: "139bc3bba3c4f73c",
|
|
18027
|
-
archive: "tar.zst",
|
|
18028
|
-
hosts: {
|
|
18029
|
-
"darwin-arm64": {
|
|
18030
|
-
checksum: "4c35af19e099a956f38932e94aa7ea31ee6e8ccf2497a7922b9784e4adba9c4e",
|
|
18031
|
-
manifest: "48753338f405766388e3556e66fbe592ff5af16089f0f577ad91bff267923dae"
|
|
18032
|
-
},
|
|
18033
|
-
"linux-x64": {
|
|
18034
|
-
checksum: "601ba7161cdc2d8fb07701aeb7e81b2bf5368aae23643e56286ff0798f25be9c",
|
|
18035
|
-
manifest: "9b3371f99d5f21b8758abc3497a8ade10e0a49d6373e9979b57eb21edc927b3f"
|
|
18036
|
-
},
|
|
18037
|
-
"linux-arm64": {
|
|
18038
|
-
checksum: "6e8931db639655525acaeb1ab8fffd76e836d2a28b5d9ba384d00f1d2e6da3ed",
|
|
18039
|
-
manifest: "5bfebf5e544c9b8a5e3405923ce57c887c6b87cae7d8891cd25e9ad251e2bc5d"
|
|
18040
|
-
}
|
|
18041
|
-
}
|
|
18042
|
-
},
|
|
18043
|
-
"swift-6.4.0-RELEASE-custom-9f57741c6333ce5e": {
|
|
18044
|
-
identity: "9f57741c6333ce5e",
|
|
18045
|
-
archive: "tar.zst",
|
|
18046
|
-
hosts: {
|
|
18047
|
-
"darwin-arm64": {
|
|
18048
|
-
checksum: "97c80de3caaa961be2f2649a839eb69cec376e8b5aa68a9a1191fcf312eaa002",
|
|
18049
|
-
manifest: "8177dea4013ba47bc0c0e14f5bb3d407a4a94636906e6c8273ef974d93d905b8"
|
|
18050
|
-
},
|
|
18051
|
-
"linux-x64": {
|
|
18052
|
-
checksum: "08bf59a5899990395aa1acc764d312e91c75844a4748a4dcd51061bc0ffbc153",
|
|
18053
|
-
manifest: "8e68a4780c7b29e1b3b43f473518138dc9a6ef63ed8f0fdb2ac3b5a9b487c7f2"
|
|
18054
|
-
},
|
|
18055
|
-
"linux-arm64": {
|
|
18056
|
-
checksum: "aa8a5b2023badafbd910bddd90f702a94338f2e83f5f62f4de17e4e20e240b0e",
|
|
18057
|
-
manifest: "4d0781f9a3648795e9f063c45643dc4f2c1d7bf7b766eee7cd99c726e5f73187"
|
|
18058
|
-
}
|
|
18059
|
-
}
|
|
18060
|
-
},
|
|
18061
|
-
"swift-6.4.0-RELEASE-custom-cbd9cef4b408cc96": {
|
|
18062
|
-
identity: "cbd9cef4b408cc96",
|
|
18063
|
-
archive: "tar.zst",
|
|
18064
|
-
hosts: {
|
|
18065
|
-
"darwin-arm64": {
|
|
18066
|
-
checksum: "97ed2a6b10ae85e73422656fe7b44fdbd5e2343d7082ef2cb39476847988e615",
|
|
18067
|
-
manifest: "49c8002809ba90b16e2619653994bc776b5bc7ef26b98796233d8b425515b734"
|
|
18068
|
-
},
|
|
18069
|
-
"linux-x64": {
|
|
18070
|
-
checksum: "b404cffaa55b783098056cce0ef568d864bc92910dafa89dd0650d0e9d019918",
|
|
18071
|
-
manifest: "19c333d87f2ffc5c716e0561b3bcb0c2a6c6015ccd4a404a739099c6aa3b898f"
|
|
18072
|
-
},
|
|
18073
|
-
"linux-arm64": {
|
|
18074
|
-
checksum: "47d8572b0438f100494edaeb4c7b24fbf5c627d7d02a09fcd68a95c6d2d780f5",
|
|
18075
|
-
manifest: "b27a2bccb5a8a0988414951b3b4a4cd9d3acc315694f59ae4c166c2f41282171"
|
|
18076
|
-
}
|
|
18077
|
-
}
|
|
18078
|
-
},
|
|
18079
|
-
"swift-6.4.0-RELEASE-custom-fb42d2535739dfd2": {
|
|
18080
|
-
identity: "fb42d2535739dfd2",
|
|
18081
|
-
archive: "tar.zst",
|
|
18082
|
-
hosts: {
|
|
18083
|
-
"darwin-arm64": {
|
|
18084
|
-
checksum: "5e417d415ca74a435755e298a1d2d19ec47637fd03479de7a7d958eb382941f1",
|
|
18085
|
-
manifest: "eb5a0356aebabe89c7b2780f8809e13d6e2ad6f342fed87cf99f9a5834344363"
|
|
18086
|
-
},
|
|
18087
|
-
"linux-arm64": {
|
|
18088
|
-
checksum: "8ac7ad97f3d68bf485423001d1ce3cd92a8d4625313c47c8071867a9aeed3af9",
|
|
18089
|
-
manifest: "6126266dd65b43c43d719e4dc4d33c4ea6a3267f99f34e3638637439a995af2e"
|
|
18090
|
-
},
|
|
18091
|
-
"linux-x64": {
|
|
18092
|
-
checksum: "7d76463079619ba822123d250601bd35f6744ed5f8054a657ce472ce4dac76c8",
|
|
18093
|
-
manifest: "f1a6c0c61d15eddb2ecfa4c3a72a5154621881ac2f0c413162ff1d0f4343bd0e"
|
|
18094
|
-
}
|
|
18095
|
-
}
|
|
18096
|
-
},
|
|
18097
|
-
"swift-6.4.0-RELEASE-custom-11345d60dca47496": {
|
|
18098
|
-
identity: "11345d60dca47496",
|
|
18099
|
-
archive: "tar.zst",
|
|
18100
|
-
hosts: {
|
|
18101
|
-
"darwin-arm64": {
|
|
18102
|
-
checksum: "3df74a95c6f3ffa45aaa412027b390c99f9af81f6f6a41bf6d58a1a3079b5b02",
|
|
18103
|
-
manifest: "8e5ed4be6adc967e4c7d955eff004c96d5dc050a589d50e1b3e694b70f9afd63"
|
|
18104
|
-
},
|
|
18105
|
-
"linux-x64": {
|
|
18106
|
-
checksum: "a80e46add069932114bacc18640dc2e6a1a8f2a3ea7306a8ea8614d5cdf6e0e7",
|
|
18107
|
-
manifest: "662d8869534f3cce827b1205973db1f9a1e1d92027005a5bdb6893f9c2a0b39d"
|
|
18108
|
-
},
|
|
18109
|
-
"linux-arm64": {
|
|
18110
|
-
checksum: "4ca69bbc284fc7d54be57c80b744b88cce997d470ff23048795db54e7a6fbcba",
|
|
18111
|
-
manifest: "85df84da2f814b6a71c264b37b83a81965ac33b5d2b465443d60c08cc7bc5dc3"
|
|
18112
|
-
}
|
|
18113
|
-
}
|
|
18114
|
-
},
|
|
18115
|
-
"swift-6.4.0-RELEASE-custom-81b2c791c27276bf": {
|
|
18116
|
-
identity: "81b2c791c27276bf",
|
|
18117
|
-
archive: "tar.gz",
|
|
18118
|
-
hosts: {
|
|
18119
|
-
"darwin-arm64": {
|
|
18120
|
-
checksum: "bc51b83d9e2e01c9873875326544734486d3ff3a868d650379c304045e8838d3",
|
|
18121
|
-
manifest: "a26eb9cb4fbd1dbd7faac20cced1ec5e67745bd358aa1180cc4abc1a0d21d6e6"
|
|
18122
|
-
},
|
|
18123
|
-
"linux-x64": {
|
|
18124
|
-
checksum: "ea63bbdecae14ff8e9e3f535b521fedc65d51b31521c5d10cc332cb91882d058",
|
|
18125
|
-
manifest: "b22b321ce3eb3fe044fa2122484a15c061f262c45d88a05b3fbace0a5bf038b6"
|
|
18126
|
-
},
|
|
18127
|
-
"linux-arm64": {
|
|
18128
|
-
checksum: "3eef4ed57830908515d8def2882e312f7cabeea57ccda5b2a7585401ef98cc48",
|
|
18129
|
-
manifest: "cfab342b8090fa83a697a391a7563cba14b771c24f07e1f8e19977f913ac88be"
|
|
18130
|
-
}
|
|
18131
|
-
}
|
|
18132
|
-
}
|
|
18133
|
-
};
|
|
18134
|
-
linuxRuntimeLibs = {
|
|
18135
|
-
x64: {
|
|
18136
|
-
url: "https://r2.sootsim.com/swift-linux-runtime/libxml2-2.9.14/x64/libxml2.so.2",
|
|
18137
|
-
checksum: "ae1982f7614096bdbd42301e7acc5f74be2aca295eb603cc81ad55d00ddde763"
|
|
18138
|
-
},
|
|
18139
|
-
arm64: {
|
|
18140
|
-
url: "https://r2.sootsim.com/swift-linux-runtime/libxml2-2.9.14/arm64/libxml2.so.2",
|
|
18141
|
-
checksum: "70acdc2a54328159fdff4ec39f5e75bda7b8301af60698b88d8fa99766252b4b"
|
|
18142
|
-
}
|
|
18143
|
-
};
|
|
18144
|
-
SWIFT_PRIVATE_DISTRIBUTION_ENV = "PEACH_SWIFT_PRIVATE_DISTRIBUTION";
|
|
18145
|
-
SWIFT_AUTOLINK_LINKER = ".peach-wasm-ld";
|
|
18146
|
-
BUILDERS_ROOT_ENV = "CONTRAST_BUILDERS_ROOT";
|
|
18147
|
-
SWIFT_CACHE_HOLD_MARKER = ".tm-hold";
|
|
18148
|
-
SWIFT_CACHE_HOLD_MS = 7 * 24 * 36e5;
|
|
18149
|
-
SwiftSdkPayloadMismatch = class extends Error {
|
|
18150
|
-
};
|
|
18151
|
-
listedSdks = /* @__PURE__ */ new Set();
|
|
18152
|
-
sdkBundles = /* @__PURE__ */ new Map();
|
|
18153
|
-
sdkFileHashes = /* @__PURE__ */ new Map();
|
|
18154
|
-
sdkFilesHashed = 0;
|
|
18155
|
-
loadedSdkHashFiles = /* @__PURE__ */ new Set();
|
|
18156
|
-
verifiedCompilers = /* @__PURE__ */ new Map();
|
|
18189
|
+
init_swift_objc_sdk_tree();
|
|
18157
18190
|
}
|
|
18158
18191
|
});
|
|
18159
18192
|
|
|
@@ -24557,6 +24590,7 @@ var init_swiftSdkLinkContract = __esm({
|
|
|
24557
24590
|
|
|
24558
24591
|
// src/swift-sdk-image-wasm.ts
|
|
24559
24592
|
function wasmReader(bytes, start) {
|
|
24593
|
+
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
24560
24594
|
let at = start;
|
|
24561
24595
|
const u = () => {
|
|
24562
24596
|
let value = 0;
|
|
@@ -24585,7 +24619,7 @@ function wasmReader(bytes, start) {
|
|
|
24585
24619
|
name: () => {
|
|
24586
24620
|
const length = u();
|
|
24587
24621
|
at += length;
|
|
24588
|
-
return
|
|
24622
|
+
return rawBuf.toString("utf8", at - length, at);
|
|
24589
24623
|
},
|
|
24590
24624
|
skip: (length) => {
|
|
24591
24625
|
at += length;
|
|
@@ -24939,7 +24973,7 @@ function codeOnlySdkImage(bytes, constructorMask) {
|
|
|
24939
24973
|
const bodies = m.bodies.map(({ start, end }) => bytes.subarray(start, end));
|
|
24940
24974
|
const initMemory = functionIndex("__wasm_init_memory") - m.importedFuncs;
|
|
24941
24975
|
{
|
|
24942
|
-
const body = Uint8Array
|
|
24976
|
+
const body = new Uint8Array(bodies[initMemory]);
|
|
24943
24977
|
const r = wasmReader(body, 0);
|
|
24944
24978
|
if (r.u() !== 0) throw new Error("sdk memory initializer has locals");
|
|
24945
24979
|
while (r.at < body.length) {
|
|
@@ -25975,7 +26009,18 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
25975
26009
|
dataOwnerSymIdx[kept] = ownerSymIdx;
|
|
25976
26010
|
kept++;
|
|
25977
26011
|
}
|
|
25978
|
-
const dataRelocs = {
|
|
26012
|
+
const dataRelocs = kept === rawData.count ? {
|
|
26013
|
+
count: kept,
|
|
26014
|
+
bytes: rawData.bytes,
|
|
26015
|
+
start: rawData.start,
|
|
26016
|
+
end: rawData.end,
|
|
26017
|
+
ro: rawData.ro,
|
|
26018
|
+
rs: rawData.rs,
|
|
26019
|
+
addend: rawData.addend,
|
|
26020
|
+
segIdx: dataSegIdx,
|
|
26021
|
+
offInSeg: dataOffInSeg,
|
|
26022
|
+
ownerSymIdx: dataOwnerSymIdx
|
|
26023
|
+
} : {
|
|
25979
26024
|
count: kept,
|
|
25980
26025
|
bytes: rawData.bytes,
|
|
25981
26026
|
start: rawData.start.slice(0, kept),
|
|
@@ -25987,26 +26032,29 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
25987
26032
|
offInSeg: dataOffInSeg.slice(0, kept),
|
|
25988
26033
|
ownerSymIdx: dataOwnerSymIdx.slice(0, kept)
|
|
25989
26034
|
};
|
|
25990
|
-
|
|
25991
|
-
|
|
25992
|
-
|
|
25993
|
-
|
|
25994
|
-
|
|
25995
|
-
|
|
25996
|
-
|
|
25997
|
-
|
|
25998
|
-
|
|
25999
|
-
const
|
|
26000
|
-
|
|
26001
|
-
|
|
26002
|
-
|
|
26003
|
-
|
|
26004
|
-
|
|
26005
|
-
|
|
26006
|
-
|
|
26007
|
-
|
|
26008
|
-
|
|
26009
|
-
|
|
26035
|
+
if (segTopSyms.size > 0) {
|
|
26036
|
+
const relocatedWords = /* @__PURE__ */ new Map();
|
|
26037
|
+
for (let i = 0; i < dataRelocs.count; i++) {
|
|
26038
|
+
const segIdx = dataRelocs.segIdx[i];
|
|
26039
|
+
if (!segTopSyms.has(segIdx)) continue;
|
|
26040
|
+
let words2 = relocatedWords.get(segIdx);
|
|
26041
|
+
if (!words2) relocatedWords.set(segIdx, words2 = /* @__PURE__ */ new Set());
|
|
26042
|
+
words2.add(dataRelocs.offInSeg[i]);
|
|
26043
|
+
}
|
|
26044
|
+
for (const [segIdx, tops] of segTopSyms) {
|
|
26045
|
+
const starts = new Map(tops.map((top) => [top.off, top.symIdx]));
|
|
26046
|
+
const relocated = relocatedWords.get(segIdx);
|
|
26047
|
+
const payload = dataStart + sPayloadStarts[segIdx];
|
|
26048
|
+
const view = new DataView(buf.buffer, buf.byteOffset + payload);
|
|
26049
|
+
for (const top of tops) {
|
|
26050
|
+
for (let at = top.off; at + 4 <= top.end; at += 4) {
|
|
26051
|
+
if (relocated?.has(at)) continue;
|
|
26052
|
+
const target = starts.get(at + (view.getInt32(at, true) & ~3));
|
|
26053
|
+
if (target === void 0 || target === top.symIdx) continue;
|
|
26054
|
+
let list2 = symDataRelocs.get(top.symIdx);
|
|
26055
|
+
if (!list2) symDataRelocs.set(top.symIdx, list2 = []);
|
|
26056
|
+
list2.push(target);
|
|
26057
|
+
}
|
|
26010
26058
|
}
|
|
26011
26059
|
}
|
|
26012
26060
|
}
|
|
@@ -26178,7 +26226,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
26178
26226
|
};
|
|
26179
26227
|
}
|
|
26180
26228
|
function parseWasmObjectFile(file, isDist) {
|
|
26181
|
-
return parseWasmObjectBytes(file,
|
|
26229
|
+
return parseWasmObjectBytes(file, import_node_fs29.default.readFileSync(file), isDist);
|
|
26182
26230
|
}
|
|
26183
26231
|
function parseWasmObjectCached(file, isDist, entries2) {
|
|
26184
26232
|
const key2 = `${isDist ? "1" : "0"}:${file}`;
|
|
@@ -26193,7 +26241,7 @@ function parseWasmObjectCached(file, isDist, entries2) {
|
|
|
26193
26241
|
function localizeDefinedWasmSymbols(bytes, names) {
|
|
26194
26242
|
const offsets = [];
|
|
26195
26243
|
const object8 = parseWasmObjectBytes("", bytes, false, offsets);
|
|
26196
|
-
const output = Uint8Array
|
|
26244
|
+
const output = new Uint8Array(bytes);
|
|
26197
26245
|
let changed = 0;
|
|
26198
26246
|
for (let index = 0; index < object8.symNames.length; index++) {
|
|
26199
26247
|
if (!names.has(object8.symNames[index])) continue;
|
|
@@ -29371,18 +29419,6 @@ function readWasmMemoryAndTableImports(bytes, layout2) {
|
|
|
29371
29419
|
}
|
|
29372
29420
|
return { memory, tableImports };
|
|
29373
29421
|
}
|
|
29374
|
-
function hasWasmExport(bytes, name3) {
|
|
29375
|
-
const section2 = wasmSections2(bytes).find((value) => value.id === 7);
|
|
29376
|
-
if (!section2) return false;
|
|
29377
|
-
const input = readWasmSection(bytes, section2.start, section2.end);
|
|
29378
|
-
for (let count = input.number(); count > 0; count--) {
|
|
29379
|
-
const found = input.name();
|
|
29380
|
-
input.byte();
|
|
29381
|
-
input.number();
|
|
29382
|
-
if (found === name3) return true;
|
|
29383
|
-
}
|
|
29384
|
-
return false;
|
|
29385
|
-
}
|
|
29386
29422
|
function withSections(bytes, layout2, replacements) {
|
|
29387
29423
|
const parts = [bytes.subarray(0, 8)];
|
|
29388
29424
|
let at = 8;
|
|
@@ -30116,23 +30152,40 @@ function reserveGuestProjectionStorage(images, capacities) {
|
|
|
30116
30152
|
};
|
|
30117
30153
|
}
|
|
30118
30154
|
function mergeGuestProjectionSpans(imageCount, spans) {
|
|
30119
|
-
const
|
|
30120
|
-
|
|
30121
|
-
)
|
|
30122
|
-
const merged = [];
|
|
30123
|
-
for (const span of sorted2) {
|
|
30155
|
+
const tableSpans = [];
|
|
30156
|
+
const memorySpans = [];
|
|
30157
|
+
for (const span of spans) {
|
|
30124
30158
|
if (!Number.isInteger(span.image) || span.image < 0 || span.image >= imageCount || !Number.isInteger(span.address) || !Number.isInteger(span.length) || span.address < 0 || span.length <= 0 || span.address + span.length > 4294967296)
|
|
30125
30159
|
throw new Error("invalid linked guest span");
|
|
30126
|
-
|
|
30127
|
-
|
|
30128
|
-
throw new Error("linked guest span has ambiguous image ownership");
|
|
30129
|
-
if (previous && previous.space === span.space && previous.image === span.image && span.address <= previous.address + previous.length) {
|
|
30130
|
-
merged[merged.length - 1] = {
|
|
30131
|
-
...previous,
|
|
30132
|
-
length: Math.max(previous.address + previous.length, span.address + span.length) - previous.address
|
|
30133
|
-
};
|
|
30134
|
-
} else merged.push(span);
|
|
30160
|
+
if (span.space === "function-table") tableSpans.push(span);
|
|
30161
|
+
else memorySpans.push(span);
|
|
30135
30162
|
}
|
|
30163
|
+
const byAddress = (a, b) => a.address - b.address || a.image - b.image;
|
|
30164
|
+
tableSpans.sort(byAddress);
|
|
30165
|
+
memorySpans.sort(byAddress);
|
|
30166
|
+
const merged = [];
|
|
30167
|
+
const mergeGroup = (group) => {
|
|
30168
|
+
let previous = null;
|
|
30169
|
+
for (const span of group) {
|
|
30170
|
+
if (previous && span.address < previous.address + previous.length && previous.image !== span.image)
|
|
30171
|
+
throw new Error("linked guest span has ambiguous image ownership");
|
|
30172
|
+
if (previous && previous.image === span.image && span.address <= previous.address + previous.length) {
|
|
30173
|
+
const end = span.address + span.length;
|
|
30174
|
+
if (end > previous.address + previous.length)
|
|
30175
|
+
previous.length = end - previous.address;
|
|
30176
|
+
} else {
|
|
30177
|
+
previous = {
|
|
30178
|
+
image: span.image,
|
|
30179
|
+
space: span.space,
|
|
30180
|
+
address: span.address,
|
|
30181
|
+
length: span.length
|
|
30182
|
+
};
|
|
30183
|
+
merged.push(previous);
|
|
30184
|
+
}
|
|
30185
|
+
}
|
|
30186
|
+
};
|
|
30187
|
+
mergeGroup(tableSpans);
|
|
30188
|
+
mergeGroup(memorySpans);
|
|
30136
30189
|
return merged;
|
|
30137
30190
|
}
|
|
30138
30191
|
function guestProjectionRegionCounts(imageCount, spans) {
|
|
@@ -30328,7 +30381,7 @@ function sdkArtifactBytes(root, artifact) {
|
|
|
30328
30381
|
const source = (0, import_node_fs32.readFileSync)(import_node_path30.default.join(sourceDirectory, "libFoundation.a"));
|
|
30329
30382
|
if (hash(source) !== artifact.sha256)
|
|
30330
30383
|
throw new Error(`SDK product artifact changed ${file}`);
|
|
30331
|
-
const transformed = Uint8Array
|
|
30384
|
+
const transformed = new Uint8Array(source);
|
|
30332
30385
|
weakenFoundationOverridesInArchive(transformed);
|
|
30333
30386
|
if (!linked.equals(transformed))
|
|
30334
30387
|
throw new Error(`SDK view transformation changed ${file}`);
|
|
@@ -30868,17 +30921,17 @@ var init_binaryen_lock = __esm({
|
|
|
30868
30921
|
"linux-x64": {
|
|
30869
30922
|
asset: "x86_64-linux",
|
|
30870
30923
|
upstreamSha256: "195ddc94f9bc89f45abdabb0b9eea86023d727ba90eac8b35b80f2544fc30572",
|
|
30871
|
-
sha256: "
|
|
30924
|
+
sha256: "1024974f254c1c2edd738246ec6af5add16d3d36b5f58a94545febda3b33c869"
|
|
30872
30925
|
},
|
|
30873
30926
|
"linux-arm64": {
|
|
30874
30927
|
asset: "aarch64-linux",
|
|
30875
30928
|
upstreamSha256: "c58562417836c5d0493d89bdefc434933bdc097db641b483df86bcfa557a107f",
|
|
30876
|
-
sha256: "
|
|
30929
|
+
sha256: "7dedfc9f5cb32e75a28831f3b5aa053fd3e0bdd74f73dc4d1b1588947236daef"
|
|
30877
30930
|
},
|
|
30878
30931
|
"darwin-arm64": {
|
|
30879
30932
|
asset: "arm64-macos",
|
|
30880
30933
|
upstreamSha256: "98aad827847af7ef990ed7098d885725c8e5b5aae75073403635617ae4e259aa",
|
|
30881
|
-
sha256: "
|
|
30934
|
+
sha256: "0b56e0a06b6a873877871537a120fd94e2121e67f4bce5f8b5252c47b615854a"
|
|
30882
30935
|
}
|
|
30883
30936
|
}
|
|
30884
30937
|
};
|
|
@@ -30907,6 +30960,45 @@ var init_wasm_features = __esm({
|
|
|
30907
30960
|
});
|
|
30908
30961
|
|
|
30909
30962
|
// src/wasm-optimize.ts
|
|
30963
|
+
function readWasmMemoryFromFile(file) {
|
|
30964
|
+
const fd = (0, import_node_fs33.openSync)(file, "r");
|
|
30965
|
+
try {
|
|
30966
|
+
const total = (0, import_node_fs33.fstatSync)(fd).size;
|
|
30967
|
+
const header = Buffer.allocUnsafe(8);
|
|
30968
|
+
if (total < 8 || (0, import_node_fs33.readSync)(fd, header, 0, 8, 0) < 8) return void 0;
|
|
30969
|
+
let offset = 8;
|
|
30970
|
+
const probe = Buffer.allocUnsafe(16);
|
|
30971
|
+
let prefixEnd = 8;
|
|
30972
|
+
while (offset < total) {
|
|
30973
|
+
const read = (0, import_node_fs33.readSync)(fd, probe, 0, Math.min(16, total - offset), offset);
|
|
30974
|
+
if (read < 2) break;
|
|
30975
|
+
const id = probe[0];
|
|
30976
|
+
let size2 = 0;
|
|
30977
|
+
let shift = 0;
|
|
30978
|
+
let at = 1;
|
|
30979
|
+
for (; ; ) {
|
|
30980
|
+
const byte = probe[at++];
|
|
30981
|
+
size2 += (byte & 127) * 2 ** shift;
|
|
30982
|
+
if (!(byte & 128)) break;
|
|
30983
|
+
shift += 7;
|
|
30984
|
+
}
|
|
30985
|
+
const next = offset + at + size2;
|
|
30986
|
+
if (id === 2 || id === 5) prefixEnd = next;
|
|
30987
|
+
if (id > 5) break;
|
|
30988
|
+
offset = next;
|
|
30989
|
+
}
|
|
30990
|
+
const prefix = Buffer.allocUnsafe(prefixEnd);
|
|
30991
|
+
let filled = 0;
|
|
30992
|
+
while (filled < prefixEnd) {
|
|
30993
|
+
const n = (0, import_node_fs33.readSync)(fd, prefix, filled, prefixEnd - filled, filled);
|
|
30994
|
+
if (n <= 0) break;
|
|
30995
|
+
filled += n;
|
|
30996
|
+
}
|
|
30997
|
+
return readWasmMemory(prefix.subarray(0, filled));
|
|
30998
|
+
} finally {
|
|
30999
|
+
(0, import_node_fs33.closeSync)(fd);
|
|
31000
|
+
}
|
|
31001
|
+
}
|
|
30910
31002
|
async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableEnd, wideExports) {
|
|
30911
31003
|
const admittedCores = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
|
|
30912
31004
|
const requestedCores = Number(process.env.BINARYEN_CORES);
|
|
@@ -30923,25 +31015,75 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableE
|
|
|
30923
31015
|
return;
|
|
30924
31016
|
}
|
|
30925
31017
|
const optimizeSize = optimize === true || optimize === "app-module";
|
|
30926
|
-
const optimizeBeforeGuard = optimize === true;
|
|
30927
31018
|
const relink = optimize === "relink";
|
|
30928
|
-
const
|
|
30929
|
-
const
|
|
30930
|
-
let input = (0, import_node_fs33.readFileSync)(file);
|
|
30931
|
-
const memory = readWasmMemory(input);
|
|
30932
|
-
const checked = `${output}.stack-checked`;
|
|
31019
|
+
const keepNames = !optimizeSize && !relink || KEEP_WASM_NAMES;
|
|
31020
|
+
const memory = readWasmMemoryFromFile(file);
|
|
30933
31021
|
if (memory?.shared && memory.maximumPages !== 65536)
|
|
30934
31022
|
throw new Error("threaded native memory must declare a 65536-page maximum");
|
|
30935
|
-
if (memory?.shared
|
|
30936
|
-
|
|
30937
|
-
|
|
30938
|
-
|
|
30939
|
-
|
|
30940
|
-
|
|
30941
|
-
|
|
30942
|
-
"
|
|
31023
|
+
if (memory?.shared) {
|
|
31024
|
+
const wideExportsFile = wideExports.size ? `${output}.wide-exports` : void 0;
|
|
31025
|
+
const tableTool = (0, import_node_path31.join)((0, import_node_path31.dirname)(binary2), "wasm-table-guard");
|
|
31026
|
+
try {
|
|
31027
|
+
if (wideExportsFile)
|
|
31028
|
+
(0, import_node_fs33.writeFileSync)(wideExportsFile, [...wideExports].join("\n") + "\n");
|
|
31029
|
+
const pipelineArgs = [
|
|
31030
|
+
"--pipeline",
|
|
31031
|
+
"--in",
|
|
31032
|
+
file,
|
|
31033
|
+
"--out",
|
|
31034
|
+
output,
|
|
31035
|
+
"--narrow",
|
|
31036
|
+
...wideExportsFile ? ["--wide-exports-file", wideExportsFile] : [],
|
|
31037
|
+
"--lower",
|
|
31038
|
+
"--shared",
|
|
31039
|
+
...keepNames ? ["--debug"] : [],
|
|
31040
|
+
...sdkTableEnd !== void 0 ? ["--slots-range", "1", String(sdkTableEnd), "--adapt"] : [],
|
|
31041
|
+
...optimizeSize ? ["--optimize", "oz"] : relink ? ["--optimize", "relink"] : [],
|
|
31042
|
+
...skipPasses.flatMap((pass) => ["--skip-pass", pass])
|
|
31043
|
+
];
|
|
31044
|
+
const { stdout } = await runBinaryen(tableTool, pipelineArgs, { env: environment });
|
|
31045
|
+
const metadata = JSON.parse(stdout);
|
|
31046
|
+
if (typeof metadata !== "object" || metadata === null || !("tableMinimum" in metadata) || typeof metadata.tableMinimum !== "number" || !Number.isSafeInteger(metadata.tableMinimum) || metadata.tableMinimum < 0)
|
|
31047
|
+
throw new Error("native table tool returned an invalid table minimum");
|
|
31048
|
+
const sectionName = new TextEncoder().encode(NATIVE_IMAGE_SECTION);
|
|
31049
|
+
const layout2 = new TextEncoder().encode(
|
|
31050
|
+
JSON.stringify({
|
|
31051
|
+
initialPages: memory.initialPages,
|
|
31052
|
+
tableMinimum: metadata.tableMinimum
|
|
31053
|
+
})
|
|
31054
|
+
);
|
|
31055
|
+
const encode = (value) => {
|
|
31056
|
+
const bytes2 = [];
|
|
31057
|
+
do {
|
|
31058
|
+
const byte = value & 127;
|
|
31059
|
+
value >>>= 7;
|
|
31060
|
+
bytes2.push(byte | (value ? 128 : 0));
|
|
31061
|
+
} while (value);
|
|
31062
|
+
return bytes2;
|
|
31063
|
+
};
|
|
31064
|
+
const body = new Uint8Array([
|
|
31065
|
+
...encode(sectionName.length),
|
|
31066
|
+
...sectionName,
|
|
31067
|
+
...layout2
|
|
31068
|
+
]);
|
|
31069
|
+
const bytes = (0, import_node_fs33.readFileSync)(output);
|
|
31070
|
+
(0, import_node_fs33.writeFileSync)(
|
|
31071
|
+
output,
|
|
31072
|
+
Buffer.concat([
|
|
31073
|
+
sdkTableEnd === void 0 ? withWasmTableMinimum(
|
|
31074
|
+
bytes,
|
|
31075
|
+
metadata.tableMinimum + NATIVE_TABLE_RESERVE_SLOTS
|
|
31076
|
+
) : bytes,
|
|
31077
|
+
Buffer.from([0, ...encode(body.length), ...body])
|
|
31078
|
+
])
|
|
30943
31079
|
);
|
|
31080
|
+
} finally {
|
|
31081
|
+
if (wideExportsFile) (0, import_node_fs33.rmSync)(wideExportsFile, { force: true });
|
|
31082
|
+
}
|
|
31083
|
+
return;
|
|
30944
31084
|
}
|
|
31085
|
+
const outputNames = keepNames ? ["-g"] : [];
|
|
31086
|
+
const input = (0, import_node_fs33.readFileSync)(file);
|
|
30945
31087
|
const narrowed = narrowWasmBoundary(input, wideExports);
|
|
30946
31088
|
const merged = `${output}.narrowed`;
|
|
30947
31089
|
if (narrowed) {
|
|
@@ -30953,7 +31095,7 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableE
|
|
|
30953
31095
|
(0, import_node_path31.join)((0, import_node_path31.dirname)(binary2), "wasm-merge"),
|
|
30954
31096
|
[
|
|
30955
31097
|
...features,
|
|
30956
|
-
...
|
|
31098
|
+
...outputNames,
|
|
30957
31099
|
guest,
|
|
30958
31100
|
NARROW_MERGE_NAMES.guest,
|
|
30959
31101
|
thunks,
|
|
@@ -30967,118 +31109,25 @@ async function runWasmOpt(file, output, optimize, skipPasses, binary2, sdkTableE
|
|
|
30967
31109
|
(0, import_node_fs33.rmSync)(guest);
|
|
30968
31110
|
(0, import_node_fs33.rmSync)(thunks);
|
|
30969
31111
|
}
|
|
30970
|
-
const
|
|
30971
|
-
const compiled = narrowed ? merged : memory?.shared && optimizeBeforeGuard ? checked : file;
|
|
31112
|
+
const compiled = narrowed ? merged : file;
|
|
30972
31113
|
const skip = skipPasses.flatMap((pass) => ["--skip-pass", pass]);
|
|
30973
31114
|
try {
|
|
30974
|
-
|
|
30975
|
-
|
|
30976
|
-
|
|
30977
|
-
|
|
30978
|
-
|
|
30979
|
-
|
|
30980
|
-
|
|
30981
|
-
|
|
30982
|
-
|
|
30983
|
-
|
|
30984
|
-
|
|
30985
|
-
|
|
30986
|
-
|
|
30987
|
-
|
|
30988
|
-
);
|
|
30989
|
-
if (memory?.shared) {
|
|
30990
|
-
const guarded = `${output}.table.wasm`;
|
|
30991
|
-
const sdkGuarded = `${output}.sdk-table.wasm`;
|
|
30992
|
-
const sdkSlots = `${output}.sdk-table-slots`;
|
|
30993
|
-
const tableTool = (0, import_node_path31.join)((0, import_node_path31.dirname)(binary2), "wasm-table-guard");
|
|
30994
|
-
try {
|
|
30995
|
-
const { stdout } = await runBinaryen(
|
|
30996
|
-
tableTool,
|
|
30997
|
-
[
|
|
30998
|
-
optimizeBeforeGuard ? lowered : compiled,
|
|
30999
|
-
guarded,
|
|
31000
|
-
names.length ? "1" : "0",
|
|
31001
|
-
...optimizeBeforeGuard ? [] : ["lower"]
|
|
31002
|
-
],
|
|
31003
|
-
{ env: environment }
|
|
31004
|
-
);
|
|
31005
|
-
const metadata = JSON.parse(stdout);
|
|
31006
|
-
if (typeof metadata !== "object" || metadata === null || !("tableMinimum" in metadata) || typeof metadata.tableMinimum !== "number" || !Number.isSafeInteger(metadata.tableMinimum) || metadata.tableMinimum < 0)
|
|
31007
|
-
throw new Error("native table tool returned an invalid table minimum");
|
|
31008
|
-
if (sdkTableEnd !== void 0) {
|
|
31009
|
-
(0, import_node_fs33.writeFileSync)(
|
|
31010
|
-
sdkSlots,
|
|
31011
|
-
Array.from({ length: sdkTableEnd - 1 }, (_, index) => index + 1).join("\n")
|
|
31012
|
-
);
|
|
31013
|
-
await runBinaryen(
|
|
31014
|
-
tableTool,
|
|
31015
|
-
[guarded, sdkGuarded, names.length ? "1" : "0", "0", sdkSlots, "adapt"],
|
|
31016
|
-
{ env: environment }
|
|
31017
|
-
);
|
|
31018
|
-
(0, import_node_fs33.renameSync)(sdkGuarded, guarded);
|
|
31019
|
-
}
|
|
31020
|
-
if (optimize)
|
|
31021
|
-
await runBinaryen(
|
|
31022
|
-
binary2,
|
|
31023
|
-
[
|
|
31024
|
-
...features,
|
|
31025
|
-
// an adapted call tests its target's type with a typed function reference.
|
|
31026
|
-
...sdkTableEnd === void 0 ? [] : ["--enable-gc"],
|
|
31027
|
-
...optimizeSize ? ["-Oz"] : RELINK_PASSES,
|
|
31028
|
-
...outputNames,
|
|
31029
|
-
...skip,
|
|
31030
|
-
guarded,
|
|
31031
|
-
"-o",
|
|
31032
|
-
output
|
|
31033
|
-
],
|
|
31034
|
-
{ env: environment }
|
|
31035
|
-
);
|
|
31036
|
-
const sectionName = new TextEncoder().encode(NATIVE_IMAGE_SECTION);
|
|
31037
|
-
const layout2 = new TextEncoder().encode(
|
|
31038
|
-
JSON.stringify({
|
|
31039
|
-
initialPages: memory.initialPages,
|
|
31040
|
-
tableMinimum: metadata.tableMinimum
|
|
31041
|
-
})
|
|
31042
|
-
);
|
|
31043
|
-
const encode = (value) => {
|
|
31044
|
-
const bytes2 = [];
|
|
31045
|
-
do {
|
|
31046
|
-
const byte = value & 127;
|
|
31047
|
-
value >>>= 7;
|
|
31048
|
-
bytes2.push(byte | (value ? 128 : 0));
|
|
31049
|
-
} while (value);
|
|
31050
|
-
return bytes2;
|
|
31051
|
-
};
|
|
31052
|
-
const body = new Uint8Array([
|
|
31053
|
-
...encode(sectionName.length),
|
|
31054
|
-
...sectionName,
|
|
31055
|
-
...layout2
|
|
31056
|
-
]);
|
|
31057
|
-
const image = optimize ? output : guarded;
|
|
31058
|
-
const bytes = (0, import_node_fs33.readFileSync)(image);
|
|
31059
|
-
(0, import_node_fs33.writeFileSync)(
|
|
31060
|
-
image,
|
|
31061
|
-
Buffer.concat([
|
|
31062
|
-
sdkTableEnd === void 0 ? withWasmTableMinimum(
|
|
31063
|
-
bytes,
|
|
31064
|
-
metadata.tableMinimum + NATIVE_TABLE_RESERVE_SLOTS
|
|
31065
|
-
) : bytes,
|
|
31066
|
-
Buffer.from([0, ...encode(body.length), ...body])
|
|
31067
|
-
])
|
|
31068
|
-
);
|
|
31069
|
-
if (!optimize) (0, import_node_fs33.renameSync)(guarded, output);
|
|
31070
|
-
} finally {
|
|
31071
|
-
(0, import_node_fs33.rmSync)(guarded, { force: true });
|
|
31072
|
-
(0, import_node_fs33.rmSync)(sdkGuarded, { force: true });
|
|
31073
|
-
(0, import_node_fs33.rmSync)(sdkSlots, { force: true });
|
|
31074
|
-
}
|
|
31075
|
-
}
|
|
31115
|
+
await runBinaryen(
|
|
31116
|
+
binary2,
|
|
31117
|
+
[
|
|
31118
|
+
...LOWERING,
|
|
31119
|
+
...optimizeSize ? ["-Oz"] : relink ? RELINK_PASSES : [],
|
|
31120
|
+
...outputNames,
|
|
31121
|
+
...skip,
|
|
31122
|
+
...features,
|
|
31123
|
+
compiled,
|
|
31124
|
+
"-o",
|
|
31125
|
+
output
|
|
31126
|
+
],
|
|
31127
|
+
{ env: environment, maxBuffer: Infinity }
|
|
31128
|
+
);
|
|
31076
31129
|
} finally {
|
|
31077
31130
|
if (narrowed) (0, import_node_fs33.rmSync)(merged, { force: true });
|
|
31078
|
-
if (memory?.shared) {
|
|
31079
|
-
(0, import_node_fs33.rmSync)(checked, { force: true });
|
|
31080
|
-
(0, import_node_fs33.rmSync)(lowered, { force: true });
|
|
31081
|
-
}
|
|
31082
31131
|
}
|
|
31083
31132
|
}
|
|
31084
31133
|
async function installWasmOpt() {
|
|
@@ -36220,9 +36269,11 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
|
|
|
36220
36269
|
objects.push({ path: object8, bytes, instrumentDynamicLookups: false });
|
|
36221
36270
|
guestObjects.set(product, objects);
|
|
36222
36271
|
};
|
|
36223
|
-
const classifyFile = (file) => {
|
|
36272
|
+
const classifyFile = (file, collectAutolink = false) => {
|
|
36224
36273
|
const bytes = (0, import_node_fs43.readFileSync)(file);
|
|
36225
36274
|
if (!file.endsWith(".a")) {
|
|
36275
|
+
if (collectAutolink)
|
|
36276
|
+
for (const library of autolinkLibraries(bytes)) libraries.add(library);
|
|
36226
36277
|
const scoped = lookups2?.rewrite(file, bytes) ?? bytes;
|
|
36227
36278
|
return addObject(file, scoped, file);
|
|
36228
36279
|
}
|
|
@@ -36230,6 +36281,8 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
|
|
|
36230
36281
|
(0, import_node_fs43.mkdirSync)(import_node_path41.default.join(members2, archive));
|
|
36231
36282
|
const ordinals = /* @__PURE__ */ new Map();
|
|
36232
36283
|
readArMembers(bytes).forEach((member, index) => {
|
|
36284
|
+
if (collectAutolink)
|
|
36285
|
+
for (const library of autolinkLibraries(member.bytes)) libraries.add(library);
|
|
36233
36286
|
const object8 = import_node_path41.default.join(members2, archive, `${index}-${import_node_path41.default.basename(member.name)}`);
|
|
36234
36287
|
const ordinal = (ordinals.get(member.name) ?? 0) + 1;
|
|
36235
36288
|
ordinals.set(member.name, ordinal);
|
|
@@ -36244,9 +36297,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
|
|
|
36244
36297
|
});
|
|
36245
36298
|
};
|
|
36246
36299
|
for (const object8 of [...link.objects, ...link.providers]) {
|
|
36247
|
-
classifyFile(object8);
|
|
36248
|
-
for (const bytes of objectMembers(object8))
|
|
36249
|
-
for (const library of autolinkLibraries(bytes)) libraries.add(library);
|
|
36300
|
+
classifyFile(object8, true);
|
|
36250
36301
|
}
|
|
36251
36302
|
for (const library of libraries) {
|
|
36252
36303
|
if (unpacked.has(library.slice(2))) continue;
|
|
@@ -36259,6 +36310,7 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
|
|
|
36259
36310
|
const hostExports = sdkHostExports(appRoot);
|
|
36260
36311
|
const guestMap = /* @__PURE__ */ new Map();
|
|
36261
36312
|
const guestMetadataNames = {};
|
|
36313
|
+
const compiles = [];
|
|
36262
36314
|
if (lookups2) {
|
|
36263
36315
|
const ledger = lookups2.link(guestObjects, [
|
|
36264
36316
|
...hostExports,
|
|
@@ -36294,33 +36346,38 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
|
|
|
36294
36346
|
const scopeLedger = import_node_path41.default.join(work, "guest-ledger.ll");
|
|
36295
36347
|
const scopeObject = import_node_path41.default.join(work, "guest-ledger.o");
|
|
36296
36348
|
(0, import_node_fs43.writeFileSync)(scopeLedger, ledger.llvmIR);
|
|
36297
|
-
|
|
36298
|
-
|
|
36299
|
-
|
|
36300
|
-
|
|
36301
|
-
|
|
36302
|
-
|
|
36303
|
-
|
|
36304
|
-
|
|
36305
|
-
|
|
36349
|
+
compiles.push(
|
|
36350
|
+
run2(import_node_path41.default.join(toolchain.toolchainBin, "clang"), [
|
|
36351
|
+
`--target=${SWIFT_WASM_TRIPLE}`,
|
|
36352
|
+
"-matomics",
|
|
36353
|
+
"-mbulk-memory",
|
|
36354
|
+
"-c",
|
|
36355
|
+
scopeLedger,
|
|
36356
|
+
"-o",
|
|
36357
|
+
scopeObject
|
|
36358
|
+
])
|
|
36359
|
+
);
|
|
36306
36360
|
eager.push(scopeObject);
|
|
36307
36361
|
}
|
|
36308
36362
|
(0, import_node_fs43.writeFileSync)(
|
|
36309
36363
|
import_node_path41.default.join(work, "image-tables.c"),
|
|
36310
36364
|
IMAGE_TABLES + (guestLookups?.source ?? "")
|
|
36311
36365
|
);
|
|
36312
|
-
|
|
36313
|
-
|
|
36314
|
-
|
|
36315
|
-
|
|
36316
|
-
|
|
36317
|
-
|
|
36318
|
-
|
|
36319
|
-
|
|
36320
|
-
|
|
36321
|
-
|
|
36322
|
-
|
|
36323
|
-
|
|
36366
|
+
compiles.push(
|
|
36367
|
+
run2(import_node_path41.default.join(toolchain.toolchainBin, "clang"), [
|
|
36368
|
+
`--target=${SWIFT_WASM_TRIPLE}`,
|
|
36369
|
+
"-O2",
|
|
36370
|
+
"-matomics",
|
|
36371
|
+
"-mbulk-memory",
|
|
36372
|
+
"-ffreestanding",
|
|
36373
|
+
...lookups2 ? ["-DPEACH_SDK_GUEST_LINK"] : [],
|
|
36374
|
+
"-c",
|
|
36375
|
+
import_node_path41.default.join(work, "image-tables.c"),
|
|
36376
|
+
"-o",
|
|
36377
|
+
tables
|
|
36378
|
+
])
|
|
36379
|
+
);
|
|
36380
|
+
await Promise.all(compiles);
|
|
36324
36381
|
const quote3 = (value) => JSON.stringify(value);
|
|
36325
36382
|
(0, import_node_fs43.writeFileSync)(
|
|
36326
36383
|
import_node_path41.default.join(work, "exports.rsp"),
|
|
@@ -36379,23 +36436,31 @@ async function linkSwiftSdkImage(moduleRoot, key2, directory2, work, scopedLooku
|
|
|
36379
36436
|
if (mask === void 0) throw new Error("sdk image lacks its constructor mask");
|
|
36380
36437
|
const code = import_node_path41.default.join(work, "code.wasm");
|
|
36381
36438
|
(0, import_node_fs43.writeFileSync)(code, codeOnlySdkImage(finished, mask));
|
|
36382
|
-
|
|
36439
|
+
const lowerPromise = lowerWasm(code, import_node_path41.default.join(work, IMAGE_FILE), {
|
|
36383
36440
|
optimize: true,
|
|
36384
36441
|
skipPasses: lookups2 ? ["duplicate-function-elimination"] : void 0
|
|
36385
36442
|
});
|
|
36443
|
+
await new Promise((resolve4) => setImmediate(resolve4));
|
|
36444
|
+
try {
|
|
36445
|
+
writeSdkManifest(
|
|
36446
|
+
work,
|
|
36447
|
+
linkMap,
|
|
36448
|
+
linkedBytes,
|
|
36449
|
+
finished,
|
|
36450
|
+
(0, import_node_fs43.readFileSync)(withRelocs),
|
|
36451
|
+
functionSlots,
|
|
36452
|
+
lookups2 && { inputs: guestMap, metadataNames: guestMetadataNames }
|
|
36453
|
+
);
|
|
36454
|
+
} catch (error) {
|
|
36455
|
+
await lowerPromise.catch(() => {
|
|
36456
|
+
});
|
|
36457
|
+
throw error;
|
|
36458
|
+
}
|
|
36459
|
+
await lowerPromise;
|
|
36386
36460
|
const image = (0, import_node_fs43.readFileSync)(import_node_path41.default.join(work, IMAGE_FILE));
|
|
36387
36461
|
sdkInterface.layout.tableEnd += unslottedFunctions(image);
|
|
36388
36462
|
if (sdkInterface.layout.tableEnd > SWIFT_SDK_APP_TABLE_BASE)
|
|
36389
36463
|
throw new Error("Swift SDK image exceeds its reserved function table range");
|
|
36390
|
-
writeSdkManifest(
|
|
36391
|
-
work,
|
|
36392
|
-
linkMap,
|
|
36393
|
-
linkedBytes,
|
|
36394
|
-
finished,
|
|
36395
|
-
(0, import_node_fs43.readFileSync)(withRelocs),
|
|
36396
|
-
functionSlots,
|
|
36397
|
-
lookups2 && { inputs: guestMap, metadataNames: guestMetadataNames }
|
|
36398
|
-
);
|
|
36399
36464
|
(0, import_node_fs43.writeFileSync)(import_node_path41.default.join(work, INTERFACE_FILE), JSON.stringify(sdkInterface));
|
|
36400
36465
|
(0, import_node_fs43.writeFileSync)(
|
|
36401
36466
|
import_node_path41.default.join(work, IMAGE_DIGEST),
|
|
@@ -36464,14 +36529,11 @@ function sdkLinkInputs(appRoot) {
|
|
|
36464
36529
|
if (!crt) throw new Error("the sdk image link found no reactor startup object");
|
|
36465
36530
|
return { flags, libraries, objects: [crt, ...objects], providers };
|
|
36466
36531
|
}
|
|
36467
|
-
function objectMembers(file) {
|
|
36468
|
-
const bytes = (0, import_node_fs43.readFileSync)(file);
|
|
36469
|
-
return file.endsWith(".a") ? readArMembers(bytes).map((member) => member.bytes) : [bytes];
|
|
36470
|
-
}
|
|
36471
36532
|
function autolinkLibraries(bytes) {
|
|
36472
36533
|
const entries2 = wasmSections(bytes).find((s) => s.name === ".swift1_autolink_entries");
|
|
36473
36534
|
if (!entries2) return [];
|
|
36474
|
-
|
|
36535
|
+
const raw2 = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
36536
|
+
return raw2.toString("utf8", entries2.start, entries2.end).split("\0").filter((entry) => entry.startsWith("-l"));
|
|
36475
36537
|
}
|
|
36476
36538
|
function sdkHostExports(appRoot) {
|
|
36477
36539
|
const release = import_node_path41.default.join(appRoot, ".build", SWIFT_WASM_TRIPLE, "release");
|
|
@@ -36557,9 +36619,17 @@ function writeSdkManifest(work, map2, linked, finished, withRelocs, functionSlot
|
|
|
36557
36619
|
return { starts, targets };
|
|
36558
36620
|
};
|
|
36559
36621
|
const byAddress = (edges2) => {
|
|
36560
|
-
const
|
|
36561
|
-
|
|
36562
|
-
|
|
36622
|
+
const count = edges2.length >>> 1;
|
|
36623
|
+
const order = new Uint32Array(count);
|
|
36624
|
+
for (let i = 0; i < count; i++) order[i] = i;
|
|
36625
|
+
order.sort((a, b) => edges2[a * 2] - edges2[b * 2]);
|
|
36626
|
+
const sorted2 = new Uint32Array(edges2.length);
|
|
36627
|
+
for (let i = 0; i < count; i++) {
|
|
36628
|
+
const src = order[i] * 2;
|
|
36629
|
+
sorted2[i * 2] = edges2[src];
|
|
36630
|
+
sorted2[i * 2 + 1] = edges2[src + 1];
|
|
36631
|
+
}
|
|
36632
|
+
return sorted2;
|
|
36563
36633
|
};
|
|
36564
36634
|
const functionData = flatten2(edges.code);
|
|
36565
36635
|
const functionCalls = flatten2(edges.calls);
|
|
@@ -36863,12 +36933,22 @@ async function buildSwiftAppModule(options2) {
|
|
|
36863
36933
|
work,
|
|
36864
36934
|
readInput
|
|
36865
36935
|
});
|
|
36866
|
-
|
|
36867
|
-
|
|
36868
|
-
|
|
36869
|
-
|
|
36870
|
-
|
|
36871
|
-
|
|
36936
|
+
const lowerPromise = link.lower();
|
|
36937
|
+
await new Promise((resolve4) => setImmediate(resolve4));
|
|
36938
|
+
let usage;
|
|
36939
|
+
let binding;
|
|
36940
|
+
try {
|
|
36941
|
+
usage = readSwiftSdkUsage(
|
|
36942
|
+
project2 ? projectOutputFile(buildRoot, map2, project2) : map2,
|
|
36943
|
+
pruned
|
|
36944
|
+
);
|
|
36945
|
+
binding = createSwiftSdkBinding(link.linkage, sdk2, usage);
|
|
36946
|
+
} catch (error) {
|
|
36947
|
+
await lowerPromise.catch(() => {
|
|
36948
|
+
});
|
|
36949
|
+
throw error;
|
|
36950
|
+
}
|
|
36951
|
+
await lowerPromise;
|
|
36872
36952
|
if (!project2)
|
|
36873
36953
|
writeSwiftSdkAppLink(import_node_path42.default.join(work, "app-link.json.gz"), {
|
|
36874
36954
|
linkage: link.linkage,
|
|
@@ -38778,7 +38858,6 @@ async function compileGuestLink(options2) {
|
|
|
38778
38858
|
bindingRows.set((address - values.address) / 8, value);
|
|
38779
38859
|
} else data.push(address, size2, value);
|
|
38780
38860
|
}
|
|
38781
|
-
const binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
|
|
38782
38861
|
const linked = (0, import_node_fs45.readFileSync)(
|
|
38783
38862
|
project2 ? projectOutputFile(work, linkedModule, project2) : linkedModule
|
|
38784
38863
|
);
|
|
@@ -38803,7 +38882,17 @@ async function compileGuestLink(options2) {
|
|
|
38803
38882
|
);
|
|
38804
38883
|
continue;
|
|
38805
38884
|
}
|
|
38806
|
-
|
|
38885
|
+
const lowerPromise = link.lower();
|
|
38886
|
+
await new Promise((resolve4) => setImmediate(resolve4));
|
|
38887
|
+
let binding;
|
|
38888
|
+
try {
|
|
38889
|
+
binding = createSwiftSdkBinding2({ ...link.linkage, data }, sdk2, usage);
|
|
38890
|
+
} catch (error) {
|
|
38891
|
+
await lowerPromise.catch(() => {
|
|
38892
|
+
});
|
|
38893
|
+
throw error;
|
|
38894
|
+
}
|
|
38895
|
+
await lowerPromise;
|
|
38807
38896
|
const finalized = finalizeGuestProjectionStorage({
|
|
38808
38897
|
map: map3,
|
|
38809
38898
|
linked,
|
|
@@ -46548,7 +46637,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
46548
46637
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
46549
46638
|
MULTI_MANIFEST_VERSION = 76;
|
|
46550
46639
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
46551
|
-
compilerSourceDigest = true ? "
|
|
46640
|
+
compilerSourceDigest = true ? "834b5c28c27bc5807cbb3c4eed5c44f7de81d47db3e3a8819bea6e6635689b24" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
46552
46641
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
46553
46642
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
46554
46643
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
@@ -86995,7 +87084,7 @@ var init_swift_standin_digest = __esm({
|
|
|
86995
87084
|
STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
|
|
86996
87085
|
SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
86997
87086
|
standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
|
|
86998
|
-
STANDIN_SOURCE_DIGEST = true ? "
|
|
87087
|
+
STANDIN_SOURCE_DIGEST = true ? "63adfed92cb0f03f7e74bd25588e866da41eaddd5ff8c13d50802edd65706617" : standinSourceDigest();
|
|
86999
87088
|
}
|
|
87000
87089
|
});
|
|
87001
87090
|
|
|
@@ -103457,7 +103546,7 @@ var init_nitro_superset = __esm({
|
|
|
103457
103546
|
init_nitroContract();
|
|
103458
103547
|
init_swift_standin_digest();
|
|
103459
103548
|
NITRO_SUPERSET_ENTRY_NAME = "superset";
|
|
103460
|
-
NITRO_COMPILER_DIGEST = true ? "
|
|
103549
|
+
NITRO_COMPILER_DIGEST = true ? "dc3119a2538cec9d009fc6b45b9a7c5729812bb7e7f263707bd7410c45a4719e" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
|
|
103461
103550
|
nitroSupersetLock = parseLock(nitro_superset_lock_default);
|
|
103462
103551
|
nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
|
|
103463
103552
|
published = /* @__PURE__ */ new Map();
|
|
@@ -104325,7 +104414,7 @@ var init_expo_eager_seam_contract = __esm({
|
|
|
104325
104414
|
|
|
104326
104415
|
// src/expo-native-compiler-digest.ts
|
|
104327
104416
|
function expoNativeCompilerDigestValue() {
|
|
104328
|
-
return true ? "
|
|
104417
|
+
return true ? "f789d146b1dafe1d68a49954dc5d223e9c982fc7b6602945b530568758babb0a" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
|
|
104329
104418
|
}
|
|
104330
104419
|
var import_node_crypto78;
|
|
104331
104420
|
var init_expo_native_compiler_digest = __esm({
|