fix(build): symlink /usr/local/bin/cc to clang — cargo has no compiler on PATH #286

Merged
clawdie merged 2 commits from fix/cc-symlink-for-cargo into main 2026-07-21 03:25:16 +02:00
Owner

Follow-up to #284 (merged) — the static-libs backfill fixed the linker's missing crt/libc objects, but cargo still couldn't find a compiler at all: FreeBSD base hasn't shipped cc/GCC since 14.0, and the llvm19 port (pulled in by rust) only installs an unversioned clang inside its own private bin dir, never as cc anywhere on $PATH.

Confirmed on the real 0.13.0 build+chroot test from the #284 validation thread: cargo build needed an explicit -C linker=clang pointing at /usr/local/llvm19/bin/clang to work at all.

Fix: after the static-libs backfill, symlink /usr/local/bin/cc → whichever llvm{19,20,21}/bin/clang is actually present in the image, so cargo's default linker discovery works with zero user configuration. Gap-fill only — skips if cc already exists, warns (doesn't fail) if no clang is found.

Gates: sh -n build.sh clean, check-format.sh clean, no "smoke" occurrences. Branch is a clean fast-forward off current main (which has #284).

🤖 Generated with Claude Code

Follow-up to #284 (merged) — the static-libs backfill fixed the linker's missing crt/libc objects, but cargo still couldn't find a compiler at all: FreeBSD base hasn't shipped `cc`/GCC since 14.0, and the `llvm19` port (pulled in by `rust`) only installs an unversioned `clang` inside its own private bin dir, never as `cc` anywhere on `$PATH`. Confirmed on the real 0.13.0 build+chroot test from the #284 validation thread: `cargo build` needed an explicit `-C linker=clang` pointing at `/usr/local/llvm19/bin/clang` to work at all. Fix: after the static-libs backfill, symlink `/usr/local/bin/cc` → whichever `llvm{19,20,21}/bin/clang` is actually present in the image, so cargo's default linker discovery works with zero user configuration. Gap-fill only — skips if `cc` already exists, warns (doesn't fail) if no clang is found. Gates: `sh -n build.sh` clean, `check-format.sh` clean, no "smoke" occurrences. Branch is a clean fast-forward off current `main` (which has #284). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(build): symlink /usr/local/bin/cc to clang for cargo linker discovery
All checks were successful
format-check / prettier (pull_request) Successful in 6s
63c3b012fd
FreeBSD base has not shipped "cc" since 14.0 dropped GCC. The clang port
puts an unversioned "clang" inside its own llvm-N/bin/ but not as "cc"
on PATH. Cargo invokes the system compiler as "cc" by default -- without
this symlink, every "cargo build" on the booted image fails:

  error: linker `cc` not found

Tested empirically: cargo build + binary execution verified inside a
chroot into the built image (PR #284 test session, 21.jul.2026). The
link succeeded only with explicit -C linker=clang; this fix makes the
default work with zero user configuration.

Searches llvm19/20/21 bin dirs so it survives clang port upgrades.
Gap-fill only -- never overwrites an existing cc.
fix(build): correct cc-symlink comment's root cause + glob + mkdir -p
All checks were successful
format-check / prettier (pull_request) Successful in 6s
38d9ae7551
Review caught two issues in the original comment (63c3b01):
- Factually inverted history: GCC left FreeBSD base in 10.0 (2014), not
  14.0, and base has shipped /usr/bin/cc as clang continuously since —
  it never stopped. Corrected to the real root cause: this image's cc
  gap is the same class of bug as #284 (the installer mfsroot pax-copied
  in as the base has no compiler toolchain at all, base or ports).
- Hardcoded llvm19/20/21 replaced with a glob (/usr/local/llvm*/bin/clang)
  so this survives llvm22+ without a code change. Verified in isolation:
  matches correctly, and the no-match case falls through to the WARN
  branch cleanly under `set -e` (POSIX no-nullglob behavior — an
  unmatched glob is a literal string that just fails the -f test).
- Added mkdir -p for /usr/local/bin before the symlink, matching the same
  belt-and-suspenders the static-libs block already omits for /usr/lib.

The unverified-assumption concern (does llvm/clang actually land in built
images?) was also raised in review but is already answered: the #284
validation chroot test used exactly /usr/local/llvm19/bin/clang, sourced
from the real generated 0.13.0.img — no new boot test needed for that
part.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
clawdie deleted branch fix/cc-symlink-for-cargo 2026-07-21 03:25:16 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
clawdie/clawdie-iso!286
No description provided.