mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
338bc2cd26
41051290ab
cmake: Ignore build subdirectories within source directory (Hennadii Stepanov)6ce50fd9d0
doc: Update for CMake-based build system (Hennadii Stepanov)9730288a0c
ci: Migrate CI scripts to CMake (Hennadii Stepanov)c360837ca5
cmake, lint: Adjust `lint_includes_build_config` (Hennadii Stepanov)3885441ee0
cmake: Add presets for native Windows builds (Hennadii Stepanov)7681746b20
cmake: Add vcpkg manifest file (Hennadii Stepanov)8b6f1c4353
cmake: Add `Coverage` and `CoverageFuzz` scripts (Hennadii Stepanov)65bdbc1ff2
cmake: Add `docs` build target (Hennadii Stepanov)fb75ebbc33
cmake: Add compiler diagnostic flags (Hennadii Stepanov)e821f0a37a
cmake: Migrate Guix build scripts to CMake (Hennadii Stepanov)747adb6ffe
cmake: Add `Maintenance` module (Hennadii Stepanov)1f60b30df0
cmake: Add `APPEND_{CPP,C,CXX,LD}FLAGS` cache variables (Hennadii Stepanov)2b43c45b13
cmake: Add `AddWindowsResources` module (Hennadii Stepanov)973a3b0c5d
cmake: Implement `install` build target (Hennadii Stepanov)84ac35cfd4
cmake: Add cross-compiling support (Hennadii Stepanov)0d01c228a7
build: Generate `toolchain.cmake` in depends (Hennadii Stepanov)91a799247d
depends: Add host-specific `cmake_system_version` variables (Hennadii Stepanov)9b31209b4c
depends: Rename `cmake_system` -> `cmake_system_name` (Hennadii Stepanov)4a5208a81d
Revert "build, qt: Do not install *.prl files" (Hennadii Stepanov)6522af62af
depends: Amend handling flags environment variables (Hennadii Stepanov)90cec4d251
cmake: Add `MULTIPROCESS` option (Hennadii Stepanov)bb1a450dcb
cmake: Build `bitcoin-chainstate` executable (Hennadii Stepanov)aed38ea58c
cmake: Build `bitcoinkernel` library (Hennadii Stepanov)975d67369b
cmake: Build `test_bitcoin-qt` executable (Hennadii Stepanov)10fcc668a3
cmake: Add `WITH_DBUS` option (Hennadii Stepanov)5bb5a4bc75
cmake: Add `libqrencode` optional package support (Hennadii Stepanov)57a6e2ef4a
cmake: Build `bitcoin-qt` executable (Hennadii Stepanov)30f642952c
cmake: Add `WERROR` option (Hennadii Stepanov)c98d4a4c34
cmake: Add `REDUCE_EXPORTS` option (Hennadii Stepanov)a01cb6e63f
cmake: Add `HARDENING` option (Hennadii Stepanov)a8a2e364ac
cmake: Add Python-based tests (Hennadii Stepanov)3d85379570
cmake: Add fuzzing options (Hennadii Stepanov)908530e312
cmake: Add `SANITIZERS` option (Hennadii Stepanov)8bb0e85631
cmake: Build `bench_bitcoin` executable (Hennadii Stepanov)801735163a
cmake: Add external signer support (Hennadii Stepanov)353e0c9e96
cmake: Add `systemtap-sdt` optional package support (Hennadii Stepanov)d2fda82b49
cmake: Add `libzmq` optional package support (Hennadii Stepanov)ae7b39a0e1
cmake: Add `libminiupnpc` optional package support (Hennadii Stepanov)6480e1dcdb
cmake: Add `libnatpmp` optional package support (Hennadii Stepanov)e73e9304a1
cmake: Build `bitcoin-util` executable (Hennadii Stepanov)027c6d7caa
cmake: Build `bitcoin-tx` executable (Hennadii Stepanov)d10c5c34c3
cmake: Add wallet functionality (Hennadii Stepanov)ab2e99b0d9
cmake: Create test suite for `ctest` (Hennadii Stepanov)959370bd76
cmake: Build `test_bitcoin` executable (Hennadii Stepanov)b27bf9700d
cmake: Build `bitcoin-cli` executable (Hennadii Stepanov)a9813df826
cmake: Build `bitcoind` executable (Hennadii Stepanov)97829ce2d5
cmake: Add `FindLibevent` module (Hennadii Stepanov)3118e40c61
cmake: Build `bitcoin_consensus` library (Hennadii Stepanov)809a2f1929
cmake: Build `bitcoin_util` static library (Hennadii Stepanov)0a9a521a70
cmake: Build `bitcoin_crypto` library (Hennadii Stepanov)958971f476
cmake: Build `univalue` static library (Hennadii Stepanov)752747fda8
cmake: Generate `obj/build.h` header (Hennadii Stepanov)1f0a78edf3
cmake: Build `minisketch` static library (Hennadii Stepanov)12bfbc8154
cmake: Build `leveldb` static library (Hennadii Stepanov)51985c5304
cmake: Build `crc32c` static library (Hennadii Stepanov)db7a198f29
cmake: Build `secp256k1` subtree (Hennadii Stepanov)dbb7ed14e8
cmake: Add `ccache` support (Hennadii Stepanov)cedfdf6c72
cmake: Redefine/adjust per-configuration flags (Hennadii Stepanov)b6b5e732c8
cmake: Add global compiler and linker flags (Hennadii Stepanov)f98327931b
cmake: Add `TryAppendLinkerFlag` module (Hennadii Stepanov)4a0af29697
cmake: Add `TryAppendCXXFlags` module (Hennadii Stepanov)35cffc497d
cmake: Add POSIX threads support (Hennadii Stepanov)fd72d00ffe
cmake: Add position independent code support (Hennadii Stepanov)07069e2bb0
cmake: Add introspection module (Hennadii Stepanov)27d687fc1f
cmake: Add `config/bitcoin-config.h` support (Hennadii Stepanov)fe5cdace5f
cmake: Print compiler and linker flags in summary (Hennadii Stepanov)70683884c5
cmake: Introduce interface libraries to encapsulate common flags (Hennadii Stepanov)a2317e27b7
cmake: Add root `CMakeLists.txt` file (Hennadii Stepanov) Pull request description: This PR introduces a new CMake-based build system, which is a drop-in replacement for the current Autotools-based build system. ML announcement: https://groups.google.com/g/bitcoindev/c/hgKkfQWzrTo As discussed during the recent CoreDev meetup in April, the switch from Autotools to CMake is intended to happen as soon as possible after branching 28.x off, which means that 29.0 will be built using CMake. This PR branch is essentially the [staging branch](https://github.com/hebasto/bitcoin/tree/cmake-staging), with every change reviewed and tested by a group of contributors, including (in alphabetical order): - [**achow101**](https://github.com/achow101) - [**fanquake**](https://github.com/fanquake) - [**maflcko**](https://github.com/maflcko) - [**m3dwards**](https://github.com/m3dwards) - [**pablomartin4btc**](https://github.com/pablomartin4btc) - [**real-or-random**](https://github.com/real-or-random) - [**ryanofsky**](https://github.com/ryanofsky) - [**sipsorcery**](https://github.com/sipsorcery) - [**TheCharlatan**](https://github.com/TheCharlatan) - [**theStack**](https://github.com/theStack) - [**theuni**](https://github.com/theuni) - [**vasild**](https://github.com/vasild) Reviewing in a separate staging repo was suggested in https://github.com/bitcoin/bitcoin/pull/27060#issuecomment-1431798320. The accompanying changes to the OSS-Fuzz project are available in https://github.com/hebasto/oss-fuzz/pull/8. Please refer to the [build options parity table](https://gist.github.com/hebasto/2ef97d3a726bfce08ded9df07f7dab5e). The "auto" value is no longer available; non-default values must be specified explicitly. Additionally, the new default values have been chosen to suit the everyday build experience for the majority of developers. System requirements for using the CMake-based build system: - CMake >= 3.22 (if not available in your system's repository, it can be downloaded from https://cmake.org/download/) - a build tool of your choice: - any Make (GNU Make is no longer a requirement); GNU Make is still required to build depends - Ninja (https://ninja-build.org/) - MSBuild - Xcode A note for Windows users: The default installation of the latest version of MSVC 17.10.4 includes both CMake 3.28.3 and the vcpkg package manager). --- We, the build system developers, kindly ask reviewers to refrain from making suggestions that are not directly related to the migration process or can be implemented separately. Bugs in the scripts and errors in the updated documentation should be the focus of this PR. Please be advised that comments not aligned with this PR's goal may be ignored. Thank you all for your understanding. ACKs for top commit: maflcko: review ACK41051290ab
🐥 sipsorcery: ACK41051290ab
. vasild: ACK41051290ab
TheCharlatan: ACK41051290ab
pablomartin4btc: tACK41051290ab
i-am-yuvi: tACK [`4105129`](41051290ab
) theuni: ACK41051290ab
. fanquake: ACK41051290ab
Tree-SHA512: 6c1445054436c6c00ad63bfa0f19d64091a2b25c9bd694f85bf2218ac358ffb774d6c000685b3ca1e9b50401babed989fa2a0694b774c211d226bfd1944c9b39
185 lines
7.4 KiB
Bash
Executable file
185 lines
7.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# Copyright (c) 2018-present The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
set -ex
|
|
|
|
export ASAN_OPTIONS="detect_leaks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"
|
|
export LSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/lsan"
|
|
export TSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/tsan:halt_on_error=1"
|
|
export UBSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1"
|
|
|
|
if [ "$CI_OS_NAME" == "macos" ]; then
|
|
top -l 1 -s 0 | awk ' /PhysMem/ {print}'
|
|
echo "Number of CPUs: $(sysctl -n hw.logicalcpu)"
|
|
else
|
|
free -m -h
|
|
echo "Number of CPUs (nproc): $(nproc)"
|
|
echo "System info: $(uname --kernel-name --kernel-release)"
|
|
lscpu
|
|
fi
|
|
echo "Free disk space:"
|
|
df -h
|
|
|
|
# What host to compile for. See also ./depends/README.md
|
|
# Tests that need cross-compilation export the appropriate HOST.
|
|
# Tests that run natively guess the host
|
|
export HOST=${HOST:-$("$BASE_ROOT_DIR/depends/config.guess")}
|
|
|
|
(
|
|
# compact->outputs[i].file_size is uninitialized memory, so reading it is UB.
|
|
# The statistic bytes_written is only used for logging, which is disabled in
|
|
# CI, so as a temporary minimal fix to work around UB and CI failures, leave
|
|
# bytes_written unmodified.
|
|
# See https://github.com/bitcoin/bitcoin/pull/28359#issuecomment-1698694748
|
|
# Tee patch to stdout to make it clear CI is testing modified code.
|
|
tee >(patch -p1) <<'EOF'
|
|
--- a/src/leveldb/db/db_impl.cc
|
|
+++ b/src/leveldb/db/db_impl.cc
|
|
@@ -1028,9 +1028,6 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) {
|
|
stats.bytes_read += compact->compaction->input(which, i)->file_size;
|
|
}
|
|
}
|
|
- for (size_t i = 0; i < compact->outputs.size(); i++) {
|
|
- stats.bytes_written += compact->outputs[i].file_size;
|
|
- }
|
|
|
|
mutex_.Lock();
|
|
stats_[compact->compaction->level() + 1].Add(stats);
|
|
EOF
|
|
)
|
|
|
|
if [ "$RUN_FUZZ_TESTS" = "true" ]; then
|
|
export DIR_FUZZ_IN=${DIR_QA_ASSETS}/fuzz_seed_corpus/
|
|
if [ ! -d "$DIR_FUZZ_IN" ]; then
|
|
${CI_RETRY_EXE} git clone --depth=1 https://github.com/bitcoin-core/qa-assets "${DIR_QA_ASSETS}"
|
|
fi
|
|
(
|
|
cd "${DIR_QA_ASSETS}"
|
|
echo "Using qa-assets repo from commit ..."
|
|
git log -1
|
|
)
|
|
elif [ "$RUN_UNIT_TESTS" = "true" ] || [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
|
|
export DIR_UNIT_TEST_DATA=${DIR_QA_ASSETS}/unit_test_data/
|
|
if [ ! -d "$DIR_UNIT_TEST_DATA" ]; then
|
|
mkdir -p "$DIR_UNIT_TEST_DATA"
|
|
${CI_RETRY_EXE} curl --location --fail https://github.com/bitcoin-core/qa-assets/raw/main/unit_test_data/script_assets_test.json -o "${DIR_UNIT_TEST_DATA}/script_assets_test.json"
|
|
fi
|
|
fi
|
|
|
|
if [ "$USE_BUSY_BOX" = "true" ]; then
|
|
echo "Setup to use BusyBox utils"
|
|
# tar excluded for now because it requires passing in the exact archive type in ./depends (fixed in later BusyBox version)
|
|
# ar excluded for now because it does not recognize the -q option in ./depends (unknown if fixed)
|
|
for util in $(busybox --list | grep -v "^ar$" | grep -v "^tar$" ); do ln -s "$(command -v busybox)" "${BINS_SCRATCH_DIR}/$util"; done
|
|
# Print BusyBox version
|
|
patch --help
|
|
fi
|
|
|
|
# Make sure default datadir does not exist and is never read by creating a dummy file
|
|
if [ "$CI_OS_NAME" == "macos" ]; then
|
|
echo > "${HOME}/Library/Application Support/Bitcoin"
|
|
else
|
|
echo > "${HOME}/.bitcoin"
|
|
fi
|
|
|
|
if [ -z "$NO_DEPENDS" ]; then
|
|
if [[ $CI_IMAGE_NAME_TAG == *centos* ]]; then
|
|
SHELL_OPTS="CONFIG_SHELL=/bin/dash"
|
|
else
|
|
SHELL_OPTS="CONFIG_SHELL="
|
|
fi
|
|
bash -c "$SHELL_OPTS make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS LOG=1"
|
|
fi
|
|
if [ "$DOWNLOAD_PREVIOUS_RELEASES" = "true" ]; then
|
|
test/get_previous_releases.py -b -t "$PREVIOUS_RELEASES_DIR"
|
|
fi
|
|
|
|
BITCOIN_CONFIG_ALL="-DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON"
|
|
if [ -z "$NO_DEPENDS" ]; then
|
|
BITCOIN_CONFIG_ALL="${BITCOIN_CONFIG_ALL} -DCMAKE_TOOLCHAIN_FILE=$DEPENDS_DIR/$HOST/toolchain.cmake"
|
|
fi
|
|
if [ -z "$NO_WERROR" ]; then
|
|
BITCOIN_CONFIG_ALL="${BITCOIN_CONFIG_ALL} -DWERROR=ON"
|
|
fi
|
|
|
|
ccache --zero-stats
|
|
PRINT_CCACHE_STATISTICS="ccache --version | head -n 1 && ccache --show-stats"
|
|
|
|
# Folder where the build is done.
|
|
BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_SCRATCH_DIR/build-$HOST}
|
|
mkdir -p "${BASE_BUILD_DIR}"
|
|
cd "${BASE_BUILD_DIR}"
|
|
|
|
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DENABLE_EXTERNAL_SIGNER=ON -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR"
|
|
|
|
if [[ "${RUN_TIDY}" == "true" ]]; then
|
|
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
|
|
fi
|
|
|
|
bash -c "cmake -S $BASE_ROOT_DIR $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( (cat CMakeFiles/CMakeOutput.log CMakeFiles/CMakeError.log) && false)"
|
|
|
|
bash -c "make $MAKEJOBS all $GOAL" || ( echo "Build failure. Verbose build follows." && make all "$GOAL" V=1 ; false )
|
|
|
|
bash -c "${PRINT_CCACHE_STATISTICS}"
|
|
du -sh "${DEPENDS_DIR}"/*/
|
|
du -sh "${PREVIOUS_RELEASES_DIR}"
|
|
|
|
if [[ $HOST = *-mingw32 ]]; then
|
|
"${BASE_ROOT_DIR}/ci/test/wrap-wine.sh"
|
|
fi
|
|
|
|
if [ -n "$USE_VALGRIND" ]; then
|
|
"${BASE_ROOT_DIR}/ci/test/wrap-valgrind.sh"
|
|
fi
|
|
|
|
if [ "$RUN_UNIT_TESTS" = "true" ]; then
|
|
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" CTEST_OUTPUT_ON_FAILURE=ON ctest "${MAKEJOBS}"
|
|
fi
|
|
|
|
if [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
|
|
DIR_UNIT_TEST_DATA="${DIR_UNIT_TEST_DATA}" LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" "${BASE_OUTDIR}"/bin/test_bitcoin --catch_system_errors=no -l test_suite
|
|
fi
|
|
|
|
if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
|
|
# shellcheck disable=SC2086
|
|
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" test/functional/test_runner.py --ci "${MAKEJOBS}" --tmpdirprefix "${BASE_SCRATCH_DIR}"/test_runner/ --ansi --combinedlogslen=99999999 --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" ${TEST_RUNNER_EXTRA} --quiet --failfast
|
|
fi
|
|
|
|
if [ "${RUN_TIDY}" = "true" ]; then
|
|
cmake -B /tidy-build -DLLVM_DIR=/usr/lib/llvm-"${TIDY_LLVM_V}"/cmake -DCMAKE_BUILD_TYPE=Release -S "${BASE_ROOT_DIR}"/contrib/devtools/bitcoin-tidy
|
|
cmake --build /tidy-build "$MAKEJOBS"
|
|
cmake --build /tidy-build --target bitcoin-tidy-tests "$MAKEJOBS"
|
|
|
|
set -eo pipefail
|
|
cd "${BASE_BUILD_DIR}/src/"
|
|
if ! ( run-clang-tidy-"${TIDY_LLVM_V}" -quiet -load="/tidy-build/libbitcoin-tidy.so" "${MAKEJOBS}" | tee tmp.tidy-out.txt ); then
|
|
grep -C5 "error: " tmp.tidy-out.txt
|
|
echo "^^^ ⚠️ Failure generated from clang-tidy"
|
|
false
|
|
fi
|
|
# Filter out files by regex here, because regex may not be
|
|
# accepted in src/.bear-tidy-config
|
|
# Filter out:
|
|
# * qt qrc and moc generated files
|
|
jq 'map(select(.file | test("src/qt/qrc_.*\\.cpp$|/moc_.*\\.cpp$") | not))' "${BASE_BUILD_DIR}/compile_commands.json" > tmp.json
|
|
mv tmp.json "${BASE_BUILD_DIR}/compile_commands.json"
|
|
cd "${BASE_ROOT_DIR}"
|
|
python3 "/include-what-you-use/iwyu_tool.py" \
|
|
-p "${BASE_BUILD_DIR}" "${MAKEJOBS}" \
|
|
-- -Xiwyu --cxx17ns -Xiwyu --mapping_file="${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp" \
|
|
-Xiwyu --max_line_length=160 \
|
|
2>&1 | tee /tmp/iwyu_ci.out
|
|
cd "${BASE_ROOT_DIR}/src"
|
|
python3 "/include-what-you-use/fix_includes.py" --nosafe_headers < /tmp/iwyu_ci.out
|
|
git --no-pager diff
|
|
fi
|
|
|
|
if [ "$RUN_FUZZ_TESTS" = "true" ]; then
|
|
# shellcheck disable=SC2086
|
|
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" test/fuzz/test_runner.py ${FUZZ_TESTS_CONFIG} "${MAKEJOBS}" -l DEBUG "${DIR_FUZZ_IN}" --empty_min_time=60
|
|
fi
|