Discussion:
native compiler glibc: make install DESTDIR=xyz?
David Wuertele
2006-04-26 19:39:56 UTC
Permalink
I'm working on a native compiler for my embedded mipsel system. My
crosstool-0.42 based cross-compiler is working nicely. I'm a little
confused about how I should cross-compile glibc for my native
toolchain.

For binutils and gcc, I did something like this:

# target-native binutils
tar xvzf binutils-2.16.1.tar.gz
mkdir build-binutils
cd build-binutils
PATH=/path/to/gcc-3.3.3-glibc-2.3.2/mipsel-dave-linux-gnu/bin:$PATH ../binutils-2.16.1/configure --build=i386-linux --target=mipsel-dave-linux-gnu --host=mipsel-dave-linux-gnu --prefix=/usr
PATH=/path/to/gcc-3.3.3-glibc-2.3.2/mipsel-dave-linux-gnu/bin:$PATH make
PATH=/path/to/gcc-3.3.3-glibc-2.3.2/mipsel-dave-linux-gnu/bin:$PATH make install DESTDIR=/path/to/my/target/root

# target-native gcc
tar xvzf gcc-3.3.3.tar.gz
mkdir build-gcc
cd build-gcc
PATH=/path/to/gcc-3.3.3-glibc-2.3.2/mipsel-dave-linux-gnu/bin:$PATH ../gcc-3.3.3/configure --build=i386-linux --target=mipsel-dave-linux-gnu --host=mipsel-dave-linux-gnu --prefix=/usr
PATH=/path/to/gcc-3.3.3-glibc-2.3.2/mipsel-dave-linux-gnu/bin:$PATH make
PATH=/path/to/gcc-3.3.3-glibc-2.3.2/mipsel-dave-linux-gnu/bin:$PATH make install DESTDIR=/path/to/my/target/root

I tried the same for glibc, but "make install" doesn't seem to
understand "DESTDIR=xyz". If I configure with
"--prefix=/path/to/my/target/root", "make install" will install it
into the right place. But when my target boots and
/path/to/my/target/root/usr is now /usr, will glibc (or gcc) get
confused?

Is there a way to create a target-native toolchain without rebuilding
glibc? That is, can I copy it from my crosstool build of glibc?

Thanks,
Dave


--
For unsubscribe information see http://sourceware.org/lists.html#faq
Mike Frysinger
2006-04-26 20:12:33 UTC
Permalink
Post by David Wuertele
I tried the same for glibc, but "make install" doesn't seem to
understand "DESTDIR=xyz".
the variable is called 'install_root' instead of 'DESTDIR'
-mike

--
For unsubscribe information see http://sourceware.org/lists.html#faq
David Wuertele
2006-04-27 01:42:20 UTC
Permalink
Me> I tried the same for glibc, but "make install" doesn't seem to
Me> understand "DESTDIR=xyz".

Mike> the variable is called 'install_root' instead of 'DESTDIR'

That fixed it, thank you! Now I've got a toolchain package that I can
mount on my target but when I try to compile a trivial file, I get
this error:

/sdk/lib/libc.so.6: file not recognized: File truncated
collect2: ld returned 1 exit status

I don't know why collect2 shouldn't like /sdk/lib/libc.so.6, it is
just a link to /sdk/lib/libc-2.3.2.so, which does exist and as far as
I can tell is perfectly complete. It includes every symbol that the
embedded system's /lib/libc-2.3.2.so has.

Any suggestions? Here is how I made the SDK:

# some setup
USEMIPS="AR=mipsel-dave-linux-gnu-ar AS=mipsel-dave-linux-gnu-as LD=mipsel-dave-linux-gnu-gcc NM=mipsel-dave-linux-gnu-nm CC=mipsel-dave-linux-gnu-gcc GCC=mipsel-dave-linux-gnu-gcc CXX=mipsel-dave-linux-gnu-g++ STRIP=mipsel-dave-linux-gnu-strip RANLIB=mipsel-dave-linux-gnu-ranlib"
mkdir -p /work/sdk

# binutils
mkdir -p /work/binutils-build; cd /work/binutils-build
/tools/crosstool-0.42/build/mipsel-dave-linux-gnu/gcc-3.3.3-glibc-2.3.2/binutils-2.14/configure --build=i386-linux --target=mipsel-dave-linux-gnu --host=mipsel-dave-linux-gnu --prefix=/sdk --disable-nls
$USEMIPS make
make install DESTDIR=/work/sdk

