From 50d6ff32d43e0df062f764fa6d96a0b75a14ba3c Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 11 Feb 2026 19:25:41 -0600 Subject: [PATCH] Update hermetic faq entry for new use.sh --- www/faq.html | 69 ++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 37 deletions(-) diff --git a/www/faq.html b/www/faq.html index 8ecc2788..7e9d57c5 100644 --- a/www/faq.html +++ b/www/faq.html @@ -536,43 +536,33 @@ other meanings to the Makefile, and you have to use scripts/single.sh or

How do I build toybox on a system with a broken $PATH?

-

Toybox can provide its own build prerequisites (I.E -perform a "hermetic" build) using the script scripts/prereq/build.sh -which is a canned minimal toybox build that basically does "cc *.c" against -saved headers to build the commands needed by the rest of the build.

- -

At the moment, building toybox on mac requires homebrew to get a .config -file, ala:

- -
-$ homebrew
-$ make macos_defconfig
-$ make clean
-$ exit
-
- -

But the rest of the hermetic build works without it:

- -
-$ cc scripts/kconfig.c
-$ KCONFIG_ALLCONFIG=kconfig/macos_miniconfig ./a.out -n > .config
-$ scripts/prereq/build.sh #ignoring SO many warnings
-$ mkdir prereq; mv toybox-prereq prereq/
-$ for i in $(prereq/toybox-prereq); do ln -s toybox-prereq prereq/$i; done
-$ PATH=$PWD/prereq:$PATH scripts/make.sh
-$ ./toybox
-
- -

If you already have an appropriate .config file you can copy in you -don't need homebrew at all (and can skip the first section above). -Editing one up by hand for qnx and similar is currently left as an exercise -for the reader (but it's a fairly simple text file format).

- -

The files in the scripts/prereq directory were created by +

Toybox can provide its own build prerequisites (I.E perform a "hermetic" +build) via scripts/prereq/build.sh which is a canned minimal toybox +build script that basically does "cc *.c" against +saved headers to build just the commands needed by the the full toybox +build scripts.

+ +

The wrapper scripts/prereq/use.sh calls that hermetic build.sh +script to create a minimal toybox-prereq, then populates a directory +of symlinks to those toybox commands plus the cc/ld/as/strip binaries +out of the host $PATH, and finally runs scripts/genconfig.sh and +scripts/make.sh +to configure and build a full toybox binary. By default it builds defconfig, +but can take as its first argument a miniconfig file.

+ +

So to build toybox on MacOS (without homebrew) run +scripts/prereq/use.sh scripts/macos_miniconfig and it should +create a toybox binary configured for mac using the host toolchain. +The scripts directory also contains freebsd_miniconfig and +android_miniconfig files enumerating the commands known to work +under those operating systems.

+ +

Most of the files in the scripts/prereq directory were created by scripts/recreate-prereq.sh which records the commands used by a toybox build, harvests stripped down headers, and writes a build.sh to compile the appropriate source files. It's a couple dozen lines of -bash if you're interested.

+bash if you're interested. (Yes we check in generated files, to break +a chicken-and-egg cycle.)

At the moment toybox's full scripts/make.sh still requires bash (until toysh is finished and promoted out of pending). Freebsd users @@ -581,9 +571,14 @@ to work around their distro's policy insisting that /bin/env can be trusted to live at a specific path but /bin/bash can't. (On Android both env and sh live in /system/bin, which is at least internally consistent.)

-

Toybox does not yet provide "make" either. You can call scripts/make.sh -directly (and scripts/test.sh and scripts/single.sh) if you've got a .config, -but until kconfig/ is replaced defconfig/menuconfig still need gmake.

+

Toybox does not yet provide "make" either. The Makefile is mostly convenience +wrappers around shell scripts, so you can directly call +"scripts/genconfig.sh -d" (defconfig), scripts/make.sh, scripts/install.sh, +scripts/test.sh, scripts/single.sh and so on, all without needing make. +The exception is menuconfig: most config +functions have been migrated to scripts/genconfig.sh using scripts/kconfig.c, +but for the moment menuconfig is still using the old kconfig/ infrastructure +and thus still needs gmake.


Q: How do I cross compile toybox?

-- 2.39.5