![]() |
DebianSlug.UseDistCCWithCrossCompiler HistoryHide minor edits - Show changes to markup October 07, 2005, at 03:35 AM
by -- suggest diverting g++ too
Added lines 89-90:
3b/ Repeat, changing gcc to g++ to support c++ dist/cross too. Deleted lines 93-94:
ln -s gcc c++ ln -s gcc g++ Changed lines 95-96 from:
ln -s gcc armeb-linux-g++ to:
ln -s g++ c++ ln -s g++ armeb-linux-g++ September 21, 2005, at 09:55 PM
by -- Add armeb-linux-g++ symlink.
Changed lines 95-96 from:
to:
ln -s gcc armeb-linux-g++ September 21, 2005, at 06:27 PM
by -- Add distcc wrapper in C.
Changed lines 25-32 from:
edit /usr/local/bin/gcc to contain this (obviously change the DISTCC_HOSTS address to the real one): #!/bin/sh export DISTCC_HOSTS="192.168.1.10 localhost/1" export PATH="/usr/local/bin:$PATH" distcc /usr/bin/armeb-linux-gcc $* to:
tweak distcc_hosts, compile the file and install the binary into /usr/local/bin/gcc. /*
* simple distcc wrapper by Lennert Buytenhek
* Released into the public domain.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static char *distcc = "/usr/bin/distcc";
static char *build_host_gcc = "/usr/bin/armeb-linux-gcc";
static char *distcc_hosts = "DISTCC_HOSTS=10.0.0.11";
static int count(char **array)
{
int i;
for (i = 0; array[i] != NULL; i++)
;
return i;
}
int main(int argc, char *argv[], char *envp[])
{
char **new_argv;
char **new_envp;
int envc;
envc = count(envp);
new_argv = malloc((argc + 2) * sizeof(char *));
new_envp = malloc((envc + 2) * sizeof(char *));
if (new_argv != NULL && new_envp != NULL) {
int i;
new_argv[0] = distcc;
memcpy(new_argv + 1, argv, argc * sizeof(char *));
new_argv[1] = build_host_gcc;
new_argv[argc + 1] = NULL;
memcpy(new_envp, envp, envc * sizeof(char *));
for (i=0;i<envc;i++) {
if (!strncmp(new_envp[i], "DISTCC_HOSTS=", 13)) {
new_envp[i] = distcc_hosts;
break;
}
}
new_envp[envc] = NULL;
if (i == envc) {
new_envp[envc] = distcc_hosts;
new_envp[envc + 1] = NULL;
}
execve(distcc, new_argv, new_envp);
}
perror("exec failed");
return 1;
}
Deleted lines 95-96:
Note that the script in (3) above may not work if the Makefile contains '"' in any of the compiler calls. That could be handled by a better wrapper. September 21, 2005, at 01:58 PM
by --
Changed line 5 from:
1/ make and test the cross compile host by following these instructions: to:
1/ make and test the cross compile host by following these instructions (or use the precompiled debian packages): September 21, 2005, at 11:08 AM
by --
Changed lines 38-39 from:
to:
ln -s gcc armeb-linux-gcc Changed lines 44-48 from:
mkdir /home/build apt-get source hello cd hello-* dpkg-buildpackage to:
mkdir /home/build apt-get source hello cd hello-* dpkg-buildpackage September 21, 2005, at 02:58 AM
by --
Changed lines 25-26 from:
edit /usr/local/bin/gcc to contain this: to:
edit /usr/local/bin/gcc to contain this (obviously change the DISTCC_HOSTS address to the real one): September 21, 2005, at 02:55 AM
by --
Changed lines 29-30 from:
# export DISTCC_HOSTS="172.16.55.77/1 66.159.209.114/1 66.159.209.56/1 localhost/1" export DISTCC_HOSTS="172.16.55.16 localhost/1" to:
export DISTCC_HOSTS="192.168.1.10 localhost/1" September 21, 2005, at 02:54 AM
by --
Changed lines 49-51 from:
watch it go much faster than on the slug! to:
watch it go much faster than on the slug! note: I carefully diffed only 2 packages; but for those two packages, the binaries generated were identical. September 21, 2005, at 02:53 AM
by --
Added lines 1-49:
The idea here is to speed up compile times by using a cross-compiler while using the native build scripts. This will only work if the version of the native and cross compilers are the same. This document assumes you are using a debian based host; but this technique should be usable with other distros. 1/ make and test the cross compile host by following these instructions: http://www.nslu2-linux.org/wiki/DebianSlug/CrossCompiling 2/ install/configure distcc apt-get install distcc vi /etc/default/distcc That should pretty much do it for the Cross Host. On the armeb host: 1/ install the important build tools: apt-get install build-essential 2/ install/configure distcc apt-get install distcc vi /etc/default/distcc 3/ divert gcc to distcc: edit /usr/local/bin/gcc to contain this: #!/bin/sh # export DISTCC_HOSTS="172.16.55.77/1 66.159.209.114/1 66.159.209.56/1 localhost/1" export DISTCC_HOSTS="172.16.55.16 localhost/1" export PATH="/usr/local/bin:$PATH" distcc /usr/bin/armeb-linux-gcc $* 4/ support other common compiler names: cd /usr/local/bin ln -s gcc cc ln -s gcc c++ ln -s gcc g++ Note that the script in (3) above may not work if the Makefile contains '"' in any of the compiler calls. That could be handled by a better wrapper. Test it! mkdir /home/build apt-get source hello cd hello-* dpkg-buildpackage watch it go much faster than on the slug! |