sebdraven / pyv8

PyV8
0 stars 0 forks source link

Homebrew & libc++ on Mac OS 10.9 #213

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Starting with 10.9, Apple has made libc++ the default, and homebrew links newly 
compiled binaries to that.  Furthermore, homebrew is compiling with clang by 
default: https://github.com/mxcl/homebrew/wiki/C---standard-libraries

This creates a problem, because the build process currently does not create 
binaries linked against libc++, and when attempting to execute the resultant 
binaries, you end up with missing symbol errors due to libstdc++ and libc++ 
being incompatible.

I'm thinking the build process should sense when it's on a 10.9 system with 
homebrew and choose the right options, or at the very least, provide some 
simple flags.  At the moment I've had to do the following to build:

Set CC and CXX to clang and clang++ respectively.
Set MACOSX_DEPLOYMENT_TARGET to 10.7 (or greater)

Basically, this: CC=clang CXX=clang++ MACOSX_DEPLOYMENT_TARGET=10.9 python 
setup.py build sdist

I also had to modify setup.py with the following diff:

Index: setup.py
===================================================================
--- setup.py    (revision 557)
+++ setup.py    (working copy)
@@ -145,7 +145,7 @@
 ]
 library_dirs = []
 libraries = []
-extra_compile_args = []
+extra_compile_args = ['-stdlib=libc++']
 extra_link_args = []
 extra_objects = []

@@ -252,7 +252,7 @@

     if BOOST_HOME:
         include_dirs += [BOOST_HOME]
-        library_dirs += [os.path.join(BOOST_HOME, 'stage/lib')]
+        library_dirs += [os.path.join(BOOST_HOME, 'lib')]
     else:
         include_dirs += [
             "/opt/local/include", # MacPorts$ sudo port install boost

This isn't a fix, just a starting to on what I had to do to get things to work 
properly on a fresh 10.9 install.  I'm assuming something more subtle will need 
to be done to resolve this.  If I can help in any way, please let me know.

Original issue reported on code.google.com by artlo...@gmail.com on 21 Nov 2013 at 6:27

GoogleCodeExporter commented 8 years ago
Thanks for your patch, please verify the patch with SVN trunk code after r559

Original comment by flier...@gmail.com on 25 Nov 2013 at 7:28

GoogleCodeExporter commented 8 years ago
I just tested this on a fresh install 10.9 system and it works great.  Thanks!

I am a bit concerned that you added the following for any Mac OS system:

extra_compile_args += ["-Wdeprecated-writable-strings", "-stdlib=libc++"]

It seems as if -stdlib=libc++ should only be added if the system is on 10.9 or 
above.  Something like the following should work:

import platform
if int(platform.mac_ver()[0].split('.')[1]) > 8:
    extra_compile_args += ["-stdlib=libc++"]

Original comment by artlo...@gmail.com on 1 Dec 2013 at 3:07