fireice-uk / xmr-stak-cpu

Monero CPU miner
GNU General Public License v3.0
1.11k stars 478 forks source link

Static builds #5

Closed dimecoin closed 7 years ago

dimecoin commented 7 years ago

A couple people where asking for static builds on forum, here is what I've been using:

https://gist.github.com/dimecoin/094c1378c423a4fb46586186723001db

fireice-uk commented 7 years ago

Can you give me logs of the glibc version on the host and target system in a build like that? In a modern OS there are no really static libs, in particular I think it will segfault on getaddrinfo().

If you can show it actually works, I will include it.

dimecoin commented 7 years ago

Sure. I'm building on Debian Testing (Stretch) and running on Debian Stable (Jessie). Let me know if you need any more information.

Build system:

[dimecoin@buildsys1:~]$ uname -a
Linux buildsys1 4.8.0-2-amd64 #1 SMP Debian 4.8.11-1 (2016-12-02) x86_64 GNU/Linux
[dimecoin@buildsys1:~]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 6.2.1-5' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc=auto --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.2.1 20161124 (Debian 6.2.1-5)
[dimecoin@buildsys1:~]$ ldd --version
ldd (Debian GLIBC 2.24-8) 2.24
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

Target:

[dimecoin@prodsys1:~]$ uname -a
Linux prodsys1 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02) x86_64 GNU/Linux
[dimecoin@prodsys1:~]$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc-4.9.real
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.2-10' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.2 (Debian 4.9.2-10)
[dimecoin@prodsys1:~]$ ldd --version
ldd (Debian GLIBC 2.19-18+deb8u6) 2.19
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

build config

[dimecoin@buildsys1:~/build/xmr-stak-cpu]$ cat CMakeLists.txt
project(xmr-stak-cpu)

cmake_minimum_required(VERSION 2.8.10)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
        message(FATAL_ERROR "GCC version must be at least 5.1!")
    endif()
endif()

#SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(CMAKE_C_FLAGS "-DNDEBUG -march=westmere -O3 -m64")
SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11")
#SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-s")
#SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-s")
set(EXECUTABLE_OUTPUT_PATH "bin")

file(GLOB SOURCES "crypto/*.c" "*.cpp")

#SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
#SET(BUILD_SHARED_LIBRARIES OFF)
#SET(CMAKE_EXE_LINKER_FLAGS "-static")

set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")

add_executable(xmr-stak-cpu ${SOURCES})
target_link_libraries(xmr-stak-cpu pthread)

[dimecoin@buildsys1:~/build/xmr-stak-cpu]$

build log

dimecoin@buildsys1:~/build/xmr-stak-cpu]$ rm CMakeCache.txt
[dimecoin@buildsys1:~/build/xmr-stak-cpu]$ make clean
[dimecoin@buildsys1:~/build/xmr-stak-cpu]$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dimecoin/build/xmr-stak-cpu
[dimecoin@buildsys1:~/build/xmr-stak-cpu]$ make
[  7%] Building C object CMakeFiles/xmr-stak-cpu.dir/crypto/c_blake256.c.o
[ 14%] Building C object CMakeFiles/xmr-stak-cpu.dir/crypto/c_groestl.c.o
[ 21%] Building C object CMakeFiles/xmr-stak-cpu.dir/crypto/c_jh.c.o
[ 28%] Building C object CMakeFiles/xmr-stak-cpu.dir/crypto/c_keccak.c.o
[ 35%] Building C object CMakeFiles/xmr-stak-cpu.dir/crypto/c_skein.c.o
[ 42%] Building C object CMakeFiles/xmr-stak-cpu.dir/crypto/cryptonight_aesni.c.o
[ 50%] Building C object CMakeFiles/xmr-stak-cpu.dir/crypto/cryptonight_common.c.o
[ 57%] Building CXX object CMakeFiles/xmr-stak-cpu.dir/cli-miner.cpp.o
[ 64%] Building CXX object CMakeFiles/xmr-stak-cpu.dir/console.cpp.o
[ 71%] Building CXX object CMakeFiles/xmr-stak-cpu.dir/executor.cpp.o
[ 78%] Building CXX object CMakeFiles/xmr-stak-cpu.dir/jconf.cpp.o
[ 85%] Building CXX object CMakeFiles/xmr-stak-cpu.dir/jpsock.cpp.o
[ 92%] Building CXX object CMakeFiles/xmr-stak-cpu.dir/minethd.cpp.o
[100%] Linking CXX executable bin/xmr-stak-cpu
[100%] Built target xmr-stak-cpu
[dimecoin@buildsys1:~/build/xmr-stak-cpu]$ sha512sum bin/xmr-stak-cpu
316108a41882b4b5ea4695344f6467a4e3a1f9d065eb5782f0e928a4ee7b483d37353d62cf880629ee5047ada7f85ae90371889661195d4efe3b6dcce0586c3c  bin/xmr-stak-cpu
[dimecoin@buildsys1:~/build/xmr-stak-cpu]$

