Skip to content

Commit d07e4c3

Browse files
committed
use guix to build
1 parent 278531b commit d07e4c3

File tree

6 files changed

+81
-35
lines changed

6 files changed

+81
-35
lines changed

.github/workflows/benchmark.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ jobs:
3131
run: |
3232
mkdir -p ${{ runner.temp }}/binaries/base
3333
mkdir -p ${{ runner.temp }}/binaries/head
34-
nix-shell --command "just build-assumeutxo-binaries $BASE_SHA $CHECKOUT_COMMIT"
35-
cp build-base/src/bitcoind ${{ runner.temp }}/binaries/base/bitcoind
36-
cp build-head/src/bitcoind ${{ runner.temp }}/binaries/head/bitcoind
34+
nix-shell --command "just build-assumeutxo-binaries-guix $BASE_SHA $CHECKOUT_COMMIT"
35+
cp binaries/base/bitcoind ${{ runner.temp }}/binaries/base/bitcoind
36+
cp binaries/head/bitcoind ${{ runner.temp }}/binaries/head/bitcoind
3737
- name: Upload binaries
3838
uses: actions/upload-artifact@v4
3939
with:
@@ -86,10 +86,14 @@ jobs:
8686
BINARIES_DIR: "${{ runner.temp }}/binaries"
8787
run: |
8888
env
89+
90+
# Patch binary shared object dependencies
91+
nix-shell --command "patch-binary $BINARIES_DIR/head/bitcoind"
92+
nix-shell --command "patch-binary $BINARIES_DIR/base/bitcoind"
93+
94+
# Run test
8995
mkdir -p "$TMP_DATADIR"
90-
CMD="nix-shell --command \"just run-assumeutxo-${{ matrix.network }}-ci $BASE_SHA $CHECKOUT_COMMIT $TMP_DATADIR $UTXO_PATH ${{ runner.temp }}/results.json ${{ matrix.dbcache }} ${{ runner.temp }}/pngs $BINARIES_DIR\""
91-
echo "Running command: $CMD"
92-
eval "$CMD"
96+
nix-shell --command "just run-assumeutxo-${{ matrix.network }}-ci $BASE_SHA $CHECKOUT_COMMIT $TMP_DATADIR $UTXO_PATH ${{ runner.temp }}/results.json ${{ matrix.dbcache }} ${{ runner.temp }}/pngs $BINARIES_DIR"
9397
- uses: actions/upload-artifact@v4
9498
with:
9599
name: result-${{ matrix.network }}

