build(cxx): align all builds on a C++14 baseline - #3419
Conversation
There was a problem hiding this comment.
Pull request overview
This PR standardizes bRPC’s non-Bazel build paths (CMake/Make/tests/examples/tools) on a C++14 minimum, updates compiler version gating accordingly, and refreshes related documentation so the baseline is consistent across the project.
Changes:
- Bumped build flags and CMake compile features/standards from C++11/C++0x to C++14 across tools, tests, and examples.
- Updated compiler version checks to require GCC 5.0+ / Clang 3.5+ (and adjusted supporting scripts).
- Updated docs and internal notes to reflect the C++14 baseline.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/trackme_server/Makefile | Switch tool build to -std=c++14. |
| tools/rpc_view/Makefile | Switch tool build to -std=c++14. |
| tools/rpc_replay/Makefile | Switch tool build to -std=c++14. |
| tools/rpc_press/Makefile | Switch tool build to -std=c++14. |
| tools/parallel_http/Makefile | Switch tool build to -std=c++14. |
| tools/print_gcc_version.sh | Update compiler detection/version reporting for new minimums (contains a Clang macro parsing bug; see comment). |
| THREAT_MODEL.md | Update security scope to require C++14 toolchain. |
| test/Makefile | Build unit tests with -std=c++14. |
| src/butil/type_traits.h | Enforce C++14+ at compile time in type-traits helpers. |
| example/ubring_performance/CMakeLists.txt | Raise example CMake standard to C++14. |
| example/thrift_extension_c++/Makefile | Switch example build to -std=c++14. |
| example/redis_c++/Makefile | Switch example build to -std=c++14. |
| example/rdma_performance/Makefile | Switch example build to -std=c++14. |
| example/multi_threaded_echo_c++/Makefile | Switch example build to -std=c++14. |
| example/memcache_c++/Makefile | Switch example build to -std=c++14. |
| example/http_c++/Makefile | Switch example build to -std=c++14. |
| example/echo_c++/Makefile | Switch example build to -std=c++14. |
| example/cmake/BrpcExample.cmake | Require cxx_std_14 for example targets. |
| docs/en/getting_started.md | Update supported compiler baseline / build instructions to C++14. |
| docs/cn/getting_started.md | Update supported compiler baseline / build instructions to C++14. |
| config_brpc.sh | Enforce GCC 5.0+ / Clang 3.5+ gate and set default -std=c++14 for non-Protobuf-22+ paths. |
| CMakeLists.txt | Raise minimum compiler versions and set BRPC C++ standard to 14. |
| CLAUDE.md | Update repository guidance to reflect C++14 minimum. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CMake, Make, tests, tools, and examples now require C++14 so every supported build path shares the same minimum language level. The compiler checks and user-facing documentation reflect that baseline.
cd9ad7e to
a20fd8a
Compare
Clear prior cores before each test binary. A passing death test can leave a core that would otherwise be used to diagnose an unrelated later failure.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (16)
tools/trackme_server/Makefile:21
- This Makefile hard-codes
-std=c++14and also overwritesCXXFLAGScoming fromconfig.mk. That defeatsconfig_brpc.shselecting-std=c++17for Protobuf>=22 and can reintroduce inconsistent language levels across Make-based builds.
include $(BRPC_PATH)/config.mk
CXXFLAGS = $(CPPFLAGS) -std=c++14 -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer
HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
tools/rpc_view/Makefile:22
- This Makefile hard-codes
-std=c++14and overwritesCXXFLAGSfromconfig.mk, which can defeatconfig_brpc.shselecting-std=c++17for Protobuf>=22 and reintroduce inconsistent language levels across Make-based builds.
CXXFLAGS = $(CPPFLAGS) -std=c++14 -DNDEBUG -O2 -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
tools/rpc_replay/Makefile:20
- This Makefile overwrites
CXXFLAGSfromconfig.mkand hard-codes-std=c++14, which can defeatconfig_brpc.shselecting-std=c++17for Protobuf>=22 and cause inconsistent language levels across Make-based builds.
CXXFLAGS = $(CPPFLAGS) -std=c++14 -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-unused-parameter
tools/rpc_press/Makefile:20
- This Makefile overwrites
CXXFLAGSfromconfig.mkand hard-codes-std=c++14. That can defeatconfig_brpc.shselecting-std=c++17for Protobuf>=22 and reintroduce inconsistent language levels across Make-based builds.
CXXFLAGS = $(CPPFLAGS) -std=c++14 -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-unused-parameter
tools/parallel_http/Makefile:20
- This Makefile overwrites
CXXFLAGSfromconfig.mkand hard-codes-std=c++14, which can defeatconfig_brpc.shselecting-std=c++17for Protobuf>=22 and cause inconsistent language levels across Make-based builds.
CXXFLAGS = $(CPPFLAGS) -std=c++14 -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-unused-parameter
example/echo_c++/Makefile:23
- This example Makefile appends
-std=c++14after includingconfig.mk, which can overrideconfig_brpc.shselecting-std=c++17for Protobuf>=22 and lead to inconsistent language levels between brpc and the example build.
CXXFLAGS+=$(CPPFLAGS) -std=c++14 -DNDEBUG -O2 -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
example/http_c++/Makefile:23
- This example Makefile appends
-std=c++14after includingconfig.mk, which can overrideconfig_brpc.shselecting-std=c++17for Protobuf>=22 and lead to inconsistent language levels between brpc and the example build.
CXXFLAGS+=$(CPPFLAGS) -std=c++14 -DNDEBUG -O2 -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
example/multi_threaded_echo_c++/Makefile:23
- This example Makefile appends
-std=c++14after includingconfig.mk, which can overrideconfig_brpc.shselecting-std=c++17for Protobuf>=22 and lead to inconsistent language levels between brpc and the example build.
CXXFLAGS+=$(CPPFLAGS) -std=c++14 -DNDEBUG -O2 -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
example/rdma_performance/Makefile:24
- This example Makefile appends
-std=c++14after includingconfig.mk, which can overrideconfig_brpc.shselecting-std=c++17for Protobuf>=22 and lead to inconsistent language levels between brpc and the example build.
CXXFLAGS+=$(CPPFLAGS) -std=c++14 -DNDEBUG -O2 -D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
example/thrift_extension_c++/Makefile:23
- This Makefile overwrites
CXXFLAGSfromconfig.mkand hard-codes-std=c++14, which can defeatconfig_brpc.shselecting-std=c++17for Protobuf>=22 and cause inconsistent language levels between brpc and the example build.
CXXFLAGS = $(CPPFLAGS) -std=c++14 -g -DNDEBUG -O2 -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
example/redis_c++/Makefile:20
- This example Makefile appends
-std=c++14after includingconfig.mk, which can overrideconfig_brpc.shselecting-std=c++17for Protobuf>=22 and lead to inconsistent language levels between brpc and the example build.
CXXFLAGS+=$(CPPFLAGS) -std=c++14 -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer
example/memcache_c++/Makefile:20
- This example Makefile appends
-std=c++14after includingconfig.mk, which can overrideconfig_brpc.shselecting-std=c++17for Protobuf>=22 and lead to inconsistent language levels between brpc and the example build.
CXXFLAGS+=$(CPPFLAGS) -std=c++14 -DNDEBUG -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer
tools/print_gcc_version.sh:33
- The grep pattern relies on
\|alternation without usinggrep -E.\|is a non-POSIX extension and can fail on BSD/macOS grep (a supported platform), causing compiler detection to return 0 andconfig_brpc.shto reject otherwise-valid compilers.
done < <("${CXX:-c++}" -dM -E - < /dev/null | grep "__clang__\|__clang_major__\|__clang_minor__\|__GNUC__\|__GNUC_MINOR__\|__GNUC_PATCHLEVEL__")
example/ubring_performance/CMakeLists.txt:76
- On CMake < 3.1.3, this only matches
CMAKE_CXX_COMPILER_ID == "Clang"and missesAppleClang, so the example may build without any-std=flag on macOS and fail to compile. The top-level CMake usesMATCHES "Clang"for this reason.
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
docs/en/getting_started.md:327
- This sentence's rationale looks outdated: switching from C++11 to C++14 doesn’t affect the boost(atomic) dependency claim (C++11 already provides
std::atomic). Consider rewording to state the actual requirement (C++14 minimum) rather than the old motivation.
c++14 is turned on by default to remove dependencies on boost (atomic).
docs/cn/getting_started.md:331
- 这里的表述沿用了原先“去除对 boost 的依赖(比如 atomic)”的理由,但将最低标准提升到 C++14 后,这个理由已不准确(C++11 就已有 std::atomic)。建议改为直接说明 bRPC 需要 C++14+。
默认启用 c++14,以去除对 boost 的依赖(比如 atomic)。
|
LGTM |
| #elif __cplusplus >= 201402L | ||
| template <typename F> | ||
| using result_of = std::result_of<F>; | ||
| #else | ||
| #error Only C++11 or later is supported. | ||
| #error Only C++14 or later is supported. |
There was a problem hiding this comment.
I don't think this needs to be modified.
What problem does this PR solve?
Issue Number: N/A
Problem Summary:
bRPC’s CMake and Make-based build paths used inconsistent C++11/C++14 settings. This establishes C++14 as the common minimum language level.
What is changed and the side effects?
Changed:
Side effects:
———
Check List: