Cross compiling "make utils".

Denys Vlasenko vda.linux at googlemail.com
Sun Jan 11 22:09:52 UTC 2009


I am not expert, so take my opinion with a grain of salt.

On Tuesday 09 December 2008 02:54, Rob Landley wrote:
> So once again I'm trying to add readelf and ldd to my cross compiler
> toolchain, to run on the host but examine target binaries, and I'm having
> problems.

You need "make hostutils". I think you discovered this already.
> 
> I pointed at this back in February 2007:
> 
> Let's start with adding "readelf" and "ldd" to the cross compiler.  This means
> they need to run on the host, and interpret target binaries.  So let's try
> doing a non-cross-compile "make utils" on an x86-64 host with an armv4l config
> file:
> 
> > $ make utils
> >  CC utils/readelf
> > cc1: error: unrecognized command line option "-mlittle-endian"
> > make[1]: *** [../utils/readelf] Error 1
> > make: *** [utils] Error 2

As a first step, I'd like to replace utils/Makefile.in with something
remotely readable, without changing the result. See attachment.

This is what "make V=1 utils" does:

make CROSS="" CC="gcc" -C utils
gcc ../utils/readelf.c -o ../utils/readelf \
    -include ../include/libc-symbols.h \
    -Wall -Wstrict-prototypes -fno-strict-aliasing -ffunction-sections \
    -fdata-sections -m32 -march=i486 -fno-stack-protector -funsigned-char \
    -fno-builtin -nostdinc -I../include -I. -I../libc/sysdeps/linux/i386 \
    -fno-asm -DUCLIBC_INTERNAL -std=gnu99 -Os -funit-at-a-time \
    -fno-tree-loop-optimize -fno-tree-dominator-opts -fno-strength-reduce \
    -fomit-frame-pointer -m32 -mpreferred-stack-boundary=2 -falign-functions=1 \
    -falign-jumps=1 -falign-labels=1 -falign-loops=1 \
    -I../libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386 \
    -I../libpthread/linuxthreads/sysdeps/i386 \
    -I../libpthread/linuxthreads/sysdeps/unix/sysv/linux \
    -I../libpthread/linuxthreads/sysdeps/pthread \
    -I../libpthread/linuxthreads \
    -I../libpthread -I../../linux-2.6.27.9-i386/usr/include/ \
    -I/.share/usr/app/gcc-4.2.1/bin/../lib/gcc/i386-pc-linux-gnu/4.2.1//include-fixed \
    -I/.share/usr/app/gcc-4.2.1/bin/../lib/gcc/i386-pc-linux-gnu/4.2.1/include \
    -DNDEBUG -DNOT_IN_libc -B../lib -Wl,-rpath-link,../lib \
    -MT ../utils/readelf -MD -MP -MF ../utils/.readelf.dep
strip -x -R .note -R .comment ../utils/readelf

This one succeeds. However, it is quite obvious that gcc flags are bogus.
makefile composed it as if it builds part of the libc.
This is extremely fragile. Much better wuld be to install
the library (libs and headers) and use those, as "normal"
library users would do.

No wonder that attempt to link ldconfig fails:

gcc ../utils/ldconfig.c ../utils/chroot_realpath.c -o ../utils/ldconfig \
    -include ../include/libc-symbols.h \
    -Wall -Wstrict-prototypes -fno-strict-aliasing -ffunction-sections \
    -fdata-sections -m32 -march=i486 -fno-stack-protector -funsigned-char \
    -fno-builtin -nostdinc -I../include -I. -I../libc/sysdeps/linux/i386 \
    -fno-asm -DUCLIBC_INTERNAL -std=gnu99 -Os -funit-at-a-time \
    -fno-tree-loop-optimize -fno-tree-dominator-opts -fno-strength-reduce \
    -fomit-frame-pointer -m32 -mpreferred-stack-boundary=2 -falign-functions=1 \
    -falign-jumps=1 -falign-labels=1 -falign-loops=1 \
    -I../libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386 \
    -I../libpthread/linuxthreads/sysdeps/i386 \
    -I../libpthread/linuxthreads/sysdeps/unix/sysv/linux \
    -I../libpthread/linuxthreads/sysdeps/pthread -I../libpthread/linuxthreads \
    -I../libpthread -I../../linux-2.6.27.9-i386/usr/include/ \
    -I/.share/usr/app/gcc-4.2.1/bin/../lib/gcc/i386-pc-linux-gnu/4.2.1//include-fixed \
    -I/.share/usr/app/gcc-4.2.1/bin/../lib/gcc/i386-pc-linux-gnu/4.2.1/include \
    -DNDEBUG -DNOT_IN_libc -B../lib -Wl,-rpath-link,../lib \
    -I../ldso/include \
    -DUCLIBC_RUNTIME_PREFIX="./!INSTALL/i386/" -DUCLIBC_LDSO=ld-uClibc.so.0 \
    -static -MT ../utils/ldconfig -MD -MP -MF ../utils/.ldconfig.dep
In file included from ../include/bits/posix1_lim.h:153,
                 from ../include/dirent.h:231,
                 from ../utils/ldconfig.c:34:
../include/bits/local_lim.h:36:26: error: linux/limits.h: No such file or directory
In file included from ../include/errno.h:36,
                 from ../utils/ldconfig.c:38:
../include/bits/errno.h:25:26: error: linux/errno.h: No such file or directory
../utils/ldconfig.c: In function 'is_shlib':
../utils/ldconfig.c:286: warning: pointer targets in passing argument 1 of 'strncmp' differ in signedness
...

I'll try to do something about it.
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile.in
Type: text/x-makefile
Size: 3394 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20090111/3007c942/attachment.bin 


More information about the uClibc mailing list