Segfault-Inc / Multicorn

Data Access Library
https://multicorn.org/
PostgreSQL License
700 stars 145 forks source link

Problems compiling with Xcode 5 (OSX 10.9) #62

Closed frensley closed 10 years ago

frensley commented 10 years ago

Seems there are some issues with linking Python in Xcode 5 (https://developer.apple.com/library/ios/technotes/tn2328/_index.html).

gcc -mmacosx-version-min=10.7 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv  -bundle -multiply_defined suppress -o multicorn.so src/errors.o src/python.o src/query.o src/multicorn.o -L/Applications/Postgres.app/Contents/Versions/9.3/lib -L/Applications/Postgres.app/Contents/Versions/9.3/lib  -L/Applications/Postgres.app/Contents/Versions/9.3/lib -Wl,-dead_strip_dylibs   -F/System/Library/Frameworks -framework Python  
ld: framework not found Python
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Using PYTHON_OVERRIDE = python also errors:

gcc -mmacosx-version-min=10.7 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv  -bundle -multiply_defined suppress -o multicorn.so src/errors.o src/python.o src/query.o src/multicorn.o -L/Applications/Postgres.app/Contents/Versions/9.3/lib -L/Applications/Postgres.app/Contents/Versions/9.3/lib  -L/Applications/Postgres.app/Contents/Versions/9.3/lib -Wl,-dead_strip_dylibs   -ldl -framework CoreFoundation -lpython2.7  
ld: library not found for -lpython2.7

Determined that $(PY_LDFLAGS) is missing from :

SHLIB_LINK = $(PY_LIBSPEC) $(PY_LDFLAGS) $(PY_ADDITIONAL_LIBS) $(filter -lintl,$(LIBS)) 

Which results in lots of missing symbol errors: [....]

"_untransformRelOptions", referenced from:
      _multicorn_GetUserMapping in python.o
      _multicorn_validator in multicorn.o
ld: symbol(s) not found for architecture x86_64

Determined that SHLIB_LINK is clobbering PGXS info. So changing SHLIB_LINK to:

SHLIB_LINK += $(PY_LIBSPEC) $(PY_LDFLAGS) $(PY_ADDITIONAL_LIBS) $(filter -lintl,$(LIBS)) 

This seems to resolve the issue. I am not sure how to patch this specifically for OSX yet. I wanted to get this into the project issues in case someone else has suggestions or stumbles onto the same problem.

rdunklau commented 10 years ago

I don't have access to an OSX box, and I don't know either how to run XCode.

Applying your proposed change when using PYTHON_OVERRIDE is not harmful, but does this resolve your issue ?

It it does, I'll merge it. Thanks for the report !

frensley commented 10 years ago

Yes the proposed changes work great. I am wondering if for OSX 10.9 (and maybe lower) should override automatically (python 2.7 is always included with OSX).