Patch for building Boost 1.40 on Mac OS X Snow Leopard

View: New views
7 Messages — Rating Filter:   Alert me  

Patch for building Boost 1.40 on Mac OS X Snow Leopard

by Stuart A. Malone :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Today I took the time to patch my local copy of Boost 1.40 to allow  
building under Snow Leopard.  You can see discussions about this  
problem in places like:

<http://continuous.wordpress.com/2009/09/06/building-boost-on-mac-os-x-10-6-with-xcode-3-2/ 
 >

<http://archives.free.net.ph/message/20090903.114048.e961e539.en.html>

My patches address two problems:

- The -m64 option is incompatible with the generation of 32-bit binaries

- Versions of Apple's gcc 4.2 and later do not support generation of  
ppc64 binaries

Since my company uses both gcc 4.0 and gcc 4.2, I wanted a solution  
that still supports ppc64 binaries when using gcc 4.0, but avoids  
creating ppc64 binaries under gcc 4.2 and later.  I believe these  
patches solve the problem and provide optimal behavior under both  
Leopard and Snow Leopard, gcc 4.0 and 4.2.1.


Best wishes,

--Stuart A. Malone
   Llamagraphics, Inc.
   Makers of Life Balance personal coaching software
   http://www.llamagraphics.com/



Index: tools/build/v2/tools/gcc.jam
===================================================================
--- tools/build/v2/tools/gcc.jam (revision 3064)
+++ tools/build/v2/tools/gcc.jam (working copy)
@@ -373,7 +373,7 @@
             {
                 option = -m32 ;
             }
-            else
+            else if $(model) = 64
             {
                 option = -m64 ;
             }
Index: tools/build/v2/tools/darwin.jam
===================================================================
--- tools/build/v2/tools/darwin.jam (revision 3064)
+++ tools/build/v2/tools/darwin.jam (working copy)
@@ -138,6 +138,13 @@
     {
         flags darwin.compile OPTIONS $(condition) : -Wno-long-double ;
     }
+    # - GCC 4.0 has the ability to generate ppc64 executables, which GCC 4.2 and later do not
+    local model = [ feature.get-values address-model : $(properties) ] ;
+    local architecture = [ feature.get-values architecture : $(properties) ] ;
+    if $(real-version) < "4.2.0" && $(model) = 32_64 && $(architecture) = combined
+    {
+        flags darwin.compile OPTIONS $(condition) : -arch ppc64 ;
+    }
 
     # - Set the link flags common with the GCC toolset.
     gcc.init-link-flags darwin darwin $(condition) ;
@@ -304,9 +311,11 @@
         : $(values) ;
 }
 
+# Generation of ppc64 for the combined/32_64 case is handled in the init rule
+# according to the version of GCC
 arch-addr-flags darwin OPTIONS : combined : 32 : -arch i386 -arch ppc : default ;
 arch-addr-flags darwin OPTIONS : combined : 64 : -arch x86_64 -arch ppc64 ;
-arch-addr-flags darwin OPTIONS : combined : 32_64 : -arch i386 -arch ppc -arch x86_64 -arch ppc64 ;
+arch-addr-flags darwin OPTIONS : combined : 32_64 : -arch i386 -arch ppc -arch x86_64 ;
 
 arch-addr-flags darwin OPTIONS : x86 : 32 : -arch i386 : default ;
 arch-addr-flags darwin OPTIONS : x86 : 64 : -arch x86_64 ;


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

smime.p7s (5K) Download Attachment

Re: Patch for building Boost 1.40 on Mac OS X Snow Leopard

by Michael Jackson-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Part of your statements need some clarification:

  The version of GCC that OS X 10.6 ships with (4.2.x) WILL indeed  
create 4-way binaries (32 and 64 Bit PPC and x86) when using the 10.5  
SDK which is entirely possible for someone to do considering that a  
developer is using OS X 10.6 but wants to target earlier versions of  
OS X running on Both PPC and Intel hardware.

   I have not looked at the patches but you will probably need to  
interrogate what SDK the developer is using before hard-setting any  
rules about what arguments can and can not be used.

_________________________________________________________
Mike Jackson                  mike.jackson@...
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio

On Oct 2, 2009, at 11:11 AM, Stuart A. Malone wrote:

