Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 116575 - new doc: DistCC Cross-compiling Guide
Summary: new doc: DistCC Cross-compiling Guide
Status: RESOLVED FIXED
Alias: None
Product: [OLD] Docs-user
Classification: Unclassified
Component: Submit New (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Xavier Neys (RETIRED)
URL: http://dev.gentoo.org/~agaffney/cross...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-23 22:27 UTC by Andrew Gaffney (RETIRED)
Modified: 2006-01-24 21:24 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
cross-compiling-distcc.xml (cross-compiling-distcc.xml,5.92 KB, text/plain)
2005-12-24 11:16 UTC, nm (RETIRED)
Details
cross-compiling-distcc.xml (cross-compiling-distcc.xml,5.92 KB, text/plain)
2005-12-24 11:23 UTC, nm (RETIRED)
Details
cross-compiling-distcc.html (cross-compiling-distcc.html,12.94 KB, text/html)
2005-12-24 11:59 UTC, nm (RETIRED)
Details
cross-compiling-distcc.html (cross-compiling-distcc.html,12.94 KB, text/plain)
2005-12-24 12:01 UTC, nm (RETIRED)
Details
cross-compiling-distcc.xml (cross-compiling-distcc.xml,5.95 KB, text/plain)
2005-12-25 10:42 UTC, nm (RETIRED)
Details
cross-compiling-distcc.xml (cross-compiling-distcc.xml,5.92 KB, text/plain)
2005-12-26 18:43 UTC, nm (RETIRED)
Details
cross-compiling-distcc.xml (cross-compiling-distcc.xml,6.49 KB, text/plain)
2006-01-04 10:21 UTC, nm (RETIRED)
Details
cross-compiling-distcc.xml (cross-compiling-distcc.xml,6.72 KB, text/plain)
2006-01-18 10:26 UTC, nm (RETIRED)
Details
cross-compiling-distcc.xml (cross-compiling-distcc.xml,7.16 KB, text/plain)
2006-01-22 12:49 UTC, nm (RETIRED)
Details
cross-compiling-distcc.xml (cross-compiling-distcc.xml,7.22 KB, text/plain)
2006-01-22 13:32 UTC, nm (RETIRED)
Details
cross-compiling-distcc.xml (cross-compiling-distcc.xml,7.20 KB, text/plain)
2006-01-22 17:02 UTC, nm (RETIRED)
Details
cross-compiling-distcc.xml.diff (cross-compiling-distcc.xml.diff,1.14 KB, patch)
2006-01-24 14:54 UTC, Marcelo Goes (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Gaffney (RETIRED) gentoo-dev 2005-12-23 22:27:06 UTC
I came up with a good way to make distcc cross-compiling Just Work(TM) without running multiple distccd's and put together a guide on how to set it up. It's still a little rough and needs to be guidexml-ified, but the method works well.
Comment 1 nm (RETIRED) gentoo-dev 2005-12-24 09:23:59 UTC
(In reply to comment #0)
> I came up with a good way to make distcc cross-compiling Just Work(TM) without
> running multiple distccd's and put together a guide on how to set it up. It's
> still a little rough and needs to be guidexml-ified, but the method works well.
> 

Sweet. I'll start XMLifying it, and will attach it to this bug. :)
Comment 2 Jan Kundrát (RETIRED) gentoo-dev 2005-12-24 09:51:34 UTC
CCing lisa, author of distcc guide.
Comment 3 nm (RETIRED) gentoo-dev 2005-12-24 11:16:11 UTC
Created attachment 75458 [details]
cross-compiling-distcc.xml

Okay, here's the first draft of this document.

It's fairly substantial, but agaffney did mention to me the possibility of adding it to the existing distcc guide. However, after XMLifying it, I really lean toward this being a separate guide, perhaps referenced from the distcc guide, as it currently wouldn't be easy to find a spot in that guide to integrate this one.

Besides that distcc guide is outdated and needs to be changed anyway, especially when this guide is committed. :)

Anyway, back to THIS bug and guide...what do you think?
Comment 4 nm (RETIRED) gentoo-dev 2005-12-24 11:23:14 UTC
Created attachment 75459 [details]
cross-compiling-distcc.xml

Corrected datestamp format (oops :) ), and clarified <abstract>.
Comment 5 Andrew Gaffney (RETIRED) gentoo-dev 2005-12-24 11:36:03 UTC
Looks good to me. Is there somewhere this can be thrown so I can see it in "final" (rendered) form?
Comment 6 nm (RETIRED) gentoo-dev 2005-12-24 11:59:52 UTC
Created attachment 75463 [details]
cross-compiling-distcc.html

Okay, I followed the documentation tips 'n tricks doc to create this html page of the XML source. I know, the font sizes are likely to be messed up, but I just followed the guide to the letter. I think XML guides undergo a final step of transformation when viewed from gentoo.org. But this gives you a fairly decent idea of what it will look like.
Comment 7 nm (RETIRED) gentoo-dev 2005-12-24 12:01:37 UTC
Created attachment 75464 [details]
cross-compiling-distcc.html

Ack. Selecting the text/html content type in Bugzilla horribly, horribly messes up the rendering. I switched to "text/plain". I know it's a hassle, but just highlight all the text, save it as a .html file, and then open it up in your browser. Sorry about that; didn't know Bugzie messes up html files so badly.
Comment 8 nm (RETIRED) gentoo-dev 2005-12-24 12:40:32 UTC
(In reply to comment #7)
> Created an attachment (id=75464) [edit]
> cross-compiling-distcc.html
> 
> Ack. Selecting the text/html content type in Bugzilla horribly, horribly messes
> up the rendering. I switched to "text/plain". I know it's a hassle, but just
> highlight all the text, save it as a .html file, and then open it up in your
> browser. Sorry about that; didn't know Bugzie messes up html files so badly.
>

Never mind. I decided to upload it on my website:

http://www.freewebs.com/nightmorph/docs/cross-compiling-distcc.html
Comment 9 Andrew Gaffney (RETIRED) gentoo-dev 2005-12-24 18:45:24 UTC
It looks good, but I've got one thing that should probably be changed.

"First, you will need to emerge crossdev on all the machines that will be involved in the compiling process."

It's not necessary to emerge crossdev on all boxes involved. You only need crossdev on a box that will be helping via distcc that is *not* the same architecture as the box being helped.
Comment 10 nm (RETIRED) gentoo-dev 2005-12-25 10:42:58 UTC
Created attachment 75510 [details]
cross-compiling-distcc.xml

Okay, here's the requested revision.
Comment 11 nm (RETIRED) gentoo-dev 2005-12-26 18:43:54 UTC
Created attachment 75577 [details]
cross-compiling-distcc.xml

Corrected a couple of typos in the above revision.

agaffney, any comments on the requested change? Everything look fine?
Comment 12 Andrew Gaffney (RETIRED) gentoo-dev 2005-12-26 20:56:59 UTC
It looks good to me.

Now that I think about it, we also need to note that that this cannot be used in conjunction with the CC=gcc method of "cross-compiling" between i[3456]86-pc-linux-gnu boxes. While it won't hurt anything, the compile will fail on the other end if the CHOST isn't the same, even though it's still x86. Users will need to either build an actual cross-compiler (i586-pc-linux-gnu cross-compiler on a i686-pc-linux-gnu box, for example) or create the proper symlinks. I don't know what symlinks need to be created, but I bet SpanKY does.
Comment 13 nm (RETIRED) gentoo-dev 2005-12-27 09:07:15 UTC
(In reply to comment #12)
I think I understand what you're saying. In the interests of simplicity, it's probably better for users to actually build a full cross-toolchain in the desired CHOST (i[3456]86), rather than relying on symlinks. I'll see about finding a place to mention that differing CHOSTS on x86 require the specific cross-toolchain, at least when moving from higher arch to lower arch. (Obviously, i686 can run anything i386 produces). :)
Comment 14 nm (RETIRED) gentoo-dev 2006-01-04 10:21:21 UTC
Created attachment 76167 [details]
cross-compiling-distcc.xml

Here's the new addendum. I put it in its own subsection called "arch-specific notes"--> in the future, any additions to particular arches can be placed here.

Sorry for the delay; I had thought that I was waiting to hear back from *you* until I rechecked the bug. ^_^
Comment 15 nm (RETIRED) gentoo-dev 2006-01-04 10:32:26 UTC
(In reply to comment #14)
Also, so that you can view the current progress, I updated the version on my website, so you can preview the "finished" product by clicking here:

http://www.freewebs.com/nightmorph/docs/cross-compiling-distcc.html

Comment 16 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-04 10:58:48 UTC
The sentence in the last paragraph about it checking argv[0] can probably be removed as it's unnecessary (yeah, yeah...I know that was my sentence :P).

Vapier, what are your thoughts on this? I figured I should ask since you're basically Mr. Cross-compile.
Comment 17 SpanKY gentoo-dev 2006-01-05 21:11:47 UTC
only trouble i see is that it may not work for packages which need to compile & run a helper util natively ...

for example, module-init-tools, e2fsprogs, ss, com_err, man, and ncurses to name some off the top of my head ... they'll prob try to invoke the native compiler as `gcc` and the cross compiler as `CHOST-gcc`
Comment 18 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-06 12:02:05 UTC
These programs would have trouble with *any* cross-distcc solution and really distcc in general then, wouldn't they?
Comment 19 SpanKY gentoo-dev 2006-01-06 15:11:03 UTC
no, why would they
Comment 20 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-06 16:59:30 UTC
If you have FEATURES="distcc" and a "vanilla" distcc setup, invoking `gcc` is just as likely to get you a distributed compile as `$CHOST-gcc`, cross-compiling or not. I'd say that a build that expects different behavior between `gcc` and `$CHOST-gcc` is broken.

Anyway, what does it matter where a helper util is compiled? The (basically) same code will be generated and it's linked back on the first box.
Comment 21 SpanKY gentoo-dev 2006-01-06 17:04:10 UTC
not really ... autoconf packages tend to look for $CBUILD-gcc now though

and it matters because the helper util is built & executed, but not installed
Comment 22 nm (RETIRED) gentoo-dev 2006-01-07 15:42:31 UTC
(In reply to comment #21) --> and all the above comments, actually :)

So what, if any, changes and/or additions need to be made to the doc thus far? I've already removed the argv[0] reference, and will upload the new doc with any additional suggestions you have.
Comment 23 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-08 08:13:31 UTC
I just re-emerged and tested module-init-tools, e2fsprogs, man, and ncurses using this method to have my sparc help my amd64 box. Everything appears to work normally. What kind of problems might this method cause for those packages?
Comment 24 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-18 09:49:11 UTC
Something needs to be clarified in this guide. People keep getting confused and thinking they need to create these wrapper scripts on the helper boxes instead of the box running emerge. Any suggestions?
Comment 25 nm (RETIRED) gentoo-dev 2006-01-18 09:58:41 UTC
(In reply to comment #24)
> Something needs to be clarified in this guide. People keep getting confused and
> thinking they need to create these wrapper scripts on the helper boxes instead
> of the box running emerge. Any suggestions?
> 
Hmm, perhaps a note saying just that? Let me see what I can come up with. I think some explicit statements to this effect right around the "modifying distcc" code example would do nicely. :)
Comment 26 nm (RETIRED) gentoo-dev 2006-01-18 10:26:47 UTC
Created attachment 77445 [details]
cross-compiling-distcc.xml

Okay, I added a few clear notes about only performing the instructions on the box running the emerge. How does this look?
Comment 27 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-18 11:10:06 UTC
That's probably fine.

After talking with Joker, there's a slightly easier/simpler method for doing this. Instead of multiple wrapper scripts, there can just be one called 'i686-pc-linux-gnu-wrapper' (or whatever CHOST):

#!/bin/bash

exec /usr/lib/distcc/bin/i686-pc-linux-gnu-${0##*/} "$@"

Then you can just link cc, gcc, g++, and c++ to the single wrapper script. There is one slight problem, though. If 'cc' is called, it will try to call i686-pc-linux-gnu-cc which doesn't exist in that directory in a default distcc setup. They will need to create that symlink as well. That's as simple as:

cd /usr/lib/distcc/bin
ln -s /usr/bin/distcc i686-pc-linux-gnu-cc

We were also trying to figure out a way to have the wrapper script determine the CHOST automatically so that one generic wrapper script would automatically work on all arches, but there's no real portable way to do it quickly.
Comment 28 nm (RETIRED) gentoo-dev 2006-01-18 11:25:32 UTC
(In reply to comment #27)
> That's probably fine.
> 
> After talking with Joker, there's a slightly easier/simpler method for doing
> this. Instead of multiple wrapper scripts, there can just be one called
> 'i686-pc-linux-gnu-wrapper' (or whatever CHOST):
> 
> #!/bin/bash
> 
> exec /usr/lib/distcc/bin/i686-pc-linux-gnu-${0##*/} "$@"
> 
> Then you can just link cc, gcc, g++, and c++ to the single wrapper script.
> There is one slight problem, though. If 'cc' is called, it will try to call
> i686-pc-linux-gnu-cc which doesn't exist in that directory in a default distcc
> setup. They will need to create that symlink as well. That's as simple as:
> 
> cd /usr/lib/distcc/bin
> ln -s /usr/bin/distcc i686-pc-linux-gnu-cc
> 
> We were also trying to figure out a way to have the wrapper script determine
> the CHOST automatically so that one generic wrapper script would automatically
> work on all arches, but there's no real portable way to do it quickly.
> 

K, I'll come up with an alt version of the guide that replaces the multiple scripts with a single script, and has the symlinks all point to a single...well, what would the individual g++ cc and so on point to?
Comment 29 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-18 11:30:35 UTC
They would link to the new "unified" wrapper script:

ln -s i686-pc-linux-gnu-wrapper gcc
ln -s i686-pc-linux-gnu-wrapper cc
ln -s i686-pc-linux-gnu-wrapper g++
ln -s i686-pc-linux-gnu-wrapper c++
Comment 30 Lisa Seelye (RETIRED) gentoo-dev 2006-01-18 11:45:34 UTC
Please read bug 84942, which basically implements this script change. Just waiting on Pyrania.
Comment 31 nm (RETIRED) gentoo-dev 2006-01-18 11:50:43 UTC
(In reply to comment #29)
> They would link to the new "unified" wrapper script:
> 
> ln -s i686-pc-linux-gnu-wrapper gcc
> ln -s i686-pc-linux-gnu-wrapper cc
> ln -s i686-pc-linux-gnu-wrapper g++
> ln -s i686-pc-linux-gnu-wrapper c++
> 

Arggh, "midair collision" with Lisa while attempting to post. :p

Okay, so what would the final ln -s look like after making this change? I assume that the code sample needs to be updated. I'm using the sparc CHOST in the rest of the instructions, as that's what's been used so far. So instead of creating multiple scripts and saving as gcc, g++, etc., we create on script named ${CHOST}-wrapper (sparc, i686, whatever) and symlink it to gcc, cc, g++, and c++, right? That's how my current version looks so far.
Comment 32 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-18 12:21:16 UTC
(In reply to comment #30)
> Please read bug 84942, which basically implements this script change. Just
> waiting on Pyrania.

The patch in that bug was written by me :) I wrote this guide in case that patch doesn't become the default (since it breaks things for CC=cc i[3456]86 "cross" compiling people), or if it just takes a while to hit the tree.
Comment 33 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-18 12:27:37 UTC
Here's the full "new" procedure:

kirara ~ # cd /usr/lib/distcc/bin
kirara bin # ls
c++  g++  i686-pc-linux-gnu-c++  i686-pc-linux-gnu-gcc
cc   gcc  i686-pc-linux-gnu-g++
kirara bin # rm c++ cc g++ gcc
kirara bin # cat > i686-pc-linux-gnu-wrapper
#!/bin/bash

exec /usr/lib/distcc/bin/i686-pc-linux-gnu-${0##*/} "$@"
kirara bin # chmod a+x i686-pc-linux-gnu-wrapper
kirara bin # ln -s /usr/bin/distcc i686-pc-linux-gnu-cc (only necessary if link doesn't already exist)
kirara bin # ln -s i686-pc-linux-gnu-wrapper gcc
kirara bin # ln -s i686-pc-linux-gnu-wrapper cc
kirara bin # ln -s i686-pc-linux-gnu-wrapper c++
kirara bin # ln -s i686-pc-linux-gnu-wrapper g++
kirara bin # ls -l
total 4
lrwxrwxrwx  1 root root 25 Jan 18 14:20 c++ -> i686-pc-linux-gnu-wrapper
lrwxrwxrwx  1 root root 25 Jan 18 14:20 cc -> i686-pc-linux-gnu-wrapper
lrwxrwxrwx  1 root root 25 Jan 18 14:20 g++ -> i686-pc-linux-gnu-wrapper
lrwxrwxrwx  1 root root 25 Jan 18 14:20 gcc -> i686-pc-linux-gnu-wrapper
lrwxrwxrwx  1 root root 15 Nov 21 10:42 i686-pc-linux-gnu-c++ -> /usr/bin/distcc
lrwxrwxrwx  1 root root 15 Jan 18 14:20 i686-pc-linux-gnu-cc -> /usr/bin/distcc
lrwxrwxrwx  1 root root 15 Nov 21 10:42 i686-pc-linux-gnu-g++ -> /usr/bin/distcc
lrwxrwxrwx  1 root root 15 Jul 27 10:52 i686-pc-linux-gnu-gcc -> /usr/bin/distcc
-rwxr-xr-x  1 root root 70 Jan 18 14:20 i686-pc-linux-gnu-wrapper
Comment 34 nm (RETIRED) gentoo-dev 2006-01-22 12:49:26 UTC
Created attachment 77858 [details]
cross-compiling-distcc.xml

Okay, here's the revised guide. Please check to make sure that the sparc toolchain names and symlinks are all valid, as I continued using the sparc examples from the original guide. Sparc is much sexier than i686, anyway. :p
Comment 35 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-22 13:27:14 UTC
You left out the part about creating the sparc-unknown-linux-gnu-cc -> /usr/bin/distcc symlink since distcc doesn't do it by default. Other than that, it looks good.
Comment 36 nm (RETIRED) gentoo-dev 2006-01-22 13:32:09 UTC
Created attachment 77859 [details]
cross-compiling-distcc.xml

Whoops, so I did. Fixed!
Comment 37 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-22 14:15:07 UTC
Spiffy. Now, what will it take to get this guide in as an official doc?
Comment 38 nm (RETIRED) gentoo-dev 2006-01-22 16:22:14 UTC
(In reply to comment #37)
> Spiffy. Now, what will it take to get this guide in as an official doc?
> 

Final version viewable at http://www.freewebs.com/nightmorph/docs/cross-compiling-distcc.html
Comment 39 Xavier Neys (RETIRED) gentoo-dev 2006-01-22 16:23:01 UTC
(In reply to comment #37)
> Spiffy. Now, what will it take to get this guide in as an official doc?

/me will add it
Comment 40 nm (RETIRED) gentoo-dev 2006-01-22 17:02:46 UTC
Created attachment 77871 [details]
cross-compiling-distcc.xml

Fixed prompts.
Comment 41 Xavier Neys (RETIRED) gentoo-dev 2006-01-23 04:32:14 UTC
In CVS. Thanks to everyone for their contribution.
Comment 42 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-24 14:15:07 UTC
After playing around with a patch to catalyst to implement this automatically, I've discovered a few "problems". I've got a slightly new procedure that seems to address them.

cd /usr/lib/distcc/bin
rm cc gcc g++ c++
cat > sparc-unknown-linux-gnu-wrapper
#!/bin/bash
exec /usr/lib/distcc/bin/sparc-unknown-linux-gnu-g${0:$[-2]} "$@"
^D
chmod a+x /usr/lib/distcc/bin/sparc-unknown-linux-gnu-wrapper
ln -s sparc-unknown-linux-gnu-wrapper cc
ln -s sparc-unknown-linux-gnu-wrapper gcc
ln -s sparc-unknown-linux-gnu-wrapper g++
ln -s sparc-unknown-linux-gnu-wrapper c++

Basically, the only changes are the contents of the wrapper script and not making the $CHOST-cc -> /usr/bin/distcc symlink.
Comment 43 Marcelo Goes (RETIRED) gentoo-dev 2006-01-24 14:54:42 UTC
Created attachment 78032 [details, diff]
cross-compiling-distcc.xml.diff
Comment 44 Andrew Gaffney (RETIRED) gentoo-dev 2006-01-24 19:50:30 UTC
Aside from one small issue (no need to specify full path to $CHOST-wrapper when chmod'ing it since you're already in /usr/lib/distcc/bin/), the patch looks fine. Can someone commit?
Comment 45 Marcelo Goes (RETIRED) gentoo-dev 2006-01-24 21:24:42 UTC
Done.