Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env bash2#3# Copyright (c) 2018-present The Bitcoin Core developers4# Distributed under the MIT software license, see the accompanying5# file COPYING or http://www.opensource.org/licenses/mit-license.php.7export LC_ALL=C.UTF-89set -o errexit -o pipefail -o xtrace11if [ "${DANGER_RUN_CI_ON_HOST}" != "1" ]; then12echo "This script will make unsafe local and global modifications, so it can only be run inside a container and requires DANGER_RUN_CI_ON_HOST=1"13exit 114fi16CFG_DONE="${BASE_ROOT_DIR}/ci.base-install-done" # Use a global setting to remember whether this script ran to avoid running it twice18if [ "$( cat "${CFG_DONE}" || true )" == "done" ]; then19echo "Skip base install"20exit 021fi23MAKEJOBS="-j$( nproc )" # Use nproc, because MAKEJOBS is the default in docker image builds.25if [ -n "$DPKG_ADD_ARCH" ]; then26dpkg --add-architecture "$DPKG_ADD_ARCH"27fi29if [ -n "${APT_LLVM_V}" ]; then30${CI_RETRY_EXE} apt-get update31${CI_RETRY_EXE} apt-get install curl -y32curl "https://apt.llvm.org/llvm-snapshot.gpg.key" | tee "/etc/apt/trusted.gpg.d/apt.llvm.org.asc"33(34# shellcheck disable=SC203435source /etc/os-release36echo "deb http://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-${APT_LLVM_V} main" > "/etc/apt/sources.list.d/llvm-toolchain-${VERSION_CODENAME}-${APT_LLVM_V}.list"37)38fi40if command -v apk >/dev/null 2>&1; then41${CI_RETRY_EXE} apk update42# shellcheck disable=SC208643${CI_RETRY_EXE} apk add --no-cache $CI_BASE_PACKAGES $PACKAGES44elif [ "$CI_OS_NAME" != "macos" ]; then45if [[ -n "${APPEND_APT_SOURCES_LIST}" ]]; then46echo "${APPEND_APT_SOURCES_LIST}" >> /etc/apt/sources.list47fi48${CI_RETRY_EXE} apt-get update49# shellcheck disable=SC208650${CI_RETRY_EXE} apt-get install --no-install-recommends --no-upgrade -y $PACKAGES $CI_BASE_PACKAGES51fi53if [[ ${HOST:-} == x86_64-w64-mingw32* ]]; then54# Install Nix packages.55NIX_BUILD_SHELL=bash nix-shell "${BASE_ROOT_DIR}/contrib/devtools/shell-win64-cross.nix" --run true56fi58if [ -n "${APT_LLVM_V}" ]; then59update-alternatives --install /usr/bin/clang++ clang++ "/usr/bin/clang++-${APT_LLVM_V}" 10060update-alternatives --install /usr/bin/clang clang "/usr/bin/clang-${APT_LLVM_V}" 10061update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer "/usr/bin/llvm-symbolizer-${APT_LLVM_V}" 10062fi64if [ -n "$PIP_PACKAGES" ]; then65# shellcheck disable=SC208666${CI_RETRY_EXE} pip3 install --user $PIP_PACKAGES67fi69if [[ -n "${USE_INSTRUMENTED_LIBCPP}" ]]; then70${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-23.1.0" /llvm-project72# LLVM is configured with LIBCXXABI_USE_LLVM_UNWINDER=OFF,73# because libunwind doesn't handle exceptions under MSAN.74# https://github.com/llvm/llvm-project/issues/8434875cmake -G Ninja -B /cxx_build/ \76-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \77-DCMAKE_BUILD_TYPE=Release \78-DLLVM_USE_SANITIZER="${USE_INSTRUMENTED_LIBCPP}" \79-DCMAKE_C_COMPILER=clang \80-DCMAKE_CXX_COMPILER=clang++ \81-DLLVM_TARGETS_TO_BUILD=Native \82-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \83-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \84-DLIBCXX_ABI_DEFINES="_LIBCPP_ABI_BOUNDED_ITERATORS;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING;_LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR;_LIBCPP_ABI_BOUNDED_UNIQUE_PTR" \85-DLIBCXX_HARDENING_MODE=debug \86-DLIBCXX_INCLUDE_TESTS=OFF \87-S /llvm-project/runtimes89ninja -C /cxx_build/ "$MAKEJOBS"91# Clear no longer needed source folder92du -sh /llvm-project93rm -rf /llvm-project94fi96if [[ ${BARE_METAL_RISCV} == "true" ]]; then97${CI_RETRY_EXE} git clone --depth=1 https://github.com/riscv-collab/riscv-gnu-toolchain -b 2026.08.25 /riscv/gcc98( cd /riscv/gcc99./configure --prefix=/opt/riscv-ilp32 --with-arch=rv32gc --with-abi=ilp32 --disable-gdb100make "$MAKEJOBS" )101rm -rf /riscv/gcc102fi104if [[ "${RUN_IWYU}" == true ]]; then105${CI_RETRY_EXE} git clone --depth=1 https://github.com/include-what-you-use/include-what-you-use -b clang_"${IWYU_LLVM_V}" /include-what-you-use106pushd /include-what-you-use107patch -p1 < "${BASE_ROOT_DIR}/ci/test/01_iwyu.patch"108popd109cmake -B /iwyu-build/ -G 'Unix Makefiles' -DCMAKE_PREFIX_PATH=/usr/lib/llvm-"${IWYU_LLVM_V}" -S /include-what-you-use110make -C /iwyu-build/ install "$MAKEJOBS"111fi113mkdir -p "${DEPENDS_DIR}/SDKs" "${DEPENDS_DIR}/sdk-sources"115OSX_SDK_BASENAME="Xcode-${XCODE_VERSION}-${XCODE_BUILD_ID}-extracted-SDK-with-libcxx-headers"117if [ -n "$XCODE_VERSION" ] && [ ! -d "${DEPENDS_DIR}/SDKs/${OSX_SDK_BASENAME}" ]; then118OSX_SDK_FILENAME="${OSX_SDK_BASENAME}.tar"119OSX_SDK_PATH="${DEPENDS_DIR}/sdk-sources/${OSX_SDK_FILENAME}"120if [ ! -f "$OSX_SDK_PATH" ]; then121${CI_RETRY_EXE} curl --location --fail "${SDK_URL}/${OSX_SDK_FILENAME}" -o "$OSX_SDK_PATH"122fi123sha256sum -c <<<"${OSX_SDK_SHA256} ${OSX_SDK_PATH}"124tar -C "${DEPENDS_DIR}/SDKs" -xf "$OSX_SDK_PATH"125fi127if [ -n "$NETBSD_VERSION" ] && [ ! -d "${DEPENDS_DIR}/SDKs/${NETBSD_SDK_BASENAME}" ]; then128mkdir -p "${DEPENDS_DIR}/SDKs/${NETBSD_SDK_BASENAME}"129while read -r NETBSD_SDK_SHA512 NETBSD_SDK_FILENAME; do130NETBSD_SDK_PATH="${DEPENDS_DIR}/sdk-sources/${NETBSD_SDK_FILENAME}"131if [ ! -f "$NETBSD_SDK_PATH" ]; then132${CI_RETRY_EXE} curl --location --fail "https://cdn.netbsd.org/pub/NetBSD/NetBSD-${NETBSD_VERSION}/amd64/binary/sets/${NETBSD_SDK_FILENAME}" -o "$NETBSD_SDK_PATH"133fi134sha512sum -c <<<"${NETBSD_SDK_SHA512} ${NETBSD_SDK_PATH}"135tar -C "${DEPENDS_DIR}/SDKs/${NETBSD_SDK_BASENAME}" -xf "$NETBSD_SDK_PATH"136done < <(printf '%b\n' "${NETBSD_SDK_SHA512SUMS}")137fi139if [ -n "$FREEBSD_VERSION" ] && [ ! -d "${DEPENDS_DIR}/SDKs/${FREEBSD_SDK_BASENAME}" ]; then140FREEBSD_SDK_FILENAME="base-${FREEBSD_VERSION}.txz"141FREEBSD_SDK_PATH="${DEPENDS_DIR}/sdk-sources/${FREEBSD_SDK_FILENAME}"142if [ ! -f "$FREEBSD_SDK_PATH" ]; then143${CI_RETRY_EXE} curl --location --fail "https://download.freebsd.org/releases/amd64/${FREEBSD_VERSION}-RELEASE/base.txz" -o "$FREEBSD_SDK_PATH"144fi145sha256sum -c <<<"${FREEBSD_SDK_SHA256} ${FREEBSD_SDK_PATH}"146mkdir -p "${DEPENDS_DIR}/SDKs/${FREEBSD_SDK_BASENAME}"147tar -C "${DEPENDS_DIR}/SDKs/${FREEBSD_SDK_BASENAME}" -xf "$FREEBSD_SDK_PATH"148fi150if [ -n "$OPENBSD_VERSION" ] && [ ! -d "${DEPENDS_DIR}/SDKs/${OPENBSD_SDK_BASENAME}" ]; then151mkdir -p "${DEPENDS_DIR}/SDKs/${OPENBSD_SDK_BASENAME}"152while read -r OPENBSD_SDK_SHA256 OPENBSD_SDK_FILENAME; do153OPENBSD_SDK_PATH="${DEPENDS_DIR}/sdk-sources/${OPENBSD_SDK_FILENAME}"154if [ ! -f "$OPENBSD_SDK_PATH" ]; then155${CI_RETRY_EXE} curl --location --fail "https://cdn.openbsd.org/pub/OpenBSD/${OPENBSD_VERSION}/amd64/${OPENBSD_SDK_FILENAME}" -o "$OPENBSD_SDK_PATH"156fi157sha256sum -c <<<"${OPENBSD_SDK_SHA256} ${OPENBSD_SDK_PATH}"158tar -C "${DEPENDS_DIR}/SDKs/${OPENBSD_SDK_BASENAME}" -xf "$OPENBSD_SDK_PATH"159done < <(printf '%b\n' "${OPENBSD_SDK_SHA256SUMS}")160(161# The SDK has versioned shared libs, but no unversioned libfoo.so symlink,162# which breaks linking the kernel with lld. Create the symlinks.163cd "${DEPENDS_DIR}/SDKs/${OPENBSD_SDK_BASENAME}/usr/lib"164ln -sf libc++abi.so.*.* libc++abi.so165ln -sf libc++.so.*.* libc++.so166ln -sf libpthread.so.*.* libpthread.so167)168fi170echo -n "done" > "${CFG_DONE}"
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.