> Today I took the time to patch my local copy of Boost 1.40 to allow  
> building under Snow Leopard.  You can see discussions about this  
> problem in places like:
>
> <http://continuous.wordpress.com/2009/09/06/building-boost-on-mac-os-x-10-6-with-xcode-3-2/ 
> >
>
> <http://archives.free.net.ph/message/20090903.114048.e961e539.en.html>
>
> My patches address two problems:
>
> - The -m64 option is incompatible with the generation of 32-bit  
> binaries
>
> - Versions of Apple's gcc 4.2 and later do not support generation of  
> ppc64 binaries
>
> Since my company uses both gcc 4.0 and gcc 4.2, I wanted a solution  
> that still supports ppc64 binaries when using gcc 4.0, but avoids  
> creating ppc64 binaries under gcc 4.2 and later.  I believe these  
> patches solve the problem and provide optimal behavior under both  
> Leopard and Snow Leopard, gcc 4.0 and 4.2.1.
>
>
> Best wishes,
>
> --Stuart A. Malone
>  Llamagraphics, Inc.
>  Makers of Life Balance personal coaching software
>  http://www.llamagraphics.com/
>
>
> <snow-leopard-
> patch.txt>_______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Patch for building Boost 1.40 on Mac OS X Snow Leopard

by Michael Jackson-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I applied bits and pieces of your patch on an OS X 10.5.8 Intel system  
and am currently compiling boost 1.40.0.

  Wondering if this patch can make it into the boost 1.40.1 release or  
what ever patch release is coming out next.

This was my command:

bjam toolset=darwin --with-test --with-filesystem --with-
program_options --with-iostreams --with-thread variant=release,debug  
threading=multi link=static runtime-link=shared --prefix=/Users/Shared/
Toolkits/boost-1_40/ -layout=tagged architecture=combined address-
model=32_64 install

--
Mike Jackson <www.bluequartz.net>

On Oct 2, 2009, at 12:58 PM, Michael Jackson wrote:

> Part of your statements need some clarification:
>
> The version of GCC that OS X 10.6 ships with (4.2.x) WILL indeed  
> create 4-way binaries (32 and 64 Bit PPC and x86) when using the  
> 10.5 SDK which is entirely possible for someone to do considering  
> that a developer is using OS X 10.6 but wants to target earlier  
> versions of OS X running on Both PPC and Intel hardware.
>
>  I have not looked at the patches but you will probably need to  
> interrogate what SDK the developer is using before hard-setting any  
> rules about what arguments can and can not be used.
>
> _________________________________________________________
> Mike Jackson                  mike.jackson@...
> BlueQuartz Software                    www.bluequartz.net
> Principal Software Engineer                  Dayton, Ohio
>
> On Oct 2, 2009, at 11:11 AM, Stuart A. Malone wrote:
>
>> Today I took the time to patch my local copy of Boost 1.40 to allow  
>> building under Snow Leopard.  You can see discussions about this  
>> problem in places like:
>>
>> <http://continuous.wordpress.com/2009/09/06/building-boost-on-mac-os-x-10-6-with-xcode-3-2/ 
>> >
>>
>> <http://archives.free.net.ph/message/ 
>> 20090903.114048.e961e539.en.html>
>>
>> My patches address two problems:
>>
>> - The -m64 option is incompatible with the generation of 32-bit  
>> binaries
>>
>> - Versions of Apple's gcc 4.2 and later do not support generation  
>> of ppc64 binaries
>>
>> Since my company uses both gcc 4.0 and gcc 4.2, I wanted a solution  
>> that still supports ppc64 binaries when using gcc 4.0, but avoids  
>> creating ppc64 binaries under gcc 4.2 and later.  I believe these  
>> patches solve the problem and provide optimal behavior under both  
>> Leopard and Snow Leopard, gcc 4.0 and 4.2.1.
>>
>>
>> Best wishes,
>>
>> --Stuart A. Malone
>> Llamagraphics, Inc.
>> Makers of Life Balance personal coaching software
>> http://www.llamagraphics.com/
>>
>>
>> <snow-leopard-
>> patch.txt>_______________________________________________
>> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
>

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Patch for building Boost 1.40 on Mac OS X Snow Leopard

by Ian Emmons :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I second the request for a patch for this issue to get into the next  
release, at least the portion of the patch that removes the -m64  
option from the command line.  This is really important for Macintosh  
developers.

Thanks,

Ian


On Oct 14, 2009, at 10:26 AM, Michael Jackson wrote:

