Error when creating crunched binary for netstat

I get the error "/usr/src/usr.bin/netstat/inet.c:86:10: fatal error: 'nl_defs.h' file not found" when trying to create a crunched binary of netstat (I'm actually adding lots of other programs but they are not causing problems only netstat so just keeping it simple for the sake of this post/question).

The error is on a brand new and fully updated FreeBSD 12.1 system however it works perfectly fine on a11.3 system. Any idea what the problem might be? Here's the details:

test:/tmp/test # uname -a
FreeBSD test.example.com 12.1-RELEASE-p3 FreeBSD 12.1-RELEASE-p3 TEST amd64

test:/tmp/test # cat test.conf
srcdirs /usr/src/bin /usr/src/sbin /usr/src/usr.bin /usr/src/usr.sbin
progs netstat
libs -lkvm -lmemstat -lxo -lutil -lnetgraph -lelf


test:/tmp/test # crunchgen -m Makefile -e test test.conf
Run "make -f Makefile" to build crunched binary.


test:/tmp/test # make
(cd /usr/src/usr.bin/netstat && make depend && make if.o inet.o main.o mbuf.o mroute.o netisr.o nl_symbols.o route.o unix.o mroute6.o ipsec.o bpf.o pfkey.o sctp.o inet6.o netgraph.o)
`if.o' is up to date.
`inet.o' is up to date.
`main.o' is up to date.
`mbuf.o' is up to date.
`mroute.o' is up to date.
`netisr.o' is up to date.
`nl_symbols.o' is up to date.
`route.o' is up to date.
`unix.o' is up to date.
`mroute6.o' is up to date.
`ipsec.o' is up to date.
`bpf.o' is up to date.
`pfkey.o' is up to date.
`sctp.o' is up to date.
`inet6.o' is up to date.
`netgraph.o' is up to date.
cc -O2 -pipe -c test.c -o test.o
echo "extern int main(int argc, char **argv, char **envp); int _crunched_netstat_stub(int argc, char **argv, char **envp){return main(argc,argv,envp);}" >netstat_stub.c
cc -O2 -pipe -c netstat_stub.c -o netstat_stub.o
cc -O2 -pipe -c /usr/src/usr.bin/netstat/inet.c -o /usr/src/usr.bin/netstat/inet.o
/usr/src/usr.bin/netstat/inet.c:86:10: fatal error: 'nl_defs.h' file not found
#include "nl_defs.h"
^~~~~~~~~~~
1 error generated.
*** Error code 1

Stop.
make: stopped in /tmp/test

test:/tmp/test #
 
An example of an improper usage and why this matters is in usr.bin/netstat.
nl_defs.h was only in DPSRCS and so was not generated during 'make all',
but only during 'make depend'. The files including it lacked proper
depenencies on it, which forced running 'make depend' to workaround that
bug. The 'make depend' target should mostly be used for incremental build
help, not to produce a working build. This specific example was broken in
the meta build until r287905 since it does not run 'make depend'.
 
Thank you for the info. I'm not sure what this means for me though or how to work around it. Would it be possible to elaborate? Thank you!
 
When I run make in "/usr/src/usr.bin/netstat" it puts everything into "/usr/obj/usr/src/amd64.amd64/usr.bin/netstat" whereas FreeBSD 11.3 kept it all in "/usr/src/usr.bin/netstat" and it seems crunchgen doesn't know to look there and assumes the objdir is simply /usr/obj prefixed to the srcdir. That seems to work for the other programs I was "crunching" but not netstat. Adding "special netstat objdir /usr/obj/usr/src/amd64.amd64/usr.bin/netstat" to the config file makes it work. Is that the correct fix?
 
Back
Top