From fae57fcf12c702502f27c19e66730e177bf54281 Mon Sep 17 00:00:00 2001 From: Andras Tantos Date: Tue, 31 Jan 2023 16:46:20 -0800 Subject: [PATCH] Fixes for mingw and cygwin builds. --- simulator/README_boost.txt | 17 ++++++++++------- simulator/common.mak | 9 ++++++++- simulator/fp_test/fp_test.cpp | 6 ++++-- simulator/sim_lib/utils.cpp | 2 +- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/simulator/README_boost.txt b/simulator/README_boost.txt index 1cfc516..747748d 100644 --- a/simulator/README_boost.txt +++ b/simulator/README_boost.txt @@ -76,16 +76,19 @@ you need to do additional changes: == MinGW =============================================================================== -Use MinGW distro from http://nuwen.net/mingw.html. That way you don't have to do -anything, you are ready to go. +For MinGW the easiest route is to use the mSYS2 environment from https://www.msys2.org/. -If you are using a stock MinGW installation, you'll have to build boost yourself. +Use 'pacman' to install boost matching your toolchain. An example would be: + + pacman -S ucrt64/mingw-w64-ucrt-x86_64-boost + +or + + pacman -S mingw64/mingw-w64-x86_64-boost =============================================================================== == Cygwin =============================================================================== -As of this writing, Cygwin is broken. Theoretically, all you have to select all -the boost libraries in the cygwin setup. -See http://comments.gmane.org/gmane.os.cygwin/158779 for what's wrong with the -current packages. +Cygwin comes with boost packages (boost-devel). Install them and you should be +good to go. diff --git a/simulator/common.mak b/simulator/common.mak index 31d8157..1ca25b6 100644 --- a/simulator/common.mak +++ b/simulator/common.mak @@ -93,7 +93,8 @@ ifndef REMOVE REMOVE = del endif #ifndef MKDIR -MKDIR = mkdir $(subst /,\,$(1)) +# MKDIR = mkdir $(subst /,\,$(1)) +MKDIR = mkdir -p $(1) #endif endif @@ -149,6 +150,11 @@ define static_lib $(1) endef endif +ifeq ($(SYSTEM),mingw) +define static_lib + :lib$(strip $(1))-mt.a +endef +endif ################################################################################# ### Setting up some common libraries @@ -171,6 +177,7 @@ COMMON_LIBS += stdc++ ifeq ("$(SYSTEM)","mingw") COMMON_LIBS += wsock32 COMMON_LIBS += ws2_32 +COMMON_LIBS += Bcrypt endif ifeq ($(SYSTEM),linux) NCURSES_LIBS += $(call static_lib, ncurses) diff --git a/simulator/fp_test/fp_test.cpp b/simulator/fp_test/fp_test.cpp index 7d2c8a6..c803bd0 100644 --- a/simulator/fp_test/fp_test.cpp +++ b/simulator/fp_test/fp_test.cpp @@ -169,6 +169,7 @@ std::string WriteTest(const std::string &aPrefix, const CInt_t &aA, const CInt_t Result = aOperation(CFloat_t(aA), CFloat_t(aB)); } catch (std::exception &) { + Result.Value = 0xdeadbeef; Overflow = true; } RetVal << "____" << (Overflow ? "1" : "0") << "_" << std::noshowbase << std::uppercase << std::hex << std::setw(16) << std::setfill('0') << Result.Value; @@ -188,6 +189,7 @@ std::string WriteTest(const std::string &aPrefix, const CInt_t &aA, CFloat_t(*aO Result = aOperation(CFloat_t(aA)); } catch (std::exception &) { + Result.Value = 0xdeadbeef; Overflow = true; } RetVal << "____" << std::noshowbase << std::uppercase << std::hex << std::setw(16) << std::setfill('0') << Result.Value; @@ -540,8 +542,8 @@ TestResult_s TestSettings(size_t aStep0Precision, size_t aStep1Precision, size_t void SearchSettings() { TestResult_s BestResult; - size_t BestStep0Precision; - size_t BestStep1Precision; + size_t BestStep0Precision = 0xdeadbeef; + size_t BestStep1Precision = 0xdeadbeef; size_t BestStep2Precision = 0; uint64_t BestStep1CorrectionFactor = 0; uint64_t BestStep2CorrectionFactor = 0; diff --git a/simulator/sim_lib/utils.cpp b/simulator/sim_lib/utils.cpp index 922672e..84e6ea1 100644 --- a/simulator/sim_lib/utils.cpp +++ b/simulator/sim_lib/utils.cpp @@ -45,7 +45,7 @@ void SetThreadAffinity(std::thread &aThread, size_t aCpuId) { CRAY_ASSERT(aCpuId < std::thread::hardware_concurrency()); CRAY_ASSERT(aCpuId < (sizeof(DWORD_PTR) *8)); DWORD_PTR CpuMask = DWORD_PTR(1) << aCpuId; - DWORD_PTR RetVal = SetThreadAffinityMask(aThread.native_handle(), CpuMask); + DWORD_PTR RetVal = SetThreadAffinityMask((HANDLE)aThread.native_handle(), CpuMask); if (RetVal == 0) throw Generic_x() << "Error calling SetThreadAffinityMask: " << HexPrinter(GetLastError()); }