[distcc] compiling with distcc on x86_64 from within a 32-bit chroot?

Benjamin R. Haskell distcc at benizi.com
Mon Jun 27 15:43:02 MDT 2011


On Mon, 27 Jun 2011, Audio Phile wrote:

> I think I understand your suggestion and I believe that I setup it up 
> according to your teachings but it's not working to call the gcc 
> inside the chroot.
>
> I made the one-liner you suggested in my home dir and installed it as 
> you suggested.  Here is the script for your reference:
>
> $ cat chroot-gcc
> #!/bin/sh
> exec schroot -p -- $0 "$@""

Too many double-quotes there?  It should end with (quotes included): $0 "$@"


> That's it!  The odd thing is that make CC=x command doesn't seem to call the script at all:
>
> $ cd /dev/shm/linux-2.6.39
>
> <<here I have the kernel source with a .config file ready to compile>>
>
> <<As a test, prove which make is running from the native x86_64 environment>>
>
> $ make --version
> GNU Make 3.82
> Built for x86_64-unknown-linux-gnu

It doesn't matter which `make` you're running with.  Depending on how 
the Makefile's written 3.82's plenty new to handle many cases of 
cross-compiling.  You might need to pass other configuration parameters, 
however (sometimes you need to pass a CTARGET=cpu-vendor-os triplet to 
make, sometimes ./configure --build=x86_64-unknown-linux-gnu 
--host=i686-pc-linux-gnu).  Not sure what you need for the kernel.

As an example, all of these steps are done on my x86_64 box:

### go into a temp dir
$ temp=`mktemp -d -t`
$ [[ -z "$temp" ]] && exit
$ cd $temp

### create a simple Makefile (think it uses GNU extensions, not sure)
$ cat > Makefile <<'MAKE'
%:	%.c
 	$(CC) $(CFLAGS) -o $@ $<
MAKE

### a Hello, World! program
$ cat > hello.c <<'HELLO'
#include <stdio.h>
int main(void) {
 	printf("Hello, world!\n");
 	return 0;
}
HELLO

### compile it natively
$ make hello
$ file hello
hello: ELF 64-bit LSB executable, x86-64, ...

### compile it for 32-bit GNU/Linux
$ rm hello
$ make CC=i686-pc-linux-gnu-gcc hello
$ file hello
hello: ELF 32-bit LSB executable, Intel 80386, ...

### compile it for Win32
$ rm hello
$ make CC=i686-pc-mingw32-gcc hello
hello: PE32 executable for MS Windows (console) Intel 80386 32-bit
$ wine ./hello
[...lots of 'fixme:' messages...]
Hello, world!

> <<Now, try calling your script via the CC= command.  It doesn't seem to work for me though>>
>
> $ make --version CC=i686-pc-linux-gnu-gcc
> GNU Make 3.82
> Built for x86_64-unknown-linux-gnu
>
> Did I mess up something?  Thank you kindly in advance for your time 
> and kind advice!

Nothing messed up AFAICT.  You're just not calling anything that would 
call the compiler, so it's still using the "build" system's `make`. 
(Which is fine.  distcc doesn't distribute 'make' steps, just 
compilation.)

You probably want something like:

$ make -j 5 CC=i686-pc-linux-gnu-gcc {...etc...}

That way `make` will run outside the chroot, but any hosts participating 
in the distcc group (which should be able to compile either x86_64 or 
i686 just fine) will accept compile jobs.

-- 
Best,
Ben


More information about the distcc mailing list