Turns out all install media ship full copies of those two manuals due to
what can be described like a makefile TOCTOU.

In /usr/src/distrib/special, Makefile.inc sets NOMAN=1 but */Makefile
only includes it in the very end through <bsd.prog.mk>.

fdisk and disklabel have NOMAN logic before that include, so they don't
see it set yet and include the whole thing:

        $ make -C fdisk manual.o
        mk -C fdisk manual.o
        mandoc -Tascii 
/usr/src/distrib/special/fdisk/../../../sbin/fdisk/fdisk.8 > fdisk.cat8
        (echo 'const unsigned char manpage[] = {';  cat fdisk.cat8 | gzip -9c | 
hexdump -ve '"0x" 1/1 "%02x,"';  echo '};'; echo 'const int manpage_sz = 
sizeof(manpage);') > manual.c
        cc -O2 -pipe  -DHAS_MBR -fno-pie -Oz -fno-stack-protector 
-fno-unwind-tables -fno-asynchronous-unwind-tables -MD -MP  -c manual.c
        $ size fdisk/obj/manual.o
        text    data    bss     dec     hex
        3552    0       0       3552    de0

Forcing it on the command line yields the desired behaviour:
        $ make -C fdisk NOMAN=1 manual.o
        (echo 'const unsigned char manpage[] = {';  echo 'no manual' | gzip -9c 
| hexdump -ve '"0x" 1/1 "%02x,"';  echo '};'; echo 'const int manpage_sz = 
sizeof(manpage);') > manual.c
        cc -O2 -pipe  -DHAS_MBR -fno-pie -Oz -fno-stack-protector 
-fno-unwind-tables -fno-asynchronous-unwind-tables -MD -MP  -c manual.c
        $ size fdisk/obj/manual.o
        text    data    bss     dec     hex
        36      0       0       36      24

Same for disklabel,  size before/after:
        text    data    bss     dec     hex
        6160    0       0       6160    1810
        36      0       0       36      24

I've confirmed this through an amd64 snapshots bsd.rd where I paged
through disklabel(8) via the 'M' command...

Here's a minimal diff to highlight this non-obvious issue and avoid
reshuffling, i.e. cut down on differences with /usr/src/sbin/*/Makefile.

Haven't built ramdisks yet to see the final size decrease, but everyone
should be happy with this.

OK?


Index: disklabel/Makefile
===================================================================
RCS file: /cvs/src/distrib/special/disklabel/Makefile,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile
--- disklabel/Makefile  21 Sep 2021 18:36:09 -0000      1.13
+++ disklabel/Makefile  25 Aug 2022 18:34:31 -0000
@@ -10,6 +10,8 @@ CLEANFILES += disklabel.cat8 manual.c
 
 .include <bsd.own.mk>
 
+# XXX set in ../Makefile.inc already but only pulled in by <bsd.prog.mk>
+NOMAN = 1
 .ifdef NOMAN
 manual.c:
        (echo 'const unsigned char manpage[] = {'; \
Index: fdisk/Makefile
===================================================================
RCS file: /cvs/src/distrib/special/fdisk/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- fdisk/Makefile      23 May 2022 16:58:11 -0000      1.6
+++ fdisk/Makefile      25 Aug 2022 18:34:15 -0000
@@ -23,6 +23,8 @@ CLEANFILES += fdisk.cat8 manual.c
 
 .include <bsd.own.mk>
 
+# XXX set in ../Makefile.inc already but only pulled in by <bsd.prog.mk>
+NOMAN = 1
 .ifdef NOMAN
 manual.c:
        (echo 'const unsigned char manpage[] = {'; \

Reply via email to