GHC 6.8.1 on Mac OS X 10.5 (Leopard)

Manuel M T Chakravarty chak at cse.unsw.edu.au
Sun Nov 18 22:17:30 EST 2007


Deborah Goldsmith:
> On Nov 6, 2007, at 4:06 PM, Manuel M T Chakravarty wrote:
>> I wasn't expecting any backwards compatibility from Leopard-built  
>> software to Tiger, but then I am also a Mac-noob and maybe there  
>> are ways to achieve that that I don't know of.  Any suggestions?
>
> Sorry, I missed this the first time around...
>
> To build binaries on Leopard that are compatible with previous  
> releases of Mac OS X, you need to use the appropriate SDK parameters  
> when invoking gcc (for includes) and the linker (for libraries).  
> This is described in the context of building a universal binary in:
>
> http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/compiling/chapter_4_section_3.html#/ 
> /apple_ref/doc/uid/TP40002850-BAJCFEBA
>
> but the same concepts (-isysroot for gcc and -Wl,-syslibroot for ld)  
> apply to building against any SDK.

Ah!  That's good to know.

>
> An SDK is basically a copy of the frameworks and libraries for a  
> particular OS release, but the libraries are just stubs to link  
> against. By pointing gcc and ld at an SDK, you use the correct  
> headers and entry points for a particular release.
>
> Caveat: I don't know how use of SDKs interacts with use of non- 
> system libraries (e.g., in /opt/local or /Library/Frameworks).
>
> Another approach is to set MAC_OS_X_VERSION_MIN_REQUIRED to  
> MAC_OS_X_VERSION_10_4 (or whatever). You then have to be careful  
> about how you use APIs that are new in Leopard. I would think the  
> SDK approach would be easier for something like ghc.
>
> If you don't do anything, by default binaries built on a particular  
> Mac OS X release will only run on that release or later.

Ok, that's very helpful information, thanks.

One annoying aspect of GHC's build system is that it is not at all  
suited for cross-compilation.  Even worse, GHC is not suited for cross- 
compilation.  At build time, GHC queries a lot of constants and other  
OS/library-dependent information and hardcodes it into generated  
code.  As a result, GHC-generated programs expect to run in the same  
environment in which the generating compiler itself was built.

Nevertheless, it's worth a try to see whether we can at least "cross- 
compile" for different OS X versions.  As long as the specific  
information queried during building GHC doesn't change, we should be  
fine.

Manuel



More information about the Glasgow-haskell-users mailing list