Skip to content

Commit 3baf6b5

Browse files
stinospfalcon
authored andcommitted
windows/py: Support 64bit mingw-w64 builds
- add mp_int_t/mp_uint_t typedefs in mpconfigport.h - fix integer suffixes/formatting in mpconfig.h and mpz.h - use MICROPY_NLR_SETJMP=1 in Makefile since the current nlrx64.S implementation causes segfaults in gc_free() - update README
1 parent a58fa27 commit 3baf6b5

5 files changed

Lines changed: 24 additions & 3 deletions

File tree

py/mpconfig.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,14 @@ typedef double mp_float_t;
849849

850850
// printf format spec to use for mp_int_t and friends
851851
#ifndef INT_FMT
852-
#ifdef __LP64__
852+
#if defined(__LP64__)
853853
// Archs where mp_int_t == long, long != int
854854
#define UINT_FMT "%lu"
855855
#define INT_FMT "%ld"
856+
#elif defined(_WIN64)
857+
#include <inttypes.h>
858+
#define UINT_FMT "%"PRIu64
859+
#define INT_FMT "%"PRId64
856860
#else
857861
// Archs where mp_int_t == int
858862
#define UINT_FMT "%u"

py/mpz.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ typedef int8_t mpz_dbl_dig_signed_t;
7373
#endif
7474

7575
#ifdef _WIN64
76-
#define MPZ_LONG_1 1i64
76+
#ifdef __MINGW32__
77+
#define MPZ_LONG_1 1LL
78+
#else
79+
#define MPZ_LONG_1 1i64
80+
#endif
7781
#else
7882
#define MPZ_LONG_1 1L
7983
#endif

windows/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ CFLAGS_MOD += -DMICROPY_USE_READLINE=2
4949
LDFLAGS_MOD += -lreadline
5050
endif
5151

52+
ifeq ($(CROSS_COMPILE),x86_64-w64-mingw32-)
53+
CFLAGS_MOD += -DMICROPY_NLR_SETJMP=1
54+
endif
55+
5256
LIB += -lws2_32
5357

5458
include ../py/mkrules.mk

windows/README

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ make CROSS_COMPILE=i586-mingw32msvc-
2020
To compile under Cygwin:
2121

2222
Install following packages using cygwin's setup.exe:
23-
mingw64-i686-gcc-core, make
23+
mingw64-i686-gcc-core, mingw64-x86_64-gcc-core, make
2424
Build using:
2525

2626
make CROSS_COMPILE=i686-w64-mingw32-
2727

28+
or for 64bit:
29+
30+
make CROSS_COMPILE=x86_64-w64-mingw32-
31+
2832

2933
To compile using Visual Studio 2013 (or higher):
3034

windows/mpconfigport.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@
108108
#if defined( __MINGW32__ ) && defined( __LP64__ )
109109
typedef long mp_int_t; // must be pointer size
110110
typedef unsigned long mp_uint_t; // must be pointer size
111+
#elif defined ( __MINGW32__ ) && defined( _WIN64 )
112+
#include <stdint.h>
113+
typedef __int64 mp_int_t;
114+
typedef unsigned __int64 mp_uint_t;
115+
#define MP_SSIZE_MAX __INT64_MAX__
111116
#elif defined ( _MSC_VER ) && defined( _WIN64 )
112117
typedef __int64 mp_int_t;
113118
typedef unsigned __int64 mp_uint_t;

0 commit comments

Comments
 (0)