Re: sparc64: ofwboot: no incremental builds due to broken libsa/libz dep

2022-10-11 Thread Todd C . Miller
On Wed, 12 Oct 2022 03:01:04 +0400, Klemens Nanni wrote:

> sparc64 also has its own under stand/,
> or do you mean that the alpha one is worse than the sparc64?

Oh yes, the alpha one is needlessly complicated.  I suppose this
is not surprising considering the source.

 - todd



Re: sparc64: ofwboot: no incremental builds due to broken libsa/libz dep

2022-10-11 Thread Klemens Nanni


12 Oct 2022 02:22:15 Todd C. Miller :

> This problem is not confined to sparc64 is it?  At least macppc
> seems to have the same issue.

Looks like it, I have not yet tested other architectures.

> Some, like amd64 and i386, cheat and
> just pull in the 4 source files from the libz directory.

Yes, that's what I meant with pxeboot.

> It looks like alpha has its own libz and libsa directories which
> seems even worse.

sparc64 also has its own under stand/,
or do you mean that the alpha one is worse than the sparc64?



Re: sparc64: ofwboot: no incremental builds due to broken libsa/libz dep

2022-10-11 Thread Todd C . Miller
This problem is not confined to sparc64 is it?  At least macppc
seems to have the same issue.  Some, like amd64 and i386, cheat and
just pull in the 4 source files from the libz directory.

It looks like alpha has its own libz and libsa directories which
seems even worse.

 - todd



sparc64: ofwboot: no incremental builds due to broken libsa/libz dep

2022-10-11 Thread Klemens Nanni
Testing the libz size fix in ofwboot.net showed that rebuilding ofwboot
after updating libz sources did not relink ofwboot as it should, imho:

$ cd sys/arch/sparc64/stand
$ make
...
$ touch ../../../lib/libz/crc32.c
$ make
===> bootblk
===> libsa
===> libz
cc -O2 -pipe -g -fno-stack-protector -msoft-float -ffreestanding  -MD 
-MP -D_LP64 -g -Wa,-Av9a -I/usr/src/sys/arch/sparc64/stand/libz/../../../.. 
-fno-pie  -DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP -I.  -D_STANDALONE -DSUN4U -I. 
-DDYNAMIC_CRC_TABLE -DBUILDFIXED -c 
/usr/src/sys/arch/sparc64/stand/libz/../../../../lib/libz/crc32.c -o crc32.o
building standard z library
ranlib libz.a
===> ofwboot
===> ofwboot.net
===> ofwbootfd

ofwboot/Makefile defines LIBSA and LIBZ as prerequisite for PROG, but the
two former variables are not defined until  which includes
"../Makefile.inc" which defines them.

It still works because a) libsa and libz are always built before ofwboot,
thus the intended but effectively missing dependency is always there, and
b) make(1) variables inside commands are evaluated lazily at run-time,
while those in targets and prerequisites are evaluated at parse-time:

$ make -C ofwboot -p | grep -C1 ^ofwboot
ofwboot : /usr/lib/crt0.o srt0.o Locore.o alloc.o boot.o 
elf64_exec.o arc4.o net.o netif_of.o ofdev.o vers.o diskprobe.o 
softraid_sparc64.o strlcpy.o strcmp.o strlcat.o strlen.o ffs.o aes_xts.o 
bcrypt_pbkdf.o blowfish.o explicit_bzero.o hmac_sha1.o pkcs5_pbkdf2.o 
rijndael.o sha1.o sha2.o softraid.o /usr/lib/libc.a /usr/lib/crtbegin.o 
/usr/lib/crtend.o 
${LD} -N -Ttext ${RELOC} -e ${ENTRY} -o ${PROG} -nopie 
-znorelro  ${OBJS} -L${LIBSADIR} ${LIBSA}  -L${LIBZDIR} ${LIBZ}


Diff below fixes this, but I doubt this is the way to go:

