[Toybox] clang build still broken

Rob Landley rob at landley.net
Tue Jul 1 09:41:29 PDT 2025


On 6/30/25 14:46, enh wrote:
> sending as a separate thread, so it's obvious that there's new
> information here... in particular, note that clang isn't complaining
> about _attribute_ ordering, it's complaining that the _definition_ it
> already saw doesn't match the redeclaration:

It built for me with the android-ndk-r27. I'm confused.

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

Define "precede". The attribute declaration is now the first thing on 
the line. (That's what commit 17d77a264ab6 changed.)

> external/toybox/lib/hash.c:22:6: note: previous definition is here
>     22 | void hash_by_name(int fd, char *name, char *result)
>        |      ^
> external/toybox/lib/hash.c:309:32: error: redefinition of 'hash_by_name'
>    309 | __attribute__((__weak__)) void hash_by_name(int fd, char
> *name, char *result)
>        |                                ^

That's not "does not match", that's "it was redefined". Which gcc allows 
if only one isn't weak, but clang ignored the weak.

> external/toybox/lib/hash.c:22:6: note: previous definition is here
>     22 | void hash_by_name(int fd, char *name, char *result)
>        |      ^

void blah(int, char *, char *)
void blah(int, char *, char *)

What differs other than one being weak? I'm not spotting it.

Sigh, I can go back to #ifdefs if clang is that buggy, but lib/* built 
with the NDK? In a clean checkout even:

$ git clone toybox clean
Cloning into 'clean'...
done.
$ cd clean
$ readlink -f ~/llvm
/home/landley/android-ndk-r27/toolchains/llvm/prebuilt/linux-x86_64/bin
$ ../llwrap make defconfig
generated/unstripped/kconfig -d > .config
$ ../llwrap make true
scripts/single.sh true
true:generated/{Config.in,newtoys.h,flags.h}
Compile true
....................
$ ./true

My ndk wrapping setup is fairly simple:

$ cat ../llwrap
#!/bin/bash
CROSS_COMPILE=~/llvm/llvm- LDFLAGS+=" --static" CFLAGS+=" 
-Werror=format-security -Werror=unused-result" "$@"
$ readlink ~/llvm
android-ndk-r27/toolchains/llvm/prebuilt/linux-x86_64/bin
$ cat ~/llvm/llvm-cc
#!/bin/bash
"$(dirname "$0")"/clang ${LLTARGET:---target=x86_64-linux-android35} "$@"

Rob


More information about the Toybox mailing list