Files
makronix/docs/CROSS.md
T

8.8 KiB

Cross-build workarounds for pkgsrc on a non-NetBSD host

Status: 2026-11-14. This documents settings that make make userland (tools/userland.sh, cross mode on a host where uname -s != NetBSD) work against the target sysroot/toolchain produced by this tree. It is not a contract; it records measured causes and what must be true before a workaround can be removed.

Rules: pkgsrc/ is not patched (pkgsrc/AGENTS.md, root AGENTS.md), so cross-only or host-specific fixes live in tools/pkgsrc-cross.mk.conf (or in our forks under ext/ when the source itself is wrong). Every statement below cites a commit, a log path, or file:line in this tree.

Where the settings live

  • tools/pkgsrc-cross.mk.conf — pkgsrc cross mk fragment (included by the bootstrap mk.conf; see tools/userland.sh ensure_mkconf).
  • Work dirs keep configured flags; after changing the fragment, work dirs must be cleaned/reconfigured (tools/userland.sh ensure_mk_key, key build/pkgsrc-work/.makronix-mk-key; tasksd t0168).

Workarounds added 2026-11-13 (task t0169)

The four settings below were introduced together in commit 4facdf5c9b (2026-11-13, "userland cross: the target's X is reachable to the compiler, and libXft's missing prototype is brought in"). Commit message evidence cites build/logs/userland-2026-11-13t.log, build/logs/xft2-single*.log, and build/logs/xft2-single4-2026-11-13.log (exit 0 for fonts/Xft2 after fixes).

1. fonts/Xft2: USE_LANGUAGES+= c c++

  • Setting: tools/pkgsrc-cross.mk.conf:130-131
    • .if ${PKGPATH} == "fonts/Xft2" / USE_LANGUAGES+= c c++
  • Cause: libXft 2.1.7 runs AC_PROG_CXX though it is a C package and does not list c++ in USE_LANGUAGES. For languages a package does not ask for, pkgsrc installs its fail-wrapper (mk/compiler.mk:380, per in-file comment), so the probe failed ("GNU C++ compiler... no", then "C++ preprocessor "cpp" fails sanity check") and configure stopped. c must remain because the recipe's USE_LANGUAGES was empty in that context; without c pkgsrc also wraps cc and the C preprocessor probe fails the same way.
  • Evidence: tools/pkgsrc-cross.mk.conf:120-129 cites build/logs/userland-2026-11-13r.log:1521, Xft2 config.log:314-318 (PKGSRC-WARNING), and build/logs/userland-2026-11-13s.log:88; commit 4facdf5c9b.
  • Native impact: possible on any host/build where pkgsrc's fail-wrapper is applied the same way for this recipe/configure behavior; needs verification on a native Makronix/NetBSD build before moving into a fork recipe (decision with Konrad, task t0169 item 2).
  • Removal criteria: fonts/Xft2 configures/builds without forcing c c++ in cross and native modes (or the fix belongs in the recipe/fork if package-specific and not cross-only), with logs showing AC_PROG_CXX/cpp sanity checks succeeding.

2. fonts/Xft2: CFLAGS+= -include freetype/ftsynth.h

  • Setting: tools/pkgsrc-cross.mk.conf:132-140
    • CFLAGS+= -include freetype/ftsynth.h
  • Cause: libXft 2.1.7 calls FT_GlyphSlot_Embolden (xftglyphs.c:177) without a declaration in scope after FreeType dropped FT_SYNTHESIS_H from ft2build.h. Configure found the symbol in the library instead of the header (config.log:1033 ac_cv_func_FT_GlyphSlot_Embolden=yes), and GCC 14 treats implicit declaration as an error.
  • Evidence: tools/pkgsrc-cross.mk.conf:132-139 cites build/logs/xft2-single2-2026-11-13.log:316 and states the declaration is in <freetype/ftsynth.h> (measured: compiles with -include freetype/ftsynth.h); commit 4facdf5c9b.
  • Native impact: this is a source/GCC-14 compatibility issue, not inherently cross-only; likely affects any GCC 14 build of this fonts/Xft2 version. Task t0169 item 2/3: verify native impact and decide whether the fix belongs in a fork/recipe patch vs cross config; consider separating general GCC-14 hardening work.
  • Removal criteria: package builds without the forced include on the supported compilers/hosts (or equivalent fix is carried in the appropriate recipe/fork), evidenced by build logs.
  • Setting: tools/pkgsrc-cross.mk.conf:158-168
    • .if ${PKGPATH} == "pkgtools/x11-links" / X11BASE=${CROSS_DESTDIR}/usr/X11R7
  • Cause: x11-links probes ${X11BASE}/<file> and /usr/<file> to build its shadow tree. In a cross build those resolved to host paths, so it linked host (Debian) xorgproto headers and did not produce Xrender.h; fonts/Xft2 then failed with Xrender.h not found despite the file existing in the target sysroot.
  • Evidence: commit 4facdf5c9b cites build/logs/userland-2026-11-13t.log:155; tools/pkgsrc-cross.mk.conf:158-165 cites measured farm state in build/obj/destdir.amd64/usr/pkg/share/x11-links/include (52 links, all to /usr/include). Pointing at ${CROSS_DESTDIR}/usr/X11R7 makes it find the target X as on a NetBSD host where /usr/X11R7 is native.
  • Native impact: cross-only in intent (host path leakage during cross build). A native NetBSD/Makronix build should use its own /usr/X11R7.
  • Removal criteria: cross build of pkgtools/x11-links produces a correct target-only shadow tree without overriding X11BASE to the sysroot, with no links outside ${CROSS_DESTDIR} and no missing headers required by dependent packages (see also tools/check-x11-links.sh, tasksd t0167).