bench-ci/run-assumeutxo-bench.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ prepare_assumeutxo_snapshot_run() {
6363
# Run the actual preparation steps
6464
clean_datadir "${TMP_DATADIR}"
6565
# Use the pre-built binaries from BINARIES_DIR
66+
"${BINARIES_DIR}/${commit}/bitcoind" --help
6667
taskset -c 0-15 "${BINARIES_DIR}/${commit}/bitcoind" -datadir="${TMP_DATADIR}" -connect="${CONNECT_ADDRESS}" -daemon=0 -chain="${CHAIN}" -stopatheight=1 -printtoconsole=0
6768
taskset -c 0-15 "${BINARIES_DIR}/${commit}/bitcoind" -datadir="${TMP_DATADIR}" -connect="${CONNECT_ADDRESS}" -daemon=0 -chain="${CHAIN}" -dbcache="${DBCACHE}" -pausebackgroundsync=1 -loadutxosnapshot="${UTXO_PATH}" -printtoconsole=0 || true
6869
clean_logs "${TMP_DATADIR}"

contrib/guix/libexec/build.sh

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
export LC_ALL=C
66
set -e -o pipefail
7+
set -x
78
export TZ=UTC
89

910
# Although Guix _does_ set umask when building its own packages (in our case,
@@ -171,6 +172,12 @@ make -C depends --jobs="$JOBS" HOST="$HOST" \
171172
${SOURCES_PATH+SOURCES_PATH="$SOURCES_PATH"} \
172173
${BASE_CACHE+BASE_CACHE="$BASE_CACHE"} \
173174
${SDK_PATH+SDK_PATH="$SDK_PATH"} \
175+
NO_QT=1 \
176+
NO_QR=1 \
177+
NO_ZMQ=1 \
178+
NO_WALLET=1 \
179+
NO_BDB=1 \
180+
NO_USDT=1 \
174181
x86_64_linux_CC=x86_64-linux-gnu-gcc \
175182
x86_64_linux_CXX=x86_64-linux-gnu-g++ \
176183
x86_64_linux_AR=x86_64-linux-gnu-gcc-ar \
@@ -208,6 +215,9 @@ mkdir -p "$OUTDIR"
208215
# CONFIGFLAGS
209216
CONFIGFLAGS="-DREDUCE_EXPORTS=ON -DBUILD_BENCH=OFF -DBUILD_GUI_TESTS=OFF -DBUILD_FUZZ_BINARY=OFF"
210217

218+
# BENCHCOINFLAGS
219+
BENCHCOINFLAGS="-DBUILD_CLI=OFF -DBUILD_TESTS=OFF -DCMAKE_CXX_FLAGS=-fno-omit-frame-pointer"
220+
211221
# CFLAGS
212222
HOST_CFLAGS="-O2 -g"
213223
HOST_CFLAGS+=$(find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;)
@@ -242,17 +252,18 @@ mkdir -p "$DISTSRC"
242252
cmake -S . -B build \
243253
--toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \
244254
-DWITH_CCACHE=OFF \
245-
${CONFIGFLAGS}
255+
${CONFIGFLAGS} \
256+
${BENCHCOINFLAGS}
246257

247258
# Build Bitcoin Core
248259
cmake --build build -j "$JOBS" ${V:+--verbose}
249260

250261
# Check that symbol/security checks tools are sane.
251-
cmake --build build --target test-security-check ${V:+--verbose}
262+
# cmake --build build --target test-security-check ${V:+--verbose}
252263
# Perform basic security checks on a series of executables.
253-
cmake --build build -j 1 --target check-security ${V:+--verbose}
264+
# cmake --build build -j 1 --target check-security ${V:+--verbose}
254265
# Check that executables only contain allowed version symbols.
255-
cmake --build build -j 1 --target check-symbols ${V:+--verbose}
266+
# cmake --build build -j 1 --target check-symbols ${V:+--verbose}
256267

257268
mkdir -p "$OUTDIR"
258269

@@ -304,15 +315,15 @@ mkdir -p "$DISTSRC"
304315
(
305316
cd installed
306317

307-
case "$HOST" in
308-
*darwin*) ;;
309-
*)
310-
# Split binaries from their debug symbols
311-
{
312-
find "${DISTNAME}/bin" -type f -executable -print0
313-
} | xargs -0 -P"$JOBS" -I{} "${DISTSRC}/build/split-debug.sh" {} {} {}.dbg
314-
;;
315-
esac
318+
# case "$HOST" in
319+
# *darwin*) ;;
320+
# *)
321+
# # Split binaries from their debug symbols
322+
# {
323+
# find "${DISTNAME}/bin" -type f -executable -print0
324+
# } | xargs -0 -P"$JOBS" -I{} "${DISTSRC}/build/split-debug.sh" {} {} {}.dbg
325+
# ;;
326+
# esac
316327

317328
case "$HOST" in
318329
*mingw*)

contrib/guix/libexec/prelude.bash

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
#!/usr/bin/env bash
22
export LC_ALL=C
33
set -e -o pipefail
4+
set -x
45

56
# shellcheck source=contrib/shell/realpath.bash
67
source contrib/shell/realpath.bash
78

89
# shellcheck source=contrib/shell/git-utils.bash
910
source contrib/shell/git-utils.bash
1011

