__libc_csu_fini and __libc_csu_init undefined while following instructions for build-webos-Collection of common programming errors

I’m trying to build OpenWebOS and just following the plan laid out in the build-webos GitHub README. I’m using a fresh 32-bit Ubuntu 12.10 installation. Things have been a bit bumpy.

However, with a tweak here and there I managed to get up to step 350 out of 2500 or (or whatever) before it errors out. The problem is the dependency of building glibc, and it’s complaining about

(...)/sysdeps/i386/start.S:107: undefined reference to `__libc_csu_fini'
(...)/sysdeps/i386/start.S:108: undefined reference to `__libc_csu_init'

Searching the web reveals various cases of people having this happen to them when not building glibc itself:

ld complains: in function “_start”, undefined reference to “__libc_csu_fini” & “__libc_csu_init”

Can’t link a C program

But this is during the build of a custom Embedded LIBC: eglibc. So it’s a little different, and the closest case I can find is this 2009 thread on an OpenEmbedded list. I’m not sure how to put their patch into action in the confusing “bakefile”-laden universe of the WebOS build structure, which is dizzyingly weird.

The monster of a command line which is failing I will “simplify” down a little to the following:

gcc -m32 -march=i586 –sysroot=/home/webos/build-webos/BUILD-qemux86/sysroots/qemux86-tcbootstrap -nostdlib -nostartfiles -o iconv/iconvconfig -Wl,-dynamic-linker=/lib/ld-linux.so.2 -Wl,-z,combreloc -Wl,-z,relro -Wl,–hash-style=both csu/crt1.o csu/crti.o `gcc -m32 -march=i586 –sysroot=/home/hostilefork/Projects/webos/build-webos/BUILD-qemux86/sysroots/qemux86-tcbootstrap –print-file-name=crtbegin.o` iconv/iconvconfig.o iconv/strtab.o iconv/xmalloc.o iconv/hash-string.o -Wl,-rpath-link=/home/webos/build-webos/BUILD-qemux86/work/i586-webos-linux/eglibc-2.16-r15+svnr20393/build-i586-webos-linux:math:elf:dlfcn:nss:nis:rt:resolv:crypt:nptl libc.so.6 libc_nonshared.a -Wl,–as-needed elf/ld.so -Wl,–no-as-needed -lgcc `gcc -m32 -march=i586 –sysroot=/home/webos/build-webos/BUILD-qemux86/sysroots/qemux86-tcbootstrap –print-file-name=crtend.o` csu/crtn.o

I’ve got a libc.a and a libc_nonshared.a file in the directory. There’s no mention of __libc_csu_init or __libc_csu_fini in the nonshared version, but they’re in the ordinary libc.a. This seems backward from what people seem to act as if should be true, although… when I look in the /usr/lib/i386-linux-gnu for what came with Ubuntu, both the shared and nonshared versions mention it. Hmmm.

If anyone reads this and goes “hey, bet I know what’s going on!” that would be nifty. 🙂

Originally posted 2013-11-09 19:42:28.