OpenWrt Forum Archive

Topic: Problem with static compile for brcm2708

The content of this topic has been archived on 20 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I was trying to compile something with -static for the raspberry pi using the standard 14.07 toolchain for brcm2708 (raspberry pi):

gt@oden:~/tmp/test-brcm2708$ arm-openwrt-linux-uclibcgnueabi-gcc -o test.rpi.static test.c -static
/home/gt/openwrt/toolchains/std-14.07-brcm2708/bin/../lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../../../arm-openwrt-linux-uclibcgnueabi/lib/libc.a(close.os):(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/home/gt/openwrt/toolchains/std-14.07-brcm2708/bin/../lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../../../arm-openwrt-linux-uclibcgnueabi/lib/libc.a(write.os):(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/home/gt/openwrt/toolchains/std-14.07-brcm2708/bin/../lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../../../arm-openwrt-linux-uclibcgnueabi/lib/libc.a(read.os):(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/home/gt/openwrt/toolchains/std-14.07-brcm2708/bin/../lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../../../arm-openwrt-linux-uclibcgnueabi/lib/libc.a(libc-cancellation.os):(.ARM.exidx.text.__libc_enable_asynccancel+0x0): undefined reference to `__aeabi_unwind_cpp_pr1'
/home/gt/openwrt/toolchains/std-14.07-brcm2708/bin/../lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../../../arm-openwrt-linux-uclibcgnueabi/lib/libc.a(libc-cancellation.os):(.ARM.exidx.text.__libc_disable_asynccancel+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/home/gt/openwrt/toolchains/std-14.07-brcm2708/bin/../lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../../../arm-openwrt-linux-uclibcgnueabi/lib/libc.a(sigrestorer.os):(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr1'
/home/gt/openwrt/toolchains/std-14.07-brcm2708/bin/../lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../../../arm-openwrt-linux-uclibcgnueabi/lib/libc.a(open.os):(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
collect2: error: ld returned 1 exit status

Not static is fine though...

gt@oden:~/tmp/test-brcm2708$ arm-openwrt-linux-uclibcgnueabi-gcc -o test.rpi test.c
(no output)

And for other targets (ar71xx and mpc85xx) it works perfectly fine:

gt@oden:~/tmp/test-ar71xx$ mips-openwrt-linux-uclibc-gcc -o test.ar71xx.static test.c -static
(no output)
gt@oden:~/tmp/test-mpc85xx$ powerpc-openwrt-linux-uclibcspe-gcc -o test.mpc85xx.static test.c -static
(no output)

I got exactly the same problem using the trunk-toolchain for brcm2708.
Is there any good reason for this?

I replicated your problem and it looks like a bug.
I filed a ticket - see https://dev.openwrt.org/ticket/19588

Other targets work because the 2 you tested are MIPS (ar71xx) and PowerPC (mpc85xx).
brcm2708 is ARM and seem to use libunwind which is either missing OR is activated by default.

Cool!

My idea was to build Node.js for the Raspberry Pi, and for some reason I thought a --fully-static build would be easier/better.
However, I managed to build a dynamic build that works just fine smile so the above is not much of a problem for me anymore.

Thank you.

I find 2 solutions.
1. write a dummy  __aeabi_unwind_cpp_pr0&__aeabi_unwind_cpp_pr1 functions in your code
2. modify build_dir/toolchain-arm_cortex-a9+neon_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/uClibc/libc/sysdeps/linux/arm/Makefile.arch

libc-static-y += $(ARCH_OUT)/aeabi_lcsts.o $(ARCH_OUT)/aeabi_math.o \
        $(ARCH_OUT)/aeabi_sighandlers.o $(ARCH_OUT)/aeabi_unwind_cpp_pr1.o

refer to: http://37iot.com/topic/55c1d921af193c0f04df310f

The discussion might have continued from here.