Skip to content

build(cxx): align all builds on a C++14 baseline - #3419

Open
darion-yaphet wants to merge 2 commits into
apache:masterfrom
darion-yaphet:chore/cxx14-minimum
Open

build(cxx): align all builds on a C++14 baseline#3419
darion-yaphet wants to merge 2 commits into
apache:masterfrom
darion-yaphet:chore/cxx14-minimum

Conversation

@darion-yaphet

Copy link
Copy Markdown
Contributor

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:

  • Updated CMake, Make, test, tool, and example build settings to require C++14.
  • Raised compiler checks to GCC 5.0+ and Clang 3.5+.
  • Updated configuration and user-facing documentation.
  • Preserved C++17 for Protobuf 22+ and Bazel.

Side effects:

  • Performance effects: None expected.
  • Breaking backward compatibility: C++11-only toolchains and build invocations are no longer supported.

———

Check List:

  • Changes compile: clean CMake brpc-static build with AppleClang 16 and -std=gnu++14.
  • Verified config_brpc.sh generation, shell syntax, and diff formatting.
  • Unit test suite not run.
  • No new feature behavior requiring tests.
  • Follows the Contributor Covenant.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tools/print_gcc_version.sh Outdated
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.
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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++14 and also overwrites CXXFLAGS coming from config.mk. That defeats config_brpc.sh selecting -std=c++17 for 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++14 and overwrites CXXFLAGS from config.mk, which can defeat config_brpc.sh selecting -std=c++17 for 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 CXXFLAGS from config.mk and hard-codes -std=c++14, which can defeat config_brpc.sh selecting -std=c++17 for 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 CXXFLAGS from config.mk and hard-codes -std=c++14. That can defeat config_brpc.sh selecting -std=c++17 for 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 CXXFLAGS from config.mk and hard-codes -std=c++14, which can defeat config_brpc.sh selecting -std=c++17 for 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++14 after including config.mk, which can override config_brpc.sh selecting -std=c++17 for 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++14 after including config.mk, which can override config_brpc.sh selecting -std=c++17 for 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++14 after including config.mk, which can override config_brpc.sh selecting -std=c++17 for 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++14 after including config.mk, which can override config_brpc.sh selecting -std=c++17 for 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 CXXFLAGS from config.mk and hard-codes -std=c++14, which can defeat config_brpc.sh selecting -std=c++17 for 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++14 after including config.mk, which can override config_brpc.sh selecting -std=c++17 for 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++14 after including config.mk, which can override config_brpc.sh selecting -std=c++17 for 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 using grep -E. \| is a non-POSIX extension and can fail on BSD/macOS grep (a supported platform), causing compiler detection to return 0 and config_brpc.sh to 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 misses AppleClang, so the example may build without any -std= flag on macOS and fail to compile. The top-level CMake uses MATCHES "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)。

@wwbmmm
wwbmmm requested a review from chenBright July 31, 2026 02:49
@wwbmmm

wwbmmm commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

LGTM

Comment thread src/butil/type_traits.h
Comment on lines +376 to +380
#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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs to be modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants