summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpsychocrypt <psychocrypt@users.noreply.github.com>2017-09-24 21:14:35 +0200
committerpsychocrypt <psychocrypt@users.noreply.github.com>2017-09-30 23:46:08 +0200
commit9967fbb0b0031f735d3ab8a275417e59cd28cac9 (patch)
tree1f8f615114a7547116f545c71d53419d5ae0c04d
parent4085d47d03c1762dfc95f893ed0ee86ad9eaee41 (diff)
downloadxmr-stak-9967fbb0b0031f735d3ab8a275417e59cd28cac9.zip
xmr-stak-9967fbb0b0031f735d3ab8a275417e59cd28cac9.tar.gz
fix windows support
- fix broken windows support
-rw-r--r--CMakeLists.txt79
-rw-r--r--WINCOMPILE.md3
-rw-r--r--backend/BackendConnector.cpp10
-rw-r--r--backend/Plugin.hpp9
-rw-r--r--backend/amd/amd_gpu/gpu.cpp7
-rw-r--r--backend/amd/minethd.h2
-rw-r--r--backend/cpu/minethd.h4
-rw-r--r--cli/cli-miner.cpp (renamed from cli-miner.cpp)18
-rw-r--r--jconf.cpp7
9 files changed, 86 insertions, 53 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f88a2a9..3412b3c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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()"
)
diff --git a/WINCOMPILE.md b/WINCOMPILE.md
index ec810af..13bbf9e 100644
--- a/WINCOMPILE.md
+++ b/WINCOMPILE.md
@@ -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
diff --git a/backend/BackendConnector.cpp b/backend/BackendConnector.cpp
index f7a63fe..bb03e69 100644
--- a/backend/BackendConnector.cpp
+++ b/backend/BackendConnector.cpp
@@ -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.");
diff --git a/backend/Plugin.hpp b/backend/Plugin.hpp
index 762f955..347d5db 100644
--- a/backend/Plugin.hpp
+++ b/backend/Plugin.hpp
@@ -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;
diff --git a/backend/amd/amd_gpu/gpu.cpp b/backend/amd/amd_gpu/gpu.cpp
index ebf1093..30aa5a8 100644
--- a/backend/amd/amd_gpu/gpu.cpp
+++ b/backend/amd/amd_gpu/gpu.cpp
@@ -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)
{
diff --git a/backend/amd/minethd.h b/backend/amd/minethd.h
index d308110..349dcfd 100644
--- a/backend/amd/minethd.h
+++ b/backend/amd/minethd.h
@@ -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();
diff --git a/backend/cpu/minethd.h b/backend/cpu/minethd.h
index 3997daa..44b216c 100644
--- a/backend/cpu/minethd.h
+++ b/backend/cpu/minethd.h
@@ -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();
diff --git a/cli-miner.cpp b/cli/cli-miner.cpp
index d7d2781..3129f34 100644
--- a/cli-miner.cpp
+++ b/cli/cli-miner.cpp
@@ -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>
diff --git a/jconf.cpp b/jconf.cpp
index 60075d9..f5fb3bc 100644
--- a/jconf.cpp
+++ b/jconf.cpp
@@ -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());
OpenPOWER on IntegriCloud