12+
# Source guix profile from the runner home directory
13+
GUIX_PROFILE=/home/github-runner/.config/guix/current
14+
. "$GUIX_PROFILE/etc/profile"
15+
16+
echo "Using the following guix command:"
17+
command -v guix
18+
guix describe
19+
1120
################
1221
# Required non-builtin commands should be invocable
1322
################
@@ -48,9 +57,10 @@ fi
4857
################
4958
# Execute "$@" in a pinned, possibly older version of Guix, for reproducibility
5059
# across time.
60+
5161
time-machine() {
5262
# shellcheck disable=SC2086
53-
guix time-machine --url=https://git.savannah.gnu.org/git/guix.git \
63+
guix time-machine --url=https://github.com/fanquake/guix.git \
5464
--commit=53396a22afc04536ddf75d8f82ad2eafa5082725 \
5565
--cores="$JOBS" \
5666
--keep-failed \

justfile

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,30 @@ default:
77

88
# Build base and head binaries for CI
99
[group('ci')]
10-
build-assumeutxo-binaries base_commit head_commit:
10+
build-assumeutxo-binaries-guix base_commit head_commit:
1111
#!/usr/bin/env bash
1212
set -euxo pipefail
13+
14+
mkdir -p binaries/base
15+
mkdir -p binaries/head
16+
1317
for build in "base:{{ base_commit }}" "head:{{ head_commit }}"; do
1418
name="${build%%:*}"
1519
commit="${build#*:}"
1620
git checkout "$commit"
17-
taskset -c 0-15 cmake -B "build-$name" \
18-
-DBUILD_BENCH=OFF \
19-
-DBUILD_CLI=OFF \
20-
-DBUILD_TESTS=OFF \
21-
-DBUILD_TX=OFF \
22-
-DBUILD_UTIL=OFF \
23-
-DENABLE_EXTERNAL_SIGNER=OFF \
24-
-DENABLE_WALLET=OFF \
25-
-DINSTALL_MAN=OFF \
26-
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
27-
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
28-
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
29-
-DCMAKE_CXX_FLAGS="-fno-omit-frame-pointer -g"
30-
taskset -c 0-15 cmake --build "build-$name" -j {{ num_cpus() }}
21+
HOSTS=x86_64-linux-gnu SOURCES_PATH=/data/SOURCES_PATH BASE_CACHE=/data/BASE_CACHE taskset -c 0-15 contrib/guix/guix-build
22+
23+
# Truncate commit hash to 12 characters
24+
short_commit=$(echo "$commit" | cut -c 1-12)
25+
26+
# Extract the Guix output
27+
tar -xzf "guix-build-${short_commit}/output/x86_64-linux-gnu/bitcoin-${short_commit}-x86_64-linux-gnu.tar.gz"
28+
29+
# Copy the binary to our binaries directory
30+
cp "bitcoin-${short_commit}/bin/bitcoind" "binaries/${name}/bitcoind"
31+
32+
# Cleanup extracted files
33+
rm -rf "bitcoin-${short_commit}"
3134
done
3235

3336
# Run signet assumeutxo CI workflow

shell.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ in pkgs.mkShell {
9292
linuxKernel.packages.linux_6_6.perf
9393
perf-tools
9494
util-linux
95+
96+
# Binary patching
97+
patchelf
98+
99+
# Guix
100+
curl
101+
getent
95102
];
96103

97104
shellHook = ''
@@ -105,5 +112,15 @@ in pkgs.mkShell {
105112
uv venv --python 3.10
106113
source .venv/bin/activate
107114
uv pip install -r pyproject.toml
115+
116+
patch-binary() {
117+
if [ -z "$1" ]; then
118+
echo "Usage: patch-binary <binary-path>"
119+
return 1
120+
fi
121+
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$1"
122+
}
123+
echo "Added patch-binary command"
124+
echo " Usage: 'patch-binary <binary_path>'"
108125
'';
109126
}

0 commit comments

Comments
 (0)