Skip to content

Commit

Permalink
ci/codeql: Fix build setup (envoyproxy#36021)
Browse files Browse the repository at this point in the history
This fixes the recent issues with codeql caused by removing some of the
setup in setup_clang.sh

this is a partial revert of that, essentially for containerless local
builds

it also prevents this codepath from being used in RBE, which was a main
goal of the previous changes

Signed-off-by: Ryan Northey <ryan@synca.io>

Signed-off-by: phlax <phlax@users.noreply.github.com>
  • Loading branch information
phlax committed Sep 26, 2024
1 parent 09c25f1 commit b26ac9a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,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
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/codeql-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/codeql-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 != '' }}
Expand All @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions bazel/setup_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF > "${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}
Expand Down
10 changes: 6 additions & 4 deletions ci/build_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ export BAZEL_STARTUP_OPTION_LIST
export BAZEL_BUILD_OPTION_LIST
export BAZEL_GLOBAL_OPTION_LIST

if [[ -e "${LLVM_ROOT}" ]]; then
"$(dirname "$0")/../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
Expand Down
7 changes: 6 additions & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,14 @@ case $CI_TARGET in

asan)
setup_clang_toolchain
if [[ -n "$ENVOY_RBE" ]]; then
ASAN_CONFIG="--config=rbe-toolchain-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"
Expand Down
2 changes: 1 addition & 1 deletion ci/filter_example_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ ln -sf "${ENVOY_SRCDIR}"/bazel/platform_mappings "${ENVOY_FILTER_EXAMPLE_SRCDIR}
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

0 comments on commit b26ac9a

Please sign in to comment.