I spent a few days over the holidays getting libc++ working on Leopard/Intel.  
Over the past week or so, I've tested this configuration and fixed various 
issues that surfaced.  As I now have all of my normal ports built and installed 
on Leopard in this configuration, I think it's now ready for a wider audience.

This brings a modern toolchain back to OS X Leopard, so users still on that old 
OS can have C++11 and C++14 support and install ports that require it.  These 
instructions apply to Snow Leopard as well.  Snow Leopard has had this support 
since the end of 2012, but I don't think I ever sent out detailed instructions, 
and the bootstrapping is much simpler now as well.

Please make sure you have a recent checkout (svn r131400 or newer) as I 
recently pushed changes to the ports tree to work around some bootstrapping 
issues.

=== libc++ on Leopard and Snow Leopard with MacPorts ===

Leopard and Snow Leopard do not include libc++ and libc++abi, so you will first 
need to install it and then rebuild your ports with the new configuration.

1) If on Leopard, see the Manual Leopard SDK Fixes below first.
2) Install MacPorts and its dependencies as you normally would or start with an 
existing up-to-date install.
3) Install the libcxx port.  When it activates, the libcxxabi and libcxx ports 
will install libc++.dylib and libc++abi.dylib to the system (which will remain 
after you uninstall MacPorts).  This will pull in a number of dependencies.
        sudo port -v -s install libcxx
4) Deactivate all your active ports (or at least the C++ ports) in order to 
prepare to rebuild them, and then activate just the new toolchain:
        sudo port -v -f deactivate active
        sudo port -v install clang-3.4 ld64 cctools
5) Edit /opt/local/etc/macports/macports.conf to contain:
        cxx_stdlib         libc++
        delete_la_files    yes
        default_compilers  macports-clang-3.4 macports-clang-3.3 gcc-4.2 
apple-gcc-4.2 gcc-4.0
6) Uninstall all the remaining inactive ports:
        sudo port -v -f uninstall inactive
7) Rebuild llvm-3.4 and clang-3.4 to use libc++, using clang-3.5:
        sudo port -v install clang-3.5
        sudo port -v uninstall llvm-3.4 clang-3.4
        sudo port -v install clang-3.4 configure.compiler=macports-clang-3.5
8) Add macports-clang-3.5 or newer to default_compilers in 
/opt/local/etc/macports/macports.conf if you want.
9) Install other ports as you normally would.

=== Manual Leopard SDK Fixes (apply to / and /Developer/SDKs/MacOSX10.5.sdk) ===

Leopard's SDK has a couple bugs which were never fixed in an update of Xcode or 
the OS.  You'll need to make these fixes yourself.

1) Update /usr/lib/libgcc_s.10.5.dylib from a newer OS (to get the missing 
stubs for __udivti3 and others):
        sudo cp /usr/lib/libgcc_s.10.5.dylib{,.bak}
        sudo scp <snow leopard or newer machine>:/usr/lib/libgcc_s.10.5.dylib 
/usr/lib/libgcc_s.10.5.dylib
    
        You will know that this worked successfully if you can compile this 
with clang-mp-3.4:

        int main() {
           __uint128_t a = 100;
           __uint128_t b = 200;
           __uint128_t c = a / b;

          return 0;
        }

2) Edit /usr/include/AvailabilityInternal.h, so ports don't try to use API that 
were added in Snow Leopard:
    --- /usr/include/AvailabilityInternal.h     2008-04-29 21:45:28.000000000 
-0700
        +++ /usr/include/AvailabilityInternal.h 2014-11-12 20:07:12.000000000 
-0800
        @@ -60,7 +60,7 @@
             #define __MAC_OS_X_VERSION_MIN_REQUIRED 
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
             // make sure a default max version is set
             #ifndef __MAC_OS_X_VERSION_MAX_ALLOWED
        -        #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_10_6
        +        #define __MAC_OS_X_VERSION_MAX_ALLOWED 1058
             #endif

             // set up internal macros

        You may be tempted to use __MAC_10_5 instead of 1058 there to match 
what is done on Snow Leopard and later SDKs, but that will fail with Leopard's 
default toolchain because it sets the deployment target to the full OS version 
(eg 10.5.8), and that needs to be less than or equal to 
__MAC_OS_X_VERSION_MAX_ALLOWED.

_______________________________________________
macports-users mailing list
macports-users@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-users

Reply via email to