feat(crust): add musl Linux targets, drop legacy -baseline names

Merged
CH
2mo ago
+206-54

Summary

Bun-compiled Linux binaries link against glibc and do not start on musl distributions (Alpine). Ship -musl targets alongside, following the convention used by Bun's own npm package, Biome, swc, oxlint, and sharp. While touching the target table, drop the legacy -baseline suffix that Bun now treats as an alias for the single x64 binary.

# before
crust build --target bun-linux-x64-baseline
# after (both in the default set)
crust build --target bun-linux-x64 --target bun-linux-x64-musl

Behavior

SurfaceBeforeAfter
Default Bun targets68 (+bun-linux-x64-musl, +bun-linux-arm64-musl)
Binary filenamesmy-cli-bun-linux-x64-baselinemy-cli-bun-linux-x64
--target bun-linux-x64-baselineacceptedUnknown target
--package Linux package.jsonos, cpuos, cpu, libc: ["glibc"] / ["musl"]
Node launcher platform keylinux-x64linux-x64 or linux-x64-musl via process.report.header.glibcVersionRuntime
Bash resolveruname -s-uname -msame, -musl appended when ldd --version reports musl
hostTarget()ignores libclibc-aware (Deno table returns null on musl hosts: no musl deno compile target)
Bash resolver shebang#!/usr/bin/env bash#!/bin/sh (Alpine ships no Bash)
Manifest / crust publishverifies os, cpu, binalso records and verifies libc
Bun compiler floorengines.bun >=1.3.14>=1.4.0
Deno / Node runtimes—unchanged

Why libc matters: the glibc and musl packages share os/cpu, so without the field npm and pnpm install both (~75 MB each). npm honors it through npm-install-checks; Bun's own @oven/bun-linux-* packages added it in 1.4.

Why Bun 1.4 is required

Bun 1.4.0: "x64 releases now ship only the baseline build. The separate build compiled with -march=haswell is gone." On 1.3.x, bun-linux-x64 selects the AVX2 build and -baseline the Nehalem one (release zips differ by ~370 KB; on 1.4.2 they're the same binary). So the canonical names are only safe on 1.4+. Declared in engines only; no runtime probe and no migration hints, by design. Library packages keep their 1.3.14 floor; only the compiler needs 1.4.

Verification

  • bun run lint, bun run format, bun run check:types: pass
  • packages/crust bun test: 81 pass; CRUST_SMOKE_PM=npm smoke (real npm install of staged packages): pass
  • podman run node:alpine: glibcVersionRuntime is undefined; launcher and bash resolver both select the musl binary and run; glibc binary fails with not found (missing ld-linux)
  • podman run alpine (bare): musl binary fails on libstdc++.so.6 until apk add libstdc++ libgcc; documented in the guide callout
  • podman run node:alpine without Bash: POSIX dist/cli runs, including through a symlink
  • Bun 1.4.2 locally: -musl-baseline output is byte-identical to -musl, confirming the suffix is inert

Not covered

  • packages/create-crust/tests/cli.smoke.test.ts keeps its own hand-rolled host-target picker that ignores musl; only relevant if that CI ever runs on Alpine. Left for a follow-up.
  • Not run on arm64 musl hardware; same table-driven path.

References