diff --git a/contrib/devtools/build_cmake.sh b/contrib/devtools/build_cmake.sh index 41ca413a7..7e50f0399 100755 --- a/contrib/devtools/build_cmake.sh +++ b/contrib/devtools/build_cmake.sh @@ -1,87 +1,87 @@ #!/usr/bin/env bash export LC_ALL=C set -euxo pipefail : "${TOPLEVEL:=$(git rev-parse --show-toplevel)}" : "${BUILD_DIR:=${TOPLEVEL}/build}" function usage() { echo "Usage: $0 [--Werror] [targets]" echo "Build the targets using cmake and ninja." echo "If no target is provided the default (all) target is built." echo echo "Options:" echo " --clang: build with clang/clang++" echo " --gcc: build with gcc/g++" echo " --Werror: add -Werror to the compiler flags" echo "Environment variables:" echo " CMAKE_FLAGS: array of the CMAKE flags to use for the build" echo " BUILD_DIR: the build directory, (default: ${BUILD_DIR}})" echo " TOPLEVEL: the project root directory, (default: ${TOPLEVEL}})" } # Default to nothing : "${CMAKE_FLAGS:=}" mkdir -p "${BUILD_DIR}" cd ${BUILD_DIR} -git clean -xffd +git clean -xffd || true read -a CMAKE_FLAGS <<< "${CMAKE_FLAGS}" TARGETS=() while [[ $# -gt 0 ]]; do case $1 in --clang) CMAKE_FLAGS+=( "-DCMAKE_C_COMPILER=clang" "-DCMAKE_CXX_COMPILER=clang++" ) shift ;; --gcc) CMAKE_FLAGS+=( "-DCMAKE_C_COMPILER=gcc" "-DCMAKE_CXX_COMPILER=g++" ) shift ;; --Werror) CMAKE_FLAGS+=( "-DCMAKE_C_FLAGS=-Werror" "-DCMAKE_CXX_FLAGS=-Werror" ) shift ;; *) TARGETS+=("$1") shift ;; esac done cmake -GNinja "${TOPLEVEL}" "${CMAKE_FLAGS[@]}" # If valid targets are given, use them, otherwise default to "all". if [ ${#TARGETS[@]} -eq 0 ]; then TARGETS=("all") else mapfile -t VALID_TARGETS < <(ninja -t targets all | cut -d ':' -f 1) # "all" is not part of the targets exported by ninja, so add it. VALID_TARGETS+=("all") IFS=" " for TARGET in "${TARGETS[@]}" do # The array prints as a space delimited word list, surround the target with # spaces to avoid partial match. if [[ ! " ${VALID_TARGETS[*]} " =~ \ ${TARGET}\ ]]; then echo "Trying to build an invalid target: ${TARGET}" exit 2 fi done fi # Run build ninja "${TARGETS[@]}" diff --git a/contrib/teamcity/build-configurations.json b/contrib/teamcity/build-configurations.json index 1cc4480ac..9229e6f85 100644 --- a/contrib/teamcity/build-configurations.json +++ b/contrib/teamcity/build-configurations.json @@ -1,190 +1,191 @@ { "templates": { "common_unix_artifacts": { "artifacts": { "CMakeCache.txt": "CMakeCache.txt", "src/bitcoind": "bin/bitcoind", "src/bitcoin-*": "bin", "src/qt/bitcoin-qt": "bin/bitcoin-qt", "src/bench/bitcoin-bench": "bin/bitcoin-bench", "src/seeder/bitcoin-seeder": "bin/bitcoin-seeder", "src/libbitcoinconsensus.*": "lib", "src/test/test_bitcoin": "bin/test_bitcoin", "src/qt/test/test_bitcoin-qt": "bin/test_bitcoin-qt", "src/seeder/test/test-seeder": "bin/test-seeder", "src/qt/test/test_bitcoin-qt.log": "log/qt/test_bitcoin-qt.log", "src/seeder/test/*.log": "log/seeder", "test/tmp/*": "functional" } } }, "builds": { "build-asan": { "script": "builds/build-asan.sh", "template": "common_unix_artifacts", "timeout": 1800, - "artifacts": { - "sanitizer_logs": "log" + "env": { + "ASAN_OPTIONS": "log_path=stdout", + "LSAN_OPTIONS": "log_path=stdout" } }, "build-autotools": { "script": "builds/build-autotools.sh", "template": "common_unix_artifacts", "timeout": 1200, "artifacts": { "src/bench/bench_bitcoin": "bin/bench_bitcoin", "config.log": "log/config.log", "src/test-suite.log": "log/test-suite.log", "src/test/*.log": "log", "src/seeder/test/test-seeder.log": "log/test-seeder.log" } }, "build-bench": { "script": "builds/build-bench.sh", "template": "common_unix_artifacts", "timeout": 1200 }, "build-clang-10": { "script": "builds/build-clang-10.sh", "template": "common_unix_artifacts", "timeout": 1200 }, "build-clang-tidy": { "script": "builds/build-clang-tidy.sh", "template": "common_unix_artifacts", "timeout": 600, "artifacts": { "clang-tidy-warnings.txt": "clang-tidy-warnings.txt" } }, "build-coverage": { "script": "builds/build-coverage.sh", "template": "common_unix_artifacts", "timeout": 3600, "artifacts": { "coverage.tar.gz": "coverage.tar.gz" } }, "build-diff": { "script": "builds/build-diff.sh", "template": "common_unix_artifacts", "timeout": 1200 }, "build-ibd": { "script": "builds/build-ibd.sh", "template": "common_unix_artifacts", "timeout": 14400, "artifacts": { "ibd/debug.log": "log/debug.log" } }, "build-ibd-no-assumevalid-checkpoint": { "script": "builds/build-ibd-no-assumevalid-checkpoint.sh", "template": "common_unix_artifacts", "timeout": 21600, "artifacts": { "ibd/debug.log": "log/debug.log" } }, "build-linux64": { "script": "builds/build-linux64.sh", "template": "common_unix_artifacts", "timeout": 1200 }, "build-linux-aarch64": { "script": "builds/build-linux-aarch64.sh", "template": "common_unix_artifacts", "timeout": 1800, "environment": { "QEMU_LD_PREFIX": "/usr/aarch64-linux-gnu" } }, "build-linux-arm": { "script": "builds/build-linux-arm.sh", "template": "common_unix_artifacts", "timeout": 1800, "environment": { "QEMU_LD_PREFIX": "/usr/arm-linux-gnueabihf" } }, "build-make-generator": { "script": "builds/build-make-generator.sh", "template": "common_unix_artifacts", "timeout": 1200 }, "build-master": { "script": "builds/build-master.sh", "template": "common_unix_artifacts", "timeout": 4800 }, "build-osx": { "script": "builds/build-osx.sh", "template": "common_unix_artifacts", "timeout": 600, "artifacts": { "src/qt/BitcoinABC-Qt.app": "bin", "Bitcoin-ABC.dmg": "Bitcoin-ABC.dmg" } }, "build-secp256k1": { "script": "builds/build-secp256k1.sh", "template": "common_unix_artifacts", "timeout": 900, "artifacts": { "src/secp256k1/libsecp256k1*": "lib" } }, "build-tsan": { "script": "builds/build-tsan.sh", "template": "common_unix_artifacts", "timeout": 1800, - "artifacts": { - "sanitizer_logs": "log" + "env": { + "TSAN_OPTIONS": "log_path=stdout" } }, "build-ubsan": { "script": "builds/build-ubsan.sh", "template": "common_unix_artifacts", "timeout": 1800, - "artifacts": { - "sanitizer_logs": "log" + "env": { + "UBSAN_OPTIONS": "log_path=stdout" } }, "build-win64": { "script": "builds/build-win64.sh", "timeout": 1200, "artifacts": { "CMakeCache.txt": "CMakeCache.txt", "src/bitcoind.exe": "bin/bitcoind.exe", "src/bitcoin-*.exe": "bin", "src/qt/bitcoin-qt.exe": "bin/bitcoin-qt.exe", "src/bench/bitcoin-bench.exe": "bin/bitcoin-bench.exe", "src/libbitcoinconsensus*": "lib", "src/test/test_bitcoin.exe": "bin/test_bitcoin.exe", "src/qt/test/test_bitcoin-qt.exe": "bin/test_bitcoin-qt.exe", "src/qt/test/test_bitcoin-qt.log": "log/qt/test_bitcoin-qt.log", "bitcoin-abc-*-x86_64-w64-mingw32.exe": "bitcoin-abc-x86_64-w64-mingw32.exe" } }, "build-without-cli": { "script": "builds/build-without-cli.sh", "template": "common_unix_artifacts", "timeout": 1200 }, "build-without-wallet": { "script": "builds/build-without-wallet.sh", "template": "common_unix_artifacts", "timeout": 1200 }, "build-without-zmq": { "script": "builds/build-without-zmq.sh", "template": "common_unix_artifacts", "timeout": 1800 }, "check-seeds": { "script": "builds/check-seeds.sh", "template": "common_unix_artifacts", "timeout": 600 } } } diff --git a/contrib/teamcity/ci-fixture.sh b/contrib/teamcity/ci-fixture.sh index ddd68f09c..e887ea878 100755 --- a/contrib/teamcity/ci-fixture.sh +++ b/contrib/teamcity/ci-fixture.sh @@ -1,73 +1,55 @@ #!/usr/bin/env bash export LC_ALL=C.UTF-8 set -euxo pipefail : "${TOPLEVEL:=$(git rev-parse --show-toplevel)}" : "${BUILD_DIR:=${TOPLEVEL}/build}" DEVTOOLS_DIR="${TOPLEVEL}/contrib/devtools" # Base directories for sanitizer related files SAN_SUPP_DIR="${TOPLEVEL}/test/sanitizer_suppressions" SAN_LOG_DIR="${BUILD_DIR}/sanitizer_logs" # Create the log directory if it doesn't exist and clear it mkdir -p "${SAN_LOG_DIR}" rm -rf "${SAN_LOG_DIR:?}"/* -# Needed options are set by the build system, add the log path to all runs -export ASAN_OPTIONS="log_path=${SAN_LOG_DIR}/asan.log" -export LSAN_OPTIONS="log_path=${SAN_LOG_DIR}/lsan.log" -export TSAN_OPTIONS="log_path=${SAN_LOG_DIR}/tsan.log" -export UBSAN_OPTIONS="log_path=${SAN_LOG_DIR}/ubsan.log" - run_test_bitcoin() { # Usage: run_test_bitcoin "Context as string" [arguments...] ninja test_bitcoin TEST_BITCOIN_JUNIT="junit_results_unit_tests${1:+_${1// /_}}.xml" TEST_BITCOIN_SUITE_NAME="Bitcoin ABC unit tests${1:+ $1}" # More sanitizer options are needed to run the executable directly - ASAN_OPTIONS="malloc_context_size=0:${ASAN_OPTIONS}" \ - LSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/lsan:${LSAN_OPTIONS}" \ - TSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/tsan:${TSAN_OPTIONS}" \ - UBSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/ubsan:print_stacktrace=1:halt_on_error=1:${UBSAN_OPTIONS}" \ + ASAN_OPTIONS="malloc_context_size=0:${ASAN_OPTIONS:-}" \ + LSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/lsan:${LSAN_OPTIONS:-}" \ + TSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/tsan:${TSAN_OPTIONS:-}" \ + UBSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/ubsan:print_stacktrace=1:halt_on_error=1:${UBSAN_OPTIONS:-}" \ ./src/test/test_bitcoin \ --logger=HRF:JUNIT,message,${TEST_BITCOIN_JUNIT} \ -- \ -testsuitename="${TEST_BITCOIN_SUITE_NAME}" \ "${@:2}" } -# Facility to print out sanitizer log outputs to the build log console -print_sanitizers_log() { - for log in "${SAN_LOG_DIR}"/*.log.* - do - if [ -f "${log}" ]; then - echo "*** Output of ${log} ***" - cat "${log}" - fi - done -} -trap "print_sanitizers_log" ERR - # It is valid to call the function with no argument, so ignore SC2120 # shellcheck disable=SC2120 build_with_cmake() { CMAKE_FLAGS="${CMAKE_FLAGS[*]}" "${DEVTOOLS_DIR}"/build_cmake.sh "$@" } build_with_autotools() { CONFIGURE_FLAGS="${CONFIGURE_FLAGS[*]}" "${DEVTOOLS_DIR}"/build_autotools.sh "$@" } run_ibd() { "${TOPLEVEL}"/contrib/teamcity/ibd.sh "$@" } build_static_dependencies() { "${DEVTOOLS_DIR}"/build_depends.sh }