Files
mines/rin/miner/BUILD_GUIDE.md

9.3 KiB
Raw Blame History

RinHash Miner - Simple Build Guide

🚀 Quick Build Commands

Prerequisites

sudo apt update
sudo apt install build-essential autotools-dev autoconf pkg-config libcurl4-openssl-dev libjansson-dev libssl-dev libgmp-dev zlib1g-dev git automake libtool docker.io

If you're using VS Code, the project now includes pre-configured tasks for easy building:

  1. Open in VS Code:

    cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner
    code .
    
  2. Use Build Tasks:

    • Press Ctrl+Shift+P (or Cmd+Shift+P on Mac)
    • Type "Tasks: Run Task"
    • Select "Build Windows CPU Miner (Smart)" - RECOMMENDED
    • Or choose other build options as needed

Available VS Code Tasks:

  • Build Windows CPU Miner (Smart) - Automatically detects curl and builds optimally
  • Build Windows CPU Miner (Original Curl) - Forces original curl implementation
  • Build Windows CPU Miner (NO_CURL Fallback) - Direct socket fallback
  • Clean Windows Build - Clean build artifacts
  • Test Windows Executable - Verify build results

Benefits:

  • No need to remember complex Docker commands
  • Automatic curl detection and optimal build selection
  • Integrated terminal output in VS Code
  • One-click building from the IDE

1. Build GPU Library (ROCm/HIP)

cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner/gpu/RinHash-hip

# Compile GPU kernel
/opt/rocm-6.4.3/bin/hipcc -c -O3 -fPIC rinhash.hip.cu -o build/rinhash.o

# Compile SHA3 component
/opt/rocm-6.4.3/bin/hipcc -c -O3 -fPIC sha3-256.hip.cu -o build/sha3-256.o

# Link shared library
/opt/rocm-6.4.3/bin/hipcc -shared -O3 build/rinhash.o build/sha3-256.o -o rocm-direct-output/gpu-libs/librinhash_hip.so -L/opt/rocm-6.4.3/lib -lamdhip64

# Install system-wide
sudo cp rocm-direct-output/gpu-libs/librinhash_hip.so /usr/local/lib/
sudo ldconfig
cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner

# Build Windows executable with original curl implementation (recommended)
./build-windows-smart.sh

# Or use the manual command:
cd /home/db/Downloads/rinhash/cpuminer-opt-rin
sudo docker run --rm -v "$(pwd):/work" -v "$(pwd)/build/win:/output" cpuminer-windows-builder bash -c "cd /work && make clean && rm -rf Makefile Makefile.in configure config.* && ./autogen.sh && ./configure --host=x86_64-w64-mingw32 --with-curl=/usr/x86_64-w64-mingw32 CFLAGS='-O3 -march=x86-64 -DCURL_STATICLIB' LDFLAGS='-L/usr/x86_64-w64-mingw32/lib' LIBS='-lcurl -lbcrypt -ladvapi32 -lcrypt32 -lz -lws2_32 -pthread' && make -j4 && cp cpuminer.exe /output/cpuminer-curl.exe && cp /work/cpuminer.exe /output/"

# Verify build success
ls -la build/win/cpuminer*.exe

SUCCESS: The smart build script now automatically:

  • Detects curl availability in the Docker container
  • Builds with original curl implementation (better performance)
  • Falls back to NO_CURL only if curl linking fails
  • Produces cpuminer-curl.exe (4.4MB) with full stratum features
  • Also creates cpuminer-nocurl.exe (3.9MB) as fallback

Why Use Original Curl Implementation?

  • Better Performance: Native curl library is optimized for networking
  • Full Stratum Support: Complete stratum protocol implementation
  • Stability: Less prone to connection drops and timeouts
  • Compatibility: Works with all mining pools and proxies
  • Security: Uses proven, battle-tested networking code

Build Output Comparison:

  • cpuminer-curl.exe (4.4MB): Original implementation with full features
  • cpuminer-nocurl.exe (3.9MB): Fallback with direct socket implementation

Recommendation: Always use cpuminer-curl.exe for production mining!

3. Alternative: Build Linux CPU Miner

cd /home/db/Downloads/rinhash/cpuminer-opt-rin

# Configure and build
./autogen.sh
./configure
make

# Or rebuild if already configured:
make clean && make

Test Mining

CPU Only

./cpuminer -a rinhash -o stratum+tcp://192.168.0.188:3333 -u db.test -p x -t 4

GPU Accelerated

./cpuminer -a rinhashgpu -o stratum+tcp://192.168.0.188:3333 -u db.test -p x -t 4

📊 Expected Performance

Algorithm Platform Threads Expected Hash Rate
rinhash (CPU) Linux 4 ~200-400 H/s
rinhash (CPU) Windows 4 ~180-360 H/s
rinhashgpu (GPU) Linux 4 ~800-1200 H/s
rinhashgpu (GPU) Windows 4 ~700-1000 H/s

🔧 Build Files

Linux

GPU Library: /usr/local/lib/librinhash_hip.so (252KB)
CPU Miner: ./cpuminer (executable)

Windows

CPU Miner: cpuminer.exe (executable)
GPU Library: librinhash_cuda.dll (if CUDA build)
Dependencies: Various .dll files (libcurl, jansson, etc.)