> I applied bits and pieces of your patch on an OS X 10.5.8 Intel  
> system and am currently compiling boost 1.40.0.
>
> Wondering if this patch can make it into the boost 1.40.1 release or  
> what ever patch release is coming out next.
>
> This was my command:
>
> bjam toolset=darwin --with-test --with-filesystem --with-
> program_options --with-iostreams --with-thread variant=release,debug  
> threading=multi link=static runtime-link=shared --prefix=/Users/
> Shared/Toolkits/boost-1_40/ -layout=tagged architecture=combined  
> address-model=32_64 install
>
> --
> Mike Jackson <www.bluequartz.net>
>
> On Oct 2, 2009, at 12:58 PM, Michael Jackson wrote:
>
>> Part of your statements need some clarification:
>>
>> The version of GCC that OS X 10.6 ships with (4.2.x) WILL indeed  
>> create 4-way binaries (32 and 64 Bit PPC and x86) when using the  
>> 10.5 SDK which is entirely possible for someone to do considering  
>> that a developer is using OS X 10.6 but wants to target earlier  
>> versions of OS X running on Both PPC and Intel hardware.
>>
>> I have not looked at the patches but you will probably need to  
>> interrogate what SDK the developer is using before hard-setting any  
>> rules about what arguments can and can not be used.
>>
>> _________________________________________________________
>> Mike Jackson                  mike.jackson@...
>> BlueQuartz Software                    www.bluequartz.net
>> Principal Software Engineer                  Dayton, Ohio
>>
>> On Oct 2, 2009, at 11:11 AM, Stuart A. Malone wrote:
>>
>>> Today I took the time to patch my local copy of Boost 1.40 to  
>>> allow building under Snow Leopard.  You can see discussions about  
>>> this problem in places like:
>>>
>>> <http://continuous.wordpress.com/2009/09/06/building-boost-on-mac-os-x-10-6-with-xcode-3-2/ 
>>> >
>>>
>>> <http://archives.free.net.ph/message/20090903.114048.e961e539.en.html 
>>> >
>>>
>>> My patches address two problems:
>>>
>>> - The -m64 option is incompatible with the generation of 32-bit  
>>> binaries
>>>
>>> - Versions of Apple's gcc 4.2 and later do not support generation  
>>> of ppc64 binaries
>>>
>>> Since my company uses both gcc 4.0 and gcc 4.2, I wanted a  
>>> solution that still supports ppc64 binaries when using gcc 4.0,  
>>> but avoids creating ppc64 binaries under gcc 4.2 and later.  I  
>>> believe these patches solve the problem and provide optimal  
>>> behavior under both Leopard and Snow Leopard, gcc 4.0 and 4.2.1.
>>>
>>>
>>> Best wishes,
>>>
>>> --Stuart A. Malone
>>> Llamagraphics, Inc.
>>> Makers of Life Balance personal coaching software
>>> http://www.llamagraphics.com/
>>>
>>>
>>> <snow-leopard-patch.txt>
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Patch for building Boost 1.40 on Mac OS X Snow Leopard

by Vladimir Prus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Friday 02 October 2009 Stuart A. Malone wrote:

> Today I took the time to patch my local copy of Boost 1.40 to allow  
> building under Snow Leopard.  You can see discussions about this  
> problem in places like:
>
> <http://continuous.wordpress.com/2009/09/06/building-boost-on-mac-os-x-10-6-with-xcode-3-2/ 
>  >
>
> <http://archives.free.net.ph/message/20090903.114048.e961e539.en.html>
>
> My patches address two problems:
>
> - The -m64 option is incompatible with the generation of 32-bit binaries

Stuart,

I have applied the -m64 part of the patch. Thanks!

I am still trying to figure the right magic to disable -ppc64 when
using 10.6 SDK. Am I right that ppc64 is not supported with 10.6
regardless of whether you are building a fat library, or not? In other
words, does explicit

        address-model=64 architecture=power

have any chance of working?

- Volodya
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Patch for building Boost 1.40 on Mac OS X Snow Leopard

by Michael Jackson-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Oct 22, 2009, at 5:13 AM, Vladimir Prus wrote:

> On Friday 02 October 2009 Stuart A. Malone wrote:
>
>> Today I took the time to patch my local copy of Boost 1.40 to allow
>> building under Snow Leopard.  You can see discussions about this
>> problem in places like:
>>
>> <http://continuous.wordpress.com/2009/09/06/building-boost-on-mac-os-x-10-6-with-xcode-3-2/
>>>
>>
>> <http://archives.free.net.ph/message/ 
>> 20090903.114048.e961e539.en.html>
>>
>> My patches address two problems:
>>
>> - The -m64 option is incompatible with the generation of 32-bit  
>> binaries
>
> Stuart,
>
> I have applied the -m64 part of the patch. Thanks!
>
> I am still trying to figure the right magic to disable -ppc64 when
> using 10.6 SDK. Am I right that ppc64 is not supported with 10.6
> regardless of whether you are building a fat library, or not? In other
> words, does explicit
>
> address-model=64 architecture=power
>
> have any chance of working?
>
> - Volodya

