gcc42 ... building for i386 _and_ ppc?

Ryan Schmidt ryandesign at macports.org
Wed Jun 13 12:25:41 PDT 2007

On Jun 13, 2007, at 10:13, William Gallafent wrote:

> I've successfully installed gcc42 on this i386 machine, and it
> works fine for creating i386 binaries. Now I want to make a
> version which creates ppc binaries.

Can't gcc already do that out of the box? I don't know, I've never  
tried with the plain (non-Apple) gcc, I'm just asking.

> In an ideal world, I'd like one which works in the same way as
> Apple's gcc, allowing the "-arch ppc" and "-arch i386" flags,
> but I understand that this would be difficult to achieve from
> GCC mainline, so I'm happy to have two separate compiler
> builds, perhaps with a different prefix, if there is no smarter
> solution.

Ah. I also didn't realize that was an Apple extension.

> So, is there a straightforward way to have two versions of gcc42
> from macports installed on this same machine, one targetting
> i386 and one ppc? In a sense, one is a cross-compiler, with
> host=i386-apple-darwin8, target=powerpc-apple-darwin8.

MacPorts, or at least the gcc portfiles, currently don't provide a  
way to do that.

> What does the "universal" variant of gcc42 do? I'm not
> interested in having compiler binaries for ppc, just in
> creating ppc output from the compiler, so I suspect this is not
> for me.

+universal is a generic variant available to all ports. It works for  
simple ports based on autoconf. gcc42 is far from simple, so  
+universal probably explodes everywhere for it.

> Is there anything I need to consider when targetting Mac OS
> 10.3.9 with a compiler built in this way? I'm aware
> of "MACOS_DEPLOYMENT_TARGET=10.3" ... do I also
> need --with-sysroot=/Developer/SDKs/MacOSX10.3.9.sdk or
> anything else similar? Isn't Mac OS X.3.9
> powerpc-apple-darwin7, rather than darwin8? Does this matter?

No idea.

> Pointers to relevant documentation would be welcome!

If you can figure out how to build gcc such that it can create  
universal binaries, or such that it cross-compiles (though I thought  
it already could), then we can adapt the MacPorts portfiles to  
install gcc in that way. But discovering whether and how gcc supports  
that is probably a question best asked on the gcc list.

More information about the macports-users mailing list