Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

ci: verify mold linkage in rust lane executables

Steven Enamakel55c986279d6e
diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml
new file mode 100644
index 0000000000..aad85536b6
--- /dev/null
+++ b/.github/actionlint.yaml
@@ -0,0 +1,3 @@
+self-hosted-runner:
+ labels:
+ - openhuman-ex63
diff --git a/.github/workflows/ci-lanes.yml b/.github/workflows/ci-lanes.yml
index 13bdc6544a..42643e20c0 100644
--- a/.github/workflows/ci-lanes.yml
+++ b/.github/workflows/ci-lanes.yml
@@ -147,6 +147,13 @@ jobs:
steps.filter.outputs['rust-tauri'] == 'true')
run: bash scripts/ci/self-hosted/diff-cover.sh ci-out/lcov "origin/${{ inputs.base-ref }}" ci-out/diff-cover
+ - name: Verify mold in actual lane executables
+ if: >-
+ !cancelled() && steps.summary.outcome == 'success' &&
+ (steps.filter.outputs['rust-core'] == 'true' ||
+ steps.filter.outputs['rust-tauri'] == 'true')
+ run: node scripts/ci/self-hosted/verify-linkage.mjs
+
- name: Save Tinymold cache
if: ${{ always() && steps.tinymold.outcome == 'success' }}
continue-on-error: true
diff --git a/scripts/ci/self-hosted/verify-linkage.mjs b/scripts/ci/self-hosted/verify-linkage.mjs
new file mode 100644
index 0000000000..c32a5d8e2c
--- /dev/null
+++ b/scripts/ci/self-hosted/verify-linkage.mjs
@@ -0,0 +1,54 @@
+#!/usr/bin/env node
+// Inspect real lane outputs, rather than assuming a linker flag took effect.
+import { execFileSync } from "node:child_process";
+import { readdirSync, statSync, mkdirSync, writeFileSync } from "node:fs";
+import { join, dirname } from "node:path";
+import { pathToFileURL } from "node:url";
+
+export function classifyElf(sections, comments) {
+ return {
+ executable: /\s\.interp\s/.test(sections),
+ instrumented: /__llvm_prf_(cnts|data)/.test(sections),
+ mold: /\bmold\s+\d/.test(comments),
+ };
+}
+
+export function findProof(root, instrumented) {
+ const visit = (directory) => {
+ for (const entry of readdirSync(directory, { withFileTypes: true })) {
+ const path = join(directory, entry.name);
+ if (entry.isDirectory()) {
+ if (["incremental", "build", ".fingerprint"].includes(entry.name)) continue;
+ const result = visit(path);
+ if (result) return result;
+ } else if (entry.isFile() && (statSync(path).mode & 0o111) && /\/debug\/(deps|examples)\//.test(path)) {
+ try {
+ const options = { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] };
+ const sections = execFileSync("readelf", ["-SW", path], options);
+ const comments = execFileSync("readelf", ["--string-dump=.comment", path], options);
+ const kind = classifyElf(sections, comments);
+ if (!kind.executable || kind.instrumented !== instrumented) continue;
+ if (!kind.mold) throw new Error(`ELF lacks mold metadata: ${path}`);
+ return { path, ...kind, comments: comments.trim() };
+ } catch (error) {
+ if (error.message.startsWith("ELF lacks mold")) throw error;
+ }
+ }
+ }
+ return null;
+ };
+ const result = visit(root);
+ if (!result) throw new Error(`No ${instrumented ? "instrumented" : "uninstrumented"} lane executable under ${root}`);
+ return result;
+}
+
+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
+ const output = process.argv[2] ?? "ci-out/linkage.json";
+ const proof = [
+ findProof("target/ci-private-build", false),
+ findProof("target/ci-private-coverage", true),
+ ];
+ mkdirSync(dirname(output), { recursive: true });
+ writeFileSync(output, `${JSON.stringify(proof, null, 2)}\n`);
+ console.log(JSON.stringify(proof, null, 2));
+}