OS
$ system_profiler SPSoftwareDataType
Software:
System Software Overview:
System Version: macOS 10.12 (16A323)
Kernel Version: Darwin 16.0.0
Compiler
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin16.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Protobuf 2.6.1, sources from https://github.com/apache/mesos/blob/master/3rdparty/protobuf-2.6.1.tar.gz
The following error escalated warning gets generated
In file included from ../3rdparty/protobuf-2.6.1/src/google/protobuf/generated_message_util.h:44:
In file included from ../3rdparty/protobuf-2.6.1/src/google/protobuf/stubs/once.h:81:
In file included from ../3rdparty/protobuf-2.6.1/src/google/protobuf/stubs/atomicops.h:184:
../3rdparty/protobuf-2.6.1/src/google/protobuf/stubs/atomicops_internals_macosx.h:47:9: error:
'OSAtomicCompareAndSwap32' is deprecated: first deprecated in macOS 10.12 - Use
std::atomic_compare_exchange_strong_explicit(std::memory_order_relaxed) from <atomic> instead
[-Werror,-Wdeprecated-declarations]
if (OSAtomicCompareAndSwap32(old_value, new_value,
^
/usr/include/libkern/OSAtomicDeprecated.h:502:9: note: 'OSAtomicCompareAndSwap32' has been explicitly marked deprecated
here
bool OSAtomicCompareAndSwap32( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
^
Confirmed the same issue on my side too with both 2.6.1 and master at HEAD.
Same issue.
https://github.com/google/protobuf/releases/download/v3.1.0/protobuf-cpp-3.1.0.tar.gz
In file included from no_warning_test.cc:2:
In file included from ./google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from ./google/protobuf/stubs/atomicops.h:199:
./google/protobuf/stubs/atomicops_internals_macosx.h:47:9: error:
'OSAtomicCompareAndSwap32' is deprecated: first deprecated in macOS 10.12
- Use
std::atomic_compare_exchange_strong_explicit(std::memory_order_relaxed)
frominstead [-Werror,-Wdeprecated-declarations]
if (OSAtomicCompareAndSwap32(old_value, new_value,
^
Same, shoot. Can't build it.
Edit: Removed -Werror from makefile, now it works. 馃槑
Unfortunately I can't reproduce this right now because I don't have access to a Mac with Sierra on it. For those who can reproduce it, have you tried using the replacement that the deprecation warning suggests (std::atomic_compare_exchange_strong_explicit(std::memory_order_relaxed))? I'm not sure if this will work because we don't compile for C++11 by default and I believe the atomics are new in C++11. The other thing we could try is to disable the warning with -Wno-deprecated-declarations, but that's not ideal because it might have to be changed in the build setups not in protobuf itself but in the projects that depend on it (e.g. Mesos).
I think the right solution is to add another atomicops_internals_cxx11.h header file using C++11 atomics for the implementation, then add a #ifdef/#else/#endif in atomicops.h to select atomicops_internals_cxx11.h instead of atomicops_internals_macosx.h when the macos version is high enough:
https://github.com/google/protobuf/blob/master/src/google/protobuf/stubs/atomicops.h#L199
Can someone having access to Mac Sierra help contribute a pull request?
btw: If you're here because https://github.com/grpc/grpc fails to build, note that the gRPC Makefile passes its own CPPFLAGS to the protobuf make invocation: https://github.com/grpc/grpc/blob/master/Makefile#L1190
In that case, removing -Werror from the protobuf Makefile won't be enough because it still gets passed as CPPFLAGS from the gRPC Makefile.
The easiest work-around for us was to run the gRPC make with the environment variable CPPFLAGS="-Wno-deprecated-declarations" set.
This is fixed in https://github.com/google/protobuf/pull/2337
Follow many threads in GitHub and test with tags/v3.0.0 & tags/v3.1.0 @ macOS Sierra (10.12.1)
Most helpful comment
Confirmed the same issue on my side too with both 2.6.1 and master at HEAD.