🚨 Troubleshooting

Linux Issues

  • GPU not found: Check ROCm installation at /opt/rocm-6.4.3/
  • Library missing: Run sudo ldconfig after installing
  • Compilation errors: Install missing dependencies listed above
  • Segmentation fault: Use simple algorithms without load control

Windows Issues

  • MSYS2 issues: Use MinGW 64-bit terminal, not regular MSYS2
  • CUDA not found: Install CUDA Toolkit and Visual Studio Build Tools
  • Missing DLLs: Include required DLL files when distributing
  • Performance: Windows may have 10-20% lower performance than Linux
  • Build failures: Ensure Visual Studio Build Tools are installed for CUDA

🪟 Windows Build Instructions

Prerequisites for Windows

# Install Docker Desktop for Windows from https://www.docker.com/products/docker-desktop
# Make sure Docker Desktop is running

Option 2: MSYS2 (Advanced)

# Download and install MSYS2 from https://www.msys2.org/
# Open MSYS2 MinGW 64-bit terminal and run:

pacman -Syu
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-curl mingw-w64-x86_64-jansson mingw-w64-x86_64-openssl mingw-w64-x86_64-gmp mingw-w64-x86_64-zlib mingw-w64-x86_64-autotools mingw-w64-x86_64-pkg-config

Windows CPU Miner Build

# Open PowerShell or Command Prompt in Windows
cd C:\path\to\your\rinhash\cpuminer-opt-rin

# Build Windows executable using Docker (NO_CURL fallback for networking)
docker run --rm -v "${PWD}:/work" -v "${PWD}/build/win:/output" cpuminer-windows-builder bash -c "cd /work && make clean && rm -rf Makefile Makefile.in configure config.* && ./autogen.sh && ./configure --host=x86_64-w64-mingw32 CFLAGS='-O3 -march=x86-64 -DNO_CURL' LDFLAGS='-static' && make -j4 && cp cpuminer.exe /output/"

# Verify build success
dir build\win\cpuminer.exe
REM Alternative Windows Command Prompt version
cd C:\path\to\your\rinhash\cpuminer-opt-rin

docker run --rm -v "%CD%:/work" -v "%CD%/build/win:/output" cpuminer-windows-builder bash -c "cd /work && make clean && rm -rf Makefile Makefile.in configure config.* && ./autogen.sh && ./configure --host=x86_64-w64-mingw32 CFLAGS='-O3 -march=x86-64 -DNO_CURL' LDFLAGS='-static' && make -j4 && cp cpuminer.exe /output/"

dir build\win\cpuminer.exe

Using Docker from Linux Host

# Cross-compile for Windows
cd /home/db/Downloads/rinhash/cpuminer-opt-rin
sudo docker run --rm -v "$(pwd):/work" -v "$(pwd)/build/win:/output" cpuminer-windows-builder bash -c "cd /work && make clean && rm -rf Makefile Makefile.in configure config.* && ./autogen.sh && ./configure --host=x86_64-w64-mingw32 CFLAGS='-O3 -march=x86-64 -DNO_CURL' LDFLAGS='-static' && make -j4 && cp cpuminer.exe /output/"

Using MSYS2 (Advanced)

# Open MSYS2 MinGW 64-bit terminal
cd /c/path/to/mines/rin/miner/cpuminer-opt-rin

# Configure and build
./autogen.sh
./configure CFLAGS="-O3 -march=native -funroll-loops -fomit-frame-pointer"
make -j$(nproc)

Windows GPU Build Options

CUDA Build (NVIDIA GPUs)

# Prerequisites: Install CUDA Toolkit and Visual Studio
cd gpu/RinHash-cuda
build-cuda.bat

ROCm Build (AMD GPUs) - Limited Support

# Note: ROCm on Windows has limited support
# Consider using WSL2 with ROCm instead
cd gpu/RinHash-hip
# Use Linux build instructions in WSL2

Windows Testing

CPU Only (NO_CURL Direct Socket)

REM Navigate to build directory
cd C:\path\to\rinhash\cpuminer-opt-rin\build\win

REM Test CPU mining (direct socket connection, no curl dependency)
cpuminer.exe -a rinhash -o stratum+tcp://192.168.0.188:3333 -u db.test -p x -t 4

GPU Accelerated (if available)

REM Test GPU mining (requires GPU library)
cpuminer.exe -a rinhashgpu -o stratum+tcp://192.168.0.188:3333 -u db.test -p x -t 1

Production Mining (Zergpool Example)

REM Real mining pool example
cpuminer.exe -a rinhash -o stratum+tcp://rinhash.mine.zergpool.com:7148 -u bc1qjn4m6rmrveuxhk02a5qhe4r6kdcsvvt3vhdn9j -p c=BTC,mc=RIN,ID=StrixHalo -t 8

Debugging Network Issues

REM Enable verbose logging to debug connection issues
cpuminer.exe -a rinhash -o stratum+tcp://pool.example.com:3333 -u test -p x -t 1 -D

📝 Notes

  • GPU implementation uses 4 blocks × 256 threads = 1024 GPU threads
  • Automatic fallback to CPU if GPU library unavailable
  • Thread count (-t) affects CPU threads, not GPU load directly
  • Windows builds are primarily for CPU mining; GPU support is limited