1
1
#! /usr/bin/env bash
2
2
export LC_ALL=C
3
3
set -e -o pipefail
4
+ export TZ=UTC
4
5
5
6
# Check that environment variables assumed to be set by the environment are set
6
7
echo " Building for platform triple ${HOST:? not set} with reference timestamp ${SOURCE_DATE_EPOCH:? not set} ..."
@@ -36,23 +37,41 @@ store_path() {
36
37
--expression=' s|"[[:space:]]*$||'
37
38
}
38
39
39
- # Determine output paths to use in CROSS_* environment variables
40
- CROSS_GLIBC=" $( store_path glibc-cross-${HOST} ) "
41
- CROSS_GLIBC_STATIC=" $( store_path glibc-cross-${HOST} static) "
42
- CROSS_KERNEL=" $( store_path linux-libre-headers-cross-${HOST} ) "
43
- CROSS_GCC=" $( store_path gcc-cross-${HOST} ) "
44
- CROSS_GCC_LIBS=( " ${CROSS_GCC} /lib/gcc/${HOST} " /* ) # This expands to an array of directories...
45
- CROSS_GCC_LIB=" ${CROSS_GCC_LIBS[0]} " # ...we just want the first one (there should only be one)
46
-
47
40
# Set environment variables to point Guix's cross-toolchain to the right
48
41
# includes/libs for $HOST
49
- #
50
- # NOTE: CROSS_C_INCLUDE_PATH is missing ${CROSS_GCC_LIB}/include-fixed, because
51
- # the limits.h in it is missing a '#include_next <limits.h>'
52
- #
53
- export CROSS_C_INCLUDE_PATH=" ${CROSS_GCC_LIB} /include:${CROSS_GLIBC} /include:${CROSS_KERNEL} /include"
54
- export CROSS_CPLUS_INCLUDE_PATH=" ${CROSS_GCC} /include/c++:${CROSS_GCC} /include/c++/${HOST} :${CROSS_GCC} /include/c++/backward:${CROSS_C_INCLUDE_PATH} "
55
- export CROSS_LIBRARY_PATH=" ${CROSS_GCC} /lib:${CROSS_GCC} /${HOST} /lib:${CROSS_GCC_LIB} :${CROSS_GLIBC} /lib:${CROSS_GLIBC_STATIC} /lib"
42
+ case " $HOST " in
43
+ * mingw* )
44
+ # Determine output paths to use in CROSS_* environment variables
45
+ CROSS_GLIBC=" $( store_path " mingw-w64-x86_64-winpthreads" ) "
46
+ CROSS_GCC=" $( store_path " gcc-cross-${HOST} " ) "
47
+ CROSS_GCC_LIBS=( " ${CROSS_GCC} /lib/gcc/${HOST} " /* ) # This expands to an array of directories...
48
+ CROSS_GCC_LIB=" ${CROSS_GCC_LIBS[0]} " # ...we just want the first one (there should only be one)
49
+
50
+ NATIVE_GCC=" $( store_path gcc-glibc-2.27-toolchain) "
51
+ export LIBRARY_PATH=" ${NATIVE_GCC} /lib:${NATIVE_GCC} /lib64"
52
+ export CPATH=" ${NATIVE_GCC} /include"
53
+
54
+ export CROSS_C_INCLUDE_PATH=" ${CROSS_GCC_LIB} /include:${CROSS_GCC_LIB} /include-fixed:${CROSS_GLIBC} /include"
55
+ export CROSS_CPLUS_INCLUDE_PATH=" ${CROSS_GCC} /include/c++:${CROSS_GCC} /include/c++/${HOST} :${CROSS_GCC} /include/c++/backward:${CROSS_C_INCLUDE_PATH} "
56
+ export CROSS_LIBRARY_PATH=" ${CROSS_GCC} /lib:${CROSS_GCC} /${HOST} /lib:${CROSS_GCC_LIB} :${CROSS_GLIBC} /lib"
57
+ ;;
58
+ * linux* )
59
+ CROSS_GLIBC=" $( store_path " glibc-cross-${HOST} " ) "
60
+ CROSS_GLIBC_STATIC=" $( store_path " glibc-cross-${HOST} " static) "
61
+ CROSS_KERNEL=" $( store_path " linux-libre-headers-cross-${HOST} " ) "
62
+ CROSS_GCC=" $( store_path " gcc-cross-${HOST} " ) "
63
+ CROSS_GCC_LIBS=( " ${CROSS_GCC} /lib/gcc/${HOST} " /* ) # This expands to an array of directories...
64
+ CROSS_GCC_LIB=" ${CROSS_GCC_LIBS[0]} " # ...we just want the first one (there should only be one)
65
+
66
+ # NOTE: CROSS_C_INCLUDE_PATH is missing ${CROSS_GCC_LIB}/include-fixed, because
67
+ # the limits.h in it is missing a '#include_next <limits.h>'
68
+ export CROSS_C_INCLUDE_PATH=" ${CROSS_GCC_LIB} /include:${CROSS_GLIBC} /include:${CROSS_KERNEL} /include"
69
+ export CROSS_CPLUS_INCLUDE_PATH=" ${CROSS_GCC} /include/c++:${CROSS_GCC} /include/c++/${HOST} :${CROSS_GCC} /include/c++/backward:${CROSS_C_INCLUDE_PATH} "
70
+ export CROSS_LIBRARY_PATH=" ${CROSS_GCC} /lib:${CROSS_GCC} /${HOST} /lib:${CROSS_GCC_LIB} :${CROSS_GLIBC} /lib:${CROSS_GLIBC_STATIC} /lib"
71
+ ;;
72
+ * )
73
+ exit 1 ;;
74
+ esac
56
75
57
76
# Sanity check CROSS_*_PATH directories
58
77
IFS=' :' read -ra PATHS <<< " ${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}"
@@ -74,16 +93,20 @@ export GUIX_LD_WRAPPER_DISABLE_RPATH=yes
74
93
[ -e /usr/bin/env ] || ln -s --no-dereference " $( command -v env) " /usr/bin/env
75
94
76
95
# Determine the correct value for -Wl,--dynamic-linker for the current $HOST
77
- glibc_dynamic_linker=$(
78
- case " $HOST " in
79
- i686-linux-gnu) echo /lib/ld-linux.so.2 ;;
80
- x86_64-linux-gnu) echo /lib64/ld-linux-x86-64.so.2 ;;
81
- arm-linux-gnueabihf) echo /lib/ld-linux-armhf.so.3 ;;
82
- aarch64-linux-gnu) echo /lib/ld-linux-aarch64.so.1 ;;
83
- riscv64-linux-gnu) echo /lib/ld-linux-riscv64-lp64d.so.1 ;;
84
- * ) exit 1 ;;
85
- esac
86
- )
96
+ case " $HOST " in
97
+ * linux* )
98
+ glibc_dynamic_linker=$(
99
+ case " $HOST " in
100
+ i686-linux-gnu) echo /lib/ld-linux.so.2 ;;
101
+ x86_64-linux-gnu) echo /lib64/ld-linux-x86-64.so.2 ;;
102
+ arm-linux-gnueabihf) echo /lib/ld-linux-armhf.so.3 ;;
103
+ aarch64-linux-gnu) echo /lib/ld-linux-aarch64.so.1 ;;
104
+ riscv64-linux-gnu) echo /lib/ld-linux-riscv64-lp64d.so.1 ;;
105
+ * ) exit 1 ;;
106
+ esac
107
+ )
108
+ ;;
109
+ esac
87
110
88
111
# Environment variables for determinism
89
112
export QT_RCC_TEST=1
@@ -136,11 +159,27 @@ DISTNAME="$(basename "$SOURCEDIST" '.tar.gz')"
136
159
# Binary Tarball Building #
137
160
# ##########################
138
161
139
- # Similar flags to Gitian
140
- CONFIGFLAGS=" --enable-glibc-back-compat --enable-reduce-exports --disable-bench --disable-gui-tests"
141
- HOST_CFLAGS=" -O2 -g -ffile-prefix-map=${PWD} =."
142
- HOST_CXXFLAGS=" -O2 -g -ffile-prefix-map=${PWD} =."
143
- HOST_LDFLAGS=" -Wl,--as-needed -Wl,--dynamic-linker=$glibc_dynamic_linker -static-libstdc++"
162
+ # CONFIGFLAGS
163
+ CONFIGFLAGS=" --enable-reduce-exports --disable-bench --disable-gui-tests"
164
+ case " $HOST " in
165
+ * linux* ) CONFIGFLAGS+=" --enable-glibc-back-compat" ;;
166
+ esac
167
+
168
+ # CFLAGS
169
+ HOST_CFLAGS=" -O2 -g"
170
+ case " $HOST " in
171
+ * linux* ) HOST_CFLAGS+=" -ffile-prefix-map=${PWD} =." ;;
172
+ * mingw* ) HOST_CFLAGS+=" -fno-ident" ;;
173
+ esac
174
+
175
+ # CXXFLAGS
176
+ HOST_CXXFLAGS=" $HOST_CFLAGS "
177
+
178
+ # LDFLAGS
179
+ case " $HOST " in
180
+ * linux* ) HOST_LDFLAGS=" -Wl,--as-needed -Wl,--dynamic-linker=$glibc_dynamic_linker -static-libstdc++" ;;
181
+ * mingw* ) HOST_LDFLAGS=" -Wl,--no-insert-timestamp" ;;
182
+ esac
144
183
145
184
# Make $HOST-specific native binaries from depends available in $PATH
146
185
export PATH=" ${BASEPREFIX} /${HOST} /native/bin:${PATH} "
@@ -160,7 +199,7 @@ export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}"
160
199
${CONFIGFLAGS} \
161
200
CFLAGS=" ${HOST_CFLAGS} " \
162
201
CXXFLAGS=" ${HOST_CXXFLAGS} " \
163
- LDFLAGS=" ${HOST_LDFLAGS} "
202
+ ${HOST_LDFLAGS : + LDFLAGS=" ${HOST_LDFLAGS} " }
164
203
165
204
sed -i.old ' s/-lstdc++ //g' config.status libtool src/univalue/config.status src/univalue/libtool
166
205
@@ -169,9 +208,21 @@ export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}"
169
208
170
209
# Perform basic ELF security checks on a series of executables.
171
210
make -C src --jobs=1 check-security ${V: +V=1}
172
- # Check that executables only contain allowed gcc, glibc and libstdc++
173
- # version symbols for Linux distro back-compatibility.
174
- make -C src --jobs=1 check-symbols ${V: +V=1}
211
+
212
+ case " $HOST " in
213
+ * linux* |* mingw* )
214
+ # Check that executables only contain allowed gcc, glibc and libstdc++
215
+ # version symbols for Linux distro back-compatibility.
216
+ make -C src --jobs=1 check-symbols ${V: +V=1}
217
+ ;;
218
+ esac
219
+
220
+ # Make the os-specific installers
221
+ case " $HOST " in
222
+ * mingw* )
223
+ make deploy ${V: +V=1}
224
+ ;;
225
+ esac
175
226
176
227
# Setup the directory where our Bitcoin Core build for HOST will be
177
228
# installed. This directory will also later serve as the input for our
@@ -180,9 +231,21 @@ export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}"
180
231
mkdir -p " ${INSTALLPATH} "
181
232
# Install built Bitcoin Core to $INSTALLPATH
182
233
make install DESTDIR=" ${INSTALLPATH} " ${V: +V=1}
234
+
235
+ case " $HOST " in
236
+ * mingw* )
237
+ cp -f --target-directory=" $OUTDIR " ./* -setup-unsigned.exe
238
+ ;;
239
+ esac
183
240
(
184
241
cd installed
185
242
243
+ case " $HOST " in
244
+ * mingw* )
245
+ mv --target-directory=" $DISTNAME " /lib/ " $DISTNAME " /bin/* .dll
246
+ ;;
247
+ esac
248
+
186
249
# Prune libtool and object archives
187
250
find . -name " lib*.la" -delete
188
251
find . -name " lib*.a" -delete
@@ -196,19 +259,60 @@ export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}"
196
259
find " ${DISTNAME} /lib" -type f -print0
197
260
} | xargs -0 -n1 -P" $MAX_JOBS " -I{} " ${DISTSRC} /contrib/devtools/split-debug.sh" {} {} {}.dbg
198
261
199
- cp " ${DISTSRC} /doc/README.md" " ${DISTNAME} /"
262
+ case " $HOST " in
263
+ * mingw* )
264
+ cp " ${DISTSRC} /doc/README_windows.txt" " ${DISTNAME} /readme.txt"
265
+ ;;
266
+ * linux* )
267
+ cp " ${DISTSRC} /doc/README.md" " ${DISTNAME} /"
268
+ ;;
269
+ esac
200
270
201
271
# Finally, deterministically produce {non-,}debug binary tarballs ready
202
272
# for release
203
- find " ${DISTNAME} " -not -name " *.dbg" -print0 \
204
- | sort --zero-terminated \
205
- | tar --create --no-recursion --mode=' u+rw,go+r-w,a+X' --null --files-from=- \
206
- | gzip -9n > " ${OUTDIR} /${DISTNAME} -${HOST} .tar.gz" \
207
- || ( rm -f " ${OUTDIR} /${DISTNAME} -${HOST} .tar.gz" && exit 1 )
208
- find " ${DISTNAME} " -name " *.dbg" -print0 \
209
- | sort --zero-terminated \
210
- | tar --create --no-recursion --mode=' u+rw,go+r-w,a+X' --null --files-from=- \
211
- | gzip -9n > " ${OUTDIR} /${DISTNAME} -${HOST} -debug.tar.gz" \
212
- || ( rm -f " ${OUTDIR} /${DISTNAME} -${HOST} -debug.tar.gz" && exit 1 )
273
+ case " $HOST " in
274
+ * mingw* )
275
+ find " ${DISTNAME} " -not -name " *.dbg" -print0 \
276
+ | xargs -0r touch --no-dereference --date=" @${SOURCE_DATE_EPOCH} "
277
+ find " ${DISTNAME} " -not -name " *.dbg" \
278
+ | sort \
279
+ | zip -X@ " ${OUTDIR} /${DISTNAME} -${HOST// x86_64-w64-mingw32/ win64} .zip" \
280
+ || ( rm -f " ${OUTDIR} /${DISTNAME} -${HOST// x86_64-w64-mingw32/ win64} .zip" && exit 1 )
281
+ find " ${DISTNAME} " -name " *.dbg" -print0 \
282
+ | xargs -0r touch --no-dereference --date=" @${SOURCE_DATE_EPOCH} "
283
+ find " ${DISTNAME} " -name " *.dbg" \
284
+ | sort \
285
+ | zip -X@ " ${OUTDIR} /${DISTNAME} -${HOST// x86_64-w64-mingw32/ win64} -debug.zip" \
286
+ || ( rm -f " ${OUTDIR} /${DISTNAME} -${HOST// x86_64-w64-mingw32/ win64} -debug.zip" && exit 1 )
287
+ ;;
288
+ * linux* )
289
+ find " ${DISTNAME} " -not -name " *.dbg" -print0 \
290
+ | sort --zero-terminated \
291
+ | tar --create --no-recursion --mode=' u+rw,go+r-w,a+X' --null --files-from=- \
292
+ | gzip -9n > " ${OUTDIR} /${DISTNAME} -${HOST} .tar.gz" \
293
+ || ( rm -f " ${OUTDIR} /${DISTNAME} -${HOST} .tar.gz" && exit 1 )
294
+ find " ${DISTNAME} " -name " *.dbg" -print0 \
295
+ | sort --zero-terminated \
296
+ | tar --create --no-recursion --mode=' u+rw,go+r-w,a+X' --null --files-from=- \
297
+ | gzip -9n > " ${OUTDIR} /${DISTNAME} -${HOST} -debug.tar.gz" \
298
+ || ( rm -f " ${OUTDIR} /${DISTNAME} -${HOST} -debug.tar.gz" && exit 1 )
299
+ ;;
300
+ esac
213
301
)
214
302
)
303
+
304
+ case " $HOST " in
305
+ * mingw* )
306
+ cp -rf --target-directory=. contrib/windeploy
307
+ (
308
+ cd ./windeploy
309
+ mkdir unsigned
310
+ cp --target-directory=unsigned/ " $OUTDIR " /bitcoin-* -setup-unsigned.exe
311
+ find . -print0 \
312
+ | sort --zero-terminated \
313
+ | tar --create --no-recursion --mode=' u+rw,go+r-w,a+X' --null --files-from=- \
314
+ | gzip -9n > " ${OUTDIR} /${DISTNAME} -win-unsigned.tar.gz" \
315
+ || ( rm -f " ${OUTDIR} /${DISTNAME} -win-unsigned.tar.gz" && exit 1 )
316
+ )
317
+ ;;
318
+ esac
0 commit comments