diff --git a/cmake/module/GenerateSetupNsi.cmake b/cmake/module/GenerateSetupNsi.cmake deleted file mode 100644 index c8d5bd67c5f..00000000000 --- a/cmake/module/GenerateSetupNsi.cmake +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) 2023-present The Bitcoin Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or https://opensource.org/license/mit/. - -function(generate_setup_nsi) - set(abs_top_srcdir ${PROJECT_SOURCE_DIR}) - set(abs_top_builddir ${PROJECT_BINARY_DIR}) - set(CLIENT_URL ${PROJECT_HOMEPAGE_URL}) - set(CLIENT_TARNAME "bitcoin") - set(BITCOIN_WRAPPER_NAME "bitcoin") - set(BITCOIN_GUI_NAME "bitcoin-qt") - set(BITCOIN_DAEMON_NAME "bitcoind") - set(BITCOIN_CLI_NAME "bitcoin-cli") - set(BITCOIN_TX_NAME "bitcoin-tx") - set(BITCOIN_WALLET_TOOL_NAME "bitcoin-wallet") - set(BITCOIN_TEST_NAME "test_bitcoin") - set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX}) - configure_file(${PROJECT_SOURCE_DIR}/share/setup.nsi.in ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.nsi USE_SOURCE_PERMISSIONS @ONLY) -endfunction() diff --git a/cmake/module/Maintenance.cmake b/cmake/module/Maintenance.cmake index 15fbf2bea8e..43e145d63f4 100644 --- a/cmake/module/Maintenance.cmake +++ b/cmake/module/Maintenance.cmake @@ -19,32 +19,21 @@ function(setup_split_debug_script) endfunction() function(add_windows_deploy_target) + configure_file(${PROJECT_SOURCE_DIR}/cmake/script/GenerateWindowsInstaller.cmake.in ${PROJECT_BINARY_DIR}/GenerateWindowsInstaller.cmake USE_SOURCE_PERMISSIONS @ONLY) if(MINGW AND TARGET bitcoin AND TARGET bitcoin-qt AND TARGET bitcoind AND TARGET bitcoin-cli AND TARGET bitcoin-tx AND TARGET bitcoin-wallet AND TARGET bitcoin-util AND TARGET test_bitcoin) - find_program(MAKENSIS_EXECUTABLE makensis) - if(NOT MAKENSIS_EXECUTABLE) - add_custom_target(deploy - COMMAND ${CMAKE_COMMAND} -E echo "Error: NSIS not found" - ) - return() - endif() - - # TODO: Consider replacing this code with the CPack NSIS Generator. - # See https://cmake.org/cmake/help/latest/cpack_gen/nsis.html - include(GenerateSetupNsi) - generate_setup_nsi() add_custom_command( OUTPUT ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.exe - COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/release - COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ - COMMAND ${MAKENSIS_EXECUTABLE} -V2 ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.nsi - VERBATIM + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E make_directory release + COMMAND ${CMAKE_STRIP} $ -o release/$ + COMMAND ${CMAKE_STRIP} $ -o release/$ + COMMAND ${CMAKE_STRIP} $ -o release/$ + COMMAND ${CMAKE_STRIP} $ -o release/$ + COMMAND ${CMAKE_STRIP} $ -o release/$ + COMMAND ${CMAKE_STRIP} $ -o release/$ + COMMAND ${CMAKE_STRIP} $ -o release/$ + COMMAND ${CMAKE_STRIP} $ -o release/$ + COMMAND ${CMAKE_COMMAND} -D BIN_DIR=release -D LIBEXEC_DIR=release -P GenerateWindowsInstaller.cmake ) add_custom_target(deploy DEPENDS ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.exe) endif() diff --git a/cmake/script/GenerateWindowsInstaller.cmake.in b/cmake/script/GenerateWindowsInstaller.cmake.in new file mode 100644 index 00000000000..16ebdd49b8f --- /dev/null +++ b/cmake/script/GenerateWindowsInstaller.cmake.in @@ -0,0 +1,40 @@ +# Copyright (c) 2026-present The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit/. + +find_program(MAKENSIS_EXECUTABLE makensis REQUIRED) + +# Project variables. +set(CLIENT_NAME "@CLIENT_NAME@") +set(CLIENT_VERSION_MAJOR @CLIENT_VERSION_MAJOR@) +set(CLIENT_VERSION_MINOR @CLIENT_VERSION_MINOR@) +set(CLIENT_VERSION_BUILD @CLIENT_VERSION_BUILD@) +set(CLIENT_VERSION_STRING "@CLIENT_VERSION_STRING@") +set(CLIENT_URL "@PROJECT_HOMEPAGE_URL@") +set(COPYRIGHT_YEAR "@COPYRIGHT_YEAR@") +set(COPYRIGHT_HOLDERS_FINAL "@COPYRIGHT_HOLDERS_FINAL@") +set(abs_top_srcdir @PROJECT_SOURCE_DIR@) +set(EXEEXT @CMAKE_EXECUTABLE_SUFFIX@) + +# Script variables. +cmake_path(ABSOLUTE_PATH BIN_DIR NORMALIZE) +cmake_path(ABSOLUTE_PATH LIBEXEC_DIR NORMALIZE) + +# Other variables required by the `setup.nsi.in` template. +set(CLIENT_TARNAME "bitcoin") +set(BITCOIN_WRAPPER_NAME "bitcoin") +set(BITCOIN_GUI_NAME "bitcoin-qt") +set(BITCOIN_DAEMON_NAME "bitcoind") +set(BITCOIN_CLI_NAME "bitcoin-cli") +set(BITCOIN_TX_NAME "bitcoin-tx") +set(BITCOIN_WALLET_TOOL_NAME "bitcoin-wallet") +set(BITCOIN_TEST_NAME "test_bitcoin") +configure_file(@PROJECT_SOURCE_DIR@/share/setup.nsi.in ${CMAKE_CURRENT_LIST_DIR}/bitcoin-win64-setup.nsi + USE_SOURCE_PERMISSIONS @ONLY +) + +execute_process( + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + COMMAND ${MAKENSIS_EXECUTABLE} -V2 bitcoin-win64-setup.nsi + COMMAND_ERROR_IS_FATAL ANY +) diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index 1ab9cc7e455..9679e24ba85 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -1,6 +1,6 @@ #!/usr/bin/env bash export LC_ALL=C -set -e -o pipefail +set -o errexit -o pipefail # Source the common prelude, which: # 1. Checks if we're at the top directory of the Bitcoin Core repository @@ -337,8 +337,8 @@ INFO: Building ${VERSION:?not set} for platform triple ${HOST:?not set}: ADDITIONAL_GUIX_TIMEMACHINE_FLAGS: ${ADDITIONAL_GUIX_TIMEMACHINE_FLAGS} EOF - # Run the build script 'contrib/guix/libexec/build.sh' in the build - # container specified by 'contrib/guix/manifest.scm'. + # Run the build scripts 'contrib/guix/libexec/*.sh' in the build + # containers specified by 'contrib/guix/manifest*.scm'. # # Explanation of `guix shell` flags: # @@ -403,39 +403,73 @@ EOF # substitutes (pre-built packages) from servers that the user trusts. # Please read the README.md in the same directory as this file for # more information. - # - # shellcheck disable=SC2086 - time-machine shell --manifest="${PWD}/contrib/guix/manifest_build.scm" \ - --container \ - --writable-root \ - --pure \ - --no-cwd \ - --share="$PWD"=/bitcoin \ - --share="$DISTSRC_BASE"=/distsrc-base \ - --share="$OUTDIR_BASE"=/outdir-base \ - --expose="$(git rev-parse --git-common-dir)" \ - ${SOURCES_PATH:+--share="$SOURCES_PATH"} \ - ${BASE_CACHE:+--share="$BASE_CACHE"} \ - ${SDK_PATH:+--share="$SDK_PATH"} \ - --cores="$JOBS" \ - --keep-failed \ - --fallback \ - --link-profile \ - --root="$(profiledir_for_host "${HOST}")" \ - ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \ - ${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \ - -- env HOST="$host" \ - DISTNAME="$DISTNAME" \ - JOBS="$JOBS" \ - SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \ - ${V:+V=1} \ - ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} \ - ${BASE_CACHE:+BASE_CACHE="$BASE_CACHE"} \ - ${SDK_PATH:+SDK_PATH="$SDK_PATH"} \ - DISTSRC="$(distsrc_for_host "$HOST" "" /distsrc-base)" \ - OUTDIR="$(outdir_for_host "$HOST" "" /outdir-base)" \ - DIST_ARCHIVE_BASE=/outdir-base/dist-archive \ - bash -c "cd /bitcoin && bash contrib/guix/libexec/build.sh" + read -ra _guix_common_flags <<< "$ADDITIONAL_GUIX_COMMON_FLAGS" + read -ra _guix_env_flags <<< "$ADDITIONAL_GUIX_ENVIRONMENT_FLAGS" + + shell_opts=( + --manifest="${PWD}/contrib/guix/manifest_build.scm" + --container + --writable-root + --pure + --no-cwd + --share="$PWD=/bitcoin" + --share="$DISTSRC_BASE=/distsrc-base" + --share="$OUTDIR_BASE=/outdir-base" + --expose="$(git rev-parse --git-common-dir)" + ${SOURCES_PATH:+--share="$SOURCES_PATH"} + ${BASE_CACHE:+--share="$BASE_CACHE"} + ${SDK_PATH:+--share="$SDK_PATH"} + --cores="$JOBS" + --keep-failed + --fallback + --link-profile + ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} + "${_guix_common_flags[@]}" "${_guix_env_flags[@]}" + -- env HOST="$host" \ + DISTNAME="$DISTNAME" + JOBS="$JOBS" + SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" + ${V:+V=1} + ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} + ${BASE_CACHE:+BASE_CACHE="$BASE_CACHE"} + ${SDK_PATH:+SDK_PATH="$SDK_PATH"} + DISTSRC="$(distsrc_for_host "$HOST" "" /distsrc-base)" + OUTDIR="$(outdir_for_host "$HOST" "" /outdir-base)" + DIST_ARCHIVE_BASE=/outdir-base/dist-archive + ) + + case "$HOST" in + *linux*) + time-machine shell --root="$(profiledir_for_host "${HOST}")" \ + "${shell_opts[@]}" \ + bash -c "cd /bitcoin && bash contrib/guix/libexec/build_linux.sh" + + time-machine shell --manifest="${PWD}/contrib/guix/manifest_gui.scm" \ + --root="$(profiledir_for_host "${HOST}"_gui)" \ + "${shell_opts[@]}" \ + bash -c "cd /bitcoin && bash contrib/guix/libexec/build_linux_gui.sh" + ;; + *darwin*) + time-machine shell --root="$(profiledir_for_host "${HOST}")" \ + "${shell_opts[@]}" \ + bash -c "cd /bitcoin && bash contrib/guix/libexec/build_macos.sh" + + time-machine shell --manifest="${PWD}/contrib/guix/manifest_gui.scm" \ + --root="$(profiledir_for_host "${HOST}"_gui)" \ + "${shell_opts[@]}" \ + bash -c "cd /bitcoin && bash contrib/guix/libexec/build_macos_gui.sh" + ;; + *mingw*) + time-machine shell --root="$(profiledir_for_host "${HOST}")" \ + "${shell_opts[@]}" \ + bash -c "cd /bitcoin && bash contrib/guix/libexec/build_win.sh" + + time-machine shell --manifest="${PWD}/contrib/guix/manifest_gui.scm" \ + --root="$(profiledir_for_host "${HOST}"_gui)" \ + "${shell_opts[@]}" \ + bash -c "cd /bitcoin && bash contrib/guix/libexec/build_win_gui.sh" + ;; + esac ) done diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh deleted file mode 100755 index 0ec058b8de3..00000000000 --- a/contrib/guix/libexec/build.sh +++ /dev/null @@ -1,207 +0,0 @@ -#!/usr/bin/env bash -# Copyright (c) 2019-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 -set -e -o pipefail - -# shellcheck source=setup.sh -source "$(dirname "${BASH_SOURCE[0]}")/setup.sh" - -# Set environment variables to point the NATIVE toolchain to the right -# includes/libs -NATIVE_GCC="$(store_path gcc-toolchain)" - -# Set native toolchain -build_CC="${NATIVE_GCC}/bin/gcc -isystem ${NATIVE_GCC}/include" -build_CXX="${NATIVE_GCC}/bin/g++ -isystem ${NATIVE_GCC}/include/c++ -isystem ${NATIVE_GCC}/include" - -case "$HOST" in - *darwin*) export LIBRARY_PATH="${NATIVE_GCC}/lib" ;; # Required for native packages - *mingw*) export LIBRARY_PATH="${NATIVE_GCC}/lib" ;; - *) - NATIVE_GCC_STATIC="$(store_path gcc-toolchain static)" - export LIBRARY_PATH="${NATIVE_GCC}/lib:${NATIVE_GCC_STATIC}/lib" - ;; -esac - -# Set environment variables to point the CROSS toolchain to the right -# includes/libs for $HOST -case "$HOST" in - *mingw*) - # Determine output paths to use in CROSS_* environment variables - CROSS_GLIBC="$(store_path "mingw-w64-x86_64-winpthreads")" - CROSS_GCC="$(store_path "gcc-cross-${HOST}")" - CROSS_GCC_LIB_STORE="$(store_path "gcc-cross-${HOST}" lib)" - CROSS_GCC_LIBS=( "${CROSS_GCC_LIB_STORE}/lib/gcc/${HOST}"/* ) # This expands to an array of directories... - CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one) - - # The search path ordering is generally: - # 1. gcc-related search paths - # 2. libc-related search paths - # 2. kernel-header-related search paths (not applicable to mingw-w64 hosts) - export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include" - export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}" - export CROSS_LIBRARY_PATH="${CROSS_GCC_LIB_STORE}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib" - ;; - *darwin*) - # The CROSS toolchain for darwin uses the SDK and ignores environment variables. - # See depends/hosts/darwin.mk for more details. - ;; - *linux*) - CROSS_GLIBC="$(store_path "glibc-cross-${HOST}")" - CROSS_GLIBC_STATIC="$(store_path "glibc-cross-${HOST}" static)" - CROSS_KERNEL="$(store_path "linux-libre-headers-cross-${HOST}")" - CROSS_GCC="$(store_path "gcc-cross-${HOST}")" - CROSS_GCC_LIB_STORE="$(store_path "gcc-cross-${HOST}" lib)" - CROSS_GCC_LIBS=( "${CROSS_GCC_LIB_STORE}/lib/gcc/${HOST}"/* ) # This expands to an array of directories... - CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one) - - export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include:${CROSS_KERNEL}/include" - export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}" - export CROSS_LIBRARY_PATH="${CROSS_GCC_LIB_STORE}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib:${CROSS_GLIBC_STATIC}/lib" - ;; - *) - exit 1 ;; -esac - -# Sanity check CROSS_*_PATH directories -IFS=':' read -ra PATHS <<< "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}" -for p in "${PATHS[@]}"; do - if [ -n "$p" ] && [ ! -d "$p" ]; then - echo "'$p' doesn't exist or isn't a directory... Aborting..." - exit 1 - fi -done - -# Determine the correct value for -Wl,--dynamic-linker for the current $HOST -case "$HOST" in - *linux*) - glibc_dynamic_linker=$( - case "$HOST" in - x86_64-linux-gnu) echo /lib64/ld-linux-x86-64.so.2 ;; - arm-linux-gnueabihf) echo /lib/ld-linux-armhf.so.3 ;; - aarch64-linux-gnu) echo /lib/ld-linux-aarch64.so.1 ;; - riscv64-linux-gnu) echo /lib/ld-linux-riscv64-lp64d.so.1 ;; - powerpc64-linux-gnu) echo /lib64/ld64.so.1;; - powerpc64le-linux-gnu) echo /lib64/ld64.so.2;; - *) exit 1 ;; - esac - ) - ;; -esac - -#################### -# Depends Building # -#################### - -# Build the depends tree, overriding variables that assume multilib gcc -make -C depends --jobs="$JOBS" HOST="$HOST" \ - ${V:+V=1} \ - ${SOURCES_PATH+SOURCES_PATH="$SOURCES_PATH"} \ - ${BASE_CACHE+BASE_CACHE="$BASE_CACHE"} \ - ${SDK_PATH+SDK_PATH="$SDK_PATH"} \ - ${build_CC+build_CC="$build_CC"} \ - ${build_CXX+build_CXX="$build_CXX"} \ - x86_64_linux_CC=x86_64-linux-gnu-gcc \ - x86_64_linux_CXX=x86_64-linux-gnu-g++ \ - x86_64_linux_AR=x86_64-linux-gnu-gcc-ar \ - x86_64_linux_RANLIB=x86_64-linux-gnu-gcc-ranlib \ - x86_64_linux_NM=x86_64-linux-gnu-gcc-nm \ - x86_64_linux_STRIP=x86_64-linux-gnu-strip - -case "$HOST" in - *darwin*) - # Unset now that Qt is built - unset LIBRARY_PATH - ;; -esac - -########################### -# Binary Tarball Building # -########################### - -# CONFIGFLAGS -CONFIGFLAGS="-DREDUCE_EXPORTS=ON -DBUILD_BENCH=OFF -DBUILD_GUI_TESTS=OFF -DBUILD_FUZZ_BINARY=OFF -DCMAKE_SKIP_RPATH=TRUE" - -# CFLAGS -HOST_CFLAGS="-O2 -g" -HOST_CFLAGS+=$(find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;) -HOST_CFLAGS+=" -fdebug-prefix-map=${DISTSRC}/src=." -case "$HOST" in - *mingw*) HOST_CFLAGS+=" -fno-ident" ;; - *darwin*) unset HOST_CFLAGS ;; -esac - -# CXXFLAGS -HOST_CXXFLAGS="$HOST_CFLAGS" - -case "$HOST" in - arm-linux-gnueabihf) HOST_CXXFLAGS="${HOST_CXXFLAGS} -Wno-psabi" ;; -esac - -# LDFLAGS -case "$HOST" in - *linux*) HOST_LDFLAGS="-Wl,--as-needed -Wl,--dynamic-linker=$glibc_dynamic_linker -Wl,-O2" ;; - *mingw*) HOST_LDFLAGS="-Wl,--no-insert-timestamp" ;; -esac - -# EXE FLAGS -case "$HOST" in - *linux*) CMAKE_EXE_LINKER_FLAGS="-DCMAKE_EXE_LINKER_FLAGS=${HOST_LDFLAGS} -static-libstdc++ -static-libgcc" ;; -esac - -mkdir -p "$DISTSRC" -( - cd "$DISTSRC" - - # Extract the source tarball - tar --strip-components=1 -xf "${GIT_ARCHIVE}" - - # Configure this DISTSRC for $HOST - # shellcheck disable=SC2086 - env CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}" LDFLAGS="${HOST_LDFLAGS}" \ - cmake -S . -B build \ - --toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \ - -DWITH_CCACHE=OFF \ - -Werror=dev \ - ${CONFIGFLAGS} \ - ${CMAKE_EXE_LINKER_FLAGS+"$CMAKE_EXE_LINKER_FLAGS"} - - # Build Bitcoin Core - cmake --build build -j "$JOBS" - - mkdir -p "$OUTDIR" - - # Make the os-specific installers - case "$HOST" in - *mingw*) - cmake --build build -j "$JOBS" -t deploy - mv build/bitcoin-win64-setup.exe "${OUTDIR}/${DISTNAME}-win64-setup-unsigned.exe" - ;; - esac - - # Setup the directory where our Bitcoin Core build for HOST will be - # installed. This directory will also later serve as the input for our - # binary tarballs. - mkdir -p "${INSTALLPATH}" - # Install built Bitcoin Core to $INSTALLPATH - case "$HOST" in - *darwin*) - cmake --install build --strip --prefix "${INSTALLPATH}" - ;; - *) - cmake --install build --prefix "${INSTALLPATH}" - ;; - esac - - # Perform basic security checks on installed executables. - echo "Checking binary security on installed executables..." - python3 "${DISTSRC}/contrib/guix/security-check.py" "${INSTALLPATH}/bin/"* "${INSTALLPATH}/libexec/"* - # Check that executables only contain allowed version symbols. - echo "Running symbol and dynamic library checks on installed executables..." - python3 "${DISTSRC}/contrib/guix/symbol-check.py" "${INSTALLPATH}/bin/"* "${INSTALLPATH}/libexec/"* -) # $DISTSRC - -# shellcheck source=package.sh -source "$(dirname "${BASH_SOURCE[0]}")/package.sh" diff --git a/contrib/guix/libexec/build_linux.sh b/contrib/guix/libexec/build_linux.sh new file mode 100755 index 00000000000..15dc77ab138 --- /dev/null +++ b/contrib/guix/libexec/build_linux.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash +# Copyright (c) The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit. +export LC_ALL=C +set -o errexit -o pipefail + +# shellcheck source=setup.sh +source "$(dirname "${BASH_SOURCE[0]}")/setup.sh" + +# Set environment variables to point the NATIVE toolchain to the right +# includes/libs +NATIVE_GCC="$(store_path gcc-toolchain)" + +# Set native toolchain +build_CC="${NATIVE_GCC}/bin/gcc -isystem ${NATIVE_GCC}/include" +build_CXX="${NATIVE_GCC}/bin/g++ -isystem ${NATIVE_GCC}/include/c++ -isystem ${NATIVE_GCC}/include" + +NATIVE_GCC_STATIC="$(store_path gcc-toolchain static)" +export LIBRARY_PATH="${NATIVE_GCC}/lib:${NATIVE_GCC_STATIC}/lib" + +# Set environment variables to point the CROSS toolchain to the right +# includes/libs for $HOST +CROSS_GLIBC="$(store_path "glibc-cross-${HOST}")" +CROSS_GLIBC_STATIC="$(store_path "glibc-cross-${HOST}" static)" +CROSS_KERNEL="$(store_path "linux-libre-headers-cross-${HOST}")" +CROSS_GCC="$(store_path "gcc-cross-${HOST}")" +CROSS_GCC_LIB_STORE="$(store_path "gcc-cross-${HOST}" lib)" +CROSS_GCC_LIBS=( "${CROSS_GCC_LIB_STORE}/lib/gcc/${HOST}"/* ) # This expands to an array of directories... +CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one) + +export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include:${CROSS_KERNEL}/include" +export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}" +export CROSS_LIBRARY_PATH="${CROSS_GCC_LIB_STORE}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib:${CROSS_GLIBC_STATIC}/lib" + +check_cross_paths "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}" + +# Build the depends tree, overriding variables that assume multilib gcc +make -C depends --jobs="$JOBS" HOST="$HOST" \ + ${V:+V=1} \ + ${SOURCES_PATH+SOURCES_PATH="$SOURCES_PATH"} \ + ${BASE_CACHE+BASE_CACHE="$BASE_CACHE"} \ + ${build_CC+build_CC="$build_CC"} \ + ${build_CXX+build_CXX="$build_CXX"} \ + x86_64_linux_CC=x86_64-linux-gnu-gcc \ + x86_64_linux_CXX=x86_64-linux-gnu-g++ \ + x86_64_linux_AR=x86_64-linux-gnu-gcc-ar \ + x86_64_linux_RANLIB=x86_64-linux-gnu-gcc-ranlib \ + x86_64_linux_NM=x86_64-linux-gnu-gcc-nm \ + x86_64_linux_STRIP=x86_64-linux-gnu-strip \ + NO_QT=1 + +# CFLAGS +HOST_CFLAGS="-O2 -g" +HOST_CFLAGS+=$(find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;) +HOST_CFLAGS+=" -fdebug-prefix-map=${DISTSRC}/src=." + +# CXXFLAGS +HOST_CXXFLAGS="$HOST_CFLAGS" + +case "$HOST" in + arm-linux-gnueabihf) HOST_CXXFLAGS="${HOST_CXXFLAGS} -Wno-psabi" ;; +esac + +# LDFLAGS +HOST_LDFLAGS="-Wl,--as-needed -Wl,--dynamic-linker=$(glibc_dynamic_linker "$HOST") -Wl,-O2" + +mkdir -p "$DISTSRC" +( + cd "$DISTSRC" + + # Extract the source tarball + tar --strip-components=1 -xf "${GIT_ARCHIVE}" + + # Configure this DISTSRC for $HOST + env CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}" LDFLAGS="${HOST_LDFLAGS}" \ + cmake -S . -B build \ + --toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \ + -Werror=dev \ + -DBUILD_BENCH=OFF \ + -DBUILD_FUZZ_BINARY=OFF \ + -DBUILD_GUI=OFF \ + -DCMAKE_INSTALL_PREFIX="${INSTALLPATH}" \ + -DCMAKE_SKIP_RPATH=TRUE \ + -DREDUCE_EXPORTS=ON \ + -DCMAKE_EXE_LINKER_FLAGS="${HOST_LDFLAGS} -static-libstdc++ -static-libgcc" \ + -DWITH_CCACHE=OFF + + # Build Bitcoin Core + cmake --build build -j "$JOBS" + + # Install built Bitcoin Core + cmake --install build +) + +rm -rf "$DISTSRC"/build + +exit 0 diff --git a/contrib/guix/libexec/build_linux_gui.sh b/contrib/guix/libexec/build_linux_gui.sh new file mode 100755 index 00000000000..d14dda00293 --- /dev/null +++ b/contrib/guix/libexec/build_linux_gui.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +# Copyright (c) The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit. +export LC_ALL=C +set -o errexit -o pipefail + +# shellcheck source=setup.sh +source "$(dirname "${BASH_SOURCE[0]}")/setup.sh" + +# Set environment variables to point the NATIVE toolchain to the right +# includes/libs +NATIVE_GCC="$(store_path gcc-toolchain)" + +# Set native toolchain +build_CC="${NATIVE_GCC}/bin/gcc -isystem ${NATIVE_GCC}/include" +build_CXX="${NATIVE_GCC}/bin/g++ -isystem ${NATIVE_GCC}/include/c++ -isystem ${NATIVE_GCC}/include" + +NATIVE_GCC_STATIC="$(store_path gcc-toolchain static)" +export LIBRARY_PATH="${NATIVE_GCC}/lib:${NATIVE_GCC_STATIC}/lib" + +# Set environment variables to point the CROSS toolchain to the right +# includes/libs for $HOST +CROSS_GLIBC="$(store_path "glibc-cross-${HOST}")" +CROSS_GLIBC_STATIC="$(store_path "glibc-cross-${HOST}" static)" +CROSS_KERNEL="$(store_path "linux-libre-headers-cross-${HOST}")" +CROSS_GCC="$(store_path "gcc-cross-${HOST}")" +CROSS_GCC_LIB_STORE="$(store_path "gcc-cross-${HOST}" lib)" +CROSS_GCC_LIBS=( "${CROSS_GCC_LIB_STORE}/lib/gcc/${HOST}"/* ) # This expands to an array of directories... +CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one) + +export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include:${CROSS_KERNEL}/include" +export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}" +export CROSS_LIBRARY_PATH="${CROSS_GCC_LIB_STORE}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib:${CROSS_GLIBC_STATIC}/lib" + +check_cross_paths "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}" + +# Build the depends tree, overriding variables that assume multilib gcc +make -C depends --jobs="$JOBS" HOST="$HOST" \ + ${V:+V=1} \ + ${SOURCES_PATH+SOURCES_PATH="$SOURCES_PATH"} \ + ${BASE_CACHE+BASE_CACHE="$BASE_CACHE"} \ + ${build_CC+build_CC="$build_CC"} \ + ${build_CXX+build_CXX="$build_CXX"} \ + x86_64_linux_CC=x86_64-linux-gnu-gcc \ + x86_64_linux_CXX=x86_64-linux-gnu-g++ \ + x86_64_linux_AR=x86_64-linux-gnu-gcc-ar \ + x86_64_linux_RANLIB=x86_64-linux-gnu-gcc-ranlib \ + x86_64_linux_NM=x86_64-linux-gnu-gcc-nm \ + x86_64_linux_STRIP=x86_64-linux-gnu-strip + +# CFLAGS +HOST_CFLAGS="-O2 -g" +HOST_CFLAGS+=$(find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;) +HOST_CFLAGS+=" -fdebug-prefix-map=${DISTSRC}/src=." + +# CXXFLAGS +HOST_CXXFLAGS="$HOST_CFLAGS" + +case "$HOST" in + arm-linux-gnueabihf) HOST_CXXFLAGS="${HOST_CXXFLAGS} -Wno-psabi" ;; +esac + +# LDFLAGS +HOST_LDFLAGS="-Wl,--as-needed -Wl,--dynamic-linker=$(glibc_dynamic_linker "$HOST") -Wl,-O2" + +mkdir -p "$DISTSRC" +( + cd "$DISTSRC" + + # Extract the source tarball + tar --strip-components=1 -xf "${GIT_ARCHIVE}" + + # Configure this DISTSRC for $HOST + env CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}" LDFLAGS="${HOST_LDFLAGS}" \ + cmake -S . -B build \ + --toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \ + -Werror=dev \ + -DBUILD_BENCH=OFF \ + -DBUILD_CLI=OFF \ + -DBUILD_DAEMON=OFF \ + -DBUILD_FUZZ_BINARY=OFF \ + -DBUILD_GUI_TESTS=OFF \ + -DBUILD_TESTS=OFF \ + -DBUILD_TX=OFF \ + -DBUILD_UTIL=OFF \ + -DBUILD_WALLET_TOOL=OFF \ + -DCMAKE_EXE_LINKER_FLAGS="${HOST_LDFLAGS} -static-libstdc++ -static-libgcc" \ + -DCMAKE_INSTALL_PREFIX="${INSTALLPATH}" \ + -DCMAKE_SKIP_RPATH=TRUE \ + -DREDUCE_EXPORTS=ON \ + -DWITH_CCACHE=OFF + + # Build Bitcoin Core + cmake --build build -j "$JOBS" --target bitcoin-gui bitcoin-qt + + # Install built Bitcoin Core + cmake --install build --component bitcoin-gui + cmake --install build --component bitcoin-qt +) # $DISTSRC + +# shellcheck source=package.sh +source "$(dirname "${BASH_SOURCE[0]}")/package.sh" diff --git a/contrib/guix/libexec/build_macos.sh b/contrib/guix/libexec/build_macos.sh new file mode 100755 index 00000000000..213ae9a6c7f --- /dev/null +++ b/contrib/guix/libexec/build_macos.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# Copyright (c) The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit. +export LC_ALL=C +set -o errexit -o pipefail + +# shellcheck source=setup.sh +source "$(dirname "${BASH_SOURCE[0]}")/setup.sh" + +# Set environment variables to point the NATIVE toolchain to the right +# includes/libs +NATIVE_GCC="$(store_path gcc-toolchain)" + +# Set native toolchain +build_CC="${NATIVE_GCC}/bin/gcc -isystem ${NATIVE_GCC}/include" +build_CXX="${NATIVE_GCC}/bin/g++ -isystem ${NATIVE_GCC}/include/c++ -isystem ${NATIVE_GCC}/include" + +# Build the depends tree +make -C depends --jobs="$JOBS" HOST="$HOST" \ + ${V:+V=1} \ + ${SOURCES_PATH+SOURCES_PATH="$SOURCES_PATH"} \ + ${BASE_CACHE+BASE_CACHE="$BASE_CACHE"} \ + ${SDK_PATH+SDK_PATH="$SDK_PATH"} \ + ${build_CC+build_CC="$build_CC"} \ + ${build_CXX+build_CXX="$build_CXX"} \ + NO_QT=1 + +mkdir -p "$DISTSRC" +( + cd "$DISTSRC" + + # Extract the source tarball + tar --strip-components=1 -xf "${GIT_ARCHIVE}" + + # Configure this DISTSRC for $HOST + env cmake -S . -B build \ + --toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \ + -Werror=dev \ + -DBUILD_BENCH=OFF \ + -DBUILD_FUZZ_BINARY=OFF \ + -DBUILD_GUI=OFF \ + -DBUILD_GUI_TESTS=OFF \ + -DCMAKE_INSTALL_PREFIX="${INSTALLPATH}" \ + -DCMAKE_SKIP_RPATH=TRUE \ + -DREDUCE_EXPORTS=ON \ + -DWITH_CCACHE=OFF + + # Build Bitcoin Core + cmake --build build -j "$JOBS" + + # Install built Bitcoin Core + cmake --install build --strip +) + +rm -rf "$DISTSRC"/build + +exit 0 diff --git a/contrib/guix/libexec/build_macos_gui.sh b/contrib/guix/libexec/build_macos_gui.sh new file mode 100755 index 00000000000..97f1932d85e --- /dev/null +++ b/contrib/guix/libexec/build_macos_gui.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# Copyright (c) The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit. +export LC_ALL=C +set -o errexit -o pipefail + +# shellcheck source=setup.sh +source "$(dirname "${BASH_SOURCE[0]}")/setup.sh" + +# Set environment variables to point the NATIVE toolchain to the right +# includes/libs +NATIVE_GCC="$(store_path gcc-toolchain)" + +# Set native toolchain +build_CC="${NATIVE_GCC}/bin/gcc -isystem ${NATIVE_GCC}/include" +build_CXX="${NATIVE_GCC}/bin/g++ -isystem ${NATIVE_GCC}/include/c++ -isystem ${NATIVE_GCC}/include" + +# Build the depends tree +make -C depends --jobs="$JOBS" HOST="$HOST" \ + ${V:+V=1} \ + ${SOURCES_PATH+SOURCES_PATH="$SOURCES_PATH"} \ + ${BASE_CACHE+BASE_CACHE="$BASE_CACHE"} \ + ${SDK_PATH+SDK_PATH="$SDK_PATH"} \ + ${build_CC+build_CC="$build_CC"} \ + ${build_CXX+build_CXX="$build_CXX"} + +mkdir -p "$DISTSRC" +( + cd "$DISTSRC" + + # Extract the source tarball + tar --strip-components=1 -xf "${GIT_ARCHIVE}" + + # Configure this DISTSRC for $HOST + env cmake -S . -B build \ + --toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \ + -DWITH_CCACHE=OFF \ + -Werror=dev \ + -DBUILD_BENCH=OFF \ + -DBUILD_BITCOIN_BIN=OFF \ + -DBUILD_CLI=OFF \ + -DBUILD_DAEMON=OFF \ + -DBUILD_FUZZ_BINARY=OFF \ + -DBUILD_GUI_TESTS=OFF \ + -DBUILD_TESTS=OFF \ + -DBUILD_TX=OFF \ + -DBUILD_UTIL=OFF \ + -DBUILD_WALLET_TOOL=OFF \ + -DCMAKE_INSTALL_PREFIX="${INSTALLPATH}" \ + -DCMAKE_SKIP_RPATH=TRUE \ + -DREDUCE_EXPORTS=ON + + # Build Bitcoin Core + cmake --build build -j "$JOBS" --target bitcoin-gui bitcoin-qt + + # Install built Bitcoin Core + cmake --install build --strip --component bitcoin-gui + cmake --install build --strip --component bitcoin-qt +) + +# shellcheck source=package.sh +source "$(dirname "${BASH_SOURCE[0]}")/package.sh" diff --git a/contrib/guix/libexec/build_win.sh b/contrib/guix/libexec/build_win.sh new file mode 100755 index 00000000000..fc3b46aa38e --- /dev/null +++ b/contrib/guix/libexec/build_win.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash +# Copyright (c) The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit. +export LC_ALL=C +set -o errexit -o pipefail + +# shellcheck source=setup.sh +source "$(dirname "${BASH_SOURCE[0]}")/setup.sh" + +# Set environment variables to point the NATIVE toolchain to the right +# includes/libs +NATIVE_GCC="$(store_path gcc-toolchain)" + +# Set native toolchain +build_CC="${NATIVE_GCC}/bin/gcc -isystem ${NATIVE_GCC}/include" +build_CXX="${NATIVE_GCC}/bin/g++ -isystem ${NATIVE_GCC}/include/c++ -isystem ${NATIVE_GCC}/include" + +# Set environment variables to point the CROSS toolchain to the right +# includes/libs for $HOST +# Determine output paths to use in CROSS_* environment variables +CROSS_GLIBC="$(store_path "mingw-w64-x86_64-winpthreads")" +CROSS_GCC="$(store_path "gcc-cross-${HOST}")" +CROSS_GCC_LIB_STORE="$(store_path "gcc-cross-${HOST}" lib)" +CROSS_GCC_LIBS=( "${CROSS_GCC_LIB_STORE}/lib/gcc/${HOST}"/* ) # This expands to an array of directories... +CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one) + +# The search path ordering is generally: +# 1. gcc-related search paths +# 2. libc-related search paths +# 2. kernel-header-related search paths (not applicable to mingw-w64 hosts) +export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include" +export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}" +export CROSS_LIBRARY_PATH="${CROSS_GCC_LIB_STORE}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib" + +check_cross_paths "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}" + +# Build the depends tree +make -C depends --jobs="$JOBS" HOST="$HOST" \ + ${V:+V=1} \ + ${SOURCES_PATH+SOURCES_PATH="$SOURCES_PATH"} \ + ${BASE_CACHE+BASE_CACHE="$BASE_CACHE"} \ + ${build_CC+build_CC="$build_CC"} \ + ${build_CXX+build_CXX="$build_CXX"} \ + NO_QT=1 + +# CFLAGS +HOST_CFLAGS="-O2 -g" +HOST_CFLAGS+=$(find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;) +HOST_CFLAGS+=" -fdebug-prefix-map=${DISTSRC}/src=." +HOST_CFLAGS+=" -fno-ident" + +# CXXFLAGS +HOST_CXXFLAGS="$HOST_CFLAGS" + +# LDFLAGS +HOST_LDFLAGS="-Wl,--no-insert-timestamp" + +mkdir -p "$DISTSRC" +( + cd "$DISTSRC" + + # Extract the source tarball + tar --strip-components=1 -xf "${GIT_ARCHIVE}" + + # Configure this DISTSRC for $HOST + env CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}" LDFLAGS="${HOST_LDFLAGS}" \ + cmake -S . -B build \ + --toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \ + -Werror=dev \ + -DBUILD_BENCH=OFF \ + -DBUILD_FUZZ_BINARY=OFF \ + -DBUILD_GUI=OFF \ + -DBUILD_GUI_TESTS=OFF \ + -DCMAKE_INSTALL_PREFIX="${INSTALLPATH}" \ + -DREDUCE_EXPORTS=ON \ + -DWITH_CCACHE=OFF + + # Build Bitcoin Core + cmake --build build -j "$JOBS" + + # Install built Bitcoin Core + cmake --install build +) + +rm -rf "$DISTSRC"/build + +exit 0 diff --git a/contrib/guix/libexec/build_win_gui.sh b/contrib/guix/libexec/build_win_gui.sh new file mode 100755 index 00000000000..aba93eb0654 --- /dev/null +++ b/contrib/guix/libexec/build_win_gui.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +# Copyright (c) The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit. +export LC_ALL=C +set -o errexit -o pipefail + +# shellcheck source=setup.sh +source "$(dirname "${BASH_SOURCE[0]}")/setup.sh" + +# Set environment variables to point the NATIVE toolchain to the right +# includes/libs +NATIVE_GCC="$(store_path gcc-toolchain)" + +# Set native toolchain +build_CC="${NATIVE_GCC}/bin/gcc -isystem ${NATIVE_GCC}/include" +build_CXX="${NATIVE_GCC}/bin/g++ -isystem ${NATIVE_GCC}/include/c++ -isystem ${NATIVE_GCC}/include" + +# Set environment variables to point the CROSS toolchain to the right +# includes/libs for $HOST +# Determine output paths to use in CROSS_* environment variables +CROSS_GLIBC="$(store_path "mingw-w64-x86_64-winpthreads")" +CROSS_GCC="$(store_path "gcc-cross-${HOST}")" +CROSS_GCC_LIB_STORE="$(store_path "gcc-cross-${HOST}" lib)" +CROSS_GCC_LIBS=( "${CROSS_GCC_LIB_STORE}/lib/gcc/${HOST}"/* ) # This expands to an array of directories... +CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one) + +# The search path ordering is generally: +# 1. gcc-related search paths +# 2. libc-related search paths +# 2. kernel-header-related search paths (not applicable to mingw-w64 hosts) +export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include" +export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}" +export CROSS_LIBRARY_PATH="${CROSS_GCC_LIB_STORE}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib" + +check_cross_paths "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}" + +# Build the depends tree +make -C depends --jobs="$JOBS" HOST="$HOST" \ + ${V:+V=1} \ + ${SOURCES_PATH+SOURCES_PATH="$SOURCES_PATH"} \ + ${BASE_CACHE+BASE_CACHE="$BASE_CACHE"} \ + ${build_CC+build_CC="$build_CC"} \ + ${build_CXX+build_CXX="$build_CXX"} + +# CFLAGS +HOST_CFLAGS="-O2 -g" +HOST_CFLAGS+=$(find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;) +HOST_CFLAGS+=" -fdebug-prefix-map=${DISTSRC}/src=." +HOST_CFLAGS+=" -fno-ident" + +# CXXFLAGS +HOST_CXXFLAGS="$HOST_CFLAGS" + +# LDFLAGS +HOST_LDFLAGS="-Wl,--no-insert-timestamp" + +mkdir -p "$DISTSRC" +( + cd "$DISTSRC" + + # Extract the source tarball + tar --strip-components=1 -xf "${GIT_ARCHIVE}" + + # Configure this DISTSRC for $HOST + env CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}" LDFLAGS="${HOST_LDFLAGS}" \ + cmake -S . -B build \ + --toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \ + -Werror=dev \ + -DBUILD_BENCH=OFF \ + -DBUILD_BITCOIN_BIN=OFF \ + -DBUILD_CLI=OFF \ + -DBUILD_DAEMON=OFF \ + -DBUILD_FUZZ_BINARY=OFF \ + -DBUILD_GUI_TESTS=OFF \ + -DBUILD_TESTS=OFF \ + -DBUILD_TX=OFF \ + -DBUILD_UTIL=OFF \ + -DBUILD_WALLET_TOOL=OFF \ + -DCMAKE_INSTALL_PREFIX="${INSTALLPATH}" \ + -DREDUCE_EXPORTS=ON \ + -DWITH_CCACHE=OFF + + # Build Bitcoin Core + cmake --build build -j "$JOBS" --target bitcoin-qt + + # Install built Bitcoin Core + cmake --install build --component bitcoin-qt +) + +# shellcheck source=package.sh +source "$(dirname "${BASH_SOURCE[0]}")/package.sh" diff --git a/contrib/guix/libexec/package.sh b/contrib/guix/libexec/package.sh index 7228346abe7..fd080ccf293 100755 --- a/contrib/guix/libexec/package.sh +++ b/contrib/guix/libexec/package.sh @@ -8,6 +8,13 @@ set -e -o pipefail ( cd "$DISTSRC" + # Perform basic security checks on installed executables. + echo "Checking binary security on installed executables..." + python3 "${DISTSRC}/contrib/guix/security-check.py" "${INSTALLPATH}/bin/"* "${INSTALLPATH}/libexec/"* + # Check that executables only contain allowed version symbols. + echo "Running symbol and dynamic library checks on installed executables..." + python3 "${DISTSRC}/contrib/guix/symbol-check.py" "${INSTALLPATH}/bin/"* "${INSTALLPATH}/libexec/"* + ( cd installed @@ -32,7 +39,7 @@ set -e -o pipefail esac # copy over the example bitcoin.conf file. if contrib/devtools/gen-bitcoin-conf.sh - # has not been run before buildling, this file will be a stub + # has not been run before building, this file will be a stub cp "${DISTSRC}/share/examples/bitcoin.conf" "${DISTNAME}/" cp -r "${DISTSRC}/share/rpcauth" "${DISTNAME}/share/" @@ -79,6 +86,10 @@ set -e -o pipefail # Finally make tarballs for codesigning case "$HOST" in *mingw*) + # Make the installer + cmake -D BIN_DIR="${INSTALLPATH}/bin" -D LIBEXEC_DIR="${INSTALLPATH}/libexec" -P build/GenerateWindowsInstaller.cmake + mv build/bitcoin-win64-setup.exe "${OUTDIR}/${DISTNAME}-win64-setup-unsigned.exe" + cp -rf --target-directory=. contrib/windeploy ( cd ./windeploy diff --git a/contrib/guix/libexec/prelude.bash b/contrib/guix/libexec/prelude.bash index 23852767897..994f6c5cdf7 100644 --- a/contrib/guix/libexec/prelude.bash +++ b/contrib/guix/libexec/prelude.bash @@ -1,6 +1,6 @@ #!/usr/bin/env bash export LC_ALL=C -set -e -o pipefail +set -o errexit -o pipefail source contrib/shell/realpath.bash source contrib/shell/git-utils.bash diff --git a/contrib/guix/libexec/setup.sh b/contrib/guix/libexec/setup.sh index 37388f98553..e8d70d590b3 100755 --- a/contrib/guix/libexec/setup.sh +++ b/contrib/guix/libexec/setup.sh @@ -3,7 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or https://opensource.org/license/mit. export LC_ALL=C -set -e -o pipefail +set -o errexit -o pipefail # Environment variables for determinism export TAR_OPTIONS="--no-same-owner --owner=0 --group=0 --numeric-owner --mtime='@${SOURCE_DATE_EPOCH}' --sort=name" @@ -61,6 +61,31 @@ store_path() { --expression='s|"[[:space:]]*$||' } +# Sanity check CROSS_*_PATH directories +check_cross_paths() { + local p paths + IFS=':' read -ra paths <<< "$1" + for p in "${paths[@]}"; do + if [ -n "$p" ] && [ ! -d "$p" ]; then + echo "'$p' doesn't exist or isn't a directory... Aborting..." >&2 + return 1 + fi + done +} + +# Given a hostname, determine the correct value for -Wl,--dynamic-linker. +glibc_dynamic_linker() { + case "$1" in + x86_64-linux-gnu) echo /lib64/ld-linux-x86-64.so.2 ;; + arm-linux-gnueabihf) echo /lib/ld-linux-armhf.so.3 ;; + aarch64-linux-gnu) echo /lib/ld-linux-aarch64.so.1 ;; + riscv64-linux-gnu) echo /lib/ld-linux-riscv64-lp64d.so.1 ;; + powerpc64-linux-gnu) echo /lib64/ld64.so.1 ;; + powerpc64le-linux-gnu) echo /lib64/ld64.so.2 ;; + *) exit 1 ;; + esac +} + # Disable Guix ld auto-rpath behavior export GUIX_LD_WRAPPER_DISABLE_RPATH=yes diff --git a/contrib/guix/manifest_build.scm b/contrib/guix/manifest_build.scm index 576021e60d7..b9f0dd9edcf 100644 --- a/contrib/guix/manifest_build.scm +++ b/contrib/guix/manifest_build.scm @@ -1,20 +1,14 @@ (use-modules (gnu packages) ((gnu packages bash) #:select (bash-minimal)) - (gnu packages bison) ((gnu packages cmake) #:select (cmake-minimal)) (gnu packages commencement) - ((gnu packages compression) #:select (gzip xz zip)) + ((gnu packages compression) #:select (gzip)) (gnu packages cross-base) - (gnu packages gawk) (gnu packages gcc) - ((gnu packages installers) #:select (nsis-x86_64)) ((gnu packages linux) #:select (linux-libre-headers-6.1)) (gnu packages llvm) (gnu packages mingw) - (gnu packages ninja) - (gnu packages pkg-config) ((gnu packages python) #:select (python-minimal)) - ((gnu packages python-xyz) #:select (python-lief)) ((gnu packages version-control) #:select (git-minimal)) (guix build-system trivial) (guix download) @@ -262,40 +256,29 @@ chain for " target " development.")) coreutils-minimal ;; File(system) inspection grep - diffutils findutils ;; File transformation patch - gawk sed ;; Compression and archiving tar gzip - xz ;; Build tools gcc-toolchain-14 cmake-minimal gnu-make - ninja ;; Scripting python-minimal ;; (3.11) ;; Git - git-minimal - ;; Tests - python-lief) + git-minimal) (let ((target (getenv "HOST"))) (cond ((string-suffix? "-mingw32" target) - (list (make-mingw-pthreads-cross-toolchain "x86_64-w64-mingw32") - nsis-x86_64 - zip)) + (list (make-mingw-pthreads-cross-toolchain "x86_64-w64-mingw32"))) ((string-contains target "-linux-") - (list bison - pkg-config - (list gcc-toolchain-14 "static") + (list (list gcc-toolchain-14 "static") (make-bitcoin-cross-toolchain target))) ((string-contains target "darwin") (list clang-toolchain-19 lld-19 - (make-lld-wrapper lld-19 #:lld-as-ld? #t) - zip)) + (make-lld-wrapper lld-19 #:lld-as-ld? #t))) (else '()))))) diff --git a/contrib/guix/manifest_gui.scm b/contrib/guix/manifest_gui.scm new file mode 100644 index 00000000000..fdb9a32b4a3 --- /dev/null +++ b/contrib/guix/manifest_gui.scm @@ -0,0 +1,27 @@ +(use-modules (gnu packages bison) + ((gnu packages compression) #:select (xz zip)) + (gnu packages gawk) + ((gnu packages installers) #:select (nsis-x86_64)) + (gnu packages ninja) + (gnu packages pkg-config) + ((gnu packages python-xyz) #:select (python-lief))) + +(packages->manifest + (append + (list ;; Compression and archiving + xz + ;; Build tools + ninja + ;; Tests + python-lief) + (let ((target (getenv "HOST"))) + (cond ((string-suffix? "-mingw32" target) + (list zip + nsis-x86_64)) + ((string-contains target "-linux-") + (list bison + gawk + pkg-config)) + ((string-contains target "darwin") + (list zip)) + (else '()))))) diff --git a/share/setup.nsi.in b/share/setup.nsi.in index 387d78116b8..d807b718b20 100644 --- a/share/setup.nsi.in +++ b/share/setup.nsi.in @@ -72,19 +72,19 @@ ShowUninstDetails show Section -Main SEC0000 SetOutPath $INSTDIR SetOverwrite on - File @abs_top_builddir@/release/@BITCOIN_GUI_NAME@@EXEEXT@ - File @abs_top_builddir@/release/@BITCOIN_WRAPPER_NAME@@EXEEXT@ + File @BIN_DIR@/@BITCOIN_GUI_NAME@@EXEEXT@ + File @BIN_DIR@/@BITCOIN_WRAPPER_NAME@@EXEEXT@ File /oname=COPYING.txt @abs_top_srcdir@/COPYING File /oname=readme.txt @abs_top_srcdir@/doc/README_windows.txt File @abs_top_srcdir@/share/examples/bitcoin.conf SetOutPath $INSTDIR\share\rpcauth File @abs_top_srcdir@/share/rpcauth/*.* SetOutPath $INSTDIR\daemon - File @abs_top_builddir@/release/@BITCOIN_DAEMON_NAME@@EXEEXT@ - File @abs_top_builddir@/release/@BITCOIN_CLI_NAME@@EXEEXT@ - File @abs_top_builddir@/release/@BITCOIN_TX_NAME@@EXEEXT@ - File @abs_top_builddir@/release/@BITCOIN_WALLET_TOOL_NAME@@EXEEXT@ - File @abs_top_builddir@/release/@BITCOIN_TEST_NAME@@EXEEXT@ + File @BIN_DIR@/@BITCOIN_DAEMON_NAME@@EXEEXT@ + File @BIN_DIR@/@BITCOIN_CLI_NAME@@EXEEXT@ + File @BIN_DIR@/@BITCOIN_TX_NAME@@EXEEXT@ + File @BIN_DIR@/@BITCOIN_WALLET_TOOL_NAME@@EXEEXT@ + File @LIBEXEC_DIR@/@BITCOIN_TEST_NAME@@EXEEXT@ SetOutPath $INSTDIR WriteRegStr HKCU "${REGKEY}\Components" Main 1 SectionEnd