oven-sh/bun · error · Error

the order file tracer builds on linux x86-64/arm64 or macOS

Error message

the order file tracer builds on linux x86-64/arm64 or macOS arm64

What it means

generateOrderFile refuses to run except on Linux (x86-64/arm64) and macOS arm64, because the functrace.c tracer is only built and wired for those hosts. Any other platform aborts before touching the build directory.

Source

Thrown at scripts/orderfile/generate.ts:189

  const header = new BigUint64Array(raw.buffer, raw.byteOffset, TRACE_HEADER_WORDS);
  if (header[0] !== TRACE_MAGIC || header[1] !== 1n) throw new Error(`workload "${name}" wrote an invalid trace`);
  const count = Number(header[4]);
  if (count === 0) throw new Error(`workload "${name}" recorded no entries — is the tracer loading?`);
  const body = new BigUint64Array(raw.buffer, raw.byteOffset + TRACE_HEADER_WORDS * 8, count);
  const out: number[] = new Array(count);
  for (let i = 0; i < count; i++) out[i] = Number(body[i]);
  return out;
}

export function generateOrderFile(options: GenerateOptions): { count: number; outPath: string } {
  const buildDir = resolve(options.buildDir);
  const outPath = resolve(options.outPath ?? join(buildDir, "linker.order"));
  const minFunctions = options.minFunctions ?? MIN_FUNCTIONS;
  const log = (message: string) => options.verbose && console.log(message);

  const darwin = process.platform === "darwin";
  if (process.platform !== "linux" && !(darwin && process.arch === "arm64")) {
    throw new Error("the order file tracer builds on linux x86-64/arm64 or macOS arm64");
  }

  // The unstripped binary: its symbol table is what maps addresses back to names.
  const bunProfile = join(buildDir, options.exeName ?? "bun-profile");
  if (!existsSync(bunProfile)) {
    throw new Error(`${bunProfile} not found — build it first (bun run build:release)`);
  }

  const scratch = mkdtempSync(join(tmpdir(), "bun-orderfile-"));
  try {
    // ── Build the tracer and the pty runner ───────────────────────────────────
    const tracer = join(scratch, darwin ? "functrace.dylib" : "functrace.so");
    const ptyrun = join(scratch, "ptyrun");
    const cc = process.env.CC || "cc";
    const build = runCommand(
      darwin
        ? [cc, "-O2", "-dynamiclib", "-fPIC", "-o", tracer, join(here, "functrace.c")]
        : [cc, "-O2", "-shared", "-fPIC", "-o", tracer, join(here, "functrace.c"), "-ldl", "-lpthread"],

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Run the generator on a supported host: Linux x64/arm64 or Apple Silicon
  2. In CI, gate the orderfile job to supported runner labels
  3. Skip order file generation on unsupported machines — it is an optimization, not a required artifact

Example fix

# before — Intel mac
$ bun scripts/orderfile/generate.ts
Error: the order file tracer builds on linux x86-64/arm64 or macOS arm64

# after — run on linux x64 CI runner (or apple-silicon runner)
Defensive patterns

Strategy: type-guard

Type guard

function supportsOrderFileTracer(platform: NodeJS.Platform, arch: string): boolean {
  return platform === "linux" || (platform === "darwin" && arch === "arm64");
}

if (!supportsOrderFileTracer(process.platform, process.arch)) {
  console.error("Skipping order file generation — unsupported host");
  process.exit(0);
}

Prevention

When it happens

Trigger: Running scripts/orderfile/generate.ts (or the package script that calls it) on an Intel Mac or a Windows machine; a CI matrix job that accidentally includes an unsupported host for the orderfile step.

Common situations: Developers on macOS x64 trying to generate the order file locally; CI pipelines not gating the orderfile job by runner platform.

Related errors


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/5cdcde1ece10ee47. Report an issue: GitHub.