March 12, 2005

Cross-compiling Mac executables from Intel x86

Posted at 20:59 in Mozilla and mZ and planet.m.o.

In drawing up a vision for how to turbocharge the Mozilla Foundation's build farm, I've read many cool things that could lead to builds taking very little time. One of the cooler ideas (but not the coolest) is to cross-compile our Mac builds straight from Intel x86 boxes. I've asked around the office and while we all agree that this is intriguing, we wonder what drawbacks we might face. Do we lose a lot of optimizations we would otherwise get if we were compiling natively?

Of course, the resulting binaries would need to be sent to a Mac platform for testing, but if we could more closely tie our build farm story to one type of hardware platform (instead of needing G4s, G5s, and/or Xserve G5s, as well), we would be able to go farther, faster, and do so at less cost.

Anyone out there have experience with cross-compiling Mac executables from Intel x86? Did your build systems go mad and cause your hard drives to spin out of control? Did your Intel x86 box instantly take on the silver gleam of an Xserve? Spin your tall tales (with a dose of truth about whether or not it actually worked) here!

Comments

17 comments received. Post a comment.

I have no clue about this, but if you could formulate the question correctly I think this would be a great "Ask Slashdot" question, and I'm sure you would get some great answeres from there.

Just a thought
-Jed

Posted by: Jed at March 13, 2005 12:13 AM

While I never did this I'm wondering how you would link to the system libs needed for the products to work (might be onlt needed in Camino though) ?

How about using Xcode's distributed compile feature ?

Posted by: Ludovic Hirlimann at March 13, 2005 12:28 AM

Jed: Good idea. If my mini-investigation doesn't turn up enough useful data, I'll consider whipping up a question for Slashdot. Thanks!

Ludovic: Yes, for this to work the system libraries and headers need to be available to the cross-compiler. Re: Xcode's distributed compile feature, that's a promising feature. If it turns out we can't do cool stuff by cross-compiling from Linux Intel we'll need to explore options such as this to distribute the compilation and speed up build times.

Posted by: Chase at March 13, 2005 01:41 PM

See http://forums.gentoo.org/viewtopic.php?t=157213 for some old but probably still useful tips on setting up a cross-compiler for use with distcc. I've used this from time to time to try to speed up compiles on my little PowerBook with a beefier Athlon box. You'd still need a Mac to link on and run the build process from.

(Note that Xcode's distributed compile feature is just Rendezvous-enabled distcc.)

Posted by: Brion Vibber at March 13, 2005 03:53 PM

Just to follow up to myself... Using distcc, the system libraries and headers are *not* required on the cross-compiler boxes.

The source files are run through the preprocessor on the build master (presumably a Mac with real header files), then sent out to the distcc daemons with headers already included; distccd invokes the cross-compiler and sends back an .o file. Linking is done on the host machine, which has all the libraries.

Running the whole process from a Linux box might be possible, but I don't know whether a) all the build tools can be built for cross-compilation or b) Apple will crush you like a bug for copying their non-free libraries onto another box. ;)

Posted by: Brion Vibber at March 13, 2005 04:09 PM

Might be worh to check out darwin x86 (it can create fat binaries and hence cross compile).

Posted by: Ludovic Hirlimann at March 13, 2005 10:16 PM

You will lose quite a few optimizations if you don't use apple's gcc since they use their own branch for OS X.

Posted by: Rura at March 14, 2005 08:47 AM

Following up Rura's comment, this will be particularly noticeable with autovectorization (if used) in GCC4, since much of the vector work is being done on the apple-ppc branch and then moved to mainline or autovect.

Posted by: David Smith at March 14, 2005 11:42 AM

I think cross-compiling from x86 is probbaly a pretty bad idea. Apple's GCC is pretty different from the stock GCC and it seems just darn unreliable to try to make it work from a PC.

That being said, you could probably use the ever-so-helpful ccache to run all the builds quickly off of one box, preferably an Xserve or a G5. Mac builds still take a while to build even with ccache, but it would speed things up a fair amount and it would mean that all the mac bits could be built on one box, no need for multiple machines.

Oh and be glad you don't need to support the OS 9 build anymore (compiled with CodeWarrior). Now that was trouble...

Posted by: Zach at March 14, 2005 08:43 PM

I don't know... I wouldn't trust cross-compiled binaries, as much as I would natively compiled ones, to be as tuned and optimized. Sometimes things like that don't matter, but in browser used by millions, it would.

I can also foresee mysterious bugs occuring with non-natively built binaries, and you can just imagine the pain in tracking those down.

Posted by: Dimi at March 15, 2005 12:03 PM

This guy: http://forums.gentoo.org/viewtopic.php?t=157213 explains neatly how to install a working distcc in a x86 box. I was able to recompile everything like it is described there but had no chance to test.

Posted by: luix at March 15, 2005 02:42 PM

Thanks to everyone who took the time to comment. At this point it looks like I'll come up with a solution that doesn't revolve around cross-compilation for Mac binaries from x86 with the hope that we can revisit it in the future.

If anyone here ever gets such a cross-compilation to work (with all of the optimizations people get from compiling natively) please don't hesitate to let me know!

Posted by: Chase at March 15, 2005 03:06 PM

Like another poster pointed out, it sounds like the system includes and libraries are the stumbling block here. They're copyright Apple and even trying to fudge it (e.g. NFS export via gigabit ethernet so there's no permanent copy on another machine) doesn't get around the problem that the incs/libs are for use on the machine they were shipped with and not another box - I think this completely rules out cross-compilation w.r.t. Mac OS X.

