From 98c35173245fdeacfb9f5aaaddfacd05d171a02a Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 9 Sep 2024 06:40:45 +0100 Subject: [PATCH] ci/codeql: Fixes/cleanups for clang path Signed-off-by: Ryan Northey --- .bazelrc | 3 +-- .github/workflows/codeql-daily.yml | 9 +++++++-- .github/workflows/codeql-push.yml | 5 ++--- bazel/setup_clang.sh | 3 +++ ci/build_setup.sh | 10 ++++++---- ci/do_ci.sh | 7 ++++++- ci/filter_example_setup.sh | 2 +- 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.bazelrc b/.bazelrc index efb8e171dc518..167d4b29ccd5f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -272,8 +272,7 @@ build:rbe-toolchain-clang-libc++ --action_env=CXXFLAGS=-stdlib=libc++ build:rbe-toolchain-clang-libc++ --action_env=LDFLAGS=-stdlib=libc++ build:rbe-toolchain-clang-libc++ --define force_libcpp=enabled -# Do not inherit from "clang-asan" to avoid picking up flags from local clang.bazelrc. -build:rbe-toolchain-asan --config=asan +build:rbe-toolchain-asan --config=clang-asan build:rbe-toolchain-asan --linkopt -fuse-ld=lld build:rbe-toolchain-asan --action_env=ENVOY_UBSAN_VPTR=1 build:rbe-toolchain-asan --copt=-fsanitize=vptr,function diff --git a/.github/workflows/codeql-daily.yml b/.github/workflows/codeql-daily.yml index 29bf47cb5683d..af8a14f0b4f27 100644 --- a/.github/workflows/codeql-daily.yml +++ b/.github/workflows/codeql-daily.yml @@ -54,13 +54,18 @@ jobs: cd bin/clang14 wget https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz tar -xf clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz --strip-components 1 - export PATH=bin/clang14/bin:$PATH - name: Build run: | bazel/setup_clang.sh bin/clang14 bazelisk shutdown - bazelisk build -c fastbuild --spawn_strategy=local --discard_analysis_cache --nouse_action_cache --config clang --config libc++ \ + bazel build \ + -c fastbuild \ + --spawn_strategy=local \ + --discard_analysis_cache \ + --nouse_action_cache \ + --config=clang-libc++ \ + --config=ci \ //source/common/http/... - name: Clean Artifacts diff --git a/.github/workflows/codeql-push.yml b/.github/workflows/codeql-push.yml index db6aa77f37a58..b2b1209cc0ed3 100644 --- a/.github/workflows/codeql-push.yml +++ b/.github/workflows/codeql-push.yml @@ -85,7 +85,6 @@ jobs: cd bin/clang14 wget https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz tar -xf clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz --strip-components 1 - export PATH=bin/clang14/bin:$PATH - name: Build if: ${{ env.BUILD_TARGETS != '' }} @@ -97,8 +96,8 @@ jobs: --spawn_strategy=local \ --discard_analysis_cache \ --nouse_action_cache \ - --config clang \ - --config libc++ \ + --config=clang-libc++ \ + --config=ci \ $BUILD_TARGETS echo -e "Built targets...\n$BUILD_TARGETS" diff --git a/bazel/setup_clang.sh b/bazel/setup_clang.sh index 1b49ad94861df..ba17049fd0600 100755 --- a/bazel/setup_clang.sh +++ b/bazel/setup_clang.sh @@ -15,11 +15,14 @@ fi LLVM_VERSION="$("${LLVM_CONFIG}" --version)" LLVM_LIBDIR="$("${LLVM_CONFIG}" --libdir)" LLVM_TARGET="$("${LLVM_CONFIG}" --host-target)" +PATH="$("${LLVM_CONFIG}" --bindir):${PATH}" RT_LIBRARY_PATH="${LLVM_LIBDIR}/clang/${LLVM_VERSION}/lib/${LLVM_TARGET}" cat < "${BAZELRC_FILE}" # Generated file, do not edit. If you want to disable clang, just delete this file. +build:clang --host_action_env=PATH=${PATH} --action_env=PATH=${PATH} + build:clang --action_env=LLVM_CONFIG=${LLVM_CONFIG} --host_action_env=LLVM_CONFIG=${LLVM_CONFIG} build:clang --repo_env=LLVM_CONFIG=${LLVM_CONFIG} build:clang --linkopt=-L${LLVM_LIBDIR} diff --git a/ci/build_setup.sh b/ci/build_setup.sh index abdbea03859b2..68282ac7c06f3 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -119,10 +119,12 @@ export BAZEL_STARTUP_OPTION_LIST export BAZEL_BUILD_OPTION_LIST export BAZEL_GLOBAL_OPTION_LIST -if [[ -e "${LLVM_ROOT}" ]]; then - "${CURRENT_SCRIPT_DIR}/../bazel/setup_clang.sh" "${LLVM_ROOT}" -else - echo "LLVM_ROOT not found, not setting up llvm." +if [[ -z "${ENVOY_RBE}" ]]; then + if [[ -e "${LLVM_ROOT}" ]]; then + "${CURRENT_SCRIPT_DIR}/../bazel/setup_clang.sh" "${LLVM_ROOT}" + else + echo "LLVM_ROOT not found, not setting up llvm." + fi fi [[ "${BAZEL_EXPUNGE}" == "1" ]] && bazel clean "${BAZEL_BUILD_OPTIONS[@]}" --expunge diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 43aa3f7a1ffd6..e4a65158a15ee 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -351,9 +351,14 @@ case $CI_TARGET in asan) setup_clang_toolchain + if [[ -n "$ENVOY_RBE" ]]; then + ASAN_CONFIG="--config=rbe-toolchain-clang-asan" + else + ASAN_CONFIG="--config=clang-asan" + fi BAZEL_BUILD_OPTIONS+=( -c dbg - "--config=clang-asan" + "${ASAN_CONFIG}" "--build_tests_only" "--remote_download_minimal") echo "bazel ASAN/UBSAN debug build with tests" diff --git a/ci/filter_example_setup.sh b/ci/filter_example_setup.sh index be529e6f82d9c..e2d6e1b434a9e 100644 --- a/ci/filter_example_setup.sh +++ b/ci/filter_example_setup.sh @@ -29,6 +29,6 @@ cp -a "${ENVOY_SRCDIR}"/bazel/protoc "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/bazel/ cp -f "${ENVOY_SRCDIR}"/.bazelrc "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/ rm -f "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/.bazelversion cp -f "${ENVOY_SRCDIR}"/.bazelversion "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/ -cp -f "${ENVOY_SRCDIR}"/*.bazelrc "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/ +cp -f "${ENVOY_SRCDIR}"/*.bazelrc "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/ || : export FILTER_WORKSPACE_SET=1