Skip to content

Commit ca7129a

Browse files
committed
Switch to static linking and migrate Windows CI to MinGW
Simplify the build process by statically linking `libbitcoinkernel` to produces more self-contained binaries with fewer moving parts.
1 parent 7d2bf14 commit ca7129a

27 files changed

+50
-46
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,30 @@ jobs:
5959
windows:
6060
name: Build and Test on Windows
6161
runs-on: windows-latest
62+
defaults:
63+
run:
64+
shell: msys2 {0}
6265

6366
steps:
6467
- uses: actions/checkout@v4
6568

69+
- name: Set up MSYS2 with MinGW
70+
uses: msys2/setup-msys2@v2
71+
with:
72+
msystem: MINGW64
73+
update: true
74+
path-type: inherit
75+
install: >-
76+
mingw-w64-x86_64-gcc
77+
mingw-w64-x86_64-cmake
78+
mingw-w64-x86_64-boost
79+
make
80+
6681
- name: Set up Go
6782
uses: actions/setup-go@v5
6883
with:
6984
go-version: '1.23.3'
7085

71-
- name: Install Boost library
72-
run: |
73-
git clone https://github.com/microsoft/vcpkg.git
74-
cd vcpkg
75-
.\bootstrap-vcpkg.bat
76-
.\vcpkg install boost-multi-index:x64-windows boost-headers:x64-windows
77-
78-
- name: Set environment variables
79-
run: |
80-
echo "BOOST_ROOT=$env:GITHUB_WORKSPACE\vcpkg\installed\x64-windows" | Out-File -FilePath $env:GITHUB_ENV -Append
81-
echo "BOOST_INCLUDEDIR=$env:GITHUB_WORKSPACE\vcpkg\installed\x64-windows\include" | Out-File -FilePath $env:GITHUB_ENV -Append
82-
echo "$env:GITHUB_WORKSPACE\depend\bitcoin\build\bin\RelWithDebInfo" | Out-File -FilePath $env:GITHUB_PATH -Append
83-
84-
- name: Install make
85-
run: choco install make
86-
8786
- name: Build Kernel
8887
run: make build-kernel
8988

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-kernel:
88
cd depend/bitcoin && \
99
cmake -B build \
1010
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
11-
-DBUILD_SHARED_LIBS=ON \
11+
-DBUILD_SHARED_LIBS=OFF \
1212
-DBUILD_KERNEL_LIB=ON \
1313
-DBUILD_KERNEL_TEST=OFF \
1414
-DBUILD_TESTS=OFF \
@@ -21,8 +21,11 @@ build-kernel:
2121
-DBUILD_DAEMON=OFF \
2222
-DBUILD_UTIL_CHAINSTATE=OFF \
2323
-DBUILD_CLI=OFF \
24-
-DENABLE_IPC=OFF && \
25-
cmake --build build --config RelWithDebInfo --parallel$(if $(NUM_JOBS),=$(NUM_JOBS)) # Use NUM_JOBS variable if set (e.g., make build-kernel NUM_JOBS=8), otherwise auto-detect CPU cores
24+
-DENABLE_IPC=OFF \
25+
-DCMAKE_INSTALL_LIBDIR=lib \
26+
-DCMAKE_INSTALL_PREFIX=$$PWD/install && \
27+
cmake --build build --config RelWithDebInfo --parallel$(if $(NUM_JOBS),=$(NUM_JOBS)) && \
28+
cmake --install build --config RelWithDebInfo
2629

2730
build:
2831
go build ./...
@@ -32,6 +35,7 @@ test:
3235

3336
clean:
3437
rm -rf depend/bitcoin/build
38+
rm -rf depend/bitcoin/install
3539
go clean ./...
3640
go clean -testcache
3741

kernel/block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package kernel
22

33
/*
4-
#include "kernel/bitcoinkernel.h"
4+
#include "bitcoinkernel.h"
55
*/
66
import "C"
77
import (

kernel/block_hash.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package kernel
22

33
/*
4-
#include "kernel/bitcoinkernel.h"
4+
#include "bitcoinkernel.h"
55
*/
66
import "C"
77
import (

kernel/block_spent_outputs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package kernel
22

33
/*
4-
#include "kernel/bitcoinkernel.h"
4+
#include "bitcoinkernel.h"
55
*/
66
import "C"
77
import (

kernel/block_tree_entry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package kernel
22

33
/*
4-
#include "kernel/bitcoinkernel.h"
4+
#include "bitcoinkernel.h"
55
*/
66
import "C"
77

kernel/block_validation_state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package kernel
22

33
/*
4-
#include "kernel/bitcoinkernel.h"
4+
#include "bitcoinkernel.h"
55
*/
66
import "C"
77

kernel/cgo_unix.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
package kernel
44

55
/*
6-
#cgo CFLAGS: -I../depend/bitcoin/src
7-
#cgo LDFLAGS: -L../depend/bitcoin/build/lib -lbitcoinkernel -Wl,-rpath,${SRCDIR}/../depend/bitcoin/build/lib
6+
#cgo CFLAGS: -I../depend/bitcoin/install/include -DBITCOINKERNEL_STATIC
7+
#cgo darwin LDFLAGS: -L../depend/bitcoin/install/lib -lbitcoinkernel -lc++
8+
#cgo !darwin LDFLAGS: -L../depend/bitcoin/install/lib -lbitcoinkernel -lstdc++ -lm
89
*/
910
import "C"

kernel/cgo_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
package kernel
44

55
/*
6-
#cgo CFLAGS: -I../depend/bitcoin/src
7-
#cgo LDFLAGS: -L../depend/bitcoin/build/bin/RelWithDebInfo -lbitcoinkernel -lbcrypt -lshell32
6+
#cgo CFLAGS: -I../depend/bitcoin/install/include -DBITCOINKERNEL_STATIC
7+
#cgo LDFLAGS: -L../depend/bitcoin/install/lib -lbitcoinkernel -lstdc++ -lbcrypt -lshell32
88
*/
99
import "C"

kernel/chain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package kernel
22

33
/*
4-
#include "kernel/bitcoinkernel.h"
4+
#include "bitcoinkernel.h"
55
*/
66
import "C"
77

0 commit comments

Comments
 (0)