uclibc vs glibc

Robert Connolly robert at linuxfromscratch.org
Sun Nov 7 00:10:55 MST 2004


I think I have success, except that the host system is detected as -gnu 
instead of -uclibc. But otherwise its working fine {:-] I attached my 
instruction sheet. It appears as though we need to use --host/build/target on 
every package, but I'm starting to get the feeling it doesn't really matter 
excpet for packages that are patched for it. I'm interested to know what 
happens in chapter 6.

Gawk's testsuite passed. Coreutils did not... it fails strait away.

make[3]: Entering directory 
`/mnt/hlfs/sources/temp/coreutils-5.2.1/tests/basename'
-: test fail-1: stderr mismatch, comparing fail-1.1 (actual) and fail-1.E 
(expected)
*** fail-1.1    Sun Nov  7 02:02:47 2004
--- fail-1.E    Sun Nov  7 02:02:47 2004

If I run Coreutils tests with make -k I get a lot of passes, but a lot of 
failures too. Odd stuff, like no such file, and permission denied, and 
mismatches too. Coreutils doesn't leave me any .out files to look at so I'll 
shelf this for now and I'll try to get to chapter 6 (tommorrow).

nini
Robert
-------------- next part --------------
# LFS with uclibc
# robert

# This is so the cross linker is found for cross gcc's build, and again for uClibc.
# It gets removed after native tools are set up.
# This path must go on the end so the native tools in /tools/bin are used when
# they get installed.

export PATH="$PATH:/tools/cross/bin"

- Uclibc unpack

Just unpack it.

- Linux-libc-headers 2.6

cp -R include/asm-i386 ../uClibc/include/asm &&
cp -R include/{linux,sound} ../uClibc/include

- Uclibc headers

make allyesconfig &&
sed 's at RUNTIME_PREFIX.*@RUNTIME_PREFIX="/tools"@' -i .config &&
echo > extra/scripts/fix_includes.sh

# This is better than 'cp -R include /tools/include' because this doesn't install
# libintl.h because it doesn't seem to work.
# Ignore the error about missing lib/

make headers
make DEVEL_PREFIX=/tools/cross/i386-pc-linux-uclibc/ install_dev

# Remove this broken link (lets not pretend it works).
# Then remove the empty directory (lets not pretend something is inside).

rm /tools/cross/i386-pc-linux-uclibc/lib/libthread_db.so &&
rmdir /tools/cross/i386-pc-linux-uclibc/lib/

- Binutils cross linker

# The second patch might not be needed, but I don't think it hurts either.

cat ../binutils-2.15.90.0.3-uclibc-100-conf.patch \
	| sed -e 's@/lib/@/tools/lib/@g' | patch -Np1 &&
patch -Np1 -i ../binutils-2.15.90.0.3-uclibc-210-cflags.patch

mkdir ../binutils-build &&
cd ../binutils-build 

../binutils-2.15.90.0.3/configure --prefix=/tools/cross --disable-nls \
        --target=i386-pc-linux-uclibc &&
make configure-host &&
make LDFLAGS="-all-static" &&
make install &&
make -C ld clean &&
make -C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib

- Gcc cross compiler

# Just unpack gcc-core

# This is a replacement for the LFS specs patch, and adds uClibc specific stuff so
# --target=uclibc works nicer.
patch -Np1 -i ../gcc-3.4.3-uclibc_tools_conf-1.patch

mkdir ../gcc-build &&
cd ../gcc-build

# The most important thing here is --disable-shared. Untill we have a native C library
# Gcc can not build a libgcc.so (because it uses functions from libc.so).
../gcc-3.4.3/configure --prefix=/tools/cross --target=i386-pc-linux-uclibc \
    --libexecdir=/tools/cross/i386-pc-linux-uclibc/lib \
    --with-local-prefix=/tools/cross \
    --disable-nls --disable-shared --enable-languages=c

# Not BOOT_LDFLAGS because we are not doing a bootstrap here.
make LDFLAGS="-static"

make install

- uClibc build

make CROSS=i386-pc-linux-uclibc-

make RUNTIME_PREFIX=/tools/ install_runtime
make DEVEL_PREFIX=/tools/ install_dev

- Adjusting toolchain

# In binutils-build
make -C ld install

# I dont know how to avoid this. Its only for use durring cross compiling.
ln -s /tools/lib/crt* /tools/cross/i386-pc-linux-uclibc/lib

# Theres no sed(1) command in this, the gcc-uclibc-conf patch took care of it.
# Now test that the compiler works.
echo 'main(){}' > dummy.c
i386-pc-linux-uclibc-gcc dummy.c
readelf -l a.out | grep ': /tools'

- Gcc native

patch -Np1 -i ../gcc-3.4.3-uclibc_tools_conf-1.patch 

# This patch tells GCC how to build with uClibc locales for c++.
patch -Np1 -i ../gcc-3.4.1-uclibc-200-locale.patch

# This is so we don't run the fixincludes scripts.
patch -Np1 -i ../gcc-3.4.3-no_fixincludes-1.patch

mkdir ../gcc-build &&
cd ../gcc-build

# Uclibc and __cxa_atexit don't get along. --enable-clocale=uclibc, but don't define
# that or else it won't work, it will be echo'd during configure though.

# The first pass will be with the cross compiler, the bootstrap is with the native.
CC="i386-pc-linux-uclibc-gcc" \
../gcc-3.4.3/configure --prefix=/tools \
    --host=i386-pc-linux-uclibc --build=i386-pc-linux-uclibc \
    --target=i386-pc-linux-uclibc --enable-shared \
    --libexecdir=/tools/lib --with-local-prefix=/tools \
    --enable-threads=posix --disable-__cxa_atexit \
    --enable-languages=c,c++ --disable-libstdcxx-pch

make bootstrap

make install &&
ln -s gcc /tools/bin/cc

- Binutils native

cat ../binutils-2.15.90.0.3-uclibc-100-conf.patch \
        | sed -e 's@/lib/@/tools/lib/@g' | patch -Np1 &&
patch -Np1 -i ../binutils-2.15.90.0.3-uclibc-210-cflags.patch

mkdir ../binutils-build &&
cd ../binutils-build

../binutils-2.15.90.0.3/configure --prefix=/tools \
	--enable-shared --with-lib-path=/tools/lib \
	--host=i386-pc-linux-uclibc --build=i386-pc-linux-uclibc \
    --target=i386-pc-linux-uclibc &&
make &&
make install &&
make -C ld clean &&
make -C ld LIB_PATH=/usr/lib:/lib

- Gawk

./configure --prefix=/tools --host=i386-pc-linux-uclibc \
  --build=i386-pc-linux-uclibc --target=i386-pc-linux-uclibc &&
make &&
make install

- Coreutils

./configure --prefix=/tools --host=i386-pc-linux-uclibc \
  --build=i386-pc-linux-uclibc --target=i386-pc-linux-uclibc &&
make &&
make install



More information about the hlfs-dev mailing list