Cross linking our Ch5 build against a new glibc

Richard Lightman richard at nezumi.plus.com
Fri Jan 17 04:54:43 PST 2003


* Ryan Oliver <ryan.oliver at pha.com.au> [2003-01-17 08:18]:
> 
> I may have mentioned in an earlier post about building glibc
> first in chapter 5, finally I have a tentative build process
> to build Ch 5 against the new glibc.
> 
Interesting. Here are some ideas:


> mkdir /static
> 
> # We will bind mount $LFS/static to /static, so our toolchain
> # will look in the right spot when we enter chroot
> 
> mount --bind ${LFS}/static /static

Some people object to messing with the host. How about:

mkdir -p     ${LFS}${LFS}/static ${LFS}/static
mount --bind ${LFS}${LFS}/static ${LFS}/static

Also, I do not like running mount in chroot because it does not update
the host's /etc/mtab (if they do not use a symlink).

> cd ${SRC}
> export KERNEL_VER=2.4.20
> tar -xvzf ${TARBALLS}/linux-${KERNEL_VER}.tar.gz
> mv linux linux-${KERNEL_VER}
> ln -s linux-${KERNEL_VER} linux

You have been updating your kernel with patches ;-). They are now
distributed with the version number in the top level dir name:
[richard at urusai tmp]$ bzip2 -cd \
/mnt/backup/sources/ftp/ftp.uk.kernel.org/ftp.kernel.org/linux/kernel/v2.4/linux-2.4.20.tar.bz2 |
 tar -t | head -4
linux-2.4.20/
linux-2.4.20/Makefile
linux-2.4.20/MAINTAINERS
linux-2.4.20/CREDITS


> cat Makefile-DIST | sed 's/\$(PERL)/\/usr\/bin\/perl/g' > Makefile

Useless use of cat award plus obfuscated sed (-:
sed 's@\$(PERL)@/usr/bin/perl at g' Makefile-DIST > Makefile
 

> # I am not totally sure if what I have done here is perfectly correct or
> # not, the aim is to get gcc to always search /static/include for headers
> # first. Any input here from the reader would be appreciated.
> #
How about, afer building, but before installing glibc:

mkdir -p ${LFS}/host/usr
mount --bind ${LFS}/host/usr /usr
mount --bind /usr/include /static/include
# create a symlink forest in /usr/include to the host's /usr/include
# which is now in ${LFS}/host/usr/include, and overwrite the symlinks
# with your new glibc installation.

Here is a small script for creating symlink forests (cp -l can only
create symlinks in one directory, and ls -s creates symlinks to
directories, so overwriting in a sub-directory would hit the host file
instead of the symlink.) This is used from inside a makefile, so
to adapt it to your purposes, bare in mind:
  Make changes $$ to $
  Make performs macro substitions on $(macro_name)
  $(command) is a piece of magic you can ignore to change root, user,
  directory, environment and log files to the right value.
  To find out what it does, miss out the | bash

create_static_symlinks=find destdir/static -type d -o -printf '%d/%p\0' | \
  awk -F / --re-interval 'function mul(m,     o) {o=""; for(;m>0; --m){o=o"../"} return o}\
  {depth=$$1; file=gensub(/^([^\/]*\/){3}/,"",""); $$NF="";\
  print "mkdir -p $(LFS)$(__ralfs_sandbox)destdir/"gensub(/\/[^\/]*$$/,"","",file);\
  print "ln -sf "mul(depth-1)"static/"file" $(LFS)$(__ralfs_sandbox)destdir/"file}'\
  OFS=/ RS=\\0 | $(command) bash


This one from my make files, but has not been properly tested yet. It
goes through a directory tree and for each file in it removes the
corresponding symlink if it has not been overwritten.

find $(LFS)/static/ | \
while read a; do find 2>/dev/null $(LFS)"$${a#$(LFS)/static}" -printf '%l\n'; done \
  | awk\
  '/^(\.\.\/)*static\// {print gensub(/^(\.\.\/)*static\//,"rm -f $(LFS)/","",$$0)}'\
  | bash


I am working on an alternative build strategy where ${LFS} contains a
symlink forest to ${LFS}/static. It looks like I got it mostly right
because after replacing the static programs the symlinks have all gone,
and the 'delete symlinks' script above does not have anything to
delete. This strategy removes all the hard-to-spot depenencies caused
by programs hard coding paths to /static/*

Richard
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-dev' in the subject header of the message



More information about the lfs-dev mailing list