Bitcoin: Alpine Linux 3.10 (latest stable) has some build issues w/dependencies

Created on 20 Sep 2019  ·  3Comments  ·  Source: bitcoin/bitcoin

On the latest Alpine Linux release (3.10), there are build issues which prevent compilation for two packages:

  • [ ] openssl (known issue w/termio which is fixed in later versions)
  • [ ] zeromq (4.3.1 patch is too fuzzy for Alpine patch)

To reproduce this issue and the fix, clone this repo on Alpine 3.10, cd depends && make NO_QT=1. By solving these 2 items, the depends system builds without issue on Alpine and I've been able to compile the Bitcoin binaries without issue as well.

Expected behavior

Dependencies should build without an issue.

Actual behavior

OpenSSL termio header not found:

gcc -m64 -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -DOPENSSL_THREADS -D_REENTRANT -pipe -O2 -I/home/alpine/bitcoin/depends/x86_64-pc-linux-gnu/include -fPIC -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM   -c -o ui_openssl.o ui_openssl.c
ui_openssl.c:232:11: fatal error: termio.h: No such file or directory
 # include <termio.h>
           ^~~~~~~~~~
compilation terminated.

ZeroMQ patch won't apply:

make zeromq
Preprocessing zeromq...
patching file src/windows.hpp
Possibly reversed hunk 1 at 105
Hunk 1 FAILED 58/58.
 #include <winsock2.h>
 #include <windows.h>
 #include <mswsock.h>
+
+#if defined __MINGW64_VERSION_MAJOR && __MINGW64_VERSION_MAJOR < 4
+// Workaround for mingw-w64 < v4.0 which did not include ws2ipdef.h in iphlpapi.h.
+// Fixed in mingw-w64 by 9bd8fe9148924840d315b4c915dd099955ea89d1.
+#include <ws2def.h>
+#include <ws2ipdef.h>
+#endif
 #include <iphlpapi.h>

 #if !defined __MINGW32__
make: *** [funcs.mk:254: /home/alpine/bitcoin/depends/work/build/x86_64-pc-linux-gnu/zeromq/4.3.1-41472d87c95/.stamp_preprocessed] Error 1

To reproduce

In Alpine Linux 3.10:

apk update
apk add git cmake make curl gcc g++ perl automake autoconf libtool pkgconfig python3

git clone https://github.com/bitcoin/bitcoin.git && cd bitcoin
cd depends
make NO_QT=1

System information

This is on the master branch as of commit f8b0b190a.

Machine specs:

  • OS: Alpine Linux 3.10
  • CPU/RAM: AWS m5.8xlarge
  • Disk size: 80 GB
  • Disk Type (HD/SDD): EBS volume
cat /etc/alpine-release
3.10.2
Bug Build system

Most helpful comment

I also had an issue building qt on Alpine:

compiling thread/qmutex.cpp
In file included from thread/qmutex.cpp:734:
thread/qmutex_linux.cpp:49:10: fatal error: linux/futex.h: No such file or directory
 #include <linux/futex.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:10849: .obj/qmutex.o] Error 1

Although that was solved by apk installing the linux-headers.

All 3 comments

Thanks for reporting. I've reproduced both the issues. Will review your PRs.

making all in crypto/ui...
make[3]: Entering directory '/bitcoin/depends/work/build/x86_64-pc-linux-gnu/openssl/1.0.1k-9f8b92d0c9a/crypto/ui'
gcc -m64 -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -DOPENSSL_THREADS -D_REENTRANT -pipe -O2 -I/bitcoin/depends/x86_64-pc-linux-gnu/include -fPIC -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM   -c -o ui_err.o ui_err.c
gcc -m64 -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -DOPENSSL_THREADS -D_REENTRANT -pipe -O2 -I/bitcoin/depends/x86_64-pc-linux-gnu/include -fPIC -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM   -c -o ui_lib.o ui_lib.c
gcc -m64 -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -DOPENSSL_THREADS -D_REENTRANT -pipe -O2 -I/bitcoin/depends/x86_64-pc-linux-gnu/include -fPIC -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM   -c -o ui_openssl.o ui_openssl.c
ui_openssl.c:232:11: fatal error: termio.h: No such file or directory
 # include <termio.h>
           ^~~~~~~~~~
compilation terminated.
make[3]: *** [<builtin>: ui_openssl.o] Error 1
make: Entering directory '/bitcoin/depends'
Preprocessing zeromq...
patching file src/windows.hpp
Possibly reversed hunk 1 at 105
Hunk 1 FAILED 58/58.
 #include <winsock2.h>
 #include <windows.h>
 #include <mswsock.h>
+
+#if defined __MINGW64_VERSION_MAJOR && __MINGW64_VERSION_MAJOR < 4
+// Workaround for mingw-w64 < v4.0 which did not include ws2ipdef.h in iphlpapi.h.
+// Fixed in mingw-w64 by 9bd8fe9148924840d315b4c915dd099955ea89d1.
+#include <ws2def.h>
+#include <ws2ipdef.h>
+#endif
 #include <iphlpapi.h>

 #if !defined __MINGW32__
make: *** [funcs.mk:254: /bitcoin/depends/work/build/x86_64-pc-linux-gnu/zeromq/4.3.1-1e82f76cb11/.stamp_preprocessed] Error 1
make: Leaving directory '/bitcoin/depends'

One thing to note is that the patching will work fine with the apk installed patch:

patch -version
patch: unrecognized option: v
BusyBox v1.30.1 (2019-06-12 17:51:55 UTC) multi-call binary.

Usage: patch [OPTIONS] [ORIGFILE [PATCHFILE]]

    -p N    Strip N leading components from file names
    -i DIFF Read DIFF instead of stdin
    -R  Reverse patch
    -N  Ignore already applied patches
    -E  Remove output files if they become empty
    --dry-run   Don't actually change files
/ # apk add patch
(1/1) Installing patch (2.7.6-r6)
Executing busybox-1.30.1-r2.trigger
OK: 311 MiB in 64 packages
/ # patch --version
GNU patch 2.7.6
Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
Copyright (C) 1988 Larry Wall

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Larry Wall and Paul Eggert

I also had an issue building qt on Alpine:

compiling thread/qmutex.cpp
In file included from thread/qmutex.cpp:734:
thread/qmutex_linux.cpp:49:10: fatal error: linux/futex.h: No such file or directory
 #include <linux/futex.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:10849: .obj/qmutex.o] Error 1

Although that was solved by apk installing the linux-headers.

Thanks for pointing that out. I am able to reproduce this issue as well as the fix.

Was this page helpful?
0 / 5 - 0 ratings