[Toybox] Fails to build with CONFIG_SYSLOGD=y (ld: syslogd.c:(.text.logmsg+0x147): undefined reference to `prioritynames')
Rob Landley
rob at landley.net
Fri Oct 9 06:04:55 UTC 2026
On 10/8/26 05:57, zyxhere💭 wrote:
> Hi I know this is a pending command but it should build right?
It does on my Devuan Excalibur laptop (which is Debian Trixie without
systemd):
$ make syslogd
scripts/single.sh syslogd
syslogd:
warning: using unfinished code from toys/pending
Compile syslogd
....................
$
> Using toybox-0.8.15 on Gentoo linux with musl (had to patch the build
> because https://github.com/landley/toybox/pull/332 is still a thing).
I believe the only targets that still use that are the interactive
configs (menuconfig and legacy text "config" that asks yes/no
questions). Everything else is scripts/genconfig.sh now.
Doing a new menuconfig and getting rid of the old kconfig dir is
currently in my top 10 todo items, and might make it into the next
release, but my in the absence of immediate deadlines (or anybody paying
me to do this) my development work goes off on a lot of tangents.
Right after the release I wanted to go back to getting the toybox build
and test suite to run under mkroot system images (so I can start to
properly design root tests, and maybe deal with the fact that unshare -t
is FUCKING USELESS ala https://mstdn.jp/@landley/117345412207364770
which I need to design a way to deal with but am NOT playing with on my
development system again just now). Running my scripts under mkroot has
MOSTLY been blocked by missing toysh features, but there might be OTHER
things missing in mkroot (kernel config for the tests or commands I
haven't noticed I'm using) so I built a musl-static bash 5.3 to try to
implement the rest of a mkroot/packages/testsuite build script against
(since that bash version was the one in LFS 12.4 so I had the source
lying around).
And once I had the binary I wanted to wget it into an existing image so
I diverged into redoing the httpd_main() plumbing so it could act as a
standalone server without needing an inetd front end (there should be a
function in lib/net.c to call back into an inetd handler but option
parsing gets a little weird because -p [IP:]PORT -u USER[:GRP] -m limit
might be common to multiple servers...?)
But THEN I hit a weird bug where in mkroot "mount /dev/sda /mnt" says
"mount /dev/sda: need -t" but it succeeds in mounting the squashfs
_annyway_ (wha...?) and I went "I wanna strace this" but I deleted the
old aboriginal linux binaries off my website because people built
viruses with my toolchains so my old toolchains keep getting
MISIDENTIFIED AS VIRUS CODE by various scanners and it caused my domain
to wind up in spam blockers last year, and building the old aboriginal
linux versions under my current musl toolchain is doesn't work (its
config doesn't know what musl is and when I hacked past that the code
was full of #ifdef staircases that kept falling through to #errors) and
when I chopped my way through ALL THAT the link died with a bunch of ld:
syscall.o:(.rodata+0x2e080): undefined reference to `sys_getdents64
where I have no idea what musl thinks it's exporting (some horrible
macro thing maybe) that this old strace code isn't matching up with...
And I went "hang on, there's an strace.c in pending" so I started fixing
THAT up and argued with dalias on #musl about "why does musl's or1k
headers not have the mmap or lseek syscalls, I mean you've got SYS_blah
versions of syscalls you haven't got _NR_blah versions of could it at
least be consistent there... (answer, no: because Rich.) Plus trying to
figure out mips architecture support is just crazy (there's O32, N32,
N64, and whatever the hell
https://github.com/torvalds/linux/blob/v7.0/arch/mips/include/asm/syscall.h#L75
is doing let alone the function before it... v0 vs a0 map to what in the
exported array? Anyway, I got it compiling and checked something in...)
Along the way the split bug report came in which I've written half a
reply to, and mostly think I've figured out how I want to address but it
REALLY seems like there should be some kind of same_file() libc function
to collate:
toys/other/mountpoint.c: toys.exitval = !(st1.st_dev != st2.st_dev ||
st1.st_ino == st2.st_ino);
toys/pending/sh.c: if (stat(pwd, &st2) || st1.st_dev!=st2.st_dev ||
st1.st_ino!=st2.st_ino)
toys/posix/test.c: if (i==12) return (st1.st_dev==st2.st_dev) &&
(st1.st_ino==st2.st_ino);
But there aren't QUITE enough users and would the two stat bufs be the
argument or should it fstat() a supplied file descriptor or...?
Oh, and as long as I've got a static bash I once again tried to build a
static busybox to throw in the $PATH in a mkroot image on the theory
that versions of tools known to have built LFS 12.4 means I can
implement the LFS 12.4 buidl and then swap the toybox versions over one
by one like I did with busybox and gnu back in the day, but busybox
STILL refuses to build without bzip2 compressor in the $PATH bit it
turns out that gratuitous build dependency only goes back a couple
releases: 1.35 complained about its absence but built anyway, and then
died because "diff" isn't in root/build/airlock and _that_ dependency
goes back quite a ways so I wanted to rebuild adding that but the
PENDING= argument to mkroot only adds commands to the target
filesystem's toybox config so I added an AIRPEND= argument to add
pending commands to the airlock build (which involved moving be2csv and
csv2cfg up with announce() and die() and redoing the comments), and when
I noticed this email, I was trying to figure out why:
PREFIX="$AIRLOCK" KCONFIG_CONFIG=.singleconfig_airlock CROSS_COMPILE=\
make ${AIRPEND:-KCONFIG_ALLCONFIG=<(csv2cfg $(be2csv $AIRPEND) y)} \
clean defconfig toybox install_airlock && # see scripts/install.sh&&
Is turning into:
PREFIX=/home/landley/toybox/kleen/root/build/airlock
KCONFIG_CONFIG=.singleconfig_airlock CROSS_COMPILE= make diff clean
defconfig toybox install_airlock
And thus trying to do a single build of "diff", which is wrong. (That
"diff" SHOULD be "KCONFIG_ALLCONFIG=/dev/fd/63" or similar.) In the
filesystem build of toybox, it's doing:
PREFIX="$ROOT" KCONFIG_CONFIG="$TOYCFG" make clean \
${CONF:-defconfig KCONFIG_ALLCONFIG=<(csv2cfg $(be2csv $PENDING SH
ROUTE) y)} \
toybox install || exit 1
Which is working as expected. (Can I not use $($AIRPEND) inside
${AIRPEND:-} ? Do I need a temporary variable? No, don't bother
answering that, rhetorical question, I'll presumably have figured it out
or bypassed it by then...)
Anyway, let's throw your interrupt on top of the pile:
> .config and build.log attached
What does that say...
/usr/x86_64-pc-linux-musl/binutils-bin/2.47/ld: cannot find -liconv:
Invalid argument
/usr/x86_64-pc-linux-musl/binutils-bin/2.47/ld: cannot find -lselinux:
Invalid argument
/usr/x86_64-pc-linux-musl/binutils-bin/2.47/ld: cannot find -ltls:
Invalid argument
/usr/x86_64-pc-linux-musl/binutils-bin/2.47/ld: cannot find -lsmack:
Invalid argument
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
/usr/x86_64-pc-linux-musl/binutils-bin/2.47/ld: cannot find -llog:
Invalid argument
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
That's probe debris from scripts/make.sh. It's not actually an error, it
just means probes to see which libraries are available did not find some
of the libraries. It's this code:
> # Respond to V= by echoing command lines as well as running them
> do_loudly()
> {
> { [ -n "$V" ] && echo "$@" || echo -n "$DOTPROG" ; } >&2
> "$@"
> }
>
>
> # Respond to V= by echoing command lines as well as running them
> do_loudly()
> {
> { [ -n "$V" ] && echo "$@" || echo -n "$DOTPROG" ; } >&2
> "$@"
> }
>
> # --as-needed removes libraries we don't use any symbols out of, but the
> # compiler has no way to ignore a library that doesn't exist, so detect
> # and skip nonexistent libraries for it (probing in parallel).
> LIBRARIES=$(
> [ -z "$V" ] && X=/dev/null || X=/dev/stderr
> for i in util crypt m resolv selinux smack attr crypto z log iconv tls ssl
> do
> do_loudly ${CROSS_COMPILE}${CC} $CFLAGS $LDFLAGS -xc - -l$i >>$X 2>&1 \
> -o /dev/null <<<"int main(int argc,char*argv[]){return 0;}" &&
> echo -l$i &
> done | sort | xargs
> )
It really looks like you have V=1 set, because >>$X 2>&1 should sent the
error output to $X which is either /dev/null or /dev/stderr depending on
what V= is set to.
Your linux kernel builds would similarly be insanely chatty if you have
V=1 exported in your environment. I dunno how much of them would look
like failures because there's just so much output...
Did the build fail, or did you just see error messages in your log output?
Ah, right: mousepad just showed me the start of the file without an
obvious scrollbar, cursoring down there's SO MUCH MORE debris. Let's see...
lib/hash.c: In function 'hash_by_name':
lib/hash.c:33:5: warning: 'MD5_Init' is deprecated: Since OpenSSL 3.0
[-Wdeprecated-declarations]
33 | USE_MD5SUM(HASH_INIT("md5sum", MD5),)
| ^~~~~~~~~~
I haven't actually tried building syslogd with openssl support. No idea
what might go boing...
Ok, here's the relevant part. (Like the last 5% of the file.) It did
basically this:
cc -Wall -Wundef -Werror=implicit-function-declaration
-Wno-char-subscripts -Wno-pointer-sign -funsigned-char -Wno-restrict
-Wno-format-overflow -Wno-discarded-qualifiers -I . -Os
-ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables
-fno-strict-aliasing generated/unstripped/obj/*.o -Wl,--gc-sections
-Wl,--as-needed -lattr -lcrypt -lcrypto -lm -lresolv -lssl -lutil -lz -o
generated/unstripped/toybox
And got:
/usr/x86_64-pc-linux-musl/binutils-bin/2.47/ld:
generated/unstripped/obj/syslogd.o: warning: relocation against
`prioritynames' in read-only section `.text.logger_lookup'
$ grep -r prioritynames
x86_64-linux-gnu/sys/syslog.h:CODE prioritynames[] =
That's out of debian's libc. I'm using a symbol in a way that seems
normal to me, and your libc/headers get mad about it. (String constants
are also in a read only section, I can stick 'em in a normal char
pointer and the segfault's on me if I write to it. I told it
-Wno-discarded-qualifiers to get it to shut up, and it didn't obviously
complain in other commands where I took out the (void *) typecasts after
doing that, so...)
/usr/x86_64-pc-linux-musl/binutils-bin/2.47/ld:
generated/unstripped/obj/syslogd.o: in function `logmsg':
syslogd.c:(.text.logmsg+0x104): undefined reference to `facilitynames'
Let's see...
$ grep -r facilitynames /usr/include
/usr/include/x86_64-linux-gnu/sys/syslog.h:CODE facilitynames[] =
$ cd musl/musl/
~/musl/musl$ grep -r facilitynames
include/syslog.h:#define facilitynames ((CODE *)(const CODE []){ \
$ grep -r prioritynames android-ndk-r29-beta2
android-ndk-r29-beta2/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/syslog.h:static
const CODE prioritynames[] = {
I've built against debian's glibc, musl, and bionic. Your libc remains
different than any of those.
/usr/x86_64-pc-linux-musl/binutils-bin/2.47/ld:
syslogd.c:(.text.logmsg+0x147): undefined reference to `prioritynames'
Ok, hang on. Above your log was complaining that prioritynames was in a
read only segement, but NOW it's saying it doesn't exist?
PICK ONE.
/usr/x86_64-pc-linux-musl/binutils-bin/2.47/ld:
generated/unstripped/obj/syslogd.o: in function `logger_lookup':
syslogd.c:(.text.logger_lookup+0x4): undefined reference to `facilitynames'
/usr/x86_64-pc-linux-musl/binutils-bin/2.47/ld:
syslogd.c:(.text.logger_lookup+0x29): undefined reference to `prioritynames'
Same bug.
/usr/x86_64-pc-linux-musl/binutils-bin/2.47/ld: read-only segment has
dynamic relocations
And again, it simultaneously doesn't exist AND is in a read only segment.
Your link environment is contradicting itself.
Sigh, let's search the web for that first weird link message:
https://github.com/vmagnin/gtk-fortran/issues/183
Hmmm, it looks like this sort of thing happens when mixing pic and
non-pic code? Or possibly when putting a nonrelocatable symbol into a
shared library, it later barfs if you try to _use_ that symbol out of
the library because it can't relocate it...
And this one is implying that your libraries may depend on each other
and get confused when loaded out of order:
https://stackoverflow.com/questions/65407610/relocation-against-xxx-in-read-only-section-text-wrong-compiler-or-linux-se
I have no idea what the case is here, but toys/pending/syslogd.c seems
(to me) to be making fairly straightforward use of a library symbol in a
way that's previously worked on glibc, musl, and bionic.
Rob
More information about the Toybox
mailing list