micropython/ports/windows
stijn b184b6ae53 py/nlr: Fix nlr functions for 64bit ports built with gcc on Windows
The number of registers used should be 10, not 12, to match the assembly
code in nlrx64.c. With this change the 64bit mingw builds don't need to
use the setjmp implementation, and this fixes miscellaneous crashes and
assertion failures as reported in #1751 for instance.

To avoid mistakes in the future where something gcc-related for Windows
only gets fixed for one particular compiler/environment combination,
make use of a MICROPY_NLR_OS_WINDOWS macro.

To make sure everything nlr-related is now ok when built with gcc this
has been verified with:
- unix port built with gcc on Cygwin (i686-pc-cygwin-gcc and
  x86_64-pc-cygwin-gcc, version 6.4.0)
- windows port built with mingw-w64's gcc from Cygwin
 (i686-w64-mingw32-gcc and x86_64-w64-mingw32-gcc, version 6.4.0)
 and MSYS2 (like the ones on Cygwin but version 7.2.0)
2017-12-29 22:24:46 +11:00
..
msvc all: Update Makefiles and others to build with new ports/ dir layout. 2017-09-06 14:09:13 +10:00
.appveyor.yml all: Update Makefiles and others to build with new ports/ dir layout. 2017-09-06 14:09:13 +10:00
.gitignore ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
fmode.c ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
fmode.h ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
init.c ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
init.h ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
Makefile py/nlr: Fix nlr functions for 64bit ports built with gcc on Windows 2017-12-29 22:24:46 +11:00
micropython.vcxproj ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
mpconfigport.h windows/mpconfigport: Enable some features, including the Python stack 2017-12-29 22:14:16 +11:00
mpconfigport.mk ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
README.md all: Update Makefiles and others to build with new ports/ dir layout. 2017-09-06 14:09:13 +10:00
realpath.c ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
realpath.h ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
sleep.c ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
sleep.h ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
windows_mphal.c ports: Make new ports/ sub-directory and move all ports there. 2017-09-06 13:40:51 +10:00
windows_mphal.h all: Update Makefiles and others to build with new ports/ dir layout. 2017-09-06 14:09:13 +10:00

This is the experimental, community-supported Windows port of MicroPython. It is based on Unix port, and expected to remain so. The port requires additional testing, debugging, and patches. Please consider to contribute.

Building on Debian/Ubuntu Linux system

sudo apt-get install gcc-mingw-w64
make CROSS_COMPILE=i686-w64-mingw32-

If for some reason the mingw-w64 crosscompiler is not available, you can try mingw32 instead, but it comes with a really old gcc which may produce some spurious errors (you may need to disable -Werror):

sudo apt-get install mingw32 mingw32-binutils mingw32-runtime
make CROSS_COMPILE=i586-mingw32msvc-

Building under Cygwin

Install following packages using cygwin's setup.exe:

  • mingw64-i686-gcc-core
  • mingw64-x86_64-gcc-core
  • make

Build using:

make CROSS_COMPILE=i686-w64-mingw32-

Or for 64bit:

make CROSS_COMPILE=x86_64-w64-mingw32-

Building using MS Visual Studio 2013 (or higher)

In the IDE, open micropython.vcxproj and build.

To build from the command line:

msbuild micropython.vcxproj

Stack usage

The msvc compiler is quite stack-hungry which might result in a "maximum recursion depth exceeded" RuntimeError for code with lots of nested function calls. There are several ways to deal with this:

  • increase the threshold used for detection by altering the argument to mp_stack_set_limit in ports/unix/main.c
  • disable detection all together by setting MICROPY_STACK_CHECK to "0" in ports/windows/mpconfigport.h
  • disable the /GL compiler flag by setting WholeProgramOptimization to "false"

See issue 2927 for more information.

Running on Linux using Wine

The default build (MICROPY_USE_READLINE=1) uses extended Windows console functions and thus should be ran using the wineconsole tool. Depending on the Wine build configuration, you may also want to select the curses backend which has the look&feel of a standard Unix console:

wineconsole --backend=curses ./micropython.exe

For more info, see https://www.winehq.org/docs/wineusr-guide/cui-programs .

If built without line editing and history capabilities (MICROPY_USE_READLINE=0), the resulting binary can be run using the standard wine tool.