fix windows support

- fix broken windows support
This commit is contained in:
psychocrypt
2017-09-30 23:46:08 +02:00
parent 4085d47d03
commit 9967fbb0b0
9 changed files with 86 additions and 53 deletions
+57 -22
View File
@@ -163,9 +163,10 @@ endif()
# Find PThreads
################################################################################
find_package(Threads REQUIRED)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
if(NOT WIN32)
find_package(Threads REQUIRED)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif()
################################################################################
# Find microhttpd
################################################################################
@@ -268,10 +269,16 @@ endif()
# Compile & Link
################################################################################
# activate sse2 and aes-ni
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# remove warnings that f_open() is not save and f_open_s should be used
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
# disable min define to allow usage of std::min
add_definitions(-DNOMINMAX)
else()
# activate sse2 and aes-ni
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -maes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -maes")
endif()
# activate static libgcc and libstdc++ linking
@@ -282,6 +289,20 @@ if(CMAKE_LINK_STATIC)
set(LIBS "-static-libgcc -static-libstdc++ ${LIBS}")
endif()
file(GLOB SRCFILES_C "crypto/*.c")
add_library(xmr-stak-c
STATIC
${SRCFILES_C}
)
file(GLOB BACKEND_CPP "*.cpp" "backend/cpu/*.cpp" "backend/*.cpp" "crypto/*.cpp")
add_library(xmr-stak-backend
STATIC
${BACKEND_CPP}
)
target_link_libraries(xmr-stak-backend xmr-stak-c ${CMAKE_DL_LIBS})
if(CUDA_FOUND)
file(GLOB CUDASRCFILES "backend/nvidia/nvcc_code/*.cu" "backend/nvidia/*.cpp")
@@ -290,26 +311,27 @@ if(CUDA_FOUND)
SHARED
${CUDASRCFILES}
)
target_link_libraries(xmrstak_cuda_backend ${CUDA_LIBRARIES})
target_link_libraries(xmrstak_cuda_backend ${CUDA_LIBRARIES})
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_link_libraries(xmrstak_cuda_backend xmr-stak-backend)
endif()
endif()
if(OpenCL_FOUND)
file(GLOB OPENCLSRCFILES_C "backend/amd/amd_gpu/*.cpp" "console.cpp" "backend/amd/*.cpp")
file(GLOB OPENCLSRCFILES_C "backend/amd/amd_gpu/*.cpp" "backend/amd/*.cpp")
add_library(xmrstak_opencl_backend
SHARED
${OPENCLSRCFILES_C}
)
#set_property(TARGET xmrstak_opencl_backend PROPERTY C_STANDARD 99)
target_link_libraries(xmrstak_opencl_backend PUBLIC ${OpenCL_LIBRARY})
target_link_libraries(xmrstak_opencl_backend ${OpenCL_LIBRARY} )
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_link_libraries(xmrstak_opencl_backend xmr-stak-backend)
endif()
endif()
file(GLOB SRCFILES_CPP "*.cpp" "crypto/*.cpp" "backend/cpu/*.cpp" "backend/*.cpp")
file(GLOB SRCFILES_C "crypto/*.c")
file(GLOB SRCFILES_CPP "cli/*.cpp")
set_source_files_properties(${SRCFILES_CPP} PROPERTIES LANGUAGE CXX)
add_library(xmr-stak-c
STATIC
${SRCFILES_C}
)
set_property(TARGET xmr-stak-c PROPERTY C_STANDARD 99)
target_link_libraries(xmr-stak-c ${LIBS})
@@ -320,34 +342,47 @@ add_executable(xmr-stak-cpu
set(EXECUTABLE_OUTPUT_PATH "bin")
set(LIBRARY_OUTPUT_PATH "bin")
target_link_libraries(xmr-stak-cpu ${LIBS} xmr-stak-c ${CMAKE_DL_LIBS})
target_link_libraries(xmr-stak-cpu ${LIBS} xmr-stak-c xmr-stak-backend)
################################################################################
# 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-cpu
RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
if(CUDA_FOUND)
install(TARGETS xmrstak_cuda_backend
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
if(WIN32)
install(TARGETS xmrstak_cuda_backend
RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
else()
install(TARGETS xmrstak_cuda_backend
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
endif()
endif()
if(OpenCL_FOUND)
install(TARGETS xmrstak_opencl_backend
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
if(WIN32)
install(TARGETS xmrstak_opencl_backend
RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
else()
install(TARGETS xmrstak_opencl_backend
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
endif()
endif()
set(WIN_OUTPUT_RELEASE "/Release")
endif()
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/opencl"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
DESTINATION "${CMAKE_INSTALL_PREFIX}/bin${WIN_OUTPUT_RELEASE}")
# 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 \
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin${WIN_OUTPUT_RELEASE})\n \
endif()"
)
+1 -2
View File
@@ -68,8 +68,7 @@
mkdir build
cd build
cmake -G "Visual Studio 15 2017 Win64" -T v141,host=x64 ..
msbuild xmr-stak-cpu.sln /p:Configuration=Release
cmake --build . --config Release --target install
cd bin\Release
copy ..\..\..\config.txt .
```
- customize your `config.txt` file by adding the pool, username and password
+5 -5
View File
@@ -62,22 +62,22 @@ std::vector<IBackend*>* BackendConnector::thread_starter(miner_work& pWork)
std::vector<IBackend*>* pvThreads = new std::vector<IBackend*>;
auto cpuThreads = cpu::minethd::thread_starter(pvThreads->size(), pWork);
auto cpuThreads = cpu::minethd::thread_starter(static_cast<uint32_t>(pvThreads->size()), pWork);
pvThreads->insert(std::end(*pvThreads), std::begin(cpuThreads), std::end(cpuThreads));
if(cpuThreads.size() == 0)
printer::inst()->print_msg(L0, "WARNING: backend CPU disabled.");
#ifndef CONF_NO_CUDA
Plugin nvidiaPlugin("NVIDIA", "./libxmrstak_cuda_backend");
std::vector<IBackend*>* nvidiaThreads = nvidiaPlugin.startBackend(pvThreads->size(), pWork);
Plugin nvidiaPlugin("NVIDIA", "libxmrstak_cuda_backend");
std::vector<IBackend*>* nvidiaThreads = nvidiaPlugin.startBackend(static_cast<uint32_t>(pvThreads->size()), pWork);
pvThreads->insert(std::end(*pvThreads), std::begin(*nvidiaThreads), std::end(*nvidiaThreads));
if(nvidiaThreads->size() == 0)
printer::inst()->print_msg(L0, "WARNING: backend NVIDIA disabled.");
#endif
#ifndef CONF_NO_OPENCL
Plugin amdPlugin("AMD", "./libxmrstak_opencl_backend");
std::vector<IBackend*>* amdThreads = amdPlugin.startBackend(pvThreads->size(), pWork);
Plugin amdPlugin("AMD", "libxmrstak_opencl_backend");
std::vector<IBackend*>* amdThreads = amdPlugin.startBackend(static_cast<uint32_t>(pvThreads->size()), pWork);
pvThreads->insert(std::end(*pvThreads), std::begin(*amdThreads), std::end(*amdThreads));
if(amdThreads->size() == 0)
printer::inst()->print_msg(L0, "WARNING: backend AMD disabled.");
+7 -2
View File
@@ -27,17 +27,22 @@ struct Plugin
{
#ifdef WIN32
libBackend = LoadLibrary(TEXT((libName + ".dll").c_str()));
if (!libBackend)
{
std::cerr << "WARNING: "<< m_backendName <<" cannot load backend library: " << (libName + ".dll") << std::endl;
return;
}
#else
libBackend = dlopen((libName + ".so").c_str(), RTLD_LAZY);
#endif
if (!libBackend)
{
std::cerr << "WARNING: "<< m_backendName <<" cannot load backend library: " << dlerror() << std::endl;
return;
}
#endif
#ifdef WIN32
fn_starterBackend = (func_t*) GetProcAddress(libBackend, "xmrstak_start_backend");
fn_starterBackend = (starterBackend_t) GetProcAddress(libBackend, "xmrstak_start_backend");
if (!fn_starterBackend)
{
std::cerr << "WARNING: backend plugin " << libName << " contains no entry 'xmrstak_start_backend'" << std::endl;
+4 -3
View File
@@ -18,6 +18,7 @@
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#ifdef _WIN32
#include <windows.h>
@@ -552,7 +553,7 @@ size_t InitOpenCL(GpuContext* ctx, size_t num_gpus, size_t platform_idx)
#ifdef __GNUC__
cl_platform_id PlatformIDList[entries];
#else
cl_platform_id* PlatformIDList = _alloca(entries * sizeof(cl_platform_id));
cl_platform_id* PlatformIDList = (cl_platform_id*)_alloca(entries * sizeof(cl_platform_id));
#endif
if((ret = clGetPlatformIDs(entries, PlatformIDList, NULL)) != CL_SUCCESS)
{
@@ -579,7 +580,7 @@ size_t InitOpenCL(GpuContext* ctx, size_t num_gpus, size_t platform_idx)
#ifdef __GNUC__
cl_device_id DeviceIDList[entries];
#else
cl_device_id* DeviceIDList = _alloca(entries * sizeof(cl_device_id));
cl_device_id* DeviceIDList = (cl_device_id*)_alloca(entries * sizeof(cl_device_id));
#endif
if((ret = clGetDeviceIDs(PlatformIDList[platform_idx], CL_DEVICE_TYPE_GPU, entries, DeviceIDList, NULL)) != CL_SUCCESS)
{
@@ -591,7 +592,7 @@ size_t InitOpenCL(GpuContext* ctx, size_t num_gpus, size_t platform_idx)
#ifdef __GNUC__
cl_device_id TempDeviceList[num_gpus];
#else
cl_device_id* TempDeviceList = _alloca(entries * sizeof(cl_device_id));
cl_device_id* TempDeviceList = (cl_device_id*)_alloca(entries * sizeof(cl_device_id));
#endif
for(int i = 0; i < num_gpus; ++i)
{
+1 -1
View File
@@ -30,7 +30,7 @@ private:
// Bottom 24 bits allow for an hour of work at 4000 H/s
inline uint32_t calc_start_nonce(uint32_t resume)
{
return reverseBits<uint32_t>(iThreadNo + GlobalStates::iThreadCount * resume);
return reverseBits<uint32_t>(static_cast<uint32_t>(iThreadNo + GlobalStates::iThreadCount * resume));
}
void work_main();
+2 -2
View File
@@ -40,13 +40,13 @@ private:
// Bottom 22 bits allow for an hour of work at 1000 H/s
inline uint32_t calc_start_nonce(uint32_t resume)
{
return reverseBits<uint32_t>(iThreadNo + GlobalStates::iThreadCount * resume);
return reverseBits<uint32_t>(static_cast<uint32_t>(iThreadNo + GlobalStates::iThreadCount * resume));
}
// Limited version of the nonce calc above
inline uint32_t calc_nicehash_nonce(uint32_t start, uint32_t resume)
{
return start | ( ( reverseBits<uint32_t>(iThreadNo + GlobalStates::iThreadCount * resume) >> 4u ) );
return start | ( ( reverseBits<uint32_t>(static_cast<uint32_t>(iThreadNo + GlobalStates::iThreadCount * resume)) >> 4u ) );
}
void work_main();
+9 -9
View File
@@ -21,18 +21,18 @@
*
*/
#include "executor.h"
#include "backend/miner_work.h"
#include "backend/GlobalStates.hpp"
#include "backend/BackendConnector.hpp"
#include "jconf.h"
#include "console.h"
#include "donate-level.h"
#include "../executor.h"
#include "../backend/miner_work.h"
#include "../backend/GlobalStates.hpp"
#include "../backend/BackendConnector.hpp"
#include "../jconf.h"
#include "../console.h"
#include "../donate-level.h"
#include "version.h"
#include "../version.h"
#ifndef CONF_NO_HTTPD
# include "httpd.h"
# include "../httpd.h"
#endif
#include <stdlib.h>
-7
View File
@@ -310,13 +310,6 @@ bool jconf::parse_config(const char* sFilename)
}
#endif // CONF_NO_TLS
#ifdef _WIN32
if(GetSlowMemSetting() == no_mlck)
{
printer::inst()->print_msg(L0, "On Windows large pages need mlock. Please use another option.");
return false;
}
#endif // _WIN32
printer::inst()->set_verbose_level(prv->configValues[iVerboseLevel]->GetUint64());