# gcc
mkdir -p /work/gcc-build; cd /work/gcc-build
/tools/crosstool-0.42/build/mipsel-dave-linux-gnu/gcc-3.3.3-glibc-2.3.2/gcc-3.3.3/configure --build=i386-linux --target=mipsel-dave-linux-gnu --host=mipsel-dave-linux-gnu --prefix=/sdk --with-gcc-version-trigger=/tools/crosstool-0.42/build/mipsel-dave-linux-gnu/gcc-3.3.3-glibc-2.3.2/gcc-3.3.3/gcc/version.c --with-float=soft --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
$USEMIPS make
make install DESTDIR=/work/sdk

# glibc
mkdir -p /work/glibc-build; cd /work/glibc-build
/tools/crosstool-0.42/build/mipsel-dave-linux-gnu/gcc-3.3.3-glibc-2.3.2/glibc-2.3.2/configure --build=i386-linux --target=mipsel-dave-linux-gnu --host=mipsel-dave-linux-gnu --prefix=/sdk --without-fp --enable-kernel=2.4.18 --without-tls --without-__thread --without-cvs --disable-profile --disable-debug --without-gd --enable-shared --enable-add-ons=linuxthreads, --with-headers=/tools/gcc-3.3.3-glibc-2.3.2/mipsel-dave-linux-gnu/mipsel-dave-linux-gnu/include
$USEMIPS make
make install install_root=/work/sdk

# At this point, I manually edit /work/sdk/sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/specs
# to change the "*cross_compile:" value from "1" to "0".

# cramfs
cd /work/sdk && /usr/bin/mkcramfs sdk sdk.cramfs

Then, on the target, I inserted media with the cramfs image on it, and
mounted it:

$ losetup /dev/loop/0 /mnt/flash1/sdk.cramfs
$ mount /dev/loop/0 /sdk -o ro
$ export PATH=/sdk/bin:$PATH
$ which gcc
/sdk/bin/gcc

Here's what happens when I try to compile a trivial file:

$ cat main.c
int
main (int argc, char *argv[])
{
return 123;
}
$ gcc main.c
/sdk/lib/libc.so.6: file not recognized: File truncated
collect2: ld returned 1 exit status

But the file *is* there:

$ ls -l /sdk/lib/libc.so.6
lrwxrwxrwx 1 root 244 13 Dec 31 1969 /sdk/lib/libc.so.6 -> libc-2.3.2.so
$ ls -l /sdk/lib/libc-2.3.2.so
-rwxr-xr-x 1 root 244 16777215 Dec 31 1969 /sdk/lib/libc-2.3.2.so
$

Here is the verbose gcc run:

$ gcc -v main.c
Reading specs from /sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/specs
Configured with: /tools/crosstool-0.42/build/mipsel-dave-linux-gnu/gcc-3.3.3-glibc-2.3.2/gcc-3.3.3/configure --build=i386-linux --target=mipsel-dave-linux-gnu --host=mipsel-dave-linux-gnu --prefix=/sdk --with-gcc-version-trigger=/tools/crosstool-0.42/build/mipsel-dave-linux-gnu/gcc-3.3.3-glibc-2.3.2/gcc-3.3.3/gcc/version.c --with-float=soft --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.3.3
/sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/cc1 -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 main.c -quiet -dumpbase main.c -auxbase main -version -o /tmp/ccawhheU.s
GNU C version 3.3.3 (mipsel-dave-linux-gnu)
compiled by GNU C version 3.3.3.
GGC heuristics: --param ggc-min-expand=31 --param ggc-min-heapsize=4096
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/sdk/mipsel-dave-linux-gnu/include"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/sdk/include
/sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/include
End of search list.
/sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/../../../../mipsel-dave-linux-gnu/bin/as -EL -g0 -32 -v -KPIC -o /tmp/ccoJm7tV.o /tmp/ccawhheU.s
GNU assembler version 2.14 (mipsel-dave-linux-gnu) using BFD version 2.14 20030612
/sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/collect2 --eh-frame-hdr -EL -dynamic-linker /lib/ld.so.1 /sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/../../../crt1.o /sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/../../../crti.o /sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/crtbegin.o -L/sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3 -L/sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/../../../../mipsel-dave-linux-gnu/lib -L/sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/../../.. /tmp/ccoJm7tV.o -lgcc -lgcc_eh -rpath-link /lib:/usr/lib -lc -lgcc -lgcc_eh /sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/crtend.o /sdk/lib/gcc-lib/mipsel-dave-linux-gnu/3.3.3/../../../crtn.o
/sdk/lib/libc.so.6: file not recognized: File truncated
collect2: ld returned 1 exit status
$


--
For unsubscribe information see http://sourceware.org/lists.html#faq
Loading...