{"record":{"id":"5cdcde1ece10ee47","repo":"oven-sh/bun","slug":"the-order-file-tracer-builds-on-linux-x86-64-arm64","errorCode":null,"errorMessage":"the order file tracer builds on linux x86-64/arm64 or macOS arm64","messagePattern":"the order file tracer builds on linux x86-64/arm64 or macOS arm64","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/orderfile/generate.ts","lineNumber":189,"sourceCode":"  const header = new BigUint64Array(raw.buffer, raw.byteOffset, TRACE_HEADER_WORDS);\n  if (header[0] !== TRACE_MAGIC || header[1] !== 1n) throw new Error(`workload \"${name}\" wrote an invalid trace`);\n  const count = Number(header[4]);\n  if (count === 0) throw new Error(`workload \"${name}\" recorded no entries — is the tracer loading?`);\n  const body = new BigUint64Array(raw.buffer, raw.byteOffset + TRACE_HEADER_WORDS * 8, count);\n  const out: number[] = new Array(count);\n  for (let i = 0; i < count; i++) out[i] = Number(body[i]);\n  return out;\n}\n\nexport function generateOrderFile(options: GenerateOptions): { count: number; outPath: string } {\n  const buildDir = resolve(options.buildDir);\n  const outPath = resolve(options.outPath ?? join(buildDir, \"linker.order\"));\n  const minFunctions = options.minFunctions ?? MIN_FUNCTIONS;\n  const log = (message: string) => options.verbose && console.log(message);\n\n  const darwin = process.platform === \"darwin\";\n  if (process.platform !== \"linux\" && !(darwin && process.arch === \"arm64\")) {\n    throw new Error(\"the order file tracer builds on linux x86-64/arm64 or macOS arm64\");\n  }\n\n  // The unstripped binary: its symbol table is what maps addresses back to names.\n  const bunProfile = join(buildDir, options.exeName ?? \"bun-profile\");\n  if (!existsSync(bunProfile)) {\n    throw new Error(`${bunProfile} not found — build it first (bun run build:release)`);\n  }\n\n  const scratch = mkdtempSync(join(tmpdir(), \"bun-orderfile-\"));\n  try {\n    // ── Build the tracer and the pty runner ───────────────────────────────────\n    const tracer = join(scratch, darwin ? \"functrace.dylib\" : \"functrace.so\");\n    const ptyrun = join(scratch, \"ptyrun\");\n    const cc = process.env.CC || \"cc\";\n    const build = runCommand(\n      darwin\n        ? [cc, \"-O2\", \"-dynamiclib\", \"-fPIC\", \"-o\", tracer, join(here, \"functrace.c\")]\n        : [cc, \"-O2\", \"-shared\", \"-fPIC\", \"-o\", tracer, join(here, \"functrace.c\"), \"-ldl\", \"-lpthread\"],","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/orderfile/generate.ts#L171-L207","documentation":"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.","triggerScenarios":"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.","commonSituations":"Developers on macOS x64 trying to generate the order file locally; CI pipelines not gating the orderfile job by runner platform.","solutions":["Run the generator on a supported host: Linux x64/arm64 or Apple Silicon","In CI, gate the orderfile job to supported runner labels","Skip order file generation on unsupported machines — it is an optimization, not a required artifact"],"exampleFix":"# before — Intel mac\n$ bun scripts/orderfile/generate.ts\nError: the order file tracer builds on linux x86-64/arm64 or macOS arm64\n\n# after — run on linux x64 CI runner (or apple-silicon runner)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function supportsOrderFileTracer(platform: NodeJS.Platform, arch: string): boolean {\n  return platform === \"linux\" || (platform === \"darwin\" && arch === \"arm64\");\n}\n\nif (!supportsOrderFileTracer(process.platform, process.arch)) {\n  console.error(\"Skipping order file generation — unsupported host\");\n  process.exit(0);\n}","tryCatchPattern":null,"preventionTips":["Gate orderfile CI jobs by runner platform/arch labels so they never schedule on Intel Macs or Windows","Make order file generation an optional, skip-on-unsupported step rather than part of every local build"],"tags":["platform","orderfile","build","ci"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}