Merge bitcoin/bitcoin#36485: ci: refactor BUILD_TARGETS use
What changed, and why it matters
This change is a cleanup of Bitcoin Core's continuous integration (CI) scripts. It replaces an implicit rule that automatically added 'all' to build targets with an explicit list of build targets in each CI configuration. There is no security vulnerability here; it is purely a maintainability and shell-script linting improvement.
No security action required. Treat as a normal CI maintainability refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors CI environment scripts to use an explicit BUILD_TARGETS variable instead of GOAL, and removes the implicit prepending of ‘all’ in 03_test_script.sh. It also switches from unquoted word-splitting (suppressing shellcheck SC2086) to an eval-based string-to-argv conversion so BUILD_TARGETS can be passed as a proper array to cmake –build –target. The changes affect CI configuration only and do not alter shipped code, build products, or runtime behavior of Bitcoin Core.
Changed components
ci/test/00_setup_env.shci/test/00_setup_env_mac_cross.shci/test/00_setup_env_mac_cross_intel.shci/test/00_setup_env_mac_native.shci/test/00_setup_env_mac_native_fuzz.shci/test/00_setup_env_native_fuzz.shci/test/00_setup_env_native_fuzz_with_msan.shci/test/00_setup_env_native_fuzz_with_valgrind.shci/test/00_setup_env_native_iwyu.shci/test/00_setup_env_riscv_bare_cross.shci/test/00_setup_env_win64.shci/test/03_test_script.shInspect captured patch +15 / −20
### ci/test/00_setup_env.sh
@@ -64,7 +64,7 @@ export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_SCRATCH_DIR/out}
# This folder exists only on the ci guest, and on the ci host as a volume.
export PREVIOUS_RELEASES_DIR=${PREVIOUS_RELEASES_DIR:-$BASE_ROOT_DIR/prev_releases}
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkgconf curl ca-certificates ccache python3-dev rsync git procps bison e2fsprogs cmake ninja-build}
-export GOAL=${GOAL:-install}
+export BUILD_TARGETS=${BUILD_TARGETS:-"all install"}
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_SCRATCH_DIR}/qa-assets}
export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry"}
### ci/test/00_setup_env_mac_cross.sh
@@ -16,7 +16,7 @@ export XCODE_BUILD_ID=17B100
export OSX_SDK_SHA256=9600fa93644df674ee916b5e2c8a6ba8dacf631996a65dc922d003b98b5ea3b1
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
-export GOAL="deploy"
+export BUILD_TARGETS="all deploy"
printf -v BITCOIN_CONFIG "%q " \
--preset=dev-mode \
-DWITH_USDT=OFF \
### ci/test/00_setup_env_mac_cross_intel.sh
@@ -16,7 +16,7 @@ export XCODE_BUILD_ID=17B100
export OSX_SDK_SHA256=9600fa93644df674ee916b5e2c8a6ba8dacf631996a65dc922d003b98b5ea3b1
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
-export GOAL="deploy"
+export BUILD_TARGETS="all deploy"
printf -v BITCOIN_CONFIG "%q " \
--preset=dev-mode \
-DWITH_USDT=OFF \
### ci/test/00_setup_env_mac_native.sh
@@ -7,7 +7,7 @@
export LC_ALL=C.UTF-8
export PIP_PACKAGES="--break-system-packages pycapnp pyzmq"
-export GOAL="install deploy"
+export BUILD_TARGETS="all install deploy"
export RUN_MACOS_CODESIGN=true
export CMAKE_GENERATOR="Ninja"
export CI_OS_NAME="macos"
### ci/test/00_setup_env_mac_native_fuzz.sh
@@ -18,4 +18,4 @@ export OSX_SDK=""
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
export RUN_FUZZ_TESTS=true
-export GOAL="all"
+export BUILD_TARGETS="all"
### ci/test/00_setup_env_native_fuzz.sh
@@ -13,7 +13,7 @@ export NO_DEPENDS=1
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
export RUN_FUZZ_TESTS=true
-export GOAL="all"
+export BUILD_TARGETS="all"
export CI_CONTAINER_CAP="--cap-add SYS_PTRACE" # If run with (ASan + LSan), the container needs access to ptrace (https://github.com/google/sanitizers/issues/764)
printf -v BITCOIN_CONFIG "%q " \
-DBUILD_FOR_FUZZING=ON \
### ci/test/00_setup_env_native_fuzz_with_msan.sh
@@ -15,7 +15,7 @@ export MSAN_AND_LIBCXX_FLAGS="${MSAN_FLAGS} ${LIBCXX_FLAGS}"
export PACKAGES="clang-${APT_LLVM_V} llvm-${APT_LLVM_V} llvm-${APT_LLVM_V}-dev libclang-${APT_LLVM_V}-dev libclang-rt-${APT_LLVM_V}-dev"
export DEP_OPTS="DEBUG=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
-export GOAL="all"
+export BUILD_TARGETS="all"
printf -v BITCOIN_CONFIG "%q " \
-DCMAKE_BUILD_TYPE=Debug \
`# Setting CMAKE_{C,CXX}_FLAGS_DEBUG flags to an empty string ensures that the flags set in MSAN_FLAGS remain unaltered` \
### ci/test/00_setup_env_native_fuzz_with_valgrind.sh
@@ -13,7 +13,7 @@ export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
export RUN_FUZZ_TESTS=true
export FUZZ_TESTS_CONFIG="--valgrind"
-export GOAL="all"
+export BUILD_TARGETS="all"
printf -v BITCOIN_CONFIG "%q " \
-DBUILD_FOR_FUZZING=ON \
-DCMAKE_C_COMPILER=clang \
### ci/test/00_setup_env_native_iwyu.sh
@@ -16,10 +16,10 @@ export RUN_FUNCTIONAL_TESTS=false
export RUN_FUZZ_TESTS=false
export RUN_CHECK_DEPS=false
export RUN_IWYU=true
-# Adding non-codegen targets to the build goal is a workaround
+# Adding non-codegen build targets is a workaround
# for https://gitlab.kitware.com/cmake/cmake/-/work_items/27862
# and https://github.com/bitcoin-core/libmultiprocess/issues/284.
-export GOAL="codegen bitcoin_node_raw_data_headers mp_headers mptest_headers bitcoin_ipc_headers bitcoin_ipc_test_headers bitcoin_ipc_fuzz_headers"
+export BUILD_TARGETS="codegen bitcoin_node_raw_data_headers mp_headers mptest_headers bitcoin_ipc_headers bitcoin_ipc_test_headers bitcoin_ipc_fuzz_headers"
printf -v BITCOIN_CONFIG "%q " \
--preset dev-mode -DBUILD_GUI=OFF \
-DCMAKE_C_COMPILER=clang-${IWYU_LLVM_V} \
### ci/test/00_setup_env_riscv_bare_cross.sh
@@ -7,7 +7,7 @@
export LC_ALL=C.UTF-8
-export GOAL="bitcoin_consensus bitcoin_crypto secp256k1"
+export BUILD_TARGETS="all bitcoin_consensus bitcoin_crypto secp256k1"
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:26.04"
export HOST="riscv32-unknown-elf-gcc"
export PACKAGES="autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev"
### ci/test/00_setup_env_win64.sh
@@ -11,7 +11,7 @@ export HOST=x86_64-w64-mingw32ucrt
export PACKAGES="nix-bin nix-setup-systemd"
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
-export GOAL="deploy"
+export BUILD_TARGETS="all deploy"
printf -v BITCOIN_CONFIG "%q " \
--preset=dev-mode \
-DENABLE_IPC=OFF \
### ci/test/03_test_script.sh
@@ -119,16 +119,11 @@ cmake -S "$BASE_ROOT_DIR" -B "$BASE_BUILD_DIR" "${CMAKE_ARGS[@]}" || (
false
)
-BUILD_TARGETS="${GOAL}"
-if [[ "${GOAL}" != all && "${GOAL}" != *codegen* ]]; then
- BUILD_TARGETS="all ${GOAL}"
-fi
+eval "BUILD_TARGETS=($BUILD_TARGETS)"
-# shellcheck disable=SC2086
-cmake --build "${BASE_BUILD_DIR}" "$MAKEJOBS" --target $BUILD_TARGETS || (
+cmake --build "${BASE_BUILD_DIR}" "$MAKEJOBS" --target "${BUILD_TARGETS[@]}" || (
echo "Build failure. Verbose build follows."
- # shellcheck disable=SC2086
- cmake --build "${BASE_BUILD_DIR}" -j1 --target $BUILD_TARGETS --verbose
+ cmake --build "${BASE_BUILD_DIR}" -j1 --target "${BUILD_TARGETS[@]}" --verbose
false
)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.