If you are using the 10.5 SDK then that would work is my  
understanding. So BJam is going to have to figure out if the user is  
specifying an SDK or not and if they are not specifically using an SDK  
then intelligently pick one by either guessing based on the current  
version of the operating system being used (Probably the best) or  
looking in /Developer/SDKs/* and parse out what SDKs are available in  
that location.

   And don't forget that on OS X 10.5 the "/Developer" can actually be  
anywhere. There is a command line tool that can be used to get the  
installation location. On OS X 10.4 and below it was hard coded to /
Developer.

Hope some of that helps.

_________________________________________________________
Mike Jackson                  mike.jackson@...
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Re: Patch for building Boost 1.40 on Mac OS X Snow Leopard

by Boris Dušek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, I wrote this reply some time ago, but now it's also relevant:

On Thu, Oct 22, 2009 at 11:13 AM, Vladimir Prus <ghost@...> wrote:
I am still trying to figure the right magic to disable -ppc64 when
using 10.6 SDK. Am I right that ppc64 is not supported with 10.6
regardless of whether you are building a fat library, or not? In other
words, does explicit

       address-model=64 architecture=power

have any chance of working?

short answer: no
long answer: (sorry if this is already known)

I second the request for a patch for this issue to get into the next release, at least the portion of the patch that removes the -m64 option from the command line.

the "at least the -m64 portion" is important, since for the other portion of the patch, the statement "gcc-4.2 from the Developer Tools package Apple released for Snow Leopard cannot compile -arch ppc64 for any target version of OS X" is not true. I have done some experimentation quite some time ago and while I don't remember for sure, I think the combination of _both_ gcc version (selected on command-line by typing g++-4.0 or g++-4.2) and the MacOSX10.<version>.sdk (selected with bjam via macosx-version and macosx-version-min, and with bar command-line by -mmacosx-version-min=10.<version> and -isysroot /Developer/SDKs/MacOSX10.<version>.sdk) determines whether gcc-4.2 is able to compile -arch ppc64 binary.

Try it yourself with a minimal test.cpp of your own making, including a few standard header files:

This works on Snow Leopard, because there is nothing really snow-leopard specific to it - everything is used like if you were compiling on Leopard with no special flags:
g++-4.2 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk/ -arch ppc64 test.cpp -o test

The following does not work (even for -arch i386), since GCC 4.2 was not available on Tiger, and so GCC's internal headers for the 4.2 version are not available in the Tiger (10.4) SDK:
g++-4.2 -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ -arch ppc64 test.cpp -o test
test.cpp:1:20: error: iostream: No such file or directory
test.cpp:2:19: error: cstdlib: No such file or directory

If you do the above with a file that does not use any C++ standard headers (i.e. int main(){ return 0; }), it does produce an executable that works!

And this does not work, since on Snow Leopard, GCC 4.2 is available along with its internal headers, but the internal headers specially for -arch ppc64 are missing, since Snow Leopard itself does not run on ppc, and ppc is probably not supported via the Rosetta ppc emulator for Intel processors:
g++-4.2 -mmacosx-version-min=10.6 -isysroot /Developer/SDKs/MacOSX10.6.sdk/ -arch ppc64 test.cpp -o test
In file included from test.cpp:1:
/Developer/SDKs/MacOSX10.6.sdk//usr/include/c++/4.2.1/iostream:44:28: error: bits/c++config.h: No such file or directory
In file included from /Developer/SDKs/MacOSX10.6.sdk//usr/include/c++/4.2.1/ios:43,
                 from /Developer/SDKs/MacOSX10.6.sdk//usr/include/c++/4.2.1/ostream:45,
                 from /Developer/SDKs/MacOSX10.6.sdk//usr/include/c++/4.2.1/iostream:45,
                 from test.cpp:1:
/Developer/SDKs/MacOSX10.6.sdk//usr/include/c++/4.2.1/iosfwd:45:29: error: bits/c++locale.h: No such file or directory
... (much more lines)


the bits/* files are present in a platform-specific internal header, and ppc64 is missing:
find /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.0.0/ -name c++locale.h
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.0.0//i686-apple-darwin10/bits/c++locale.h
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.0.0//powerpc-apple-darwin10/bits/c++locale.h
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.0.0//x86_64-apple-darwin10/bits/c++locale.h

ppc64 bits/* files are present in the 10.5 and 10.4u SDK.

I tried now the same experiment with g++-4.0: works for 10.4u and 10.5 SDKs without problem, for 10.6 compilation works (unlike g++-4.2), but linking fails, since on Snow Leopard, system libraries are only 3-way: i386 x86_64 ppc, i.e. ppc64 is missing:
g++-4.0 -mmacosx-version-min=10.6 -isysroot /Developer/SDKs/MacOSX10.6.sdk/ -arch ppc64 test.cpp -o test
ld: warning: in /Developer/SDKs/MacOSX10.6.sdk//usr/lib/crt1.10.5.o, missing required architecture ppc64 in file
ld: warning: in /Developer/SDKs/MacOSX10.6.sdk//usr/lib/powerpc-apple-darwin10/4.0.1/libstdc++.dylib, missing required architecture ppc64 in file
ld: warning: in /Developer/SDKs/MacOSX10.6.sdk//usr/lib/libgcc_s.10.5.dylib, missing required architecture ppc64 in file
ld: warning: in /Developer/SDKs/MacOSX10.6.sdk//usr/lib/libSystemStubs.a, missing required architecture ppc64 in file
ld: warning: in /Developer/SDKs/MacOSX10.6.sdk//usr/lib/libSystem.dylib, missing required architecture ppc64 in file
Undefined symbols:
  "_fdopen", referenced from:
      _main in cckrrB6h.o
  "std::ios_base::Init::Init()", referenced from:
      __static_initialization_and_destruction_0(int, int)in cckrrB6h.o
  "___gxx_personality_v0", referenced from:
      ___gxx_personality_v0$non_lazy_ptr in cckrrB6h.o
  "std::ios_base::Init::~Init()", referenced from:
      ___tcf_0 in cckrrB6h.o
  "___cxa_atexit", referenced from:
      __static_initialization_and_destruction_0(int, int)in cckrrB6h.o
  "_fwrite", referenced from:
      _main in cckrrB6h.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

So to sum-up: Apple's developer tools contain only one g++-4.0 binary and only one g++-4.2. They also contain one SDK for each Mac OS X version for which it supports cross-compiling. These SDKs each contain system header files, system libraries, and gcc's internal headers (C++ standard library headers). The single g++-4.x binary uses, based on the SDK selected with -isysroot (macosx-version in boost.build), for linking different libraries and object files and for compiling different internal (and system) headers. Successful compilation with -arch ppc64 depends both on which g++ version you use (4.0 or 4.2) and which OS version you are (cross-)compiling for:

g++-4.2:
10.4 SDK: does not work for any arch (gcc 4.2 simply was not available in Tiger, C++ internal headers for 4.2 missing)
10.5 SDK: all archs work
10.6 SDK: -arch ppc64 does not work (Snow Leopard does not support running ppc64 executables ("Bad CPU type in executable"), it does support running ppc executables via Rosetta; and on Snow Leopard, system libraries are only 3-way: i386 x86_64 ppc;  ppc64 is missing)

g++-4.0:
10.4 SDK: all archs work (but beware that not all system libraries are 4-way, some are only 2-way (32-bit) - see paragraph below)
10.5 SDK: all archs work
10.6 SDK: same as g++-4.2 wth 10.6 SDK, just does not fail on compiling (internal headers for ppc64 are not there so I don't understand this), but rather on linking (ppc64 internal object files and system libraries do not exist)

The only other thing to be aware of is that "g++" defaults to "g++-4.0" when building on Tiger and Leopard, and to "g++-4.2" when building on Snow Leopard.

So e.g. if you use g++-4.0 or g++-4.2 and compile for 10.5 SDK, you can get 4-way binaries running on 10.5 and later. If you use g++-4.0 and compile for 10.4 SDK, you can get 4-way binaries running on 10.4 or later, but be vary that on Tiger, e.g. system's libz is 4-way, but system's libbz2 is only 2-way (32-bit), so you have to supply your own 4-way bz2 to iostreams (only a few libraries on Tiger were 4-way). And if you do that with your own 4-way static build of libbz2, you run into boost.build's library path issue that I won't go into here (this post is already way longer than I intendet it to be).

Sorry for the huge post, but I hope this attempt makes things a little bit more understandable w.r.t. building for ppc64 (and even others) _on_ Snow Leopard _for_ various target versions of Mac OS X. 

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build