cvs commit: hints crosscompiling-x86.txt

timothy at linuxfromscratch.org timothy at linuxfromscratch.org
Wed Jul 23 08:01:36 PDT 2003


timothy     03/07/23 09:01:36

  Modified:    .        crosscompiling-x86.txt
  Log:
  Complete revision.
  
  Revision  Changes    Path
  1.11      +173 -62   hints/crosscompiling-x86.txt
  
  Index: crosscompiling-x86.txt
  ===================================================================
  RCS file: /home/cvsroot/hints/crosscompiling-x86.txt,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- crosscompiling-x86.txt	16 May 2003 21:44:28 -0000	1.10
  +++ crosscompiling-x86.txt	23 Jul 2003 15:01:36 -0000	1.11
  @@ -1,14 +1,34 @@
  -TITLE:          Crosscompiling on IA-32 (x86) platforms
  -LFS VERSION:    any (fixes for 4.1)
  -AUTHOR:         Nicholas Dille
  -                Daniel Baumann <danielbaumann at linuxmail.org>
  +TITLE:		Crosscompiling on IA-32 (x86) platforms
  +LFS VERSION:	All (fixes for 4.1)
  +AUTHOR:		Daniel Baumann <danielbaumann at linuxmail.org>
   
  -SYNOPSIS:       How to compile LFS on a fast machine and use it on your old box
  +SYNOPSIS:
  +	How to compile a LFS system on a fast machine and use it on your old box
   
   HINT:
   
  -1 Introduction
  -==============
  +CHANGELOG
  +=========
  +
  +	* 2003-07-23	Initial revision
  +
  +
  +DISCLAIMER
  +==========
  +
  +You use this LFS-Hint at your own risk.
  +
  +Neither the author, nor the Linux From Scratch project accepts any reponsibility
  +for anything that happens when using this document or associated files.
  +
  +This hint is originally written by Nicholas Dille <webmaster at rakshas.de>, now
  +updated and maintained by Daniel Baumann <danielbaumann at linuxmail.org>.
  +
  +I would like to thank Nicholas for allowing to continue his good work.
  +
  +
  +INTRODUCTION
  +============
   
   Alright, we have gathered here to mourn our failing in compiling our favourite
   LFS system for our beloved outdated hardware and have either dived right into it
  @@ -17,7 +37,7 @@
   
   Lets say you call an old i486 your own but moved on to some i686 based box some
   time ago. Now you decided that the i486 might serve wonderfully as your personal
  -file/printer server, internet gateway, MP3 player, a combination or some
  +file/printer server, internet gateway, Ogg player, a combination or some
   entirely different purpose.
   
   Without even trying you can imagine that it will probably take quite some time
  @@ -39,20 +59,21 @@
   something to your convenience, completely missed some point or if you'd just
   like to give me a big hug, I'd be honestly happy to hear you out.
   
  -I'd also like to thank:
  -        * Gerard Beekmans for this wonderful project
  -        * Tommy Wareing for the uname hack
  -        * Arthur H. Johnson II for bullying me into rewriting this hint and
  +Nicholas like to thank:
  +
  +	* Gerard Beekmans, for this wonderful project
  +        * Tommy Wareing, for the uname hack
  +        * Arthur H. Johnson II, for bullying me into rewriting this hint and
   	  helping collecting new material
  -        * Christophe Devine for the kernel module uname hack
  -        * Yann Guidon for extending the kernel module uname hack
  +        * Christophe Devine, for the kernel module uname hack
  +        * Yann Guidon, for extending the kernel module uname hack
   
  -(If you feel you need to receive credits here or that I wrongly credited someone
  -here, please let me know.)
   
  +PREPARATION
  +===========
   
  -2 Why the naive approach fails
  -==============================
  +Why the naive approach fails
  +----------------------------
   
   In case you only paste the commands provided by the LFS book to your console,
   wait some time and come back for the next package you might want to read through
  @@ -61,7 +82,7 @@
   Let us devide the package which you are about to compile into two destinct
   categories: the friendly and the painful packages.
   
  -Friendly packages are configured using GNU autoconf (./configure ...) which
  +Friendly packages are configured using GNU autoconf (./configure [...]) which
   usually check for a sane environment and also try to determine which system it
   will be compiled on. This information is then passed on to gcc which then knows
   which architecture specific features it is allows to use. These packages are
  @@ -78,11 +99,8 @@
   autoconf and gcc think that the underlying architecture is of a different type.
   
   
  -3 Preparation
  -=============
  -
  -3.1 $CHOST
  -----------
  +$CHOST
  +------
   
   Autoconf normally tries to guess the type of machine we are compiling on.
   Because we use our new computer instead of the old, we have to fake this value
  @@ -116,8 +134,8 @@
   as an example for an Intel Pentium 1.
   
   
  -3.2 $CFLAGS/$CXXFLAGS
  ----------------------
  +$CFLAGS/$CXXFLAGS
  +-----------------
   
   CFLAGS is an environment variable which is used by any honourable package to
   pass user flags on to gcc. It is often used to set the optimization level (-On
  @@ -156,11 +174,12 @@
           # export CXXFLAGS=-march=pentium
   
   as an example for Intel Pentium 1. Consult the gcc online-manual on
  -http://gcc.gnu.org/ for other values.
  +http://gcc.gnu.org/ for other values. If you know what you do, you can also
  +set some optimization flags, see the optimization hint for that.
   
   
  -4 Installing friendly packages
  -==============================
  +Installing friendly packages
  +============================
   
   As I have stated before configure scripts are specially easy to persuade into
   believing to be running on a different architecture.
  @@ -177,24 +196,24 @@
   	  --enable-static-link --prefix=$LFS/static --with-curses
   
   
  -5 Installing painful packages
  -=============================
  +Installing painful packages
  +===========================
   
   This chapter will provide you with a list of packages which do not come with a
   configure script or which come with one that does not honour '--host' and
   '--target' options. Use the following fixes to proper install the packages.
   
   
  -5.1 Bin86 0.16.3
  -----------------
  +Bin86 0.16.3
  +------------
   
   Use the following commands to write your CFLAGS variable into bin86's Makefile.
   
   	# make CFLAGS="-D_POSIX_SOURCE $CFLAGS"
   
   
  -5.2 Bzip2 1.0.2
  -----------------
  +Bzip2 1.0.2
  +-----------
   
   Use the following commands to patch bzip2:
   
  @@ -215,8 +234,8 @@
           # make OPT="$CFLAGS"
   
   
  -5.3 Gcc 3.1.2
  ---------------
  +Gcc 3.1.2
  +---------
   
   Gcc compilation is devided into three parts. Stage1 is the first run, where
   CFLAGS/CXXFLAGS are respected well. In stage2, gcc compiles itselfs. To make
  @@ -230,24 +249,24 @@
   	# make BOOT_CFLAGS=$CFLAGS bootstrap
   
   
  -5.4 Kbd 1.08
  -------------
  +Kbd 1.08
  +--------
   
   Use the following commands to write your CFLAGS variable into kbd's Makefile.
   
           # make CFLAGS="$CFLAGS"
   
   
  -5.5 Lilo 22.2
  --------------
  +Lilo 22.2
  +---------
   
   Use the following make commands:
   
           # make OPT="$CFLAGS"
   
   
  -5.6 Man 1.5k
  -------------
  +Man 1.5k
  +--------
   
   Use the following commands to add your CFLAGS variable to man2html's Makefile:
   
  @@ -256,22 +275,23 @@
                   man2html/Makefile.in.backup > man2html/Makefile.in
   
   
  -5.7 Net-tools 1.60
  -------------------
  +Net-tools 1.60
  +--------------
   
   Use the following make command:
   
           # make COPTS="-D_GNU_SOURCE -Wall $CFLAGS"
   
   
  -5.8 Netkit-base 0.17
  ---------------------
  +Netkit-base 0.17
  +----------------
  +
   This package does not need any changes to the book's commands. It will pick the
   value of the CFLAGS variable and apply it correctly.
   
   
  -5.9 Perl 5.8.0
  ---------------
  +Perl 5.8.0
  +----------
   
   The configure scripts shipped with perl are not autoconf-scripts. They use
   diffrent flags for the same meaning:
  @@ -280,16 +300,16 @@
   	  --prefix=/usr
   
   
  -5.10 Procinfo 18
  -----------------
  +Procinfo 18
  +-----------
   
   Add 'CFLAGS="$CFLAGS"' to the make command:
   
           # make LDLIBS=-lncurses CFLAGS="$CFLAGS"
   
   
  -5.11 Procps 3.1.5
  ------------------
  +Procps 3.1.5
  +------------
   
   Add 'OPT="$CFLAGS"' to the make command:
   
  @@ -307,31 +327,122 @@
   accordingly.
   
   
  -5.12 Psmisc 21.2
  -----------------
  +Psmisc 21.2
  +-----------
   
   Add 'AM_CFLAGS="$CFLAGS"' to the make command:
   
           # make AM_CFLAGS="$CFLAGS"
   
   
  -5.13 Sysklogd 1.4.1
  --------------------
  +Sysklogd 1.4.1
  +--------------
   
   Add 'RPM_OPT_FLAGS="$CFLAGS"' to the make command:
   
           # make RPM_OPT_FLAGS="$CFLAGS"
   
   
  -5.14 Sysvinit 2.84
  -------------------
  +Sysvinit 2.84
  +-------------
   
   Add 'CFLAGS="-Wall -D_GNU_SOURCE $CFLAGS"' to the make command:
   
           # make -C src CFLAGS="-Wall -D_GNU_SOURCE $CFLAGS"
   
   
  -6 Notes
  --------
  +APPENDIX
  +========
  +
  +The uname hack
  +--------------
  +
  +Generally spoken the uname hack will fool the system. It pretends that linux is
  +running on different hardware.
  +
  +For example, you are using an i686 based system to compile a lfs for an old
  +i486. Then the uname hack would force uname to lie about the underlying
  +hardware - not reporting i686 but i486.
  +
  +. Traditional
  +
  +  Save the original uname program with:
  +
  +	# mv /bin/uname /bin/uname.backup
  +
  +  Create the new uname with:
  +
  +	cat > /bin/uname < "EOF"
  +	#!/bin/sh
  +
  +	/bin/uname.backup "$@" | sed "s/i[456]86/$ARCH/"
  +	EOF
  +
  +  And give it the correct permissions:
  +
  +  	# chmod 755 /bin/uname
  +
  +  The traditional uname hack will have to be installed three times:
  +  once before you start your lfs compilation to replace the uname binary of your
  +  host system, then when you enter chroot to force your statically linked
  +  environment into assuming a different architecture and last after installing
  +  sh-utils in chapter 6 because they will replace the uname binary.
  +
  +. Kernel module
  +
  +  Please check out the niftiness of this version of the uname hack!
  +
  +  Put the code below into the file uname_i586.c and compile with the following
  +  command:
  +
  +	# gcc -I/usr/src/linux/include -c -DMODULE \
  +	  -DUNAME_DUMB_STEPPING=\'4\' uname_i586.c
  +
  +  By adjusting the '4' in the compilation command you will be able to specify
  +  the desired platform at compile time without changing the code :)
  +
  +  Listing of uname_i586.c:
  +  /*
  +	This simple piece of code simply turns your ix86 into a i586 -
  +	useful if you're cross-compiling for a weaker platform.
  +
  +	Compile with: gcc -I/usr/src/linux/include -c -DMODULE uname_i586.c
  +	and then: insmod ./uname_i586.o
  +
  +	Revision : whygee at f-cpu.org, Wed Apr 10 07:45:11 CEST 2002 :
  +	added the UNAME_DUMB_STEPPING parameter/ifdef so the user can
  +	modify it at compile time. it's just a quick hack.
  +	your command line for simulating a 486 will look like :
  +		gcc -I/usr/src/linux/include -c -DMODULE \
  +			-DUNAME_DUMB_STEPPING=\'4\' uname_i586.c
  +  */
  +
  +  #include <linux/module.h>
  +  #include <linux/utsname.h>
  +
  +  #ifndef UNAME_DUMB_STEPPING
  +  #define UNAME_DUMB_STEPPING '5';
  +  /* #error "no stepping specified." */
  +  #endif
  +
  +  char save;
  +
  +  int init_module( void )
  +  {
  +  	save = system_utsname.machine[1];
  +	system_utsname.machine[1] = UNAME_DUMB_STEPPING;
  +	return( 0 );
  +  }
  +
  +  void cleanup_module( void )
  +  {
  +  	system_utsname.machine[1] = save;
  +  }
  +
  +Notes
  +-----
  +
  +. Compiling Glibc without optimization fails (need at leas -O1)
  +
   
  -Compiling Glibc without optimization fails (needs at least -O1).
  +END OF CROSSCOMPILING-X86-HINT
  
  
  
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe hints' in the subject header of the message



More information about the hints mailing list