-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.alpine
116 lines (95 loc) · 4.26 KB
/
Dockerfile.alpine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
FROM alpine:edge
ENV BUILD_PACKAGES="autoconf automake binutils curl file linux-headers git gcc g++ musl-dev make mpc1 pkgconf re2c tar libtool cmake go numactl-dev" \
AR="gcc-ar" \
RANLIB="gcc-ranlib" \
NM="gcc-nm" \
GITHUB_REPOS="\
microsoft/mimalloc:dev-slice \
curl/curl:master \
zlib-ng/zlib-ng:develop \
WyvernTKC/cpuminer-gr-avx2:main \
JayDDee/cpuminer-opt:master" \
DOWNLOAD_URLS="https://gmplib.org/download/gmp/gmp-6.2.1.tar.bz2"
RUN set -xe; \
apk add ${BUILD_PACKAGES};
RUN set -xe; \
mkdir -p /usr/src; \
cd /usr/src; \
for i in ${DOWNLOAD_URLS}; \
do curl ${i} | tar xvj & \
done; \
for i in ${GITHUB_REPOS}; \
do git clone --depth 1 -b ${i#*:} https://github.com/${i%:*} & \
done; \
git clone --depth 1 https://boringssl.googlesource.com/boringssl && wait;
ENV CFLAGS "-O3 \
-pipe \
-march=native \
-mtune=native \
-fno-exceptions \
-fno-stack-protector \
-fno-math-errno"
ENV CXXFLAGS="${CFLAGS}" \
CPPFLAGS="-D_FORTIFY_SOURCE=0" \
LDFLAGS="-L/usr/local/lib -Wl,-O1" \
LTO_CFLAGS="-flto -fno-fat-lto-objects -fdevirtualize-at-ltrans -flto-compression-level=1"
# Build Mimalloc
RUN set -xe; \
cd /usr/src/mimalloc*; \
mkdir build; cd build; cmake -DMI_INSTALL_TOPLEVEL=On .. && make -j$(nproc ) && make install;
# Build BoringSSL
RUN set -xe; \
cd /usr/src/boring*; \
CFLAGS="${CFLAGS} ${LTO_CFLAGS}" CXXFLAGS="${CXXFLAGS} ${LTO_CFLAGS}" \
mkdir build && cd build && cmake DCMAKE_BUILD_TYPE=Release .. && make -j$(nproc); \
cd .. && mkdir lib && cd lib && ln -s ../build/ssl/libssl.a && ln -s ../build/crypto/libcrypto.a;
# Build Zlib-NG
RUN set -xe; \
cd /usr/src/zlib*; \
CFLAGS="${CFLAGS} ${LTO_CFLAGS}" CXXFLAGS="${CXXFLAGS} ${LTO_CFLAGS}" \
./configure --native --zlib-compat --static || cat configure.log; \
make -j$(nproc) && make install
# Build Curl
RUN set -xe; \
cd /usr/src/curl*; \
CFLAGS="${CFLAGS} ${LTO_CFLAGS}" CXXFLAGS="${CXXFLAGS} ${LTO_CFLAGS}" \
./buildconf && ./configure --with-ssl=/usr/src/boringssl --enable-shared=no; \
make -j$(nproc) && make install
# Build gmp
RUN set -xe; \
cd /usr/src/gmp*; \
CFLAGS="${CFLAGS} ${LTO_CFLAGS}" CXXFLAGS="${CXXFLAGS} ${LTO_CFLAGS}" \
./configure --with-pic; \
make -j$(nproc) && make install
# Build Cpuminer-GR
RUN set -xe; \
cd /usr/src/cpuminer-gr*; \
sh autogen.sh; \
# Enable mimalloc (piggy patch)
sed -i '/^#include.*/i #include <mimalloc-override.h>' cpu-miner.c; \
sed -i -E 's/cpuminer_LDADD(.*)/cpuminer_LDADD\1 -lmimalloc/g' Makefile.in; \
LDFLAGS="-static ${LDFLAGS}" CFLAGS="${CFLAGS}" ./configure --with-curl --with-crypto=/usr/src/boringssl; \
make -j$(nproc);
# Build Cpuminer (Instrumented)
RUN set -xe; \
cd /usr/src/cpuminer-opt; \
sh autogen.sh; \
# Dirty patching for musl; \
echo -ne "#define be64toh(x) (x)\n#define htobe64(x) (x)" >> algo/hodl/sha512-avx.h; \
# Enable mimalloc (piggy patch)
sed -i '/^#include.*/i #include <mimalloc-override.h>' cpu-miner.c; \
sed -i -E 's/cpuminer_LDADD(.*)/cpuminer_LDADD\1 -lmimalloc/g' Makefile.in; \
#mkdir build-pgo && cd build-pgo && \
#LDFLAGS="-static ${LDFLAGS} -fprofile-arcs" CFLAGS="${CFLAGS} -fprofile-abs-path -fprofile-dir=/tmp/pgo -fprofile-generate -fprofile-update=atomic" ../configure --with-curl --with-crypto=/usr/src/boringssl; \
LDFLAGS="-static ${LDFLAGS}" ./configure --with-curl --with-crypto=/usr/src/boringssl; \
make -j$(nproc);
# Run PGO tests
#RUN set -xe; \
# echo "------ Starting PGO RUN ------" && \
# cd /usr/src/cpuminer-opt/build-pgo && timeout 120 ./cpuminer -a scrypt --param-n 1048576 -o scryptn2.mine.zergpool.com:3435 -u M8C1jQRnrkwSkDJrcni96Kq67KV5DSDkMT.$(hostname) -p c=LTC,d=0.01 || true; \
# cd /usr/src/cpuminer-opt/build-pgo && timeout 120 ./cpuminer -a allium -o allium.mine.zergpool.com:3435 -u M8C1jQRnrkwSkDJrcni96Kq67KV5DSDkMT.$(hostname) -p c=LTC || true; \
# echo "--- END PGO RUN ---";
# Build Cpuminer (Non-Instrumented)
#RUN set -xe; \
# cd /usr/src/cpuminer-opt/ && \
# CFLAGS="${CFLAGS} -Wno-error=coverage-mismatch -fprofile-use=/tmp/pgo -fprofile-partial-training" LDFLAGS="-static ${LDFLAGS}" ./configure --with-curl --with-crypto=/usr/src/boringssl && make -j$(nproc) && strip cpuminer;