diff --git a/ports/brpc/brpc-1783.diff b/ports/brpc/brpc-1783.diff deleted file mode 100644 index 40db5788ab..0000000000 --- a/ports/brpc/brpc-1783.diff +++ /dev/null @@ -1,592 +0,0 @@ -diff --git a/BUILD.bazel b/BUILD.bazel -index 11db84d02..7592a1862 100644 ---- a/BUILD.bazel -+++ b/BUILD.bazel -@@ -56,7 +56,7 @@ config_setting( - - COPTS = [ - "-DBTHREAD_USE_FAST_PTHREAD_MUTEX", -- "-D__const__=", -+ "-D__const__=__unused__", - "-D_GNU_SOURCE", - "-DUSE_SYMBOLIZE", - "-DNO_TCMALLOC", -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 057695afc..bfc9fe4f0 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -108,7 +108,7 @@ set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG - if(WITH_MESALINK) - set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DUSE_MESALINK") - endif() --set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=\\\"${BRPC_REVISION}\\\" -D__STRICT_ANSI__") -+set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__=__unused__ -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=\\\"${BRPC_REVISION}\\\" -D__STRICT_ANSI__") - set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEBUG_SYMBOL} ${THRIFT_CPP_FLAG}") - set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer") - set(CMAKE_C_FLAGS "${CMAKE_CPP_FLAGS} -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer") -diff --git a/Makefile b/Makefile -index e2e1a6b2e..da506f7c5 100644 ---- a/Makefile -+++ b/Makefile -@@ -20,10 +20,9 @@ include config.mk - - # Notes on the flags: - # 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default --# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8 --# 3. Removed -Werror: Not block compilation for non-vital warnings, especially when the -+# 2. Removed -Werror: Not block compilation for non-vital warnings, especially when the - # code is tested on newer systems. If the code is used in production, add -Werror back --CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -DBRPC_REVISION=\"$(shell ./tools/get_brpc_revision.sh .)\" -+CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -DBRPC_REVISION=\"$(shell ./tools/get_brpc_revision.sh .)\" - CXXFLAGS=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x - CFLAGS=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer - DEBUG_CXXFLAGS = $(filter-out -DNDEBUG,$(CXXFLAGS)) -DUNIT_TEST -DBVAR_NOT_LINK_DEFAULT_VARIABLES -diff --git a/config_brpc.sh b/config_brpc.sh -index 842f100f9..cf04b7260 100755 ---- a/config_brpc.sh -+++ b/config_brpc.sh -@@ -320,6 +320,10 @@ append_to_output "STATIC_LINKINGS=$STATIC_LINKINGS" - append_to_output "DYNAMIC_LINKINGS=$DYNAMIC_LINKINGS" - CPPFLAGS="-DBRPC_WITH_GLOG=$WITH_GLOG -DGFLAGS_NS=$GFLAGS_NS" - -+# Avoid over-optimizations of TLS variables by GCC>=4.8 -+# See: https://github.com/apache/incubator-brpc/issues/1693 -+CPPFLAGS="${CPPFLAGS} -D__const__=__unused__" -+ - if [ ! -z "$DEBUGSYMBOLS" ]; then - CPPFLAGS="${CPPFLAGS} $DEBUGSYMBOLS" - fi -diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md -index 2602f5b41..56f80db3b 100644 ---- a/docs/cn/getting_started.md -+++ b/docs/cn/getting_started.md -@@ -290,7 +290,7 @@ GCC7中over-aligned的问题暂时被禁止。 - - 使用其他版本的gcc可能会产生编译警告,请联系我们予以修复。 - --请在makefile中给cxxflags增加`-D__const__=`选项以避免[gcc4+中的errno问题](thread_local.md). -+请在makefile中给cxxflags增加`-D__const__=__unused__`选项以避免[gcc4+中的errno问题](thread_local.md). - - ## Clang: 3.5-4.0 - -diff --git a/docs/cn/thread_local.md b/docs/cn/thread_local.md -index f8e1a491e..41e024749 100644 ---- a/docs/cn/thread_local.md -+++ b/docs/cn/thread_local.md -@@ -57,9 +57,8 @@ Use *p ... - still the errno of original pthread, undefined b - - 严格地说这个问题不是gcc4导致的,而是glibc给__errno_location的签名不够准确,一个返回thread-local指针的函数依赖于段寄存器(TLS的一般实现方式),这怎么能算const呢?由于我们还未找到覆盖__errno_location的方法,所以这个问题目前实际的解决方法是: - --**务必在直接或间接使用bthread的项目的gcc编译选项中添加`-D__const__=`,即把`__const__`定义为空,避免gcc4做相关优化。** -+**务必在直接或间接使用bthread的项目的gcc编译选项中添加`-D__const__=__unused__`,即把`__const__`定义为一个无副作用的属性,避免gcc4做相关优化。** - --把`__const__`定义为空对程序其他部分的影响几乎为0。另外如果你没有**直接**使用errno(即你的项目中没有出现errno),或使用的是gcc --3.4,即使没有定义`-D__const__=`,程序的正确性也不会受影响,但为了防止未来可能的问题,我们强烈建议加上。 -+把`__const__`定义为`__unused__`对程序其他部分的影响几乎为0。另外如果你没有**直接**使用errno(即你的项目中没有出现errno),或使用的是gcc 3.4,即使没有定义`-D__const__=__unused__`,程序的正确性也不会受影响,但为了防止未来可能的问题,我们强烈建议加上。 - --需要说明的是,和errno类似,pthread_self也有类似的问题,不过一般pthread_self除了打日志没有其他用途,影响面较小,在`-D__const__=`后pthread_self也会正常。 -+需要说明的是,和errno类似,pthread_self也有类似的问题,不过一般pthread_self除了打日志没有其他用途,影响面较小,在`-D__const__=__unused__`后pthread_self也会正常。 -diff --git a/docs/en/getting_started.md b/docs/en/getting_started.md -index c500f5807..4242f82a0 100644 ---- a/docs/en/getting_started.md -+++ b/docs/en/getting_started.md -@@ -297,7 +297,7 @@ The over-aligned issues in GCC7 is suppressed temporarily now. - - Using other versions of gcc may generate warnings, contact us to fix. - --Adding `-D__const__=` to cxxflags in your makefiles is a must to avoid [errno issue in gcc4+](thread_local.md). -+Adding `-D__const__=__unused__` to cxxflags in your makefiles is a must to avoid [errno issue in gcc4+](thread_local.md). - - ## Clang: 3.5-4.0 - -diff --git a/example/BUILD b/example/BUILD -index ee2c6ffd0..d688749d8 100644 ---- a/example/BUILD -+++ b/example/BUILD -@@ -16,7 +16,7 @@ - COPTS = [ - "-D__STDC_FORMAT_MACROS", - "-DBTHREAD_USE_FAST_PTHREAD_MUTEX", -- "-D__const__=", -+ "-D__const__=__unused__", - "-D_GNU_SOURCE", - "-DUSE_SYMBOLIZE", - "-DNO_TCMALLOC", -diff --git a/example/asynchronous_echo_c++/CMakeLists.txt b/example/asynchronous_echo_c++/CMakeLists.txt -index 18fec20ee..4a118b19a 100644 ---- a/example/asynchronous_echo_c++/CMakeLists.txt -+++ b/example/asynchronous_echo_c++/CMakeLists.txt -@@ -81,7 +81,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -diff --git a/example/auto_concurrency_limiter/CMakeLists.txt b/example/auto_concurrency_limiter/CMakeLists.txt -index ef20bf0a7..88b784277 100644 ---- a/example/auto_concurrency_limiter/CMakeLists.txt -+++ b/example/auto_concurrency_limiter/CMakeLists.txt -@@ -70,7 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -diff --git a/example/backup_request_c++/CMakeLists.txt b/example/backup_request_c++/CMakeLists.txt -index d247bc150..fc39ba3cd 100644 ---- a/example/backup_request_c++/CMakeLists.txt -+++ b/example/backup_request_c++/CMakeLists.txt -@@ -81,7 +81,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -diff --git a/example/cancel_c++/CMakeLists.txt b/example/cancel_c++/CMakeLists.txt -index 26f2581ba..ea611e03f 100644 ---- a/example/cancel_c++/CMakeLists.txt -+++ b/example/cancel_c++/CMakeLists.txt -@@ -81,7 +81,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -diff --git a/example/cascade_echo_c++/CMakeLists.txt b/example/cascade_echo_c++/CMakeLists.txt -index 24d9249ae..6ca2e25dc 100644 ---- a/example/cascade_echo_c++/CMakeLists.txt -+++ b/example/cascade_echo_c++/CMakeLists.txt -@@ -80,7 +80,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -diff --git a/example/dynamic_partition_echo_c++/CMakeLists.txt b/example/dynamic_partition_echo_c++/CMakeLists.txt -index 5a268a6c9..8df3ad62e 100644 ---- a/example/dynamic_partition_echo_c++/CMakeLists.txt -+++ b/example/dynamic_partition_echo_c++/CMakeLists.txt -@@ -85,7 +85,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") -diff --git a/example/echo_c++/CMakeLists.txt b/example/echo_c++/CMakeLists.txt -index 4e6f5231d..d7babd7f7 100644 ---- a/example/echo_c++/CMakeLists.txt -+++ b/example/echo_c++/CMakeLists.txt -@@ -81,7 +81,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -diff --git a/example/echo_c++/Makefile b/example/echo_c++/Makefile -index 710cc7eda..fddde8cbc 100644 ---- a/example/echo_c++/Makefile -+++ b/example/echo_c++/Makefile -@@ -20,8 +20,7 @@ BRPC_PATH=../.. - include $(BRPC_PATH)/config.mk - # Notes on the flags: - # 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default --# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8 --CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer -+CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer - ifeq ($(NEED_GPERFTOOLS), 1) - CXXFLAGS+=-DBRPC_ENABLE_CPU_PROFILER - endif -diff --git a/example/grpc_c++/CMakeLists.txt b/example/grpc_c++/CMakeLists.txt -index 5f9032e1c..49010e963 100644 ---- a/example/grpc_c++/CMakeLists.txt -+++ b/example/grpc_c++/CMakeLists.txt -@@ -75,7 +75,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") -diff --git a/example/http_c++/CMakeLists.txt b/example/http_c++/CMakeLists.txt -index 388b58c2e..34f3050fa 100644 ---- a/example/http_c++/CMakeLists.txt -+++ b/example/http_c++/CMakeLists.txt -@@ -86,7 +86,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") -diff --git a/example/http_c++/Makefile b/example/http_c++/Makefile -index dc9d430f6..515456559 100644 ---- a/example/http_c++/Makefile -+++ b/example/http_c++/Makefile -@@ -20,8 +20,7 @@ BRPC_PATH=../../ - include $(BRPC_PATH)/config.mk - # Notes on the flags: - # 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default --# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8 --CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer -+CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer - ifeq ($(NEED_GPERFTOOLS), 1) - CXXFLAGS+=-DBRPC_ENABLE_CPU_PROFILER - endif -diff --git a/example/memcache_c++/CMakeLists.txt b/example/memcache_c++/CMakeLists.txt -index 2554b8295..85b4affcb 100644 ---- a/example/memcache_c++/CMakeLists.txt -+++ b/example/memcache_c++/CMakeLists.txt -@@ -81,7 +81,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -diff --git a/example/memcache_c++/Makefile b/example/memcache_c++/Makefile -index 2579f68f4..03b3d4cd7 100644 ---- a/example/memcache_c++/Makefile -+++ b/example/memcache_c++/Makefile -@@ -17,7 +17,7 @@ - - BRPC_PATH = ../../ - include $(BRPC_PATH)/config.mk --CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -fPIC -fno-omit-frame-pointer -+CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer - HDRS+=$(BRPC_PATH)/output/include - LIBS+=$(BRPC_PATH)/output/lib - HDRPATHS = $(addprefix -I, $(HDRS)) -diff --git a/example/multi_threaded_echo_c++/CMakeLists.txt b/example/multi_threaded_echo_c++/CMakeLists.txt -index c68010dc1..4a7291c47 100644 ---- a/example/multi_threaded_echo_c++/CMakeLists.txt -+++ b/example/multi_threaded_echo_c++/CMakeLists.txt -@@ -85,7 +85,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") -diff --git a/example/multi_threaded_echo_c++/Makefile b/example/multi_threaded_echo_c++/Makefile -index 558b77c36..cd344f98d 100644 ---- a/example/multi_threaded_echo_c++/Makefile -+++ b/example/multi_threaded_echo_c++/Makefile -@@ -20,8 +20,7 @@ BRPC_PATH=../.. - include $(BRPC_PATH)/config.mk - # Notes on the flags: - # 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default --# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8 --CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer -+CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer - ifeq ($(NEED_GPERFTOOLS), 1) - CXXFLAGS+=-DBRPC_ENABLE_CPU_PROFILER - endif -diff --git a/example/multi_threaded_echo_fns_c++/CMakeLists.txt b/example/multi_threaded_echo_fns_c++/CMakeLists.txt -index 148490a05..8345076eb 100644 ---- a/example/multi_threaded_echo_fns_c++/CMakeLists.txt -+++ b/example/multi_threaded_echo_fns_c++/CMakeLists.txt -@@ -85,7 +85,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") -diff --git a/example/nshead_extension_c++/CMakeLists.txt b/example/nshead_extension_c++/CMakeLists.txt -index 72c9b4183..b0b93a23d 100644 ---- a/example/nshead_extension_c++/CMakeLists.txt -+++ b/example/nshead_extension_c++/CMakeLists.txt -@@ -81,7 +81,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -diff --git a/example/nshead_pb_extension_c++/CMakeLists.txt b/example/nshead_pb_extension_c++/CMakeLists.txt -index 82c055bab..448c7070f 100644 ---- a/example/nshead_pb_extension_c++/CMakeLists.txt -+++ b/example/nshead_pb_extension_c++/CMakeLists.txt -@@ -81,7 +81,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -diff --git a/example/parallel_echo_c++/CMakeLists.txt b/example/parallel_echo_c++/CMakeLists.txt -index 65b251530..b24bb41f9 100644 ---- a/example/parallel_echo_c++/CMakeLists.txt -+++ b/example/parallel_echo_c++/CMakeLists.txt -@@ -85,7 +85,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") -diff --git a/example/partition_echo_c++/CMakeLists.txt b/example/partition_echo_c++/CMakeLists.txt -index fecdfa0c3..25d98dbe5 100644 ---- a/example/partition_echo_c++/CMakeLists.txt -+++ b/example/partition_echo_c++/CMakeLists.txt -@@ -85,7 +85,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") -diff --git a/example/redis_c++/CMakeLists.txt b/example/redis_c++/CMakeLists.txt -index f1bafece8..a7b008b5a 100644 ---- a/example/redis_c++/CMakeLists.txt -+++ b/example/redis_c++/CMakeLists.txt -@@ -90,7 +90,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -diff --git a/example/redis_c++/Makefile b/example/redis_c++/Makefile -index 4ba9505f0..7c94e195d 100644 ---- a/example/redis_c++/Makefile -+++ b/example/redis_c++/Makefile -@@ -17,7 +17,7 @@ - - BRPC_PATH = ../../ - include $(BRPC_PATH)/config.mk --CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -fPIC -fno-omit-frame-pointer -+CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer - HDRS+=$(BRPC_PATH)/output/include - LIBS+=$(BRPC_PATH)/output/lib - HDRPATHS = $(addprefix -I, $(HDRS)) -diff --git a/example/selective_echo_c++/CMakeLists.txt b/example/selective_echo_c++/CMakeLists.txt -index 74135282e..7d65c7759 100644 ---- a/example/selective_echo_c++/CMakeLists.txt -+++ b/example/selective_echo_c++/CMakeLists.txt -@@ -85,7 +85,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") -diff --git a/example/session_data_and_thread_local/CMakeLists.txt b/example/session_data_and_thread_local/CMakeLists.txt -index 120f92e22..28ba03565 100644 ---- a/example/session_data_and_thread_local/CMakeLists.txt -+++ b/example/session_data_and_thread_local/CMakeLists.txt -@@ -85,7 +85,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") -diff --git a/example/streaming_echo_c++/CMakeLists.txt b/example/streaming_echo_c++/CMakeLists.txt -index 57fe261e7..34e041d77 100644 ---- a/example/streaming_echo_c++/CMakeLists.txt -+++ b/example/streaming_echo_c++/CMakeLists.txt -@@ -81,7 +81,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") -+set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") - - if(CMAKE_VERSION VERSION_LESS "3.1.3") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -diff --git a/example/thrift_extension_c++/Makefile b/example/thrift_extension_c++/Makefile -index 980b2085b..47b381fdb 100644 ---- a/example/thrift_extension_c++/Makefile -+++ b/example/thrift_extension_c++/Makefile -@@ -20,8 +20,7 @@ BRPC_PATH = ../../ - include $(BRPC_PATH)/config.mk - # Notes on the flags: - # 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default --# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8 --CXXFLAGS = $(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer -+CXXFLAGS = $(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer - ifeq ($(NEED_GPERFTOOLS), 1) - CXXFLAGS+=-DBRPC_ENABLE_CPU_PROFILER - endif -diff --git a/src/butil/errno.h b/src/butil/errno.h -index 0390a840b..14856eeb6 100644 ---- a/src/butil/errno.h -+++ b/src/butil/errno.h -@@ -22,7 +22,12 @@ - #ifndef BUTIL_BAIDU_ERRNO_H - #define BUTIL_BAIDU_ERRNO_H - --#define __const__ -+#ifndef __const__ -+// Avoid over-optimizations of TLS variables by GCC>=4.8 -+// See: https://github.com/apache/incubator-brpc/issues/1693 -+#define __const__ __unused__ -+#endif -+ - #include // errno - #include "butil/macros.h" // BAIDU_CONCAT - -diff --git a/test/BUILD.bazel b/test/BUILD.bazel -index c4649ab12..a170eaf8c 100644 ---- a/test/BUILD.bazel -+++ b/test/BUILD.bazel -@@ -24,7 +24,7 @@ config_setting( - COPTS = [ - "-D__STDC_FORMAT_MACROS", - "-DBTHREAD_USE_FAST_PTHREAD_MUTEX", -- "-D__const__=", -+ "-D__const__=__unused__", - "-D_GNU_SOURCE", - "-DUSE_SYMBOLIZE", - "-DNO_TCMALLOC", -diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt -index f3e0c9bb3..980794f5f 100644 ---- a/test/CMakeLists.txt -+++ b/test/CMakeLists.txt -@@ -52,7 +52,7 @@ else() - endif() - - set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}") --set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES -D__STRICT_ANSI__ -include ${PROJECT_SOURCE_DIR}/test/sstream_workaround.h") -+set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__=__unused__ -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES -D__STRICT_ANSI__ -include ${PROJECT_SOURCE_DIR}/test/sstream_workaround.h") - set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -g -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer") - use_cxx11() - -diff --git a/test/Makefile b/test/Makefile -index 99f7b4f74..5aa90e8be 100644 ---- a/test/Makefile -+++ b/test/Makefile -@@ -18,7 +18,7 @@ - NEED_GPERFTOOLS=1 - NEED_GTEST=1 - include ../config.mk --CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES --include sstream_workaround.h -+CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES --include sstream_workaround.h - CXXFLAGS=$(CPPFLAGS) -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x - - #required by butil/crc32.cc to boost performance for 10x -diff --git a/tools/BUILD b/tools/BUILD -index 99f472fda..04b3abbf9 100644 ---- a/tools/BUILD -+++ b/tools/BUILD -@@ -16,7 +16,7 @@ - COPTS = [ - "-D__STDC_FORMAT_MACROS", - "-DBTHREAD_USE_FAST_PTHREAD_MUTEX", -- "-D__const__=", -+ "-D__const__=__unused__", - "-D_GNU_SOURCE", - "-DUSE_SYMBOLIZE", - "-DNO_TCMALLOC", -diff --git a/tools/parallel_http/Makefile b/tools/parallel_http/Makefile -index 5b8664708..a57c5d5f5 100644 ---- a/tools/parallel_http/Makefile -+++ b/tools/parallel_http/Makefile -@@ -17,7 +17,7 @@ - - BRPC_PATH = ../../ - include $(BRPC_PATH)/config.mk --CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-unused-parameter -+CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-unused-parameter - HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS)) - LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS)) - STATIC_LINKINGS += $(BRPC_PATH)/output/lib/libbrpc.a -diff --git a/tools/rpc_press/Makefile b/tools/rpc_press/Makefile -index c1d866d05..8cae3033c 100644 ---- a/tools/rpc_press/Makefile -+++ b/tools/rpc_press/Makefile -@@ -17,7 +17,7 @@ - - BRPC_PATH = ../../ - include $(BRPC_PATH)/config.mk --CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-unused-parameter -+CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-unused-parameter - HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS)) - LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS)) - STATIC_LINKINGS += $(BRPC_PATH)/output/lib/libbrpc.a -diff --git a/tools/rpc_replay/Makefile b/tools/rpc_replay/Makefile -index fcd5eb6f9..8f4eadde8 100644 ---- a/tools/rpc_replay/Makefile -+++ b/tools/rpc_replay/Makefile -@@ -17,7 +17,7 @@ - - BRPC_PATH = ../../ - include $(BRPC_PATH)/config.mk --CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-unused-parameter -+CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-unused-parameter - HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS)) - LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS)) - STATIC_LINKINGS += $(BRPC_PATH)/output/lib/libbrpc.a -diff --git a/tools/rpc_view/Makefile b/tools/rpc_view/Makefile -index c654cfd5a..13f026cbe 100644 ---- a/tools/rpc_view/Makefile -+++ b/tools/rpc_view/Makefile -@@ -19,8 +19,7 @@ BRPC_PATH = ../../ - include $(BRPC_PATH)/config.mk - # Notes on the flags: - # 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default --# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8 --CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer -+CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer - HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS)) - LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS)) - STATIC_LINKINGS += $(BRPC_PATH)/output/lib/libbrpc.a -diff --git a/tools/trackme_server/Makefile b/tools/trackme_server/Makefile -index 79e8536d0..5bdd53f86 100644 ---- a/tools/trackme_server/Makefile -+++ b/tools/trackme_server/Makefile -@@ -17,7 +17,7 @@ - - BRPC_PATH = ../../ - include $(BRPC_PATH)/config.mk --CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -fPIC -fno-omit-frame-pointer -+CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer - HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS)) - LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS)) - STATIC_LINKINGS += $(BRPC_PATH)/output/lib/libbrpc.a diff --git a/ports/brpc/fix-build.patch b/ports/brpc/fix-build.patch index 3b764730d1..eae7f26742 100644 --- a/ports/brpc/fix-build.patch +++ b/ports/brpc/fix-build.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 5f46dc0..fe12819 100644 +index 9edc0a68..af786821 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ option(WITH_DEBUG_SYMBOLS "With debug symbols" ON) @@ -82,37 +82,28 @@ index 5f46dc0..fe12819 100644 z) diff --git a/cmake/FindGFLAGS.cmake b/cmake/FindGFLAGS.cmake -index dfad5fd..83a167f 100644 +index dfad5fd8..8423d55a 100644 --- a/cmake/FindGFLAGS.cmake +++ b/cmake/FindGFLAGS.cmake -@@ -15,7 +15,8 @@ - - set(_gflags_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - --find_path(GFLAGS_INCLUDE_PATH gflags/gflags.h) -+find_package(gflags CONFIG REQUIRED) -+get_target_property(GFLAGS_INCLUDE_PATH gflags::gflags INTERFACE_INCLUDE_DIRECTORIES) - - if (GFLAGS_STATIC) - if (WIN32) -@@ -24,7 +25,7 @@ if (GFLAGS_STATIC) +@@ -24,7 +24,9 @@ if (GFLAGS_STATIC) set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) endif (WIN32) endif (GFLAGS_STATIC) -find_library(GFLAGS_LIBRARY NAMES gflags libgflags) ++find_package(gflags CONFIG REQUIRED) +set(GFLAGS_LIBRARY gflags::gflags) ++get_target_property(GFLAGS_INCLUDE_PATH gflags::gflags INTERFACE_INCLUDE_DIRECTORIES) if(GFLAGS_INCLUDE_PATH AND GFLAGS_LIBRARY) set(GFLAGS_FOUND TRUE) endif(GFLAGS_INCLUDE_PATH AND GFLAGS_LIBRARY) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 209c0e2..b9434ee 100644 +index fbcc7cc5..1c61c4ce 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt -@@ -30,17 +30,22 @@ add_dependencies(SOURCES_LIB PROTO_LIB) - # shared library needs POSITION_INDEPENDENT_CODE +@@ -31,16 +31,24 @@ add_dependencies(SOURCES_LIB PROTO_LIB) set_property(TARGET ${SOURCES_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1) set_property(TARGET ${BUTIL_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1) -- + +if(NOT BUILD_SHARED_LIBS) add_library(brpc-static STATIC $ $ @@ -122,25 +113,25 @@ index 209c0e2..b9434ee 100644 +if(WITH_THRIFT) target_link_libraries(brpc-static thrift) endif() -- + +target_link_libraries(brpc-static PUBLIC ${DYNAMIC_LIB}) +if(BRPC_WITH_GLOG) + target_link_libraries(brpc-static ${GLOG_LIB}) +endif() +target_include_directories(brpc-static PUBLIC $) SET_TARGET_PROPERTIES(brpc-static PROPERTIES OUTPUT_NAME brpc CLEAN_DIRECT_OUTPUT 1) -- + +endif() +if(0) # for protoc-gen-mcpack set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/output/bin) -@@ -49,35 +54,56 @@ set(protoc_gen_mcpack_SOURCES +@@ -49,35 +57,58 @@ set(protoc_gen_mcpack_SOURCES ) add_executable(protoc-gen-mcpack ${protoc_gen_mcpack_SOURCES}) -- +endif() + if(BUILD_SHARED_LIBS) add_library(brpc-shared SHARED $ $ @@ -165,11 +156,11 @@ index 209c0e2..b9434ee 100644 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) else() -- target_link_libraries(protoc-gen-mcpack brpc-static ${BRPC_PRIVATE_LIBS} pthread) +- target_link_libraries(protoc-gen-mcpack brpc-static ${DYNAMIC_LIB} pthread) endif() -- + -install(TARGETS brpc-static +if(NOT BUILD_SHARED_LIBS) +install(TARGETS brpc-static EXPORT unofficial-brpcTargets diff --git a/ports/brpc/portfile.cmake b/ports/brpc/portfile.cmake index a2353e2a3a..01f0ac5945 100644 --- a/ports/brpc/portfile.cmake +++ b/ports/brpc/portfile.cmake @@ -1,13 +1,12 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO apache/incubator-brpc - REF 29491107cbf405a494aaf80ee32344ba34e1d7e4 #1.2.0 - SHA512 bd4c67967796592030903041ddb9205e24c9f196e63ebc153e08fbce723d93d27cd4f30f3c2cf904a93cda66ffa9db7d465d6e5fdac27a045ae84afad3dd1dc3 + REF "${VERSION}" + SHA512 c9779e2bf4a69228ba37960101844f2d33c1a442204d5630e7e191d11b496831a61f1d5da37813b135f24c491bd7d23eb18fa0de9423ac7e13bbf84d8fc48fb8 HEAD_REF master PATCHES fix-build.patch fix-boost-ptr.patch - brpc-1783.diff #https://github.com/apache/incubator-brpc/pull/1783 ) vcpkg_cmake_configure( diff --git a/ports/brpc/vcpkg.json b/ports/brpc/vcpkg.json index eb3fca14cb..4f5b7f8692 100644 --- a/ports/brpc/vcpkg.json +++ b/ports/brpc/vcpkg.json @@ -1,7 +1,6 @@ { "name": "brpc", - "version": "1.2.0", - "port-version": 1, + "version": "1.3.0", "description": "Industrial-grade RPC framework used throughout Baidu, with 1,000,000+ instances and thousands kinds of services, called \"baidu-rpc\" inside Baidu.", "homepage": "https://github.com/apache/incubator-brpc", "license": "Apache-2.0", diff --git a/versions/b-/brpc.json b/versions/b-/brpc.json index 32298858cf..f219cd5ead 100644 --- a/versions/b-/brpc.json +++ b/versions/b-/brpc.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "14c66f674d539da678233b47be27be7e7f419901", + "version": "1.3.0", + "port-version": 0 + }, { "git-tree": "2ed01cdb3f05cfc779d3162de470045bda69f985", "version": "1.2.0", diff --git a/versions/baseline.json b/versions/baseline.json index ec78272546..d39f3f974d 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -1225,8 +1225,8 @@ "port-version": 5 }, "brpc": { - "baseline": "1.2.0", - "port-version": 1 + "baseline": "1.3.0", + "port-version": 0 }, "brunocodutra-metal": { "baseline": "2.1.4",