From 6f3d50ae240eb3b2ab372a79afc7971ef51b6d28 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Fri, 5 Sep 2025 09:32:24 +0300 Subject: [PATCH] win build --- rin/miner/Dockerfile.windows-build | 120 ++++++++++++++++++++ rin/miner/Dockerfile.windows-build-complete | 105 +++++++++++++++++ rin/miner/Dockerfile.windows-build-simple | 93 +++++++++++++++ rin/miner/build-windows-docker.sh | 41 +++++++ 4 files changed, 359 insertions(+) create mode 100644 rin/miner/Dockerfile.windows-build create mode 100644 rin/miner/Dockerfile.windows-build-complete create mode 100644 rin/miner/Dockerfile.windows-build-simple create mode 100644 rin/miner/build-windows-docker.sh diff --git a/rin/miner/Dockerfile.windows-build b/rin/miner/Dockerfile.windows-build new file mode 100644 index 0000000..ce00fa4 --- /dev/null +++ b/rin/miner/Dockerfile.windows-build @@ -0,0 +1,120 @@ +# Dockerfile for cross-compiling cpuminer-opt for Windows on Linux +FROM ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive + +# Install cross-compilation tools and some dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + autotools-dev \ + automake \ + autoconf \ + pkg-config \ + libtool \ + wget \ + curl \ + git \ + unzip \ + mingw-w64 \ + mingw-w64-tools \ + && rm -rf /var/lib/apt/lists/* + +# Set up cross-compilation environment +ENV HOST=x86_64-w64-mingw32 +ENV CC=${HOST}-gcc +ENV CXX=${HOST}-g++ +ENV AR=${HOST}-ar +ENV STRIP=${HOST}-strip +ENV RANLIB=${HOST}-ranlib +ENV PKG_CONFIG=${HOST}-pkg-config + +# Create build directory +WORKDIR /build + +# Build zlib for Windows +RUN wget https://github.com/madler/zlib/archive/refs/tags/v1.3.1.tar.gz -O zlib-1.3.1.tar.gz && \ + tar -xzf zlib-1.3.1.tar.gz && \ + cd zlib-1.3.1 && \ + CC=${HOST}-gcc AR=${HOST}-ar RANLIB=${HOST}-ranlib ./configure --prefix=/usr/${HOST} --static && \ + make && make install && \ + cd .. && rm -rf zlib-1.3.1* + +# Build GMP for Windows +RUN wget https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz && \ + tar -xf gmp-6.3.0.tar.xz && \ + cd gmp-6.3.0 && \ + ./configure --host=${HOST} --prefix=/usr/${HOST} --enable-static --disable-shared && \ + make -j$(nproc) && make install && \ + cd .. && rm -rf gmp-6.3.0* + +# Build a minimal OpenSSL for Windows (or we could skip this and just use system curl) +RUN wget https://www.openssl.org/source/openssl-3.0.15.tar.gz && \ + tar -xzf openssl-3.0.15.tar.gz && \ + cd openssl-3.0.15 && \ + ./Configure mingw64 --cross-compile-prefix=${HOST}- --prefix=/usr/${HOST} no-shared && \ + make -j$(nproc) && make install_sw && \ + cd .. && rm -rf openssl-3.0.15* + +# Build libcurl for Windows +RUN wget https://curl.se/download/curl-8.8.0.tar.gz && \ + tar -xzf curl-8.8.0.tar.gz && \ + cd curl-8.8.0 && \ + ./configure --host=${HOST} --prefix=/usr/${HOST} \ + --with-openssl=/usr/${HOST} \ + --with-zlib=/usr/${HOST} \ + --enable-static --disable-shared \ + --disable-ldap --disable-ldaps \ + --without-libpsl --without-nghttp2 \ + --without-brotli --without-zstd && \ + make -j$(nproc) && make install && \ + cd .. && rm -rf curl-8.8.0* + +# Build jansson for Windows +RUN wget https://github.com/akheron/jansson/releases/download/v2.14/jansson-2.14.tar.gz && \ + tar -xzf jansson-2.14.tar.gz && \ + cd jansson-2.14 && \ + ./configure --host=${HOST} --prefix=/usr/${HOST} --enable-static --disable-shared && \ + make -j$(nproc) && make install && \ + cd .. && rm -rf jansson-2.14* + +# Set up environment for cross-compilation +ENV PKG_CONFIG_PATH="/usr/${HOST}/lib/pkgconfig" +ENV LDFLAGS="-L/usr/${HOST}/lib" +ENV CPPFLAGS="-I/usr/${HOST}/include" + +# Copy cpuminer source +COPY cpuminer /build/cpuminer + +WORKDIR /build/cpuminer + +# Build script +RUN echo '#!/bin/bash\n\ +set -e\n\ +\n\ +echo "Cleaning previous builds..."\n\ +make clean || true\n\ +rm -f config.status\n\ +\n\ +echo "Running autogen..."\n\ +./autogen.sh\n\ +\n\ +echo "Configuring for Windows cross-compile..."\n\ +./configure \\\n\ + --host=${HOST} \\\n\ + --with-curl=/usr/${HOST} \\\n\ + CFLAGS="-O3 -march=x86-64 -mtune=generic -msse2 -static" \\\n\ + LDFLAGS="-L/usr/${HOST}/lib -static" \\\n\ + CPPFLAGS="-I/usr/${HOST}/include"\n\ +\n\ +echo "Building cpuminer..."\n\ +make -j$(nproc)\n\ +\n\ +echo "Stripping binary..."\n\ +${STRIP} cpuminer.exe\n\ +\n\ +echo "Build complete! cpuminer.exe created."\n\ +ls -la cpuminer.exe\n\ +file cpuminer.exe\n\ +' > /build/build-windows.sh && chmod +x /build/build-windows.sh + +CMD ["/build/build-windows.sh"] \ No newline at end of file diff --git a/rin/miner/Dockerfile.windows-build-complete b/rin/miner/Dockerfile.windows-build-complete new file mode 100644 index 0000000..ec86281 --- /dev/null +++ b/rin/miner/Dockerfile.windows-build-complete @@ -0,0 +1,105 @@ +# Complete source build using git clone +FROM ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive + +# Install MinGW and development tools +RUN apt-get update && apt-get install -y \ + build-essential \ + automake \ + autoconf \ + pkg-config \ + libtool \ + wget \ + git \ + mingw-w64 \ + mingw-w64-tools \ + && rm -rf /var/lib/apt/lists/* + +# Set cross-compilation environment +ENV HOST=x86_64-w64-mingw32 +ENV CC=${HOST}-gcc +ENV CXX=${HOST}-g++ +ENV AR=${HOST}-ar +ENV STRIP=${HOST}-strip +ENV RANLIB=${HOST}-ranlib + +WORKDIR /build + +# Build zlib for Windows first +RUN wget https://github.com/madler/zlib/archive/refs/tags/v1.3.1.tar.gz -O zlib-1.3.1.tar.gz && \ + tar -xzf zlib-1.3.1.tar.gz && \ + cd zlib-1.3.1 && \ + CC=${HOST}-gcc AR=${HOST}-ar RANLIB=${HOST}-ranlib ./configure --prefix=/usr/${HOST} --static && \ + make libz.a && \ + cp libz.a /usr/${HOST}/lib/ && \ + cp zlib.h zconf.h /usr/${HOST}/include/ && \ + cd .. && rm -rf zlib-1.3.1* + +# Build GMP (essential for cpuminer) +RUN wget https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz && \ + tar -xf gmp-6.3.0.tar.xz && \ + cd gmp-6.3.0 && \ + ./configure --host=${HOST} --prefix=/usr/${HOST} --enable-static --disable-shared && \ + make -j$(nproc) && make install && \ + cd .. && rm -rf gmp-6.3.0* + +# Build jansson (needed for JSON RPC) +RUN wget https://github.com/akheron/jansson/releases/download/v2.14/jansson-2.14.tar.gz && \ + tar -xzf jansson-2.14.tar.gz && \ + cd jansson-2.14 && \ + ./configure --host=${HOST} --prefix=/usr/${HOST} --enable-static --disable-shared && \ + make -j$(nproc) && make install && \ + cd .. && rm -rf jansson-2.14* + +# Build a basic libcurl (with zlib support) +RUN wget https://curl.se/download/curl-8.8.0.tar.gz && \ + tar -xzf curl-8.8.0.tar.gz && \ + cd curl-8.8.0 && \ + ./configure --host=${HOST} --prefix=/usr/${HOST} \ + --with-zlib=/usr/${HOST} \ + --enable-static --disable-shared \ + --disable-ldap --disable-ldaps \ + --without-ssl --without-libpsl --without-nghttp2 \ + --without-brotli --without-zstd && \ + make -j$(nproc) && make install && \ + cd .. && rm -rf curl-8.8.0* + +# Clone the complete cpuminer-opt source +RUN git clone https://github.com/JayDDee/cpuminer-opt.git cpuminer-opt + +WORKDIR /build/cpuminer-opt + +# Create build script +RUN echo '#!/bin/bash\n\ +set -e\n\ +\n\ +echo "Cleaning previous builds..."\n\ +make clean || true\n\ +rm -f config.status\n\ +\n\ +echo "Running autogen..."\n\ +./autogen.sh\n\ +\n\ +echo "Configuring for Windows cross-compile..."\n\ +./configure \\\n\ + --host=${HOST} \\\n\ + --with-curl=/usr/${HOST} \\\n\ + CFLAGS="-O3 -march=x86-64 -static-libgcc" \\\n\ + LDFLAGS="-L/usr/${HOST}/lib -static" \\\n\ + CPPFLAGS="-I/usr/${HOST}/include" \\\n\ + LIBS="-static -lcurl -lz -lws2_32 -lwldap32 -lwinmm" \\\n\ + --enable-static=yes\n\ +\n\ +echo "Building cpuminer..."\n\ +make -j$(nproc)\n\ +\n\ +echo "Stripping binary..."\n\ +${STRIP} cpuminer.exe\n\ +\n\ +echo "Build complete! cpuminer.exe created."\n\ +ls -la cpuminer.exe\n\ +file cpuminer.exe\n\ +' > /build/build-windows.sh && chmod +x /build/build-windows.sh + +CMD ["/build/build-windows.sh"] diff --git a/rin/miner/Dockerfile.windows-build-simple b/rin/miner/Dockerfile.windows-build-simple new file mode 100644 index 0000000..8898dd5 --- /dev/null +++ b/rin/miner/Dockerfile.windows-build-simple @@ -0,0 +1,93 @@ +# Simple cross-compile approach using system packages where possible +FROM ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive + +# Install MinGW and development tools +RUN apt-get update && apt-get install -y \ + build-essential \ + automake \ + autoconf \ + pkg-config \ + libtool \ + wget \ + mingw-w64 \ + mingw-w64-tools \ + && rm -rf /var/lib/apt/lists/* + +# Set cross-compilation environment +ENV HOST=x86_64-w64-mingw32 +ENV CC=${HOST}-gcc +ENV CXX=${HOST}-g++ +ENV AR=${HOST}-ar +ENV STRIP=${HOST}-strip +ENV RANLIB=${HOST}-ranlib + +WORKDIR /build + +# Use a minimal build - just build the few deps we absolutely need +# Build GMP (essential for cpuminer) +RUN wget https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz && \ + tar -xf gmp-6.3.0.tar.xz && \ + cd gmp-6.3.0 && \ + ./configure --host=${HOST} --prefix=/usr/${HOST} --enable-static --disable-shared && \ + make -j$(nproc) && make install && \ + cd .. && rm -rf gmp-6.3.0* + +# Build jansson (needed for JSON RPC) +RUN wget https://github.com/akheron/jansson/releases/download/v2.14/jansson-2.14.tar.gz && \ + tar -xzf jansson-2.14.tar.gz && \ + cd jansson-2.14 && \ + ./configure --host=${HOST} --prefix=/usr/${HOST} --enable-static --disable-shared && \ + make -j$(nproc) && make install && \ + cd .. && rm -rf jansson-2.14* + +# Build a basic libcurl (simplified) +RUN wget https://curl.se/download/curl-8.8.0.tar.gz && \ + tar -xzf curl-8.8.0.tar.gz && \ + cd curl-8.8.0 && \ + ./configure --host=${HOST} --prefix=/usr/${HOST} \ + --enable-static --disable-shared \ + --disable-ldap --disable-ldaps \ + --without-ssl --without-libpsl --without-nghttp2 \ + --without-brotli --without-zstd --without-zlib && \ + make -j$(nproc) && make install && \ + cd .. && rm -rf curl-8.8.0* + +# Copy cpuminer source +COPY cpuminer /build/cpuminer + +WORKDIR /build/cpuminer + +# Create a build script with minimal dependencies +RUN echo '#!/bin/bash\n\ +set -e\n\ +\n\ +echo "Cleaning previous builds..."\n\ +make clean || true\n\ +rm -f config.status\n\ +\n\ +echo "Running autogen..."\n\ +./autogen.sh\n\ +\n\ +echo "Configuring for Windows cross-compile (minimal deps)..."\n\ +./configure \\\n\ + --host=${HOST} \\\n\ + --with-curl=/usr/${HOST} \\\n\ + CFLAGS="-O3 -march=x86-64 -static-libgcc" \\\n\ + LDFLAGS="-L/usr/${HOST}/lib -static" \\\n\ + CPPFLAGS="-I/usr/${HOST}/include"\n\ +\n\ +echo "Building cpuminer..."\n\ +make -j$(nproc)\n\ +\n\ +echo "Stripping binary..."\n\ +${STRIP} cpuminer.exe\n\ +\n\ +echo "Build complete! cpuminer.exe created."\n\ +ls -la cpuminer.exe\n\ +file cpuminer.exe\n\ +' > /build/build-windows.sh && chmod +x /build/build-windows.sh + +CMD ["/build/build-windows.sh"] + diff --git a/rin/miner/build-windows-docker.sh b/rin/miner/build-windows-docker.sh new file mode 100644 index 0000000..cca57a0 --- /dev/null +++ b/rin/miner/build-windows-docker.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Script to build cpuminer for Windows using Docker cross-compilation + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_DIR="$SCRIPT_DIR" + +echo "Building cpuminer for Windows using Docker..." +echo "Working directory: $REPO_DIR" + +# Build the Docker image +echo "Building Docker image with MinGW toolchain..." +docker build -t cpuminer-windows-builder -f Dockerfile.windows-build-complete . + +# Run the build +echo "Running Windows cross-compilation..." +docker run --rm -v "$REPO_DIR:/output" cpuminer-windows-builder bash -c " + /build/build-windows.sh && + echo 'Copying binary to output...' && + cp /build/cpuminer/cpuminer.exe /output/ && + echo 'Copying required DLLs...' && + cp /build/cpuminer/*.dll /output/ 2>/dev/null || echo 'No DLLs to copy from source' +" + +if [ -f "$REPO_DIR/cpuminer.exe" ]; then + echo "" + echo "✅ Build successful!" + echo "Windows executable: $REPO_DIR/cpuminer.exe" + echo "" + echo "File info:" + file "$REPO_DIR/cpuminer.exe" || true + ls -la "$REPO_DIR/cpuminer.exe" + echo "" + echo "The executable is ready to run on Windows x64." + echo "Make sure to include any required DLL files when distributing." +else + echo "❌ Build failed - cpuminer.exe not found" + exit 1 +fi