Posted by: Richard Lloyd at March 17, 2005 02:23 AM

I've always wondered this: Why does the building of binaries take so long? Sounds like people here might know.

Posted by: David Naylor at March 17, 2005 10:15 AM

fhkv poiuyt http://ghjkldcapslea.com/

Posted by: Salamon at April 3, 2005 03:19 AM

online phentermine buy phentermine cod phentermine online phentermine side effects dangers phentermine 375mg cheap phentermine 375 buy phentermine cod cheapest phentermine phentermine pharmacy buy phentermine phentermine diet pills free shipping cheap phentermine phentermine cod phentermine online buy cheap phentermine free fedex herbal phentermine ingredients phentermine cheap phentermine diet pills diet pills phentermine online ordering overnight phentermine buy cheap phentermine online pharmacy phentermine online phentermine online cheap diet pills buy cheap phentermine online pharmacy phentermine diet pill phentermine prescription phentermine for sale phentermine blue phentermine ingredients extra cheap phentermine buy cheap phentermine online pharmacy buy phentermine phentermine prescriptions phentermine online cyber pharmacy phentermine phentermine prices phentermine in florida phentermine 37 5mg phentermine overnight delivery cheap phentermine buy cheap phentermine phentermine overnight delivery online phentermine phentermine tablets phentermine prescription cod phentermine ups online cheap phentermine cheap phentermine time released phentermine order phentermine buy phentermine lowest price phentermine online phentermine lowest cost phentermine buy cheap phentermine online pharmacy how does phentermine work phentermine discount phentermine florida phentermine 30 mg phentermine 30 mg lowest phentermine prices online phentermine prescription phentermine lowest price phentermine 30 mg phentermine diet pill online phentermine weight loss phentermine phentermine sale lowest phentermine prices phentermine on line phentermine pill online discount phentermine and methamphetamine herbal phentermine ingredients phentermine online phentermine 30mg cheap phentermine 375mg phentermine tablets phentermine info phentermine without prescription phentermine online cheap diet pills cheap phentermine phentermine diet pills phentermine 375mg cheap best price phentermine phentermine diet pills diet pills phentermine prices cheap phentermine cheapest phentermine pills phentermine cod overnight cod phentermine cod phentermine ups how does phentermine work phentermine 30 mg order phentermine online phentermine 30mg phentermine quick phentermine cheap discount phentermine buy phentermine online cheapest phentermine cheapest phentermine cheap phentermine free shipping discount phentermine cheap phentermine phentermine diet pill phentermine side effects buy phentermine phentermine cod buy cheap phentermine online pharmacy phentermine prices buy phentermine phentermine in florida cheap phentermine free shipping cheap phentermine phentermine prescriptions buy cheap phentermine online

Posted by: phentermine pharmacy at April 24, 2005 01:15 AM

ambien side effects

Posted by: ambien side effects at April 29, 2005 01:20 PM

Post a comment




Remember Me?