Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine Linux 3.10 (latest stable) has some build issues w/dependencies #16925

Closed
2 tasks
nmarley opened this issue Sep 20, 2019 · 3 comments · Fixed by #16926 or #16927
Closed
2 tasks

Alpine Linux 3.10 (latest stable) has some build issues w/dependencies #16925

nmarley opened this issue Sep 20, 2019 · 3 comments · Fixed by #16926 or #16927

Comments

@nmarley
Copy link
Contributor

nmarley commented Sep 20, 2019

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 f8b0b19.

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
@fanquake
Copy link
Member

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

fanquake added a commit to fanquake/core-review that referenced this issue Sep 21, 2019
@fanquake
Copy link
Member

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.

@nmarley
Copy link
Contributor Author

nmarley commented Sep 24, 2019

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

@laanwj laanwj closed this as completed in bb83d23 Sep 30, 2019
laanwj added a commit that referenced this issue Sep 30, 2019
463a1d5 Refresh ZeroMQ 4.3.1 patch (Nathan Marley)

Pull request description:

  Currently in Alpine Linux (latest, 3.10) in the depends system, one of the ZeroMQ patches won't apply cleanly because the context around the patch has changed and Alpine's `patch` implementation can't handle the diff.

  Some patch implementations can't handle fuzz / too much divergence from the original code.

  This PR just tweaks the context code around the patch so that less-sophisticated patch implementations (such as on Alpine Linux) can apply the patch without errors.

  This partially fixes #16925

ACKs for top commit:
  fanquake:
    ACK 463a1d5 - Tested building zeromq in depends inside an [Alpine container](https://github.com/fanquake/core-review/blob/master/docker/alpine.dockerfile) as well as on macOS.

Tree-SHA512: d6e3cb60835cdd090b9b864ca9cb33961687606bc9184fbbeb7a54ec23db4057b9317b65c5c276fb8c5492cb3cfcc4a7f3369f049551f4eb0915db971f2290ce
sidhujag pushed a commit to syscoin/syscoin that referenced this issue Oct 2, 2019
568aa0c Add OpenSSL termios fix for musl libc (Nathan Marley)

Pull request description:

  Currently the version of OpenSSL included in the depends system won't build on musl based systems because `termio.h` does not exist. The proper header named `termios.h` does exist.

  This PR adds a patch for OpenSSL to replace the `termio.h` header with `termios.h`, which is the proper POSIX header as I understand it.

  This is a known issue as `TERMIOS` (not `TERMIO`) should be the default, and is fixed in later versions of OpenSSL. There is discussion on the OpenSSL repo here: openssl/openssl#163

  This has been [fixed in OpenSSL](openssl/openssl@64e6bf6).

  This partly fixes bitcoin#16925 and allows building Bitcoin on Alpine using the depends system.

ACKs for top commit:
  laanwj:
    ACK 568aa0c

Tree-SHA512: d0aac116b7a1133bdecb34a9fb6c63db0336a3547585c07ed31ac9c5edb97e9570dcbf931e7fbc7172ce0735b6bfc11fb204e015532fcd90496a233e8fc17081
sidhujag pushed a commit to syscoin/syscoin that referenced this issue Oct 2, 2019
463a1d5 Refresh ZeroMQ 4.3.1 patch (Nathan Marley)

Pull request description:

  Currently in Alpine Linux (latest, 3.10) in the depends system, one of the ZeroMQ patches won't apply cleanly because the context around the patch has changed and Alpine's `patch` implementation can't handle the diff.

  Some patch implementations can't handle fuzz / too much divergence from the original code.

  This PR just tweaks the context code around the patch so that less-sophisticated patch implementations (such as on Alpine Linux) can apply the patch without errors.

  This partially fixes bitcoin#16925

ACKs for top commit:
  fanquake:
    ACK 463a1d5 - Tested building zeromq in depends inside an [Alpine container](https://github.com/fanquake/core-review/blob/master/docker/alpine.dockerfile) as well as on macOS.

Tree-SHA512: d6e3cb60835cdd090b9b864ca9cb33961687606bc9184fbbeb7a54ec23db4057b9317b65c5c276fb8c5492cb3cfcc4a7f3369f049551f4eb0915db971f2290ce
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants