Skip to content

Fix the compiling error for xcode 10#5238

Closed
JerryShih wants to merge 1 commit intoprotocolbuffers:masterfrom
JerryShih:xcode10
Closed

Fix the compiling error for xcode 10#5238
JerryShih wants to merge 1 commit intoprotocolbuffers:masterfrom
JerryShih:xcode10

Conversation

@JerryShih
Copy link

The xcode 10 removes the deprecated libstdc++ library. Now, we should
use libc++ instead.

Here is the error message when I try to build the protobuf with cpp implementation.

warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from google/protobuf/pyext/extension_dict.cc:34:
./google/protobuf/pyext/extension_dict.h:39:10: fatal error: 'memory' file not found
#include

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@JerryShih
Copy link
Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Oct 8, 2018
@JerryShih
Copy link
Author

@anandolee
Could you please review this change?

@JerryShih
Copy link
Author

@TeBoring
How about this change?

@TeBoring
Copy link
Contributor

Do you known since which version of xcode does libc++ exist? We probably can add it by default.

@JerryShih
Copy link
Author

JerryShih commented Oct 24, 2018

@TeBoring
Maybe start from xcode5. What's the minimum requirement to build protobuf at mac? Could I change to libc++ by default?

@TeBoring
Copy link
Contributor

We provide support for up to osx 10.6 for now. It seems xcode 4 can still be run on osx 10.6.
https://stackoverflow.com/questions/13047630/what-is-the-latest-version-of-xcode-i-can-use-on-10-6-8
However, we do cross-compiling. If we don't use libc++, our binary won't work on machines with only xcode10 installed.
So the problem is that it's impossible to have a binary that supports both xcode4 and xcode10. Is that true?

@TeBoring
Copy link
Contributor

https://gitlab.kitware.com/cmake/cmake/issues/18396
https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes

Libgcc is obsoleted. Xcode 10 can no longer build apps with deployment targets of macOS 10.4 and 10.5. (42818150, 38035243)

I feel since xcode10 still claims to support osx10.6, it should not deprecate libstdc++...

@TeBoring
Copy link
Contributor

In https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes, it suggests:

C++ projects must now migrate to libc++ and are recommended to set a deployment target of macOS 10.9 or later, or iOS 7 or later

Perhaps the proper change is to set MACOSX_DEPLOYMENT_TARGET: https://github.com/grpc/grpc/blame/0a1d0d25a2392a0fa70d8ad54c572bdc726b62d3/tools/distrib/python/grpcio_tools/setup.py#L123

@TeBoring TeBoring assigned TeBoring and unassigned anandolee Oct 24, 2018
@JerryShih
Copy link
Author

@TeBoring
It looks like the xcode 4.3 has libc++.
https://stackoverflow.com/questions/9345271/xcode-4-3-and-c11-include-paths/13621792

In https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes, it suggests:

C++ projects must now migrate to libc++ and are recommended to set a deployment target of macOS 10.9 or later, or iOS 7 or later

Perhaps the proper change is to set MACOSX_DEPLOYMENT_TARGET: https://github.com/grpc/grpc/blame/0a1d0d25a2392a0fa70d8ad54c572bdc726b62d3/tools/distrib/python/grpcio_tools/setup.py#L123

I can't catch the idea that we could change MACOSX_DEPLOYMENT_TARGET. You said that the protobuf could run at 10.6. How could we change MACOSX_DEPLOYMENT_TARGET to 10.9?

@TeBoring
Copy link
Contributor

TeBoring commented Oct 25, 2018 via email

@JerryShih
Copy link
Author

@TeBoring
So, what should I do for the next step?
We could replace the libstdc++ with libc++. The xcode 4.3 has libc++.
Do you mean I could add "os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'" to setup.py?

@TeBoring
Copy link
Contributor

TeBoring commented Oct 25, 2018 via email

The xcode 10 removes the deprecated libstdc++ library. We could set
"MACOSX_DEPLOYMENT_TARGET" to "10.9" to use libc++ instead.
@JerryShih
Copy link
Author

@TeBoring
Here is the patch with "os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'" only.
Thank you.

@TeBoring
Copy link
Contributor

Could you do me a favor to send another PR with the same change to python-wheel-dev branch?
I need to run a test on the branch.

@JerryShih
Copy link
Author

@TeBoring
Here is the pr for python-wheel-kekoro-dev branch.
#5303

@TeBoring
Copy link
Contributor

TeBoring commented Dec 1, 2018

Fixed in #5406

@TeBoring TeBoring closed this Dec 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants