I've got miscompiles of mksh with gcc-13 on x32 with dietlibc.
I could reproduce this in a chroot by doing…
export CC='diet -Os gcc'
export CFLAGS='-g -Wformat -Werror=format-security -Wall -Wextra'
export CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2 -DMKSH_BUILDMEAT'
sh Build.sh -r -j
./mksh -c 'x=q; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo .$x.'
… in an mksh source tree. (Output is “..” but “.a.” was expected.)
Adding -fno-builtin-strchr to CFLAGS makes the problem go away.
This is as far as I could reduce this; more would involve diving
into the gcc internals.
Dixi quod… This is a regression against gcc-12 (= 12.3.0-8); if I install that and export CC='diet -Os gcc-12' it works. In case this is relevant: that codepath uses setjmp/longjmp quite a bit, and builds for glibc, musl or klibc don’t trigger this, so it’s probably a combination of several things. Using dietlibc/amd64 is also fine, and dietlibc-wise, they are good as identical: differ only in start.S and syscall numbers, and a few sections in header files. bye, //mirabilos