From 4955a37df7cabfdeec277ccbb96918de7744b4be Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Fri, 1 Nov 2019 23:15:57 +0000 Subject: [PATCH 01/14] build: switch to libc++ by default Signed-off-by: Lizan Zhou --- ci/build_setup.sh | 4 ++-- ci/do_ci.sh | 2 +- docs/root/intro/version_history.rst | 1 + test/common/stats/stat_test_utility.cc | 3 ++- test/integration/stats_integration_test.cc | 9 ++++++--- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ci/build_setup.sh b/ci/build_setup.sh index 519e8f57b88f..bbe2a9d93f1a 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -21,7 +21,7 @@ function setup_gcc_toolchain() { fi } -function setup_clang_toolchain() { +function setup_clang_libstdcxx_toolchain() { if [[ -z "${ENVOY_RBE}" ]]; then export BAZEL_BUILD_OPTIONS="--config=clang ${BAZEL_BUILD_OPTIONS}" else @@ -30,7 +30,7 @@ function setup_clang_toolchain() { echo "clang toolchain configured" } -function setup_clang_libcxx_toolchain() { +function setup_clang_toolchain() { if [[ -z "${ENVOY_RBE}" ]]; then export BAZEL_BUILD_OPTIONS="--config=libc++ ${BAZEL_BUILD_OPTIONS}" else diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 6d3584c38704..7725fe294630 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -204,7 +204,7 @@ elif [[ "$CI_TARGET" == "bazel.compile_time_options" ]]; then --define path_normalization_by_default=true \ --define deprecated_features=disabled \ " - setup_clang_libcxx_toolchain + setup_clang_libstdcxx_toolchain # This doesn't go into CI but is available for developer convenience. echo "bazel with different compiletime options build with tests..." diff --git a/docs/root/intro/version_history.rst b/docs/root/intro/version_history.rst index 0688662013b0..f6f63eb2d54a 100644 --- a/docs/root/intro/version_history.rst +++ b/docs/root/intro/version_history.rst @@ -3,6 +3,7 @@ Version history 1.13.0 (pending) ================ +* build: official released binary is now built against libc++. * tcp_proxy: added :ref:`hash_policy` 1.12.0 (October 31, 2019) diff --git a/test/common/stats/stat_test_utility.cc b/test/common/stats/stat_test_utility.cc index ef13cdab3748..8520266e433f 100644 --- a/test/common/stats/stat_test_utility.cc +++ b/test/common/stats/stat_test_utility.cc @@ -114,7 +114,8 @@ MemoryTest::Mode MemoryTest::mode() { // on some platforms, so try to force-allocate some heap memory // and determine whether we can measure it. const size_t start_mem = Memory::Stats::totalCurrentlyAllocated(); - volatile std::string long_string("more than 22 chars to exceed libc++ short-string optimization"); + volatile std::unique_ptr long_string = std::make_unique( + "more than 22 chars to exceed libc++ short-string optimization"); const size_t end_mem = Memory::Stats::totalCurrentlyAllocated(); bool can_measure_memory = end_mem > start_mem; diff --git a/test/integration/stats_integration_test.cc b/test/integration/stats_integration_test.cc index aeb41d47ab82..302920542ce4 100644 --- a/test/integration/stats_integration_test.cc +++ b/test/integration/stats_integration_test.cc @@ -257,6 +257,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithFakeSymbolTable) { // 2019/09/30 8354 43310 44000 Implement transport socket match. // 2019/10/17 8537 43308 44000 add new enum value HTTP3 // 2019/10/17 8484 43340 44000 stats: add unit support to histogram + // 2019/11/01 8859 43563 44000 build: switch to libc++ by default // Note: when adjusting this value: EXPECT_MEMORY_EQ is active only in CI // 'release' builds, where we control the platform and tool-chain. So you @@ -270,7 +271,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithFakeSymbolTable) { // If you encounter a failure here, please see // https://github.com/envoyproxy/envoy/blob/master/source/docs/stats.md#stats-memory-tests // for details on how to fix. - EXPECT_MEMORY_EQ(m_per_cluster, 43340); // 104 bytes higher than a debug build. + EXPECT_MEMORY_EQ(m_per_cluster, 43563); // 104 bytes higher than a debug build. EXPECT_MEMORY_LE(m_per_cluster, 44000); } @@ -301,6 +302,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithRealSymbolTable) { // 2019/09/30 8354 34969 35000 Implement transport socket match. // 2019/10/17 8537 34966 35000 add new enum value HTTP3 // 2019/10/17 8484 34998 35000 stats: add unit support to histogram + // 2019/11/01 8859 35221 36000 build: switch to libc++ by default // Note: when adjusting this value: EXPECT_MEMORY_EQ is active only in CI // 'release' builds, where we control the platform and tool-chain. So you @@ -314,7 +316,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithRealSymbolTable) { // If you encounter a failure here, please see // https://github.com/envoyproxy/envoy/blob/master/source/docs/stats.md#stats-memory-tests // for details on how to fix. - EXPECT_MEMORY_EQ(m_per_cluster, 34998); // 104 bytes higher than a debug build. + EXPECT_MEMORY_EQ(m_per_cluster, 35221); // 104 bytes higher than a debug build. EXPECT_MEMORY_LE(m_per_cluster, 36000); } @@ -340,6 +342,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeHostSizeWithStats) { // ---------- ----- ----------------- ----- // 2019/09/09 8189 2739 3100 Initial per-host memory snapshot // 2019/09/10 8216 1283 1315 Use primitive counters for host stats + // 2019/10/01 8850 1299 1315 build: switch to libc++ by default // Note: when adjusting this value: EXPECT_MEMORY_EQ is active only in CI // 'release' builds, where we control the platform and tool-chain. So you @@ -349,7 +352,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeHostSizeWithStats) { // If you encounter a failure here, please see // https://github.com/envoyproxy/envoy/blob/master/source/docs/stats.md#stats-memory-tests // for details on how to fix. - EXPECT_MEMORY_EQ(m_per_host, 1283); + EXPECT_MEMORY_EQ(m_per_host, 1299); EXPECT_MEMORY_LE(m_per_host, 1315); } From 22bed80770749fbeeb36a6933f264cd38222582c Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Sat, 2 Nov 2019 00:16:05 +0000 Subject: [PATCH 02/14] remove stale TODO Signed-off-by: Lizan Zhou --- .bazelrc | 2 -- 1 file changed, 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index 92fbe61e9fd0..2024c6c8877a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -88,8 +88,6 @@ build:clang-msan --linkopt -fsanitize=memory build:clang-msan --copt -fsanitize-memory-track-origins=2 # Clang with libc++ -# TODO(cmluciano) fix and re-enable _LIBCPP_VERSION testing for TCMALLOC in Envoy::Stats::TestUtil::hasDeterministicMallocStats -# and update stats_integration_test with appropriate m_per_cluster value build:libc++ --config=clang build:libc++ --action_env=CXXFLAGS=-stdlib=libc++ build:libc++ --action_env=BAZEL_CXXOPTS=-stdlib=libc++ From 7660ca477293e2b70d7629acb7d6642e05b11500 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Mon, 4 Nov 2019 06:40:44 +0000 Subject: [PATCH 03/14] debug Signed-off-by: Lizan Zhou --- test/tools/config_load_check/config_load_check.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/config_load_check/config_load_check.cc b/test/tools/config_load_check/config_load_check.cc index a36e531c53b1..fa25a8a626ec 100644 --- a/test/tools/config_load_check/config_load_check.cc +++ b/test/tools/config_load_check/config_load_check.cc @@ -21,8 +21,8 @@ int main(int argc, char* argv[]) { << std::endl; return EXIT_FAILURE; } - try { + try { Envoy::Event::Libevent::Global::initialize(); Envoy::Thread::MutexBasicLockable lock; Envoy::Logger::Context logging_context(static_cast(2), From 7d4319291a29b5f1e7c6a0091009417b5a52491d Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Mon, 4 Nov 2019 07:42:03 +0000 Subject: [PATCH 04/14] debug Signed-off-by: Lizan Zhou --- .bazelrc | 2 +- bazel/envoy_internal.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index 2024c6c8877a..3d5b546fbae3 100644 --- a/.bazelrc +++ b/.bazelrc @@ -150,7 +150,7 @@ build:remote-ci --remote_cache=grpcs://remotebuildexecution.googleapis.com build:remote-ci --remote_executor=grpcs://remotebuildexecution.googleapis.com # Fuzz builds -build:asan-fuzzer --config=asan +build:asan-fuzzer --config=clang-asan build:asan-fuzzer --define=FUZZING_ENGINE=libfuzzer build:asan-fuzzer --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION build:asan-fuzzer --copt=-fsanitize=fuzzer-no-link diff --git a/bazel/envoy_internal.bzl b/bazel/envoy_internal.bzl index 06ab0d4787d1..ec6489982a0d 100644 --- a/bazel/envoy_internal.bzl +++ b/bazel/envoy_internal.bzl @@ -89,7 +89,7 @@ def envoy_select_force_libcpp(if_libcpp, default = None): def envoy_stdlib_deps(): return select({ - "@envoy//bazel:asan_build": ["@envoy//bazel:dynamic_stdlib"], +# "@envoy//bazel:asan_build": ["@envoy//bazel:dynamic_stdlib"], "@envoy//bazel:tsan_build": ["@envoy//bazel:dynamic_stdlib"], "//conditions:default": ["@envoy//bazel:static_stdlib"], }) From 43be1d7cb8b24d64750faf5ee858866e9d22c4f0 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Mon, 4 Nov 2019 07:56:00 +0000 Subject: [PATCH 05/14] debug Signed-off-by: Lizan Zhou --- bazel/envoy_internal.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/bazel/envoy_internal.bzl b/bazel/envoy_internal.bzl index ec6489982a0d..6a7e483e1ecc 100644 --- a/bazel/envoy_internal.bzl +++ b/bazel/envoy_internal.bzl @@ -89,7 +89,6 @@ def envoy_select_force_libcpp(if_libcpp, default = None): def envoy_stdlib_deps(): return select({ -# "@envoy//bazel:asan_build": ["@envoy//bazel:dynamic_stdlib"], "@envoy//bazel:tsan_build": ["@envoy//bazel:dynamic_stdlib"], "//conditions:default": ["@envoy//bazel:static_stdlib"], }) From 12a54de8d0842812e22b9a9847974f43470d0ccc Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Mon, 4 Nov 2019 09:18:50 +0000 Subject: [PATCH 06/14] tests only Signed-off-by: Lizan Zhou --- bazel/envoy_test.bzl | 3 +-- ci/do_ci.sh | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bazel/envoy_test.bzl b/bazel/envoy_test.bzl index 9e10b95e8b8c..77876b7b4c62 100644 --- a/bazel/envoy_test.bzl +++ b/bazel/envoy_test.bzl @@ -88,9 +88,8 @@ def envoy_cc_fuzz_test( test_lib_name = name + "_lib" envoy_cc_test_library( name = test_lib_name, - deps = deps + [ + deps = deps + envoy_stdlib_deps() + [ repository + "//test/fuzz:fuzz_runner_lib", - repository + "//bazel:dynamic_stdlib", ], repository = repository, tags = tags, diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 7725fe294630..fb3172da78ea 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -145,7 +145,7 @@ elif [[ "$CI_TARGET" == "bazel.debug.server_only" ]]; then exit 0 elif [[ "$CI_TARGET" == "bazel.asan" ]]; then setup_clang_toolchain - BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} -c dbg --config=clang-asan" + BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} -c dbg --config=clang-asan --build_tests_only" echo "bazel ASAN/UBSAN debug build with tests" echo "Building and testing envoy tests ${TEST_TARGETS}" bazel_with_collection test ${BAZEL_BUILD_OPTIONS} ${TEST_TARGETS} @@ -174,10 +174,10 @@ elif [[ "$CI_TARGET" == "bazel.tsan" ]]; then setup_clang_toolchain echo "bazel TSAN debug build with tests" echo "Building and testing envoy tests ${TEST_TARGETS}" - bazel_with_collection test ${BAZEL_BUILD_OPTIONS} -c dbg --config=clang-tsan ${TEST_TARGETS} + bazel_with_collection test ${BAZEL_BUILD_OPTIONS} -c dbg --config=clang-tsan --build_tests_only ${TEST_TARGETS} echo "Building and testing envoy-filter-example tests..." cd "${ENVOY_FILTER_EXAMPLE_SRCDIR}" - bazel_with_collection test ${BAZEL_BUILD_OPTIONS} -c dbg --config=clang-tsan \ + bazel_with_collection test ${BAZEL_BUILD_OPTIONS} -c dbg --config=clang-tsan --build_tests_only \ //:echo2_integration_test //http-filter-example:http_filter_integration_test //:envoy_binary_test exit 0 elif [[ "$CI_TARGET" == "bazel.dev" ]]; then From 0797cd596e600fcbfc66a33366fbca67f31d8c1b Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Mon, 4 Nov 2019 20:40:59 +0000 Subject: [PATCH 07/14] revert debug Signed-off-by: Lizan Zhou --- bazel/envoy_internal.bzl | 1 + test/tools/config_load_check/config_load_check.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bazel/envoy_internal.bzl b/bazel/envoy_internal.bzl index 573089da19ce..8a8a88ad2d0b 100644 --- a/bazel/envoy_internal.bzl +++ b/bazel/envoy_internal.bzl @@ -95,6 +95,7 @@ def envoy_select_force_libcpp(if_libcpp, default = None): def envoy_stdlib_deps(): return select({ + "@envoy//bazel:asan_build": ["@envoy//bazel:dynamic_stdlib"], "@envoy//bazel:tsan_build": ["@envoy//bazel:dynamic_stdlib"], "//conditions:default": ["@envoy//bazel:static_stdlib"], }) diff --git a/test/tools/config_load_check/config_load_check.cc b/test/tools/config_load_check/config_load_check.cc index fa25a8a626ec..a36e531c53b1 100644 --- a/test/tools/config_load_check/config_load_check.cc +++ b/test/tools/config_load_check/config_load_check.cc @@ -21,8 +21,8 @@ int main(int argc, char* argv[]) { << std::endl; return EXIT_FAILURE; } - try { + Envoy::Event::Libevent::Global::initialize(); Envoy::Thread::MutexBasicLockable lock; Envoy::Logger::Context logging_context(static_cast(2), From feffa2a77c9f82e778b11d22328943587f0f114f Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Mon, 4 Nov 2019 20:44:41 +0000 Subject: [PATCH 08/14] revert debug Signed-off-by: Lizan Zhou --- ci/do_ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index fb3172da78ea..58a87463a17f 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -177,7 +177,7 @@ elif [[ "$CI_TARGET" == "bazel.tsan" ]]; then bazel_with_collection test ${BAZEL_BUILD_OPTIONS} -c dbg --config=clang-tsan --build_tests_only ${TEST_TARGETS} echo "Building and testing envoy-filter-example tests..." cd "${ENVOY_FILTER_EXAMPLE_SRCDIR}" - bazel_with_collection test ${BAZEL_BUILD_OPTIONS} -c dbg --config=clang-tsan --build_tests_only \ + bazel_with_collection test ${BAZEL_BUILD_OPTIONS} -c dbg --config=clang-tsan \ //:echo2_integration_test //http-filter-example:http_filter_integration_test //:envoy_binary_test exit 0 elif [[ "$CI_TARGET" == "bazel.dev" ]]; then From 86b0f67c769ee0d4ed30973259dc0566924308a0 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Tue, 5 Nov 2019 04:32:05 +0000 Subject: [PATCH 09/14] allow overridding Signed-off-by: Lizan Zhou --- .azure-pipelines/linux.yml | 2 +- ci/build_setup.sh | 30 +++++++++++++++++------------- ci/do_ci.sh | 1 + 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.azure-pipelines/linux.yml b/.azure-pipelines/linux.yml index 001b2da1dd79..ba05472720c4 100644 --- a/.azure-pipelines/linux.yml +++ b/.azure-pipelines/linux.yml @@ -86,7 +86,7 @@ jobs: env: ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory) ENVOY_RBE: "true" - BAZEL_BUILD_EXTRA_OPTIONS: "--config=remote-ci --config=remote --jobs=$(RbeJobs) --curses=no" + BAZEL_BUILD_EXTRA_OPTIONS: "--config=remote-ci --jobs=$(RbeJobs) --curses=no" BAZEL_REMOTE_CACHE: grpcs://remotebuildexecution.googleapis.com BAZEL_REMOTE_INSTANCE: projects/envoy-ci/instances/default_instance GCP_SERVICE_ACCOUNT_KEY: $(GcpServiceAccountKey) diff --git a/ci/build_setup.sh b/ci/build_setup.sh index bbe2a9d93f1a..13dc119e9e05 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -11,32 +11,36 @@ export PPROF_PATH=/thirdparty_build/bin/pprof echo "ENVOY_SRCDIR=${ENVOY_SRCDIR}" function setup_gcc_toolchain() { + if [[ ! -z "${ENVOY_STDLIB}" && "${ENVOY_STDLIB}" != "libstdc++" ]]; then + echo "gcc toolchain doesn't support ${ENVOY_STDLIB}." + exit 1 + fi if [[ -z "${ENVOY_RBE}" ]]; then export CC=gcc export CXX=g++ export BAZEL_COMPILER=gcc echo "$CC/$CXX toolchain configured" else - export BAZEL_BUILD_OPTIONS="--config=rbe-toolchain-gcc ${BAZEL_BUILD_OPTIONS}" - fi -} - -function setup_clang_libstdcxx_toolchain() { - if [[ -z "${ENVOY_RBE}" ]]; then - export BAZEL_BUILD_OPTIONS="--config=clang ${BAZEL_BUILD_OPTIONS}" - else - export BAZEL_BUILD_OPTIONS="--config=rbe-toolchain-clang ${BAZEL_BUILD_OPTIONS}" + export BAZEL_BUILD_OPTIONS="--config=remote-gcc ${BAZEL_BUILD_OPTIONS}" fi - echo "clang toolchain configured" } function setup_clang_toolchain() { + ENVOY_STDLIB="${ENVOY_STDLIB:-libc++}" if [[ -z "${ENVOY_RBE}" ]]; then - export BAZEL_BUILD_OPTIONS="--config=libc++ ${BAZEL_BUILD_OPTIONS}" + if [[ "${ENVOY_STDLIB}" == "libc++" ]]; + export BAZEL_BUILD_OPTIONS="--config=libc++ ${BAZEL_BUILD_OPTIONS}" + else + export BAZEL_BUILD_OPTIONS="--config=clang ${BAZEL_BUILD_OPTIONS}" + fi else - export BAZEL_BUILD_OPTIONS="--config=rbe-toolchain-clang-libc++ ${BAZEL_BUILD_OPTIONS}" + if [[ "${ENVOY_STDLIB}" == "libc++" ]]; + export BAZEL_BUILD_OPTIONS="--config=remote-clang-libc++ ${BAZEL_BUILD_OPTIONS}" + else + export BAZEL_BUILD_OPTIONS="--config=remote-clang ${BAZEL_BUILD_OPTIONS}" + fi fi - echo "clang toolchain with libc++ configured" + echo "clang toolchain with ${ENVOY_STDLIB} configured" } # Create a fake home. Python site libs tries to do getpwuid(3) if we don't and the CI diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 58a87463a17f..8a94eca98828 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -204,6 +204,7 @@ elif [[ "$CI_TARGET" == "bazel.compile_time_options" ]]; then --define path_normalization_by_default=true \ --define deprecated_features=disabled \ " + ENVOY_STDLIB="${ENVOY_STDLIB:-libstdc++}" setup_clang_libstdcxx_toolchain # This doesn't go into CI but is available for developer convenience. echo "bazel with different compiletime options build with tests..." From 1c4b8a759be35a599b72a3ce99a293a96d3ad900 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Tue, 5 Nov 2019 04:50:07 +0000 Subject: [PATCH 10/14] docs Signed-off-by: Lizan Zhou --- bazel/README.md | 15 ++++----------- ci/README.md | 6 ++++++ ci/run_envoy_docker.sh | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/bazel/README.md b/bazel/README.md index a4aea1f5178e..263a7dc50bbe 100644 --- a/bazel/README.md +++ b/bazel/README.md @@ -149,20 +149,13 @@ set different options. See below to configure test IP versions. ## Linking against libc++ on Linux -To link Envoy against libc++, use the following commands: +To link Envoy against libc++, follow the [quick start](#quick-start-bazel-build-for-developers) to setup Clang+LLVM and run: ``` -export CC=clang -export CXX=clang++ bazel build --config=libc++ //source/exe:envoy-static ``` -Note: this assumes that both: clang compiler and libc++ library are installed in the system, -and that `clang` and `clang++` are available in `$PATH`. On some systems, you might need to -include them in the search path, e.g. `export PATH=/usr/lib/llvm-9/bin:$PATH`. -You might also need to ensure libc++ is installed correctly on your system, e.g. on Ubuntu this -might look like `sudo apt-get install libc++abi-9-dev libc++-9-dev`. - -Note: this configuration currently doesn't work with Remote Execution or Docker sandbox. +Or use our configuration with Remote Execution or Docker sandbox, pass `--config=remote-clang-libc++` or +`--config=docker-clang-libc++` respectively. ## Using a compiler toolchain in a non-standard location @@ -178,7 +171,7 @@ for more details. ## Supported compiler versions We now require Clang >= 5.0 due to known issues with std::string thread safety and C++14 support. GCC >= 7 is also -known to work. Currently the CI is running with Clang 8. +known to work. Currently the CI is running with Clang 9. ## Clang STL debug symbols diff --git a/ci/README.md b/ci/README.md index 496a5740976a..ff60702c5a8e 100644 --- a/ci/README.md +++ b/ci/README.md @@ -31,6 +31,12 @@ repository. We use the Clang compiler for all CI runs with tests. We have an additional CI run with GCC which builds binary only. +# C++ standard library + +As of November 2019 after [#8859](https://github.com/envoyproxy/envoy/pull/8859) the official released binary is +[linked against libc++ on Linux](https://github.com/envoyproxy/envoy/blob/master/bazel/README.md#linking-against-libc-on-linux). +To override the C++ standard library in your build, set environment variable `ENVOY_STDLIB` to `libstdc++` or `libc++`. + # Building and running tests as a developer An example basic invocation to build a developer version of the Envoy static binary (using the Bazel `fastbuild` type) is: diff --git a/ci/run_envoy_docker.sh b/ci/run_envoy_docker.sh index 5cf5acb2ef75..301d5d67ccd1 100755 --- a/ci/run_envoy_docker.sh +++ b/ci/run_envoy_docker.sh @@ -24,7 +24,7 @@ mkdir -p "${ENVOY_DOCKER_BUILD_DIR}" # Since we specify an explicit hash, docker-run will pull from the remote repo if missing. docker run --rm ${DOCKER_TTY_OPTION} -e HTTP_PROXY=${http_proxy} -e HTTPS_PROXY=${https_proxy} \ -u "${USER}":"${USER_GROUP}" -v "${ENVOY_DOCKER_BUILD_DIR}":/build -v /var/run/docker.sock:/var/run/docker.sock ${GIT_VOLUME_OPTION} \ - -e BAZEL_BUILD_EXTRA_OPTIONS -e BAZEL_EXTRA_TEST_OPTIONS -e BAZEL_REMOTE_CACHE \ + -e BAZEL_BUILD_EXTRA_OPTIONS -e BAZEL_EXTRA_TEST_OPTIONS -e BAZEL_REMOTE_CACHE -e ENVOY_STDLIB \ -e BAZEL_REMOTE_INSTANCE -e GCP_SERVICE_ACCOUNT_KEY -e NUM_CPUS -e ENVOY_RBE -e FUZZIT_API_KEY \ -v "$PWD":/source --cap-add SYS_PTRACE --cap-add NET_RAW --cap-add NET_ADMIN "${IMAGE_NAME}":"${IMAGE_ID}" \ /bin/bash -lc "groupadd --gid $(id -g) -f envoygroup && useradd -o --uid $(id -u) --gid $(id -g) --no-create-home \ From 68c5f0c46e4b8311124fb73d396eba59ddec1327 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Tue, 5 Nov 2019 04:56:42 +0000 Subject: [PATCH 11/14] fix Signed-off-by: Lizan Zhou --- ci/build_setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build_setup.sh b/ci/build_setup.sh index 13dc119e9e05..ba3d1fe586db 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -28,13 +28,13 @@ function setup_gcc_toolchain() { function setup_clang_toolchain() { ENVOY_STDLIB="${ENVOY_STDLIB:-libc++}" if [[ -z "${ENVOY_RBE}" ]]; then - if [[ "${ENVOY_STDLIB}" == "libc++" ]]; + if [[ "${ENVOY_STDLIB}" == "libc++" ]]; then export BAZEL_BUILD_OPTIONS="--config=libc++ ${BAZEL_BUILD_OPTIONS}" else export BAZEL_BUILD_OPTIONS="--config=clang ${BAZEL_BUILD_OPTIONS}" fi else - if [[ "${ENVOY_STDLIB}" == "libc++" ]]; + if [[ "${ENVOY_STDLIB}" == "libc++" ]]; then export BAZEL_BUILD_OPTIONS="--config=remote-clang-libc++ ${BAZEL_BUILD_OPTIONS}" else export BAZEL_BUILD_OPTIONS="--config=remote-clang ${BAZEL_BUILD_OPTIONS}" From 98ce9d97183ebe583af675f3bfdbee2a304b51b3 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Tue, 5 Nov 2019 07:54:21 +0000 Subject: [PATCH 12/14] fix Signed-off-by: Lizan Zhou --- ci/do_ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 8a94eca98828..cfbfa81d9754 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -205,7 +205,7 @@ elif [[ "$CI_TARGET" == "bazel.compile_time_options" ]]; then --define deprecated_features=disabled \ " ENVOY_STDLIB="${ENVOY_STDLIB:-libstdc++}" - setup_clang_libstdcxx_toolchain + setup_clang_toolchain # This doesn't go into CI but is available for developer convenience. echo "bazel with different compiletime options build with tests..." From 8055bad613121f83c6722effc703267693b6f4a7 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 6 Nov 2019 06:16:59 +0000 Subject: [PATCH 13/14] propagate build image to fuzzit Signed-off-by: Lizan Zhou --- bazel/fuzzit_wrapper.sh | 4 ++-- ci/do_ci.sh | 2 +- ci/run_envoy_docker.sh | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bazel/fuzzit_wrapper.sh b/bazel/fuzzit_wrapper.sh index 7c69f7879256..5f66247bb867 100755 --- a/bazel/fuzzit_wrapper.sh +++ b/bazel/fuzzit_wrapper.sh @@ -13,7 +13,7 @@ if [[ ! -z "${FUZZIT_API_KEY}" ]]; then "${FUZZIT}" create target --skip-if-exists --public-corpus envoyproxy/"${FUZZIT_TARGET_NAME}" # Run fuzzing first so this is not affected by local-regression timeout - "${FUZZIT}" create job --skip-if-not-exists --type fuzzing envoyproxy/"${FUZZIT_TARGET_NAME}" "${FUZZER_BINARY}" + "${FUZZIT}" create job --skip-if-not-exists --host "${ENVOY_BUILD_IMAGE}" --type fuzzing envoyproxy/"${FUZZIT_TARGET_NAME}" "${FUZZER_BINARY}" fi -"${FUZZIT}" create job --skip-if-not-exists --type local-regression envoyproxy/"${FUZZIT_TARGET_NAME}" "${FUZZER_BINARY}" +"${FUZZIT}" create job --skip-if-not-exists --host "${ENVOY_BUILD_IMAGE}" --type local-regression envoyproxy/"${FUZZIT_TARGET_NAME}" "${FUZZER_BINARY}" diff --git a/ci/do_ci.sh b/ci/do_ci.sh index cfbfa81d9754..78a1a78d1dc6 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -278,7 +278,7 @@ elif [[ "$CI_TARGET" == "bazel.fuzzit" ]]; then echo "bazel ASAN libFuzzer build with fuzz tests ${FUZZ_TEST_TARGETS}" echo "Building fuzzers and run under Fuzzit" bazel_with_collection test ${BAZEL_BUILD_OPTIONS} --config=asan-fuzzer ${FUZZ_TEST_TARGETS} \ - --test_env=FUZZIT_API_KEY --test_timeout=1200 --run_under=//bazel:fuzzit_wrapper + --test_env=FUZZIT_API_KEY --test_env=ENVOY_BUILD_IMAGE --test_timeout=1200 --run_under=//bazel:fuzzit_wrapper exit 0 elif [[ "$CI_TARGET" == "fix_format" ]]; then # proto_format.sh needs to build protobuf. diff --git a/ci/run_envoy_docker.sh b/ci/run_envoy_docker.sh index 301d5d67ccd1..219a86123686 100755 --- a/ci/run_envoy_docker.sh +++ b/ci/run_envoy_docker.sh @@ -20,12 +20,14 @@ USER_GROUP=root [[ -t 1 ]] && DOCKER_TTY_OPTION=-it +export ENVOY_BUILD_IMAGE="${IMAGE_NAME}:${IMAGE_ID}" + mkdir -p "${ENVOY_DOCKER_BUILD_DIR}" # Since we specify an explicit hash, docker-run will pull from the remote repo if missing. docker run --rm ${DOCKER_TTY_OPTION} -e HTTP_PROXY=${http_proxy} -e HTTPS_PROXY=${https_proxy} \ -u "${USER}":"${USER_GROUP}" -v "${ENVOY_DOCKER_BUILD_DIR}":/build -v /var/run/docker.sock:/var/run/docker.sock ${GIT_VOLUME_OPTION} \ -e BAZEL_BUILD_EXTRA_OPTIONS -e BAZEL_EXTRA_TEST_OPTIONS -e BAZEL_REMOTE_CACHE -e ENVOY_STDLIB \ - -e BAZEL_REMOTE_INSTANCE -e GCP_SERVICE_ACCOUNT_KEY -e NUM_CPUS -e ENVOY_RBE -e FUZZIT_API_KEY \ - -v "$PWD":/source --cap-add SYS_PTRACE --cap-add NET_RAW --cap-add NET_ADMIN "${IMAGE_NAME}":"${IMAGE_ID}" \ + -e BAZEL_REMOTE_INSTANCE -e GCP_SERVICE_ACCOUNT_KEY -e NUM_CPUS -e ENVOY_RBE -e FUZZIT_API_KEY -e ENVOY_BUILD_IMAGE \ + -v "$PWD":/source --cap-add SYS_PTRACE --cap-add NET_RAW --cap-add NET_ADMIN "${ENVOY_BUILD_IMAGE}" \ /bin/bash -lc "groupadd --gid $(id -g) -f envoygroup && useradd -o --uid $(id -u) --gid $(id -g) --no-create-home \ --home-dir /source envoybuild && usermod -a -G pcap envoybuild && su envoybuild -c \"cd source && $*\"" From 90af0f8839e004d5e2f9530e0ddcb7c94a889f08 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 6 Nov 2019 18:21:37 +0000 Subject: [PATCH 14/14] docs Signed-off-by: Lizan Zhou --- bazel/README.md | 2 ++ ci/README.md | 3 ++- docs/root/intro/version_history.rst | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bazel/README.md b/bazel/README.md index 263a7dc50bbe..ff50a66da8bb 100644 --- a/bazel/README.md +++ b/bazel/README.md @@ -157,6 +157,8 @@ bazel build --config=libc++ //source/exe:envoy-static Or use our configuration with Remote Execution or Docker sandbox, pass `--config=remote-clang-libc++` or `--config=docker-clang-libc++` respectively. +If you want to make libc++ as default, add a line `build --config=libc++` to the `user.bazelrc` file in Envoy source root. + ## Using a compiler toolchain in a non-standard location By setting the `CC` and `LD_LIBRARY_PATH` in the environment that Bazel executes from as diff --git a/ci/README.md b/ci/README.md index ff60702c5a8e..0fad59a89b48 100644 --- a/ci/README.md +++ b/ci/README.md @@ -35,7 +35,8 @@ We use the Clang compiler for all CI runs with tests. We have an additional CI r As of November 2019 after [#8859](https://github.com/envoyproxy/envoy/pull/8859) the official released binary is [linked against libc++ on Linux](https://github.com/envoyproxy/envoy/blob/master/bazel/README.md#linking-against-libc-on-linux). -To override the C++ standard library in your build, set environment variable `ENVOY_STDLIB` to `libstdc++` or `libc++`. +To override the C++ standard library in your build, set environment variable `ENVOY_STDLIB` to `libstdc++` or `libc++` and +run `./ci/do_ci.sh` as described below. # Building and running tests as a developer diff --git a/docs/root/intro/version_history.rst b/docs/root/intro/version_history.rst index a6bf8c8c2635..5671dbcf55fd 100644 --- a/docs/root/intro/version_history.rst +++ b/docs/root/intro/version_history.rst @@ -3,9 +3,9 @@ Version history 1.13.0 (pending) ================ -* build: official released binary is now built against libc++. * access log: added FILTER_STATE :ref:`access log formatters ` and gRPC access logger. * api: remove all support for v1 +* build: official released binary is now built against libc++. * redis: performance improvement for larger split commands by avoiding string copies. * tcp_proxy: added :ref:`hash_policy` * tls: remove TLS 1.0 and 1.1 from client defaults