Hi Waldemar, all.
Commit that introduced a single libc and deduplicated threading code, i.e.: http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/?id=29ff9055c80efe77... has affected statically built uClibc.
After that commit if someone tries to link any application with libc.a, he gets the message like this: ---------------------------------->8------------------------------------ ..../libgcc.a(unwind-dw2-fde-dip.o): In function `_Unwind_Find_FDE': ..../libgcc/unwind-dw2-fde-dip.c:465: undefined reference to `dl_iterate_phdr' ..../bin/ld: GOT and PLT relocations cannot be fixed with a non dynamic linker. ..../bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status ---------------------------------->8------------------------------------
Seems like there are complicated cyclic dependencies between libgcc.a and libc.a as when we pass libc to linker twice, e.g in the following order: ---------------------------------->8------------------------------------ -lc -lgcc -lc -lgcc ---------------------------------->8------------------------------------ linking is processed without any errors.
To reproduce the issue try to build a simple hello world program like: ---------------------------------->8------------------------------------ #include <stdio.h>
int main() { printf("hello world\n"); return 0; } ---------------------------------->8------------------------------------ and link with the latest statically built uClibc (libc.a) for ARC for example and you will get the error, described above.
Also you can find these errors in buildroot autobuilder's logs for different architectures: xtensa: http://autobuild.buildroot.net/results/566/56636ab66a68045c43419feb7d5f356a7... arc: http://autobuild.buildroot.net/results/025/02593e7f2eac19b77bcaad3b0e9e8f947...
Thanks. -- Best regards, Vlad Zakharov vzakhar@synopsys.com
Hello,
On Thu, 8 Dec 2016 09:34:49 +0000, Vlad Zakharov wrote:
Also you can find these errors in buildroot autobuilder's logs for different architectures: xtensa: http://autobuild.buildroot.net/results/566/56636ab66a68045c43419feb7d5f356a7... arc: http://autobuild.buildroot.net/results/025/02593e7f2eac19b77bcaad3b0e9e8f947...
Both of these are because -static is missing from the final link command line. We've already discussed them on the Buildroot mailing list.
For the ARC failure / sdl_mixer, Waldemar sent a patch (which I haven't applied yet, because I requested a better explanation in the patch).
For the Xtensa / lua failure, I don't think a patch has been submitted yet, but it's the same problem.
Thomas
Hi Thomas,
On Thu, 2016-12-08 at 12:48 +0100, Thomas Petazzoni wrote:
Hello,
On Thu, 8 Dec 2016 09:34:49 +0000, Vlad Zakharov wrote:
Also you can find these errors in buildroot autobuilder's logs for different architectures: xtensa: http://autobuild.buildroot.net/results/566/56636ab66a68045c43419feb7d5f356a7... arc: http://autobuild.buildroot.net/results/025/02593e7f2eac19b77bcaad3b0e9e8f947...
Both of these are because -static is missing from the final link command line. We've already discussed them on the Buildroot mailing list.
For the ARC failure / sdl_mixer, Waldemar sent a patch (which I haven't applied yet, because I requested a better explanation in the patch).
But sdl_mixer is not the only package that fails with static uclibc. E.g, the following packages: fxload-2008_10_13 berkeleydb-5.3.29 picocom-2.1 dante-1.4.1 uclibc-ng-test-4ad1c23ae2eb30888cda520c739cc26150512487 dvblast-3.0
and many others are failing too.
For the Xtensa / lua failure, I don't think a patch has been submitted yet, but it's the same problem.
Thomas
Thanks.
Hello,
On Fri, 9 Dec 2016 12:01:44 +0000, Vlad Zakharov wrote:
Both of these are because -static is missing from the final link command line. We've already discussed them on the Buildroot mailing list.
For the ARC failure / sdl_mixer, Waldemar sent a patch (which I haven't applied yet, because I requested a better explanation in the patch).
But sdl_mixer is not the only package that fails with static uclibc. E.g, the following packages: fxload-2008_10_13 berkeleydb-5.3.29 picocom-2.1 dante-1.4.1 uclibc-ng-test-4ad1c23ae2eb30888cda520c739cc26150512487 dvblast-3.0
and many others are failing too.
Right, and I bet for all of them it's because -static is not passed at link stage.
Best regards,
Thomas
Hi again,
On Fri, 2016-12-09 at 14:53 +0100, Thomas Petazzoni wrote:
Hello,
On Fri, 9 Dec 2016 12:01:44 +0000, Vlad Zakharov wrote:
Both of these are because -static is missing from the final link command line. We've already discussed them on the Buildroot mailing list.
For the ARC failure / sdl_mixer, Waldemar sent a patch (which I haven't applied yet, because I requested a better explanation in the patch).
But sdl_mixer is not the only package that fails with static uclibc. E.g, the following packages: fxload-2008_10_13 berkeleydb-5.3.29 picocom-2.1 dante-1.4.1 uclibc-ng-test-4ad1c23ae2eb30888cda520c739cc26150512487 dvblast-3.0
and many others are failing too.
Right, and I bet for all of them it's because -static is not passed at link stage.
Best regards,
Thomas
Just to clarify: the only thing we need to do is to pass $LDFLAGS containing "-static" at link stage to all of this packages? I mean we should update each package's Makefile.in?
Thanks.
Hello,
On Fri, 9 Dec 2016 13:59:53 +0000, Vlad Zakharov wrote:
Just to clarify: the only thing we need to do is to pass $LDFLAGS containing "-static" at link stage to all of this packages? I mean we should update each package's Makefile.in?
Yes, that's the idea.
Thomas
I'm also seeing static linking issues on mipsel using uclibc-ng 1.0.20. A "hello world" c++ application will compile, but gives segmentation fault. Compiling with the following produces a working binary.
(mipsel-linux-)g++ -static hello.c++ -o hello -lc -lgcc -lc
thanks, Lance
Hi, Lance Fredrickson wrote,
I'm also seeing static linking issues on mipsel using uclibc-ng 1.0.20. A "hello world" c++ application will compile, but gives segmentation fault. Compiling with the following produces a working binary.
(mipsel-linux-)g++ -static hello.c++ -o hello -lc -lgcc -lc
does it start with 1.0.20 or before?
I am adding C++ checks to my embedded-test regression soon, so that this shouldn't happen in the future without recognizing.
best regards Waldemar
On 12/8/2016 10:33 AM, Waldemar Brodkorb wrote:
does it start with 1.0.20 or before?
Going back through my previous builds, it appears between 1.0.17 & 1.0.18. So it seems when the change to a unified libc. I don't do as much with mipsel, so only now just noticing. I did notice too that binary sizes have grown significantly. A mipsel hello world binary under 1.0.17 compiled static and stripped is 104k. In 1.0.20 static and stripped when I measured was 1.2Mb.
thanks, Lance
Hi Lance, Lance Fredrickson wrote,
On 12/8/2016 10:33 AM, Waldemar Brodkorb wrote:
does it start with 1.0.20 or before?
Going back through my previous builds, it appears between 1.0.17 & 1.0.18. So it seems when the change to a unified libc. I don't do as much with mipsel, so only now just noticing. I did notice too that binary sizes have grown significantly. A mipsel hello world binary under 1.0.17 compiled static and stripped is 104k. In 1.0.20 static and stripped when I measured was 1.2Mb.
Are you sure? I know the binaries are bigger now and there is a patch in my queue to fix this. But the difference is not 1 Mb.
With my patch I have following sizes:
find openadk/root_* -name helloworld.static -exec ls -la {} ; -rwxr-xr-x 1 wbx wbx 18792 Dec 8 20:48 openadk/root_generic-arm_uclibc-ng_arm1176jzf_s_soft_eabi/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 59980 Dec 9 01:57 openadk/root_generic-nds32_uclibc-ng_nds32le/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 9252 Dec 8 18:50 openadk/root_nsim-arcv1_uclibc-ng_arc700/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 9252 Dec 8 19:18 openadk/root_nsim-arcv1_uclibc-ng_arc700eb/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 9252 Dec 8 19:03 openadk/root_nsim-arcv2_uclibc-ng_archs/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 9252 Dec 8 19:32 openadk/root_nsim-arcv2_uclibc-ng_archseb/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 11072 Dec 8 18:36 openadk/root_qemu-alpha_uclibc-ng/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 64776 Dec 8 19:47 openadk/root_qemu-arm-versatilepb-nommu_uclibc-ng_soft_eabi/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 19208 Dec 8 20:02 openadk/root_qemu-arm-versatilepb_uclibc-ng_arm926ej_s_soft_eabi/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 18808 Dec 8 20:17 openadk/root_qemu-arm-vexpress-a9_uclibc-ng_cortex_a9_hard_eabihf/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 13624 Dec 8 20:33 openadk/root_qemu-arm-vexpress-a9_uclibc-ng_cortex_a9_soft_eabi/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 53968 Dec 8 21:49 openadk/root_qemu-cris_uclibc-ng_crisv32/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 56060 Dec 8 22:50 openadk/root_qemu-m68k-mcf5208_uclibc-ng_cf5208/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 54444 Dec 8 22:39 openadk/root_qemu-m68k-q800_uclibc-ng_68040/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 18292 Dec 8 23:15 openadk/root_qemu-microblaze-s3adsp1800_uclibc-ng_microblaze/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 18292 Dec 8 23:02 openadk/root_qemu-microblaze-s3adsp1800_uclibc-ng_microblazeel/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 20740 Dec 9 01:32 openadk/root_qemu-mips64_uclibc-ng_mips64el_n32/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 23632 Dec 9 01:47 openadk/root_qemu-mips64_uclibc-ng_mips64el_n64/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 20780 Dec 9 01:16 openadk/root_qemu-mips64_uclibc-ng_mips64el_o32/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 20740 Dec 9 00:46 openadk/root_qemu-mips64_uclibc-ng_mips64_n32/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 23632 Dec 9 01:01 openadk/root_qemu-mips64_uclibc-ng_mips64_n64/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 20780 Dec 9 00:30 openadk/root_qemu-mips64_uclibc-ng_mips64_o32/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 20780 Dec 9 00:00 openadk/root_qemu-mips_uclibc-ng_mips32el_hard/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 20780 Dec 9 00:15 openadk/root_qemu-mips_uclibc-ng_mips32el_soft/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 20780 Dec 8 23:30 openadk/root_qemu-mips_uclibc-ng_mips32_hard/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 20780 Dec 8 23:45 openadk/root_qemu-mips_uclibc-ng_mips32_soft/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 17616 Dec 9 02:10 openadk/root_qemu-nios2_uclibc-ng/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 13740 Dec 9 02:50 openadk/root_qemu-ppc-bamboo_uclibc-ng_soft/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 13832 Dec 9 02:36 openadk/root_qemu-ppc-macppc_uclibc-ng_hard/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 13420 Dec 9 03:22 openadk/root_qemu-sh_uclibc-ng_sh4/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 13420 Dec 9 03:36 openadk/root_qemu-sh_uclibc-ng_sh4eb/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 20032 Dec 9 03:48 openadk/root_qemu-sparc_uclibc-ng_v8/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 14000 Dec 9 04:27 openadk/root_qemu-x86_64_uclibc-ng/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 9320 Dec 9 04:12 openadk/root_qemu-x86_uclibc-ng/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 18172 Dec 9 04:40 openadk/root_qemu-xtensa_uclibc-ng_dc233c/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 47008 Dec 9 05:06 openadk/root_qemu-xtensa_uclibc-ng_de212/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 17396 Dec 9 04:53 openadk/root_qemu-xtensa_uclibc-ng_kc705_be/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 51500 Dec 8 21:19 openadk/root_sim-bfin_uclibc-ng_bf512_fdpic/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 52316 Dec 8 21:06 openadk/root_sim-bfin_uclibc-ng_bf512_flat/usr/bin/helloworld.static -rwxr-xr-x 1 wbx wbx 92120 Dec 9 02:22 openadk/root_sim-or1k_uclibc-ng/usr/bin/helloworld.static
best regards Waldemar