Alexander Nasonov's shared items

Saturday, September 30, 2006

CLFS 1.0.0 x86 report: Compile GNU/Linux from FreeBSD

I was able to build a temporary system on my Pentium M notebook but I couldn't boot it :( Few words about my system. It runs recently compiled FreeBSD 6.2 PRERELEASE. For package management I use ports and pkgsrc. Some tools required to build CLFS are either missing in the base FreeBSD system or don't understand an option. In these cases, I either appended /usr/pkg/bin to the $PATH or provided a full path to required tool. 1. Never run make, it's different from GNU make: run /usr/pkg/bin/gmake. 2. FreeBSD's cp doesn't accept -a: use /usr/local/bin/gcp. 3. FreeBSD's install doesn't accept -D: use /usr/local/bin/ginstall. 4. tic is in /usr/pkg/bin directory. 5. Other installed pkgsrc packages that were used when I appended /usr/pkg/bin to the $PATH. Many CLFS packages compile fine. Reported only those sections that I had to complete differently. 5.3. Build Variables CLFS_HOST=i386-cross-freebsd6 CLFS_TARGET=i686-pc-linux-gnu 4.5. Setting Up the Environment Specify full path to bash and env programs in .bash_profile: cat > ~/.bash_profile << "EOF" exec /usr/bin/env -i HOME=${HOME} TERM=${TERM} PS1='\u:\w\$ ' /usr/pkg/bin/bash EOF 5.7. Glibc-2.4 Make sure that gmake is in the $PATH. $ PATH=$PATH:/usr/pkg/bin BUILD_CC="gcc" CC="${CLFS_TARGET}-gcc" AR="${CLFS_TARGET}-ar" RANLIB="${CLFS_TARGET}-ranlib" ../glibc-2.4/configure --prefix=/tools --host=${CLFS_TARGET} --build=${CLFS_HOST} --disable-profile --enable-add-ons --with-tls --enable-kernel=2.6.0 --with-__thread --with-binutils=/cross-tools/bin --with-headers=/tools/include --cache-file=config.cache $ PATH=$PATH:/usr/pkg/bin /usr/pkg/bin/gmake $ PATH=$PATH:/usr/pkg/bin /usr/pkg/bin/gmake install 6.5.1. Installation of Ncurses Make sure that tic is in the $PATH when installing ncurses. $ PATH=$PATH:/usr/pkg/bin /usr/pkg/bin/gmake install 6.6.1. Installation of Bash Linking of bash 3.1 fails with "/usr/bin/ld: cannot find -ldl" error. Strange that the command is gcc -rdynamic -g -O2 -o mkbuiltins mkbuiltins.o -ldl I would assume that i686-pc-linux-gnu-gcc would be a better compiler for cross build. To get rid of this error, I appended --enable-static-link option to ./configure: $ ./configure --prefix=/tools --build=${CLFS_HOST} --host=${CLFS_TARGET} --without-bash-malloc --cache-file=config.cache --enable-static-link 6.13.1. Installation of Grep Extra packages are required. It's still an open issue which ones, though. $ PATH=$PATH:/usr/pkg/bin ./configure --prefix=/tools --build=${CLFS_HOST} --host=${CLFS_TARGET} --disable-perl-regexp $ PATH=$PATH:/usr/pkg/bin /usr/pkg/bin/gmake $ PATH=$PATH:/usr/pkg/bin /usr/pkg/bin/gmake install 6.17.1. Installation of Sed It fails to compile because ./intl/Makefile and ./po/Makefile are empty after configure stage. To fix it, remove intl and po from SUBDIRS variable in ./Makefile. 7.9.1. Installation of Udev FreeBSD's install doesn't support -D option. You should use ginstall instead: cp Makefile{,.orig} sed -e 's/^\(INSTALL = \)\/usr\/bin\/install/\1\/usr\/local\/bin\/ginstall/' Makefile.orig > Makefile Make sure that a path to ginstall is correct. 7.11. Linux- I couldn't cross-compile it. 7.12. GRUB-0.97 I skipped this step. 7.17. Populating /dev I couldn't make nodes even with gmknod. Presumaly, ext2 driver on FreeBSD doesn't support this operation. 7.18. Changing Ownership You can't run chown successfully on FreeBSD because group "root" doesn't exist. Replace it with a numeric form: chown -Rv root:0 ${CLFS} Resulting system couldn't run /sbin/init. I booted from LFS 6.2-3 LiveCD and chroot'ed to /mnt/clfs. Bash started, buildins seemed to work but when I ran /sbin/init it printed "wait_for(1099): Invalid argument." and exited from /tools/bin/bash. Most successfull command was "cat /etc/passwd" which printed the content of /etc/passwd but it also broke execution of /tools/bin/bash.


  1. Great.. that's what i'm currently struggling to do

  2. This comment has been removed by a blog administrator.

  3. I'm building kernel on freebsd 6.1 stable release, haven't managed to do it though ,..

  4. [ I never get notified about comments to my posts. Hmm. I should check my settings. ]

    Back to cross compilation. I finally built the kernel. Read this thread:

  5. Anonymous5:01 pm is very informative. The article is very professionally written. I enjoy reading every day.
    quick loan