Why -O and -g in universal variants?

Ryan Schmidt ryandesign at macports.org
Sun Feb 25 02:20:56 PST 2007


On Feb 25, 2007, at 04:06, Cédric Luthi wrote:

> On 2/25/07, Ryan Schmidt wrote:
>
>> http://trac.macports.org/projects/macports/changeset/22269
>>
>> Why are -O and -g being used in the universal variant?
>
> Probably because the author copy-pasted the Technical Note TN2137
> <http://developer.apple.com/technotes/tn2005/tn2137.html> example ;-)

Thanks for noticing that; that sounds likely. I have submitted  
feedback to Apple to clarify the use of those options. However, they  
have not acted upon other feedback I sent them months ago about that  
same article, so I don't expect them to act on this either.

My understanding is that -g turns on some kind of debugging code, and  
-O is an optimization level. Neither of those seem to me to have any  
bearing on a universal binary. That is: if -g or -O are useful, then  
they would be useful for all ports at all times, and not just in the  
+universal variants of some ports. Therefore, I believe -g and -O  
should be removed from the +universal variants, where they occur. I  
have built universal binaries myself outside of MacPorts, and I did  
not use the -g or -O options like that.


> By the way, this technical note also says:
> "Note: On an Intel-based Macintosh system the libraries are already
> universal, and support the Intel and PowerPC architectures, and you
> may specify only the -arch i386 -arch ppc options for CFLAGS; on a
> PowerPC-based Macintosh, you must use the MacOSX10.4u SDK"
>
> If I remember correctly from the tests I did some time ago, "you may
> specify only" should read "you must specify only". Specifying the
> isysroot on Intel Macs would fail the compilation!

I don't see why that would be so. The universal 10.4 SDK is there to  
provide you with universal versions of system libraries regardless of  
what platform you're building on. It should always be safe and  
correct to use the universal SDK.

> So this command:
> env CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
> ppc" LDFLAGS="-arch i386 -arch ppc" ./configure ...
>
> would work on PPC Macs but would fail on Intel Macs.
>
> As I'm not on an Intel Mac right now, I can't test. Can anyone  
> confirm this ?

I do not believe your assessment is correct here either. I believe  
using...

env CFLAGS="-arch i386 -arch ppc" LDFLAGS="-arch i386 -arch ppc" ./ 
configure

...would produce a universal binary on an Intel Mac, because on an  
Intel Mac, the system libraries are universal, but on a PowerPC Mac,  
the system libraries are PPC only, so this would not produce a  
universal binary. It would probably produce error messages when  
trying to build the -arch i386 part.

I think I heard somewhere that in 10.5 the system libraries will be  
universal on both architectures. But I see no reason why you  
shouldn't always specify the universal SDK using -isysroot.





More information about the macports-dev mailing list