Cross compiling GLIBC for my ARM SoC -
i seeing weird within chroot-ed debian armel environment.
but first, bit of backstory... long, question complex , potential help depends on knowing total story.
i have embedded arm soc runs linux - more specifically, debian armel lenny on 2.6.17 kernel. debian distro upgradeable later versions (sudo apt-get dist-upgrade) , can brought speed, armel versions of squeeze or wheezy.
the problem kernel custom one... arm soc in question not part of mainline kernel, pretty much abandoned @ 2.6.17.
if know how linux , glibc work, can see problem - glibc versions compiled minimum supported kernel version... has moved way past 2.6.17. if seek e.g. chroot debian squeeze...
$ # within little arm machine running debian lenny $ sudo debootstrap --arch armel squeeze /squeeze \ http://ftp.whatevercountry.debian.org/debian $ sudo -i # mount -t proc none /squeeze/proc # mount -t sysfs none /squeeze/sys # mount -t devpts none /squeeze/dev/pts # chroot /squeeze fatal: kernel old ...we see message glibc of squeeze, telling not compiled work old kernel (2.6.17).
the same problem happens wheezy, - since newer squeeze - , in fact happen debian version on, since glibc won't work on 2.6.17 kernel.
at first thought deal breaker - realized can in theory recompile glibc work older kernel soc using... i'd need identical environment used build libc6 bundle in e.g. debian squeeze.
i guessing compilation of glibc , preparation of libc6_2.11.3-4.deb file done via automated cross-compiling machinery invented gods of debian.
i no god... nor find in google how become 1 - i.e. how utilize core i5 host, cross-compile glibc using exact same settings packaged version (inside debian squeeze) using.
so tricked - figured out how setup arm version of debian squeeze on core i5 (a technique uses static version of qemu-arm binary).
once chrooted in x86-hosted version of debian-armel-squeeze, able simply...
$ cd /var/tmp $ apt-get source libc6 ... $ # edit in - compile kernel... $ vi eglibc-2.11.3/debian/sysdeps/linux.mk ... min_kernel_supported := 2.6.17 ... $ export deb_build_opts="nocheck parallel=1" $ cd eglibc-2.11.3 $ dpkg-buildpackage -b -d -us -uc ...and after 3 hours (the core i5-hosted chrooted version of debian-armel-squeeze much slower native machine...) got libc6 .deb package. take 3 months build in soc, not complaining.
going within real arm soc, copied libc files (.so) of new bundle on default ones of squeeze , tried chroot...
# chroot squeeze/ root@ttsiodras:/# yes! worked! (or seemed)
my custom libc reported within chroot:
# /lib/libc.so.6 gnu c library (debian eglibc 2.11.3-4) stable release version 2.11.3, roland mcgrath et al. copyright (c) 2009 free software foundation, inc. free software; see source copying conditions. there no warranty; not merchantability or fitness particular purpose. compiled gnu cc version 4.4.5. compiled on linux 2.6.26 scheme on 2014-10-23. available extensions: crypt add-on version 2.1 michael glad , others gnu libidn simon josefsson native posix threads library ulrich drepper et al back upwards architectures added on, not maintained in glibc core. bind-8.2.3-t5b bug reporting instructions, please see: <http://www.debian.org/bugs/>. things seemed work - copied file, invoked ls...
but when tried utilize apt-get install apps squeeze, started getting... unexpected errors:
# apt-get install indent reading bundle lists... done building dependency tree... done next new packages installed: indent 0 upgraded, 1 newly installed, 0 remove , 0 not upgraded. need 110 kb of archives. after operation, 516 kb of additional disk space used. get:1 http://ftp.gr.debian.org/debian/ squeeze/main indent armel 2.2.11-1 [110 kb] fetched 110 kb in 0s (236 kb/s) tar: ./control: cannot utime: function not implemented tar: ./md5sums: cannot utime: function not implemented tar: .: cannot utime: function not implemented tar: exiting failure status due previous errors dpkg-deb: subprocess tar returned error exit status 2 dpkg: error processing /var/cache/apt/archives/indent_2.2.11-1_armel.deb (--unpack): subprocess dpkg-deb --control returned error exit status 2 configured not write apport reports rm: cannot remove `/var/lib/dpkg/tmp.ci': function not implemented dpkg: error while cleaning up: subprocess rm cleanup returned error exit status 1 errors encountered while processing: /var/cache/apt/archives/indent_2.2.11-1_armel.deb e: sub-process /usr/bin/dpkg returned error code (1) oh-oh... bunch of function not implemented. sounds glibc reporting basic things not working...
i managed strace (don't inquire how) , figured out -at functions failing: openat, mkdirat, renameat, etc - reporting enosys.
it appears partially successful - scheme calls failing in new glibc.
is impossible compile squeeze or wheeze glibc execute under 2.6.17?
any ideas/pointers on did wrong and/or how proceed much appreciated...
i made :-)
i followed gilles's advice (from unix stackexchange) , decided properly: i.e. manage finish cross-compilation of glibc. started crosstool-ng, , disappointed - seeing didn't back upwards old kernel. kept @ it, though - manually editing configuration file saved crosstool-ng changes these on default arm-gnueabi build configuration:
$ ct-ng arm-unknown-linux-gnueabi $ ct-ng menuconfig ... $ vi .config $ cat .config ... ct_kernel_version="2.6.17" ct_kernel_v_2_6_17=y ct_libc_version="2.13" ct_libc_glibc_v_2_13=y ct_libc_glibc_min_kernel_version="2.6.9" ct_libc_glibc_min_kernel="2.6.9 ... $ ct-ng +libc after numerous tests , failed attempts, above changes did - got compiled version of glibc work kernel, , copied resulting files debian lenny arm machine:
$ cd .build/arm-unknown-linux-gnueabi/build/build-libc-final/ $ tar zcpf newlibc.tgz $(find . -type f -iname \*.so) $ scp newlibc.tgz root@mybook:. i went way , moved past squeeze: debootstrapped /wheezy , - - overwrote glibc versions of armel-debootstrapped /wheezy own:
# # in arm machine # cd /wheezy/lib/arm-linux-gnueabi/ # mv /var/tmp/ohmygod/libc.so libc-2.13.so # mv /var/tmp/ohmygod/rt/librt.so librt-2.13.so ... ...etc, making sure didn't miss shared libraries.
finally, copied on ldd , ldconfig binaries (which part of glibc), , chrooted within /wheezy.
it worked.
i can assume compilation of glibc chroot-ed qemu-arm somehow messed things - maybe configure process detects stuff running environment - whereas cross-compilation can't misled.
so naturally moved next step, , used busybox-static shell replace {/bin,/sbin,...} folders of old lenny wheezy ones - , rebooted brand new wheezy :-)
i hereby claim my wd mybook world edition 1 on planet running debian wheezy :-) if else interested, can upload tarball of libc files someplace.
arm glibc
No comments:
Post a Comment