4. Global X include/lib paths: CPPFLAGS+= -I=${X11BASE}/include, LDFLAGS+= -L=${X11BASE}/lib

  • Setting: tools/pkgsrc-cross.mk.conf:179-189
    • CPPFLAGS+= -I=${X11BASE}/include
    • LDFLAGS+= -L=${X11BASE}/lib
  • Cause: X is target base (X11_TYPE=native, X11BASE=/usr/X11R7) and mk/x11.buildlink3.mk:31 passes absolute configure flags (--x-includes=/usr/X11R7/include --x-libraries=/usr/X11R7/lib). On a non-NetBSD cross host those absolute paths do not resolve into the sysroot; --sysroot and cwrappers did not fix it (wrappers rewrote paths into the work .x11-buildlink shadow tree of host X). GCC's sysroot-relative = form (-I=/..., -L=/...) is resolved against <sysroot> and passed through by wrappers.
  • Evidence: commit 4facdf5c9b and tools/pkgsrc-cross.mk.conf:179-188 cite measurement in a work directory (./cwrapper/bin/cc -c -I=/usr/X11R7/include compiles) and reference the x11-links host-shadow issue above.
  • Native impact: intended for cross builds on non-NetBSD hosts; on native builds absolute /usr/X11R7 paths are normally correct. Needs confirmation that native behavior is unaffected (or scope-guard if necessary) — task t0169 item 2.
  • Removal criteria: cross GNU-configure/pkgsrc X builds resolve target X headers/libs correctly without global sysroot-relative overrides (e.g. if cwrappers/sysroot handling is fixed upstream or in our config), evidenced by successful builds and no host-X leakage.

Additional cross-build settings currently present (observed 2026-11-14)

These are in tools/pkgsrc-cross.mk.conf now and affect cross builds, but were not listed as the original four items in tasksd t0169; they should be reviewed and either folded into this document's evidence/removal criteria or split into follow-up tasks:

  • tools/pkgsrc-cross.mk.conf:143-156 — cross/cross-libtool-base: CONFIGURE_ARGS+= --with-sysroot=${CROSS_DESTDIR} (commit-era rationale in comments; cites build/logs/userland-2026-11-14e.log, build/logs/mcde-single-2026-11-14.log).
  • tools/pkgsrc-cross.mk.conf:171-177 — PREPEND_PATH+= ${TOOLDIR}/bin for ksh93/bin/package finding $CC by name in cross builds (cites build/logs/userland-2026-11-14c.log:5299).
  • Commit 719967a4ee (2026-11-13, tools/pkglist.sh): narrowed "built" set (set+repo, not fetched games) to avoid host-tools stage building unnecessary tool chains; evidence build/logs/userland-2026-11-13o.log:5,61.
  • Commit 6c2d627ae3 (2026-11-13, ext/src/mcde/motif/config/util/makestrs.c): GCC 14 incompat-pointer-types fix in MCDE Motif fork source (not a pkgsrc cross-mk workaround); evidence build/logs/userland-2026-11-13u.log:1267-1313. This is a candidate for "general GCC-14 hardening" tracking (t0169 item 3).

Open questions / decisions (Konrad)

  • Which of the fonts/Xft2 fixes (1,2) also apply to native builds, and should they move into a fork/recipe instead of global cross config?
  • Should global CPPFLAGS/LDFLAGS sysroot-relative overrides be scoped more narrowly if they affect native builds?
  • Whether to add this documentation link/summary into docs/BUILD-CONTRACT.md requires user request (docs/AGENTS.md: BUILD-CONTRACT changed only when the user asks).

License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.