# make -C ofwboot -p | grep -C1 ^ofwboot 
# parent targets: all 
ofwboot : 
/usr/src/sys/arch/sparc64/stand/ofwboot/../libsa//libsa.a 
/usr/src/sys/arch/sparc64/stand/ofwboot/../libz//libz.a /usr/lib/crt0.o srt0.o 
Locore.o alloc.o boot.o elf64_exec.o arc4.o net.o netif_of.o ofdev.o vers.o 
diskprobe.o softraid_sparc64.o strlcpy.o strcmp.o strlcat.o strlen.o ffs.o 
aes_xts.o bcrypt_pbkdf.o blowfish.o explicit_bzero.o hmac_sha1.o pkcs5_pbkdf2.o 
rijndael.o sha1.o sha2.o softraid.o /usr/lib/libc.a /usr/lib/crtbegin.o 
/usr/lib/crtend.o 
${LD} -N -Ttext ${RELOC} -e ${ENTRY} -o ${PROG} -nopie 
-znorelro  ${OBJS} -L${LIBSADIR} ${LIBSA}  -L${LIBZDIR} ${LIBZ}

# touch ../../../lib/libz/crc32.c 
# make
===> bootblk
===> libsa
===> libz
cc -O2 -pipe -g -fno-stack-protector -msoft-float -ffreestanding  -MD 
-MP -D_LP64 -g -Wa,-Av9a -I/usr/src/sys/arch/sparc64/stand/libz/../../../.. 
-fno-pie  -DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP -I.  -D_STANDALONE -DSUN4U -I. 
-DDYNAMIC_CRC_TABLE -DBUILDFIXED -c 
/usr/src/sys/arch/sparc64/stand/libz/../../../../lib/libz/crc32.c -o crc32.o
building standard z library
ranlib libz.a
===> ofwboot
Warning: target 
/usr/src/sys/arch/sparc64/stand/ofwboot/../libsa//libsa.a (prerequisite of: 
ofwboot) does not have any command (BUG)
Warning: target /usr/src/sys/arch/sparc64/stand/ofwboot/../libz//libz.a 
(prerequisite of: ofwboot) does not have any command (BUG)
ld -N -Ttext 10 -e _start -o ofwboot -nopie -znorelro  srt0.o 
Locore.o alloc.o boot.o elf64_exec.o arc4.o net.o netif_of.o ofdev.o vers.o 
diskprobe.o softraid_sparc64.o strlcpy.o strcmp.o strlcat.o strlen.o ffs.o 
aes_xts.o bcrypt_pbkdf.o blowfish.o explicit_bzero.o hmac_sha1.o pkcs5_pbkdf2.o 
rijndael.o sha1.o sha2.o softraid.o 
-L/usr/src/sys/arch/sparc64/stand/ofwboot/../libsa 
/usr/src/sys/arch/sparc64/stand/ofwboot/../libsa/obj/libsa.a  
-L/usr/src/sys/arch/sparc64/stand/ofwboot/../libz 
/usr/src/sys/arch/sparc64/stand/ofwboot/../libz/obj/libz.a
===> ofwboot.net
Warning: target 
/usr/src/sys/arch/sparc64/stand/ofwboot.net/../libsa//libsa.a (prerequisite of: 
ofwboot.net) does not have any command (BUG)
Warning: target 
/usr/src/sys/arch/sparc64/stand/ofwboot.net/../libz//libz.a (prerequisite of: 
ofwboot.net) does not have any command (BUG)
ld -N -Ttext 10 -e _start -o ofwboot.net -nopie -znorelro  srt0.o 
Locore.o alloc.o boot.o elf64_exec.o arc4.o net.o netif_of.o ofdev.o vers.o 
strlcpy.o strcmp.o strlcat.o strlen.o ffs.o 
-L/usr/src/sys/arch/sparc64/stand/ofwboot.net/../libsa 
/usr/src/sys/arch/sparc64/stand/ofwboot.net/../libsa/obj/libsa.a  
-L/usr/src/sys/arch/sparc64/stand/ofwboot.net/../libz 
/usr/src/sys/arch/sparc64/stand/ofwboot.net/../libz/obj/libz.a
===> ofwbootfd
Warning: target 
/usr/src/sys/arch/sparc64/stand/ofwbootfd/../libsa//libsa.a (prerequisite of: 
ofwbootfd) does not have any command (BUG)
Warning: target 
/usr/src/sys/arch/sparc64/stand/ofwbootfd/../lib