]> gitweb.factorcode.org Git - factor.git/commitdiff
Support for MinGW compiler. Need to instal MinGW compiler and runtime.
authornomennescio <nomennescio@factorcode.org>
Tue, 5 Nov 2019 12:57:09 +0000 (13:57 +0100)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 10 Dec 2019 16:53:32 +0000 (08:53 -0800)
build.sh
vm/Config.windows
vm/Config.windows.x86.32
vm/master.hpp
vm/os-windows.cpp

index fba998ee4ec15461e29ab0e2dd618b762b664273..4e3e7bfe39af7253087fd5fe65d4d28b8b47647a 100755 (executable)
--- 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
index 0b5f843420badbf0c9e61818db86a076dc3ea5c5..3dd37e99fbc4630a63422768aabd5e45370a69c3 100644 (file)
@@ -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 -
+LINKER = $(CPP) -shared -o 
 LINK_WITH_ENGINE = -l$(DLL_PREFIX)factor$(DLL_SUFFIX)
index 82cad23ef653cc946f505e360167092a30517d76..56b7f7fa484f4bf2f073e0c9e6a1ecc85ba98aa9 100644 (file)
@@ -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
index 8aa0d9787c89e2e90694bf4bb304832734fe5183..bac9e5f7ed0f05cf5b768dca32633b95f9fec966 100644 (file)
@@ -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)
index d5ecad1d099fbcd96b0dbbf407dd907edd2adf22..d6b74888c203d2e5b861f957dde8e35070472e27 100644 (file)
@@ -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) {