I can build the protocol buffers
(https://github.com/protocolbuffers/protobuf/tree/v3.15.8) using gcc on
CentOS 7 or using clang on my Mac, but not using clang on CentOS 7. I feel
like I'm missing something obvious.
$ unzip protobuf-3.15.8.zip
$ cd protobuf-3.15.8
# on my Mac (host machine)
$ mkdir build_on_mac
$ cd build_on_mac
$ cmake ../cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
-Dprotobuf_BUILD_TESTS=OFF
$ make
$ cd ..
# on my CentOS 7 box (currently a VM, but have an actual box too)
$ mkdir build_on_linux
$ cd build_on_linux
$ cmake ../cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
-Dprotobuf_BUILD_TESTS=OFF
$ make
That second one gets me this:
. . .
[ 31%] Building CXX object
CMakeFiles/libprotobuf.dir/vagrant/protobuf-3.15.8/src/google/protobuf/any.cc.o
In file included from
/vagrant/protobuf-3.15.8/src/google/protobuf/any.cc:34:
In file included from
/vagrant/protobuf-3.15.8/src/google/protobuf/descriptor.h:65:
/vagrant/protobuf-3.15.8/src/google/protobuf/stubs/mutex.h:117:7: warning:
unknown attribute 'capability' ignored [-Wattributes]
class GOOGLE_PROTOBUF_CAPABILITY("mutex") PROTOBUF_EXPORT WrappedMutex {
^
/vagrant/protobuf-3.15.8/src/google/protobuf/stubs/mutex.h:55:54: note:
expanded from macro 'GOOGLE_PROTOBUF_CAPABILITY'
#define GOOGLE_PROTOBUF_CAPABILITY(x) __attribute__((capability(x)))
^
/vagrant/protobuf-3.15.8/src/google/protobuf/stubs/mutex.h:120:15: warning:
unknown attribute 'acquire_capability' ignored [-Wattributes]
void Lock() GOOGLE_PROTOBUF_ACQUIRE() { mu_.lock(); }
^
/vagrant/protobuf-3.15.8/src/google/protobuf/stubs/mutex.h:52:18: note:
expanded from macro 'GOOGLE_PROTOBUF_ACQUIRE'
__attribute__((acquire_capability(__VA_ARGS__)))
^
/vagrant/protobuf-3.15.8/src/google/protobuf/stubs/mutex.h:121:17: warning:
unknown attribute 'release_capability' ignored [-Wattributes]
void Unlock() GOOGLE_PROTOBUF_RELEASE() { mu_.unlock(); }
^
/vagrant/protobuf-3.15.8/src/google/protobuf/stubs/mutex.h:54:18: note:
expanded from macro 'GOOGLE_PROTOBUF_RELEASE'
__attribute__((release_capability(__VA_ARGS__)))
^
In file included from
/vagrant/protobuf-3.15.8/src/google/protobuf/any.cc:36:
/vagrant/protobuf-3.15.8/src/google/protobuf/message.h:234:13: error:
constexpr
constructor never produces a constant expression [-Winvalid-constexpr]
constexpr Message() {}
^
/vagrant/protobuf-3.15.8/src/google/protobuf/message.h:234:13: note:
non-literal type 'google::protobuf::MessageLite' cannot be used in a
constant expression
3 warnings and 1 error generated.
make[2]: ***
[CMakeFiles/libprotobuf.dir/vagrant/protobuf-3.15.8/src/google/protobuf/any.cc.o]
Error 1
make[1]: *** [CMakeFiles/libprotobuf.dir/all] Error 2
make: *** [all] Error 2
I'd like to use clang for cross compiling and toolchain consistency
reasons. That's the error I get both in my VM and on my actual machine.
Additional info:
$ uname -a ; cmake --version ; clang --version
Linux localhost.localdomain 3.10.0-1160.15.2.el7.x86_64 #1 SMP Wed Feb 3
15:06:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
cmake version 3.23.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
Thanks for any help you can provide.
Nathan
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/protobuf/7ba0a048-be95-42f0-9af0-d89067d410a7n%40googlegroups.com.