Running on target

[dimecoin@buildsys1:~/build/xmr-stak-cpu]$ scp bin/xmr-stak-cpu prodsys1:/tmp/
xmr-stak-cpu                                                                                                                                                 100% 1662KB   1.6MB/s   00:01
[dimecoin@buildsys1:~/build/xmr-stak-cpu]$ scp config.txt prodsys1:/tmp
config.txt                                                                                                                                                   100% 5008   417.2KB/s   00:00
[dimecoin@buildsys1:~/build/xmr-stak-cpu]$ ssh prodsys1
[dimecoin@prodsys1:/tmp]$ uname -a
Linux prodsys1 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02) x86_64 GNU/Linux
[dimecoin@prodsys1:~]$ cd /tmp
[dimecoin@prodsys1:/tmp]$ sha512sum /tmp/xmr-stak-cpu
316108a41882b4b5ea4695344f6467a4e3a1f9d065eb5782f0e928a4ee7b483d37353d62cf880629ee5047ada7f85ae90371889661195d4efe3b6dcce0586c3c  /tmp/xmr-stak-cpu
[dimecoin@prodsys1:/tmp]$ /tmp/xmr-stak-cpu
-------------------------------------------------------------------
XMR-Stak-CPU mining software, CPU Version.
Based on CPU mining code by wolf9466 (heavily optimized by myself).
Brought to you by fireice_uk under GPLv3.

Configurable dev donation level is set to 5.0 %

You can use following keys to display reports:
'h' - hashrate
'r' - results
'c' - connection
-------------------------------------------------------------------
[2017-01-05 19:24:06] : Starting single thread, affinity: 0.
[2017-01-05 19:24:06] : Starting single thread, affinity: 1.
[2017-01-05 19:24:06] : Starting single thread, affinity: 2.
[2017-01-05 19:24:06] : Starting single thread, affinity: 3.
[2017-01-05 19:24:06] : Connecting to pool prodsys1.internaldomain.com:5555 ...
[2017-01-05 19:24:06] : Connected. Logging in...
[2017-01-05 19:24:06] : Difficulty changed. Now: 1000.
[2017-01-05 19:24:06] : New block detected.
HASHRATE REPORT
| ID | 2.5s |  60s |  15m | ID | 2.5s |  60s |  15m |
|  0 | (na) | (na) | (na) |  1 | (na) | (na) | (na) |
|  2 | (na) | (na) | (na) |  3 | (na) | (na) | (na) |
-----------------------------------------------------
Totals:   (na) (na) (na) H/s
Highest:   0.0 H/s
HASHRATE REPORT
| ID | 2.5s |  60s |  15m | ID | 2.5s |  60s |  15m |
|  0 | 28.5 | (na) | (na) |  1 | 29.8 | (na) | (na) |
|  2 | 29.4 | (na) | (na) |  3 | 26.2 | (na) | (na) |
-----------------------------------------------------
Totals:   113.9 (na) (na) H/s
Highest:  113.9 H/s
fireice-uk commented 7 years ago

I added the relevant build options to CMakeLists.txt :+1: