From 2fc643b69c3acb15c2d674c341620422a7081bf9 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Wed, 13 Jun 2018 03:41:13 +0000 Subject: [PATCH] Update clang to 6.0 and use it for release binaries. Signed-off-by: Piotr Sikora --- .circleci/config.yml | 14 ++++------ Makefile | 27 ++++++++++++++----- script/check-style | 4 +-- script/pre-commit | 2 +- script/release-binary | 17 ++++++++---- src/envoy/http/authn/http_filter_test.cc | 2 +- .../http/authn/origin_authenticator_test.cc | 2 +- .../http/authn/peer_authenticator_test.cc | 2 +- .../http/jwt_auth/jwt_authenticator_test.cc | 2 +- .../http/jwt_auth/token_extractor_test.cc | 2 +- .../api_spec/http_api_spec_parser_test.cc | 2 +- .../control/http/attributes_builder_test.cc | 2 +- .../control/http/request_handler_impl_test.cc | 2 +- .../control/tcp/attributes_builder_test.cc | 2 +- .../control/tcp/request_handler_impl_test.cc | 2 +- src/istio/mixerclient/client_impl_test.cc | 2 +- src/istio/mixerclient/quota_cache_test.cc | 2 +- src/istio/mixerclient/report_batch_test.cc | 2 +- tools/bazel.rc.ci | 1 - tools/bazel.rc.cloudbuilder | 1 - 20 files changed, 53 insertions(+), 39 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dbfb6e1eec3..db59eae9322 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,13 +3,11 @@ version: 2 jobs: build: docker: - - image: istio/ci:go1.9-bazel0.11 + - image: istio/ci:go1.10-bazel0.15-clang6.0 environment: - BAZEL_TEST_ARGS: "--test_env=ENVOY_IP_TEST_VERSIONS=v4only --test_output=all" resource_class: xlarge steps: - - run: curl -Lo /tmp/bazel.deb https://github.com/bazelbuild/bazel/releases/download/0.15.2/bazel_0.15.2-linux-x86_64.deb && sudo dpkg -i /tmp/bazel.deb && rm /tmp/bazel.deb - - run: sudo apt-get update && sudo apt-get install -y ninja-build pkg-config - checkout - restore_cache: keys: @@ -32,13 +30,11 @@ jobs: destination: /proxy/bin linux_asan: docker: - - image: istio/ci:go1.9-bazel0.11 + - image: istio/ci:go1.10-bazel0.15-clang6.0 environment: - BAZEL_TEST_ARGS: "--test_env=ENVOY_IP_TEST_VERSIONS=v4only --test_output=all" resource_class: xlarge steps: - - run: curl -Lo /tmp/bazel.deb https://github.com/bazelbuild/bazel/releases/download/0.15.2/bazel_0.15.2-linux-x86_64.deb && sudo dpkg -i /tmp/bazel.deb && rm /tmp/bazel.deb - - run: sudo apt-get update && sudo apt-get install -y ninja-build pkg-config - checkout - restore_cache: keys: @@ -53,13 +49,11 @@ jobs: - /home/circleci/.cache/bazel linux_tsan: docker: - - image: istio/ci:go1.9-bazel0.11 + - image: istio/ci:go1.10-bazel0.15-clang6.0 environment: - BAZEL_TEST_ARGS: "--test_env=ENVOY_IP_TEST_VERSIONS=v4only --test_output=all" resource_class: xlarge steps: - - run: curl -Lo /tmp/bazel.deb https://github.com/bazelbuild/bazel/releases/download/0.15.2/bazel_0.15.2-linux-x86_64.deb && sudo dpkg -i /tmp/bazel.deb && rm /tmp/bazel.deb - - run: sudo apt-get update && sudo apt-get install -y ninja-build pkg-config - checkout - restore_cache: keys: @@ -78,6 +72,8 @@ jobs: environment: - BAZEL_STARTUP_ARGS: "--output_base /Users/distiller/.cache/bazel" - BAZEL_TEST_ARGS: "--test_env=ENVOY_IP_TEST_VERSIONS=v4only --test_output=all" + - CC: clang + - CXX: clang++ steps: - run: sudo ntpdate -vu time.apple.com - run: brew install bazel cmake coreutils go libtool ninja wget diff --git a/Makefile b/Makefile index a64c4227219..501d2ebb14f 100644 --- a/Makefile +++ b/Makefile @@ -17,30 +17,42 @@ TOP := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) SHELL := /bin/bash LOCAL_ARTIFACTS_DIR ?= $(abspath artifacts) ARTIFACTS_DIR ?= $(LOCAL_ARTIFACTS_DIR) -BAZEL_STARTUP_ARGS ?= --batch +BAZEL_STARTUP_ARGS ?= BAZEL_BUILD_ARGS ?= BAZEL_TEST_ARGS ?= HUB ?= TAG ?= +ifeq "$(origin CC)" "default" +CC := clang-6.0 +endif +ifeq "$(origin CXX)" "default" +CXX := clang++-6.0 +endif build: - @bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) //... + CC=$(CC) CXX=$(CXX) bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) //... + @bazel shutdown # Build only envoy - fast build_envoy: - bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) //src/envoy:envoy + CC=$(CC) CXX=$(CXX) bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) //src/envoy:envoy + @bazel shutdown clean: @bazel clean + @bazel shutdown test: - bazel $(BAZEL_STARTUP_ARGS) test $(BAZEL_TEST_ARGS) //... + CC=$(CC) CXX=$(CXX) bazel $(BAZEL_STARTUP_ARGS) test $(BAZEL_TEST_ARGS) //... + @bazel shutdown test_asan: - CC=clang-5.0 CXX=clang++-5.0 bazel $(BAZEL_STARTUP_ARGS) test $(BAZEL_TEST_ARGS) --config=clang-asan //... + CC=$(CC) CXX=$(CXX) bazel $(BAZEL_STARTUP_ARGS) test $(BAZEL_TEST_ARGS) --config=clang-asan //... + @bazel shutdown test_tsan: - CC=clang-5.0 CXX=clang++-5.0 bazel $(BAZEL_STARTUP_ARGS) test $(BAZEL_TEST_ARGS) --config=clang-tsan //... + CC=$(CC) CXX=$(CXX) bazel $(BAZEL_STARTUP_ARGS) test $(BAZEL_TEST_ARGS) --config=clang-tsan //... + @bazel shutdown check: @script/check-license-headers @@ -50,7 +62,8 @@ artifacts: build @script/push-debian.sh -c opt -p $(ARTIFACTS_DIR) deb: - @bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) //tools/deb:istio-proxy + CC=$(CC) CXX=$(CXX) bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) //tools/deb:istio-proxy + @bazel shutdown .PHONY: build clean test check artifacts diff --git a/script/check-style b/script/check-style index 53cada67c79..d9cf3fce522 100755 --- a/script/check-style +++ b/script/check-style @@ -18,7 +18,7 @@ # ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -CLANG_VERSION_REQUIRED="5.0.0" +CLANG_VERSION_REQUIRED="6.0.0" CLANG_FORMAT=$(which clang-format-${CLANG_VERSION_REQUIRED%.*}) if [[ ! -x "${CLANG_FORMAT}" ]]; then # Install required clang version to a folder and cache it. @@ -28,7 +28,7 @@ if [[ ! -x "${CLANG_FORMAT}" ]]; then if [ "$(uname)" == "Darwin" ]; then CLANG_BIN="x86_64-apple-darwin.tar.xz" elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then - CLANG_BIN="linux-x86_64-ubuntu14.04.tar.xz" + CLANG_BIN="x86_64-linux-gnu-ubuntu-14.04.tar.xz" else echo "Unsupported environment." ; exit 1 ; fi diff --git a/script/pre-commit b/script/pre-commit index e0a5db52927..a87c08396c7 100755 --- a/script/pre-commit +++ b/script/pre-commit @@ -38,7 +38,7 @@ if [[ ! -x "${CLANG_FORMAT}" ]]; then fi CLANG_FORMAT_VERSION="$(${CLANG_FORMAT} -version | cut -d ' ' -f 3)" -CLANG_FORMAT_VERSION_REQUIRED="5.0.0" +CLANG_FORMAT_VERSION_REQUIRED="6.0.0" if ! [[ "${CLANG_FORMAT_VERSION}" =~ "${CLANG_FORMAT_VERSION_REQUIRED}" ]]; then echo "Skipping: clang-format ${CLANG_FORMAT_VERSION_REQUIRED} required." exit 0 diff --git a/script/release-binary b/script/release-binary index cf5dc5385ab..ebde3fc43c3 100755 --- a/script/release-binary +++ b/script/release-binary @@ -17,6 +17,11 @@ ################################################################################ # set -ex + +# Use clang for the release builds. +CC=${CC:-clang-6.0} +CXX=${CXX:-clang++-6.0} + # The bucket name to store proxy binary DST="gs://istio-build/proxy" @@ -54,7 +59,7 @@ gsutil stat "${DST}/${BINARY_NAME}" \ || echo 'Building a new binary.' # Build the release binary with symbol -bazel --batch build --config=release-symbol //src/envoy:envoy_tar +CC=${CC} CXX=${CXX} bazel build --config=release-symbol //src/envoy:envoy_tar BAZEL_TARGET="bazel-bin/src/envoy/envoy_tar.tar.gz" cp -f "${BAZEL_TARGET}" "${BINARY_NAME}" sha256sum "${BINARY_NAME}" > "${SHA256_NAME}" @@ -67,7 +72,7 @@ BINARY_NAME="envoy-alpha-${SHA}.tar.gz" SHA256_NAME="envoy-alpha-${SHA}.sha256" # Build the release binary -bazel --batch build --config=release //src/envoy:envoy_tar +CC=${CC} CXX=${CXX} bazel build --config=release //src/envoy:envoy_tar BAZEL_TARGET="bazel-bin/src/envoy/envoy_tar.tar.gz" cp -f "${BAZEL_TARGET}" "${BINARY_NAME}" sha256sum "${BINARY_NAME}" > "${SHA256_NAME}" @@ -78,7 +83,7 @@ gsutil cp "${BINARY_NAME}" "${SHA256_NAME}" "${DST}/" BINARY_NAME="istio-proxy-${SHA}.deb" SHA256_NAME="istio-proxy-${SHA}.sha256" -bazel --batch build --config=release //tools/deb:istio-proxy +CC=${CC} CXX=${CXX} bazel build --config=release //tools/deb:istio-proxy BAZEL_TARGET="bazel-bin/tools/deb/istio-proxy.deb" cp -f "${BAZEL_TARGET}" "${BINARY_NAME}" sha256sum "${BINARY_NAME}" > "${SHA256_NAME}" @@ -91,7 +96,7 @@ gsutil cp "${BINARY_NAME}" "${SHA256_NAME}" "${DST}/" # Build the debug binary BINARY_NAME="envoy-debug-${SHA}.tar.gz" SHA256_NAME="envoy-debug-${SHA}.sha256" -bazel --batch build -c dbg //src/envoy:envoy_tar +CC=${CC} CXX=${CXX} bazel build -c dbg //src/envoy:envoy_tar BAZEL_TARGET="bazel-bin/src/envoy/envoy_tar.tar.gz" cp -f "${BAZEL_TARGET}" "${BINARY_NAME}" sha256sum "${BINARY_NAME}" > "${SHA256_NAME}" @@ -102,7 +107,7 @@ gsutil cp "${BINARY_NAME}" "${SHA256_NAME}" "${DST}/" BINARY_NAME="istio-proxy-debug-${SHA}.deb" SHA256_NAME="istio-proxy-debug-${SHA}.sha256" -bazel --batch build -c dbg //tools/deb:istio-proxy +CC=${CC} CXX=${CXX} bazel build -c dbg //tools/deb:istio-proxy BAZEL_TARGET="bazel-bin/tools/deb/istio-proxy.deb" cp -f "${BAZEL_TARGET}" "${BINARY_NAME}" sha256sum "${BINARY_NAME}" > "${SHA256_NAME}" @@ -110,3 +115,5 @@ sha256sum "${BINARY_NAME}" > "${SHA256_NAME}" # Copy it to the bucket. echo "Copying ${BINARY_NAME} ${SHA256_NAME} to ${DST}/" gsutil cp "${BINARY_NAME}" "${SHA256_NAME}" "${DST}/" + +bazel shutdown diff --git a/src/envoy/http/authn/http_filter_test.cc b/src/envoy/http/authn/http_filter_test.cc index ae529f9d7d1..08376bfb9a3 100644 --- a/src/envoy/http/authn/http_filter_test.cc +++ b/src/envoy/http/authn/http_filter_test.cc @@ -31,12 +31,12 @@ using Envoy::Http::Istio::AuthN::FilterContext; using istio::authn::Payload; using istio::authn::Result; using istio::envoy::config::filter::http::authn::v2alpha1::FilterConfig; +using testing::_; using testing::AtLeast; using testing::Invoke; using testing::NiceMock; using testing::ReturnRef; using testing::StrictMock; -using testing::_; namespace iaapi = istio::authentication::v1alpha1; diff --git a/src/envoy/http/authn/origin_authenticator_test.cc b/src/envoy/http/authn/origin_authenticator_test.cc index 0a4211692f0..a2a2cd7e858 100644 --- a/src/envoy/http/authn/origin_authenticator_test.cc +++ b/src/envoy/http/authn/origin_authenticator_test.cc @@ -27,13 +27,13 @@ namespace iaapi = istio::authentication::v1alpha1; using istio::authn::Payload; using istio::authn::Result; +using testing::_; using testing::DoAll; using testing::MockFunction; using testing::NiceMock; using testing::Return; using testing::SetArgPointee; using testing::StrictMock; -using testing::_; namespace Envoy { namespace Http { diff --git a/src/envoy/http/authn/peer_authenticator_test.cc b/src/envoy/http/authn/peer_authenticator_test.cc index 60f04a827ec..cce09dbdc99 100644 --- a/src/envoy/http/authn/peer_authenticator_test.cc +++ b/src/envoy/http/authn/peer_authenticator_test.cc @@ -26,13 +26,13 @@ namespace iaapi = istio::authentication::v1alpha1; using istio::authn::Payload; +using testing::_; using testing::DoAll; using testing::MockFunction; using testing::NiceMock; using testing::Return; using testing::SetArgPointee; using testing::StrictMock; -using testing::_; namespace Envoy { namespace Http { diff --git a/src/envoy/http/jwt_auth/jwt_authenticator_test.cc b/src/envoy/http/jwt_auth/jwt_authenticator_test.cc index e3acc734f89..fd35224e7fe 100644 --- a/src/envoy/http/jwt_auth/jwt_authenticator_test.cc +++ b/src/envoy/http/jwt_auth/jwt_authenticator_test.cc @@ -22,9 +22,9 @@ using ::istio::envoy::config::filter::http::jwt_auth::v2alpha1:: JwtAuthentication; +using ::testing::_; using ::testing::Invoke; using ::testing::NiceMock; -using ::testing::_; namespace Envoy { namespace Http { diff --git a/src/envoy/http/jwt_auth/token_extractor_test.cc b/src/envoy/http/jwt_auth/token_extractor_test.cc index f4befee63b3..8c5dac0d69f 100644 --- a/src/envoy/http/jwt_auth/token_extractor_test.cc +++ b/src/envoy/http/jwt_auth/token_extractor_test.cc @@ -19,9 +19,9 @@ using ::istio::envoy::config::filter::http::jwt_auth::v2alpha1:: JwtAuthentication; +using ::testing::_; using ::testing::Invoke; using ::testing::NiceMock; -using ::testing::_; namespace Envoy { namespace Http { diff --git a/src/istio/api_spec/http_api_spec_parser_test.cc b/src/istio/api_spec/http_api_spec_parser_test.cc index ff7a409a066..db46b2acbef 100644 --- a/src/istio/api_spec/http_api_spec_parser_test.cc +++ b/src/istio/api_spec/http_api_spec_parser_test.cc @@ -27,8 +27,8 @@ using ::istio::mixer::v1::Attributes; using ::istio::mixer::v1::config::client::HTTPAPISpec; using ::istio::utils::AttributesBuilder; -using ::testing::Invoke; using ::testing::_; +using ::testing::Invoke; namespace istio { namespace api_spec { diff --git a/src/istio/control/http/attributes_builder_test.cc b/src/istio/control/http/attributes_builder_test.cc index d0f6bfa00ec..236731b86c4 100644 --- a/src/istio/control/http/attributes_builder_test.cc +++ b/src/istio/control/http/attributes_builder_test.cc @@ -29,8 +29,8 @@ using ::google::protobuf::util::MessageDifferencer; using ::istio::mixer::v1::Attributes; using ::istio::mixer::v1::Attributes_StringMap; -using ::testing::Invoke; using ::testing::_; +using ::testing::Invoke; namespace istio { namespace control { diff --git a/src/istio/control/http/request_handler_impl_test.cc b/src/istio/control/http/request_handler_impl_test.cc index ba0f436687b..a541666d00e 100644 --- a/src/istio/control/http/request_handler_impl_test.cc +++ b/src/istio/control/http/request_handler_impl_test.cc @@ -35,8 +35,8 @@ using ::istio::mixerclient::MixerClient; using ::istio::mixerclient::TransportCheckFunc; using ::istio::quota_config::Requirement; -using ::testing::Invoke; using ::testing::_; +using ::testing::Invoke; namespace istio { namespace control { diff --git a/src/istio/control/tcp/attributes_builder_test.cc b/src/istio/control/tcp/attributes_builder_test.cc index d215ab8b8c7..52ee3a984a2 100644 --- a/src/istio/control/tcp/attributes_builder_test.cc +++ b/src/istio/control/tcp/attributes_builder_test.cc @@ -26,9 +26,9 @@ using ::google::protobuf::TextFormat; using ::google::protobuf::util::MessageDifferencer; +using ::testing::_; using ::testing::Invoke; using ::testing::Return; -using ::testing::_; namespace istio { namespace control { diff --git a/src/istio/control/tcp/request_handler_impl_test.cc b/src/istio/control/tcp/request_handler_impl_test.cc index 9f978b171ce..259fd06d7ce 100644 --- a/src/istio/control/tcp/request_handler_impl_test.cc +++ b/src/istio/control/tcp/request_handler_impl_test.cc @@ -31,8 +31,8 @@ using ::istio::mixerclient::MixerClient; using ::istio::mixerclient::TransportCheckFunc; using ::istio::quota_config::Requirement; -using ::testing::Invoke; using ::testing::_; +using ::testing::Invoke; namespace istio { namespace control { diff --git a/src/istio/mixerclient/client_impl_test.cc b/src/istio/mixerclient/client_impl_test.cc index f15022239ce..ee38af82753 100644 --- a/src/istio/mixerclient/client_impl_test.cc +++ b/src/istio/mixerclient/client_impl_test.cc @@ -27,8 +27,8 @@ using ::istio::mixer::v1::CheckRequest; using ::istio::mixer::v1::CheckResponse; using ::istio::mixerclient::CheckResponseInfo; using ::istio::quota_config::Requirement; -using ::testing::Invoke; using ::testing::_; +using ::testing::Invoke; namespace istio { namespace mixerclient { diff --git a/src/istio/mixerclient/quota_cache_test.cc b/src/istio/mixerclient/quota_cache_test.cc index 9d613db8874..9f691a3dd19 100644 --- a/src/istio/mixerclient/quota_cache_test.cc +++ b/src/istio/mixerclient/quota_cache_test.cc @@ -27,8 +27,8 @@ using ::istio::mixer::v1::CheckRequest; using ::istio::mixer::v1::CheckResponse; using ::istio::mixer::v1::ReferencedAttributes; using ::istio::quota_config::Requirement; -using ::testing::Invoke; using ::testing::_; +using ::testing::Invoke; namespace istio { namespace mixerclient { diff --git a/src/istio/mixerclient/report_batch_test.cc b/src/istio/mixerclient/report_batch_test.cc index aec33ab251b..8893d8e4535 100644 --- a/src/istio/mixerclient/report_batch_test.cc +++ b/src/istio/mixerclient/report_batch_test.cc @@ -23,8 +23,8 @@ using ::google::protobuf::util::error::Code; using ::istio::mixer::v1::Attributes; using ::istio::mixer::v1::ReportRequest; using ::istio::mixer::v1::ReportResponse; -using ::testing::Invoke; using ::testing::_; +using ::testing::Invoke; namespace istio { namespace mixerclient { diff --git a/tools/bazel.rc.ci b/tools/bazel.rc.ci index 664f7b13380..eda2c0fd2ee 100644 --- a/tools/bazel.rc.ci +++ b/tools/bazel.rc.ci @@ -1,7 +1,6 @@ # This is from Bazel's former travis setup, to avoid blowing up the RAM usage. startup --host_jvm_args=-Xmx8192m startup --host_jvm_args=-Xms8192m -startup --batch # This is so we understand failures better build --verbose_failures diff --git a/tools/bazel.rc.cloudbuilder b/tools/bazel.rc.cloudbuilder index 664f7b13380..eda2c0fd2ee 100644 --- a/tools/bazel.rc.cloudbuilder +++ b/tools/bazel.rc.cloudbuilder @@ -1,7 +1,6 @@ # This is from Bazel's former travis setup, to avoid blowing up the RAM usage. startup --host_jvm_args=-Xmx8192m startup --host_jvm_args=-Xms8192m -startup --batch # This is so we understand failures better build --verbose_failures