[lfs-dev] A method to build 32bits lfs on pure 64bits host

Ken Moffat zarniwhoop at ntlworld.com
Fri Dec 30 17:31:45 PST 2016

On Fri, Dec 23, 2016 at 02:21:13AM +0800, xinglp wrote:
> 2016-12-23 1:57 GMT+08:00 DJ Lucas <dj at linuxfromscratch.org>:
> >
> >
> > On December 22, 2016 11:25:43 AM CST, xinglp <xinglp at gmail.com> wrote:
> >>
> >>Then when I build lfs on this hybrid system(64bits kernel + 32bits
> >>userspace), I got a pure 64bits system, and finally I find out the
> >>reason:
> >>'uname -m' outputs x86_64 on this hybrid system.
> >>
> >>This's very interesting. And by hacking uname (in coreutils) I can
> >>build pure 32bits system on this hybrid system.
> >>I think everytihngs can be controlled by uname when building lfs with
> >>a IA32_EMULATION  enabled 64bits kernel host.
> >>
> >>So here is the step to build 32bits lfs on pure 64bits host.
> >>1. hack host's uname.
> >>  cd coreutils-...
> >>  patch -Np1 -i  coreutils-uname_m.patch
> >>  ./configure && make -j$(nproc --all)
> >>  cp src/uname $(which uname)  #no big deal to overwrite host's uname.
> >>
> >>2. patch jhalfs and run jhalfs like below:
> >>  _UNAME_M=i686 ./jhalfs run
> >>
> >>Then you will get a 32bits lfs.
> >>
> >>I also skip the build of 32bit kernel, since it has no use for me.
> >
> >
> > FYI, there were several ways to do this. Easiest, IMO, was to write a wrapper script for uname. Also there was the unamemod kernel module. This was from early 2.6 days, I haven't updated it, or looked for an update since around 2.6.19 (last time I've needed it) but shouldn't be too much work to update. The source for the module is in my homedir (/~dj/) if you'd like to take a look. Unfortunately, I don't have the original source. The closest I have is at http://archive.linuxfromscratch.org/mail-archives/lfs-support/2005-October/028792.html . The bin attachment (just rename to tar.bz2).
> Yes, wrapper script is easier than my method. unamemod is more safe
> when something use uname system call (man 2 uname).

Sorry for the delay in replying, or if somebody has already said the
same thing (I've been offline with hardware failures since early on
21st local time, my incoming mail is only up to a little after the
post I'm replying to, so still most of a week behind).  Anyway -

When I used to build on a G5 ppc64 mac I had to use a 64-bit kernel.
But that machine was horribly underpowered and it was easier to build
32-bit userspace.  To fix the 'uname' problem I invoked my build
scripts with linux32 (possibly, need to be root to do that).  And
then used a cross-compiler (pass-1-style, in /opt) to build the
64-bit kernel.

I recall I was thinking about doing the same on my machine where I
sometimes ran i686, but I think that box died before I got around to
trying it.

`I shall take my mountains', said Lu-Tze. `The climate will be good
for them.'     -- Small Gods

More information about the lfs-dev mailing list