Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patches to enable compilation under Windows with MSYS2 or Cygwin64 #2056

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
project(xmr-stak)

cmake_minimum_required(VERSION 3.4.0)
project(xmr-stak)

# enforce C++11
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -444,8 +443,13 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif()

if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "-Wl,-z,noexecstack ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-Wl,-z,noexecstack ${CMAKE_C_FLAGS}")
if(CMAKE_RC_COMPILER MATCHES "windres") # lame hack to detect Cygwin
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_WIN32 -U__USE_W32_SOCKETS -D_POSIX_C_SOURCE=200112")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_WIN32 -U__USE_W32_SOCKETS -D_POSIX_C_SOURCE=200112")
else()
set(CMAKE_CXX_FLAGS "-Wl,-z,noexecstack ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-Wl,-z,noexecstack ${CMAKE_C_FLAGS}")
endif()
endif()

# activate static libgcc and libstdc++ linking
Expand Down
6 changes: 6 additions & 0 deletions xmrstak/backend/cpu/crypto/cryptonight_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ cryptonight_ctx* cryptonight_alloc_ctx(size_t use_fast_mem, size_t use_mlock, al
ptr->long_state = (uint8_t*)mmap(NULL, hashMemSize, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
#else
#ifndef MAP_HUGETLB
#define MAP_HUGETLB 0
#endif
#ifndef MAP_POPULATE
#define MAP_POPULATE 0
#endif
ptr->long_state = (uint8_t*)mmap(NULL, hashMemSize, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, -1, 0);
#endif
Expand Down
7 changes: 7 additions & 0 deletions xmrstak/backend/cpu/minethd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
#include <thread>
#include <bitset>

#ifdef __CYGWIN__
#define _WIN32
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#endif

#ifdef _WIN32
#include <windows.h>
#else
Expand Down
3 changes: 3 additions & 0 deletions xmrstak/http/httpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

#ifndef CONF_NO_HTTPD

#ifdef __CYGWIN__
#include <strings.h>
#endif

#include "httpd.hpp"
#include "webdesign.hpp"
Expand Down
3 changes: 3 additions & 0 deletions xmrstak/http/httpd.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#pragma once

#include <stdlib.h>
#ifdef __CYGWIN__
#include <sys/select.h>
#endif

struct MHD_Daemon;
struct MHD_Connection;
Expand Down
5 changes: 5 additions & 0 deletions xmrstak/jconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@
#include <numeric>
#include <algorithm>

#ifdef __CYGWIN__
#include <strings.h>
#include <cpuid.h>
#else
#ifdef _WIN32
#define strcasecmp _stricmp
#include <intrin.h>
#else
#include <cpuid.h>
#endif
#endif


using namespace rapidjson;
Expand Down
5 changes: 4 additions & 1 deletion xmrstak/misc/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
#include <time.h>


#ifdef __CYGWIN__
#include <strings.h>
#endif //__CYGWIN__
#ifdef _WIN32
#define strncasecmp _strnicmp
#endif // _WIN32
Expand Down Expand Up @@ -470,7 +473,7 @@ void executor::on_miner_result(size_t pool_id, job_result& oResult)
}
}

#ifndef _WIN32
#if !defined(_WIN32) && !defined(__CYGWIN__)

#include <signal.h>
void disable_sigpipe()
Expand Down