[Toybox] new clang build break

enh enh at google.com
Mon Jun 30 10:33:04 PDT 2025


On Mon, Jun 30, 2025 at 10:26 AM Rob Landley <rob at landley.net> wrote:
>
> On 6/30/25 07:17, enh wrote:
> > another vote for having a clang build in ci :-)
>
> I have one here, just forgot. Sorry.

well, i meant github so i can see at a glance before i try whether a
build is known-bad or not.

(though at the moment, the gcc asan stuff means all builds look bad.)

> 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.

as usual: i don't mean the ndk, i just mean whatever clang is in the
github docker image.

> > 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")));

the compiler's alias stuff only works if it's in the same translation
unit as the definition.

(this is annoying to me in bionic, where i often want to say things
like "foo_l() is just foo()" but can only do so in the same file as
the definition of foo(), which doesn't work if i'm just pulling in the
openbsd foo(), say.)

> 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".

heh, that's actually my most-wanted non-existent preprocessor feature too.

> Should I just have a portability.h stanza adding
> the prototype under #ifdef __BIONIC__ or...?

just have su etc depend on "not android", given that none of them make
any sense there?

> Rob


More information about the Toybox mailing list