git: e179ee000ef2 - stable/14 - loader: Add WITH/WITHOUT_LOADER_PXEBOOT build option

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 13 Aug 2024 17:31:40 UTC
The branch stable/14 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=e179ee000ef2731a7baa6edc32ed8bfcca751f8b

commit e179ee000ef2731a7baa6edc32ed8bfcca751f8b
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-08-05 21:19:21 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-08-13 17:31:38 +0000

    loader: Add WITH/WITHOUT_LOADER_PXEBOOT build option
    
    Make it possible to disable pxeboot. This loader will fail to build when
    it's too large. When /boot/loader needs to be larger like that, this
    options will disable a component whose build will fail. It is an explicit
    option rather than implicit when things are too large to force the user to
    make the explicit tradeoffs rather than wonder why they have a stale pxeboot
    or other odd failure mode.
    
    MFC After:              3 days
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D46212
    
    (cherry picked from commit 20d35d5817851df3a6d20e75df2e14a192b94940)
---
 share/mk/src.opts.mk                       |  1 +
 stand/i386/Makefile                        |  2 +-
 tools/build/options/WITHOUT_LOADER_PXEBOOT | 10 ++++++++++
 tools/build/options/WITH_LOADER_PXEBOOT    | 25 +++++++++++++++++++++++++
 4 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index 788c6a9b956f..3ff71df3e0da 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -132,6 +132,7 @@ __DEFAULT_YES_OPTIONS = \
     LOADER_KBOOT \
     LOADER_LUA \
     LOADER_OFW \
+    LOADER_PXEBOOT \
     LOADER_UBOOT \
     LOCALES \
     LOCATE \
diff --git a/stand/i386/Makefile b/stand/i386/Makefile
index 883cd4a556bb..5e52b1e12c30 100644
--- a/stand/i386/Makefile
+++ b/stand/i386/Makefile
@@ -17,7 +17,7 @@ SUBDIR.${MK_LOADER_LUA}+= loader_lua
 SUBDIR.yes+=	loader_simp
 
 # special boot programs, 'self-extracting boot2+loader'
-SUBDIR.yes+=	pxeldr
+SUBDIR.${MK_LOADER_PXEBOOT}+=	pxeldr
 
 SUBDIR.${MK_LOADER_ZFS}+=	zfsboot gptzfsboot
 
diff --git a/tools/build/options/WITHOUT_LOADER_PXEBOOT b/tools/build/options/WITHOUT_LOADER_PXEBOOT
new file mode 100644
index 000000000000..e6b09381884e
--- /dev/null
+++ b/tools/build/options/WITHOUT_LOADER_PXEBOOT
@@ -0,0 +1,10 @@
+Do not build pxeboot on i386/amd64.
+When the pxeboot is too large, or unneeded, it may be disabled with this option.
+See
+.Va WITH_LOADER_PXEBOOT
+for how to adjust the defaults when you need both a larger
+.Pa /boot/loader
+and
+.Pa /boot/pxeboot
+.Pp
+This option only has an effect on x86.
diff --git a/tools/build/options/WITH_LOADER_PXEBOOT b/tools/build/options/WITH_LOADER_PXEBOOT
new file mode 100644
index 000000000000..01d4a0b86a66
--- /dev/null
+++ b/tools/build/options/WITH_LOADER_PXEBOOT
@@ -0,0 +1,25 @@
+Build pxeboot on i386/amd64.
+The PXE Boot loader package needs more space than we may have in the boot loader.
+If you need to increase
+.Va LOADERSIZE
+beyond 500000, then building
+.Xr pxeboot 8
+will fail.
+To allow a larger
+.Va LOADERSIZE
+for some environments, it may be necessary to disable pxeboot builds or adjust
+its defaults.
+You can set the default loader for pxeboot to use independently of the system
+default by setting
+.Va PXEBOOT_DEFAULT_INTERP
+to one of
+.Dq lua ,
+.Dq 4th ,
+or
+.Dq simp .
+The limit on the size of the loader used for
+.Xr pxeboot 8
+can be set independently with
+.Va PXEBOOTSIZE .
+.Pp
+This option only has an effect on x86.