Skip to content

Commit

Permalink
Merge pull request #86 from fireice-uk/dev
Browse files Browse the repository at this point in the history
Merge into master
  • Loading branch information
fireice-uk authored Apr 26, 2017
2 parents e58a09f + 620cd67 commit 068b6fa
Show file tree
Hide file tree
Showing 15 changed files with 543 additions and 164 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@ obj/
xmr-stak-cpu.layout
xmr-stak-cpu.depend
config-debug.txt

# netbeans project files
/nbproject/

# tmp files
*~

# merge original backup files
*.orig
129 changes: 112 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,133 @@
project(xmr-stak-cpu)

cmake_minimum_required(VERSION 2.8.10)
cmake_minimum_required(VERSION 3.0.1)

# enforce C++11
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 11)

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "install prefix" FORCE)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

# allow user to extent CMAKE_PREFIX_PATH via environment variable
list(APPEND CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")

################################################################################
# CMake user options
################################################################################

# gcc 5.1 is the first GNU version without CoW strings
# https://github.com/fireice-uk/xmr-stak-nvidia/pull/10#issuecomment-290821792
# If you remove this guard to compile with older gcc versions the miner will produce
# a high rate of wrong shares.
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
message(FATAL_ERROR "GCC version must be at least 5.1!")
endif()
endif()

set(BUILD_TYPE "Release;Debug")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build" FORCE)
endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${BUILD_TYPE}")

# option to add static libgcc and libstdc++
option(CMAKE_LINK_STATIC "link as much as possible libraries static" OFF)

################################################################################
# Find PThreads
################################################################################

find_package(Threads REQUIRED)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})

################################################################################
# Find microhttpd
################################################################################

option(MICROHTTPD_REQUIRED "Enable or disable the requirement of microhttp (http deamon)" ON)
find_library(MHTD NAMES microhttpd)
if("${MHTD}" STREQUAL "MHTD-NOTFOUND")
message(FATAL_ERROR "libmicrohttpd is required")
if(MICROHTTPD_REQUIRED)
message(FATAL_ERROR "microhttpd NOT found: use `-DMICROHTTPD_REQUIRED=OFF` to build without http deamon support")
else()
message(STATUS "microhttpd NOT found: disable http server")
add_definitions("-DCONF_NO_HTTPD")
endif()
else()
set(LIBS ${LIBS} ${MHTD})
endif()

find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
###############################################################################
# Find OpenSSL
###############################################################################

#set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CONFIGURATION_TYPES "RELEASE;STATIC")
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE RELEASE)
option(OpenSSL_REQUIRED "Enable or disable the requirement of OpenSSL" ON)
find_package(OpenSSL)
if(OPENSSL_FOUND)
include_directories(${OPENSSL_INCLUDE_DIR})
set(LIBS ${LIBS} ${OPENSSL_LIBRARIES})
else()
if(OpenSSL_REQUIRED)
message(FATAL_ERROR "OpenSSL NOT found: use `-DOpenSSL_REQUIRED=OFF` to build without SSL support")
else()
if(NOT OPENSSL_FOUND)
add_definitions("-DCONF_NO_TLS")
endif()
endif()
endif()

set(CMAKE_C_FLAGS "-DNDEBUG -march=westmere -O3 -m64 -s")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11")
################################################################################
# Compile & Link
################################################################################

# activate sse2 and aes-ni
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -maes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -maes")

# activate static libgcc and libstdc++ linking
if(CMAKE_LINK_STATIC)
set(BUILD_SHARED_LIBRARIES OFF)
set(DL_LIB ${CMAKE_DL_LIBS})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(LIBS "-static-libgcc -static-libstdc++ ${LIBS}")
endif()

set(CMAKE_EXE_LINKER_FLAGS_RELSEASE "")
set(CMAKE_EXE_LINKER_FLAGS_STATIC "-static-libgcc -static-libstdc++")
file(GLOB SRCFILES_CPP "*.cpp" "crypto/*.cpp")
file(GLOB SRCFILES_C "crypto/*.c")

add_library(xmr-stak-c
STATIC
${SRCFILES_C}
)
set_property(TARGET xmr-stak-c PROPERTY C_STANDARD 99)

add_executable(xmr-stak-cpu
${SRCFILES_CPP}
)

set(EXECUTABLE_OUTPUT_PATH "bin")
target_link_libraries(xmr-stak-cpu ${LIBS} xmr-stak-c)

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

# do not install the binary if the project and install are equal
if( NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "${PROJECT_BINARY_DIR}" )
install(TARGETS xmr-stak-amd
RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
endif()

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


# avoid overwrite of user defined settings
# install `config.txt`if file not exists in `${CMAKE_INSTALL_PREFIX}/bin`
install(CODE " \
if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/bin/config.txt)\n \
file(INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/config.txt \
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)\n \
endif()"
)
73 changes: 60 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
### XMR-Stak-CPU - Monero mining software
# XMR-Stak-CPU - Monero mining software

XMR-Stak is a universal Stratum pool miner. This is the CPU-mining version; there is also an [AMD GPU version](https://github.com/fireice-uk/xmr-stak-amd) and an [NVIDA GPU version](https://github.com/fireice-uk/xmr-stak-nvidia)

#### HTML reports
## HTML reports
<img src="https://gist.githubusercontent.com/fireice-uk/2da301131ac01695ff79539a27b81d68/raw/4c09cdeee86f94df2e9dd86b927e64aded6184f5/xmr-stak-cpu-hashrate.png" width="260"> <img src="https://gist.githubusercontent.com/fireice-uk/2da301131ac01695ff79539a27b81d68/raw/4c09cdeee86f94df2e9dd86b927e64aded6184f5/xmr-stak-cpu-results.png" width="260"> <img src="https://gist.githubusercontent.com/fireice-uk/2da301131ac01695ff79539a27b81d68/raw/4c09cdeee86f94df2e9dd86b927e64aded6184f5/xmr-stak-cpu-connection.png" width="260">

#### Usage on Windows
## Usage on Windows
1) Edit the config.txt file to enter your pool login and password.
2) Double click the exe file.

