[Toybox] [PATCH] Fix portability towards musl by including string.h.
me at kroovy.de
me at kroovy.de
Thu Aug 13 18:36:50 UTC 2026
Rob Landley <rob at landley.net> wrote:
> On 8/12/26 16:55, kroovy via Toybox wrote:
> > Signed-off-by: kroovy <me at kroovy.de>
> > ---
> > lib/portability.h | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/lib/portability.h b/lib/portability.h
> > index fa497c19..b4076e5a 100644
> > --- a/lib/portability.h
> > +++ b/lib/portability.h
> > @@ -26,6 +26,7 @@
> > // For musl
> > #define _ALL_SOURCE
> > #include <regex.h>
> > +#include <string.h>
> > #ifndef REG_STARTEND
> > #define REG_STARTEND 0
> > #endif
>
> A) string.h is #included in toys.h under "General posix-2008 headers".
>
> B) I build against musl regularly, using the toolchains at
> https://landley.net/bin/toolchains/latest/ and the resulting binaries go
> in https://landley.net/bin/toybox/latest/ and
> https://landley.net/bin/mkroot/latest/
>
> What symptom did you see from the missing #include? (I can see there
> being a sequencing issue, since the general headers go after
> portability.h, but I didn't encounter this building last release's
> binaries in June, and if it's shown up since the musl-1.2.6 release in
> https://landley.net/bin/toolchains/latest/README it's probably a
> regression Rich should hear about...
>
> Rob
I'm using alpinelinux's version:
musl-1.2.6-r2
git clone https://codeberg.org/landley/toybox.git
make defconfig
make
results in the following error:
scripts/make.sh
Compile toybox
.........In file included from /usr/include/fortify/sys/select.h:26,
from /usr/include/sys/types.h:71,
from ./lib/portability.h:59,
from ./toys.h:9,
from lib/elf.c:6:
/usr/include/fortify/string.h:137:1: error: 'strncat' undeclared here (not in a function)
137 | _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s,
| ^~~~~~~~~~~
In file included from /usr/include/fortify/sys/select.h:26,
from /usr/include/sys/types.h:71,
from ./lib/portability.h:59,
from ./toys.h:9,
from lib/deflate.c:11:
/usr/include/fortify/string.h:137:1: error: 'strncat' undeclared here (not in a function)
137 | _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s,
| ^~~~~~~~~~~
In file included from /usr/include/fortify/sys/select.h:26,
from /usr/include/sys/types.h:71,
from ./lib/portability.h:59,
from ./toys.h:9,
from lib/args.c:10:
[...]
see also:
https://kroovy.de/paste/gcc_error.txt
https://kroovy.de/paste/gcc_version.txt
More information about the Toybox
mailing list