[Toybox] new clang build break

Rob Landley rob at landley.net
Mon Jun 30 07:26:34 PDT 2025


On 6/30/25 07:17, enh wrote:
> another vote for having a clang build in ci :-)

I have one here, just forgot. Sorry.

It's easy for me to test individual commands with the NDK, but I can't 
do the full all-commands "make tests" because defconfig tries to build 
commands that won't build under android (like su), and building 
android_defconfig enables selinux but for some reason ndk-r27 doesn't 
have "selinux.h".

When doing lib/ tweaks I usually build/test "defconfig", and am working 
towards making that more feasible with the NDK build, but it's not there 
yet.

> external/toybox/lib/hash.c:309:21: error: attribute declaration must
> precede definition [-Werror,-Wignored-attributes]
>    309 | void __attribute__((__weak__)) hash_by_name(int fd, char
> *name, char *result)

Reordered. (I had no idea being brittle about that was a way it could 
inconsistently fail between compiler versions.)

Speaking of ndk defconfig builds: su breaks because it hasn't go 
tcrypt(), and one of the things I _want_ to do with this sort of 
plumbing is have my own crypt() implementation using the builtin hashes 
when the library doesn't provide a usable one. I cribbed some syntax 
from musl for this:

char *krypt(const char *phrase, const char *setting)
{
   return "boom";
}
extern __typeof(crypt) crypt __attribute__((__weak__, __alias__("krypt")));

And this time llvm isn't complaining about the attribute order, it's 
complaining about the lack of prototype:

lib/hash.c:406:17: error: use of undeclared identifier 'crypt'; did you 
mean 'krypt'?
   406 | extern __typeof(crypt) crypt __attribute__((__weak__, 
__alias__("krypt")));

https://pubs.opengroup.org/onlinepubs/9799919799/functions/crypt.html 
says crypt() is prototyped in unistd.h, but the android NDK doesn't 
provide a prototype for crypt():

$ grep -rw crypt 
android-ndk-r27/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include

I can __has_include() for a header, but unistd.h is there. There's no 
#ifdef syntax for "is this function prototype available after you've 
included the header". Should I just have a portability.h stanza adding 
the prototype under #ifdef __BIONIC__ or...?

Rob


More information about the Toybox mailing list