From: nomennescio Date: Tue, 5 Nov 2019 12:57:09 +0000 (+0100) Subject: Support for MinGW compiler. Need to instal MinGW compiler and runtime. X-Git-Tag: 0.99~3623 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=c33a4060661cf4d8a6c94322e445cec09c34503f Support for MinGW compiler. Need to instal MinGW compiler and runtime. --- diff --git a/build.sh b/build.sh index fba998ee4e..4e3e7bfe39 100755 --- a/build.sh +++ b/build.sh @@ -92,7 +92,7 @@ check_ret() { set_downloader() { test_program_installed wget if [[ $? -ne 0 ]] ; then - DOWNLOADER=wget + DOWNLOADER="wget -nd" DOWNLOADER_NAME=wget return fi @@ -154,6 +154,23 @@ clang_version_ok() { } set_cc() { + + # on Cygwin we MUST use the MinGW "cross-compiler", therefore check these first + # furthermore, we prefer 64 bit over 32 bit versions if both are available + test_programs_installed x86_64-w64-mingw32-gcc x86_64-w64-mingw32-g++ + if [[ $? -ne 0 ]] ; then + [ -z "$CC" ] && CC=x86_64-w64-mingw32-gcc + [ -z "$CXX" ] && CXX=x86_64-w64-mingw32-g++ + return + fi + + test_programs_installed i686-w64-mingw32-gcc i686-w64-mingw32-g++ + if [[ $? -ne 0 ]] ; then + [ -z "$CC" ] && CC=i686-w64-mingw32-gcc + [ -z "$CXX" ] && CXX=i686-w64-mingw32-g++ + return + fi + test_programs_installed clang clang++ if [[ $? -ne 0 ]] && clang_version_ok ; then [ -z "$CC" ] && CC=clang @@ -161,6 +178,7 @@ set_cc() { return fi + # gcc and g++ will fail to correctly build Factor on Cygwin test_programs_installed gcc g++ if [[ $? -ne 0 ]] ; then [ -z "$CC" ] && CC=gcc @@ -187,8 +205,8 @@ check_installed_programs() { ensure_program_installed uname ensure_program_installed git ensure_program_installed wget curl - ensure_program_installed clang gcc - ensure_program_installed clang++ g++ cl + ensure_program_installed clang x86_64-w64-mingw32-gcc i686-w64-mingw32-gcc gcc + ensure_program_installed clang++ x86_64-w64-mingw32-g++ i686-w64-mingw32-g++ g++ cl ensure_program_installed make gmake ensure_program_installed md5sum md5 ensure_program_installed cut diff --git a/vm/Config.windows b/vm/Config.windows index 0b5f843420..3dd37e99fb 100644 --- a/vm/Config.windows +++ b/vm/Config.windows @@ -1,4 +1,4 @@ -SITE_CFLAGS += -mno-cygwin -mwindows +SITE_CFLAGS += -mwindows CFLAGS_CONSOLE += -mconsole SHARED_FLAG = -shared SHARED_DLL_EXTENSION=.dll @@ -7,7 +7,7 @@ LIBS = -lm PLAF_DLL_OBJS += vm/os-windows.o vm/mvm-windows.o PLAF_EXE_OBJS += vm/resources.o vm/main-windows.o -PLAF_MASTER_HEADERS += vm/os-windows.hpp vm/mvm-windows.hpp +PLAF_MASTER_HEADERS += vm/os-windows.hpp EXE_SUFFIX= EXE_EXTENSION=.exe @@ -15,5 +15,5 @@ DLL_SUFFIX= DLL_EXTENSION=.dll CONSOLE_EXTENSION=.com -LINKER = $(CPP) -shared -mno-cygwin -o +LINKER = $(CPP) -shared -o LINK_WITH_ENGINE = -l$(DLL_PREFIX)factor$(DLL_SUFFIX) diff --git a/vm/Config.windows.x86.32 b/vm/Config.windows.x86.32 index 82cad23ef6..56b7f7fa48 100644 --- a/vm/Config.windows.x86.32 +++ b/vm/Config.windows.x86.32 @@ -1,6 +1,6 @@ PLAF_DLL_OBJS += vm/os-windows-x86.32.o PLAF_MASTER_HEADERS += vm/os-windows.32.hpp DLL_PATH=http://factorcode.org/dlls -WINDRES=windres +WINDRES=windres -F pe-i386 include vm/Config.windows include vm/Config.x86.32 diff --git a/vm/master.hpp b/vm/master.hpp index 8aa0d9787c..bac9e5f7ed 100644 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -43,6 +43,8 @@ #elif defined(__INTEL_COMPILER) #define FACTOR_COMPILER_VERSION \ "Intel C Compiler " FACTOR_STRINGIZE(__INTEL_COMPILER) +#elif defined(__MINGW32__) +#define FACTOR_COMPILER_VERSION "MinGW (GCC " __VERSION__ ")" #elif defined(__GNUC__) #define FACTOR_COMPILER_VERSION "GCC " __VERSION__ #elif defined(_MSC_FULL_VER) @@ -79,7 +81,7 @@ #error "Unsupported architecture" #endif -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined (__MINGW32__) #define WINDOWS #define WINNT #elif defined(WIN32) diff --git a/vm/os-windows.cpp b/vm/os-windows.cpp index d5ecad1d09..d6b74888c2 100644 --- a/vm/os-windows.cpp +++ b/vm/os-windows.cpp @@ -185,12 +185,14 @@ uint64_t nano_count() { void sleep_nanos(uint64_t nsec) { Sleep((DWORD)(nsec / 1000000)); } +#ifndef EXCEPTION_DISPOSITION typedef enum _EXCEPTION_DISPOSITION { ExceptionContinueExecution = 0, ExceptionContinueSearch = 1, ExceptionNestedException = 2, ExceptionCollidedUnwind = 3 } EXCEPTION_DISPOSITION; +#endif LONG factor_vm::exception_handler(PEXCEPTION_RECORD e, void* frame, PCONTEXT c, void* dispatch) {