Skip to content

Commit 34cfa19

Browse files
author
Tor Didriksen
committed
Bug#35123848 failed to compile in static mode
When building with -static-libgcc -static-libstdc++ we need to build the bundled protobuf with static libraries as well. Patch is based on a contribution from: Alex Xing <whuxingying@qq.com> Change-Id: I9abaa01a8579d1958a945e544619e65201ecc2c5
1 parent 1ca8dc4 commit 34cfa19

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

extra/protobuf/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,13 @@ SET(protobuf_BUILD_EXAMPLES OFF CACHE INTERNAL "")
100100
IF(SOLARIS)
101101
SET(protobuf_BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
102102
ELSE()
103-
SET(protobuf_BUILD_SHARED_LIBS ON CACHE INTERNAL "")
103+
# With static C/C++ libraries, protoc with shared libs will segfault,
104+
# so use static libs instead.
105+
IF(CMAKE_CXX_FLAGS MATCHES "-static-libgcc")
106+
SET(protobuf_BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
107+
ELSE()
108+
SET(protobuf_BUILD_SHARED_LIBS ON CACHE INTERNAL "")
109+
ENDIF()
104110
ENDIF()
105111

106112
SET(protobuf_MSVC_STATIC_RUNTIME OFF CACHE INTERNAL "")

0 commit comments

Comments
 (0)