Expand Down Expand Up @@ -42,22 +42,27 @@ lBoYbHZRpcWUfDO8o2y+ZQIs+yzMoJHHBBXB9fsHlwq62PTtzjsEVwB2aq9ABzk=
```

#### Usage on Linux (Debian-based distros)
## Compile on Linux (Debian-based distros)

### GNU Compiler
```
sudo apt-get install libmicrohttpd-dev libssl-dev cmake build-essential
cmake .
make
make install
```

GCC version 5.1 or higher is required for full C++11 support. CMake release compile scripts, as well as CodeBlocks build environment for debug builds is included.
- GCC version 5.1 or higher is required for full C++11 support. CMake release compile scripts, as well as CodeBlocks build environment for debug builds is included.

To do a static build for a system without gcc 5.1+
### To do a static build for a system without gcc 5.1+
```
cmake -DCMAKE_BUILD_TYPE=STATIC
make
cmake -DCMAKE_LINK_STATIC=ON .
make install
```
Note - cmake caches variables, so if you want to do a dynamic build later you need to specify '-DCMAKE_BUILD_TYPE=RELEASE'


You can find a complete compile guide under [Advanced Compile Options](#advanced-compile-options).

#### CPU mining performance

Performance is nearly identical to the closed source paid miners. Here are some numbers:
Expand All @@ -67,16 +72,22 @@ Performance is nearly identical to the closed source paid miners. Here are some
* **Dual X5650** - 466 H/s (depends on NUMA)
* **Dual E5640** - 365 H/s (same as above)

#### Default dev donation
## Default dev donation
By default the miner will donate 1% of the hashpower (1 minute in 100 minutes) to my pool. If you want to change that, edit **donate-level.h** before you build the binaries.

If you want to donate directly to support further development, here is my wallet

fireice-uk:
```
4581HhZkQHgZrZjKeCfCJxZff9E3xCgHGF25zABZz7oR71TnbbgiS7sK9jveE6Dx6uMs2LwszDuvQJgRZQotdpHt1fTdDhk
```

#### PGP Key
psychocrypt:
```
43NoJVEXo21hGZ6tDG6Z3g4qimiGdJPE6GRxAmiWwm26gwr62Lqo7zRiCJFSBmbkwTGNuuES9ES5TgaVHceuYc4Y75txCTU
```

## PGP Key
```
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2
Expand Down Expand Up @@ -110,7 +121,7 @@ c4hC0Yg9Dha1OoE5CJCqVL+ic4vAyB1urAwBlsd/wH8=
-----END PGP PUBLIC KEY BLOCK-----
```

### Common Issues
## Common Issues

**SeLockMemoryPrivilege failed**

Expand Down Expand Up @@ -160,4 +171,40 @@ You can also do it Windows-style and simply run-as-root, but this is NOT recomme
This typically means you are trying to run it on a CPU that does not have [AES](https://en.wikipedia.org/wiki/AES_instruction_set). This only happens on older version of miner, new version gives better error message (but still wont' work since your CPU doesn't support the required instructions).



## Advanced Compile Options

The build system is CMake, if you are not familiar with CMake you can learn more [here](https://cmake.org/runningcmake/).

### Short Description

There are two easy ways to set variables for `cmake` to configure *xmr-stak-cpu*
- use the ncurses GUI
- `ccmake .`
- edit your options
- end the GUI by pressing the key `c`(create) and than `g`(generate)
- set Options on the command line
- enable a option: `cmake . -DNAME_OF_THE_OPTION=ON`
- disable a option `cmake . -DNAME_OF_THE_OPTION=OFF`
- set a value `cmake . -DNAME_OF_THE_OPTION=value`

After the configuration you need to call
`make install` for slow sequential build
or
`make -j install` for faster parallel build
and install.

### xmr-stak-cpu Compile Options
- `CMAKE_INSTALL_PREFIX` install miner to the home folder
- `cmake . -DCMAKE_INSTALL_PREFIX=$HOME/xmr-stak-cpu`
- you can find the binary and the `config.txt` file after `make install` in `$HOME/xmr-stak-cpu/bin`
- `CMAKE_LINK_STATIC` link libgcc and libstdc++ libraries static (default OFF)
- disable with `cmake . -DCMAKE_LINK_STATIC=ON`
-`CMAKE_BUILD_TYPE` set the build type
- valid options: `Release` or `Debug`
- you should always keep `Release` for your productive miners
- `MICROHTTPD_REQUIRED` allow to disable/enable the dependency *microhttpd*
- by default enabled
- there is no *http* interface available if option is disabled: `cmake . -DMICROHTTPD_REQUIRED=OFF`
- `OpenSSL_REQUIRED`allow to disable/enable the dependency *OpenSSL*
- by default enabled
- it is not possible to connect to a *https* secured pool if optin is disabled: `cmake . -DOpenSSL_REQUIRED=OFF`
Loading

0 comments on commit 068b6fa

Please sign in to comment.