Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use -x c++ to enable C++ mode #91

Closed
wants to merge 1 commit into from

Conversation

ryandesign
Copy link

Use the generic flags -x c++ to enable C++ mode, instead of the Clang-specific -stdlib=libc++ and Mac-specific -mmacosx-version-min=10.7.

Fixes build failure on Mac OS X 10.6.

This reverts part of #67 and fixes it a different way.

The reason why any fix was necessary in the first place is that apparently distutils compiles all code, even C++ code, using the C compiler. This seems to be a longstanding distutils bug. The C compiler of course doesn't expect C++ code, which appears to be what caused the missing symbols mentioned in #66. (It appears that only some systems are affected. Reverting the change from #67, I see the missing symbol errors on OS X 10.8, but not on macOS 10.13. It may depend on the clang version or on which C++ standard library is used. #66 doesn't mention what version of macOS was being used there.)

The solution implemented in #67 was to enable C++ mode in the C compiler by using the flag -stdlib=libc++. And libc++ was first shipped in Mac OS X 10.7, so the flag -mmacosx-version-min=10.7 was added.

This causes build failure on Mac OS X 10.6 and earlier, because those OS versions don't use clang by default, and only clang understands -stdlib:

cc1plus: error: unrecognized command line option "-stdlib=libc++"
error: command '/usr/bin/gcc-4.2' failed with exit status 1

The plyvel code isn't doing anything that's specific to libc++ or Mac OS X 10.7 or later, and it compiles fine using libstdc++, which is the default C++ standard library on OS X 10.8 and earlier. The revised solution implemented in this PR is to enable C++ mode in the C compiler using the standard -x c++ flag instead. I have verified this compiles fine on Mac OS X 10.6 and that a test file containing import plyvel runs without showing any missing symbol errors.

Use the generic flags -x c++ to enable C++ mode, instead of the
Clang-specific -stdlib=libc++ and Mac-specific -mmacosx-version-min=10.7.

Fixes build failure on Mac OS X 10.6.
@wbolster
Copy link
Owner

wbolster commented Apr 9, 2019

sorry for the late response @ryandesign. i totally forgot about this.

would this also fix #95?

@wbolster
Copy link
Owner

thanks all, see #97

@wbolster wbolster closed this Apr 16, 2019
@wbolster wbolster added the builds label May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants