Skip to content

Instantly share code, notes, and snippets.

@equalsraf
Last active November 10, 2021 09:54
Show Gist options
  • Save equalsraf/6cc26951981fa254b53a80cf73eaf47d to your computer and use it in GitHub Desktop.
Save equalsraf/6cc26951981fa254b53a80cf73eaf47d to your computer and use it in GitHub Desktop.
New instructions for building nvim in Windows

[WIP]

Windows/MSYS2

In Windows we build using the toolchain provided by MSYS2 - the resulting binaries DO NOT link against the MSYS2 runtime.

Start by installing the necessary dependencies

pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-libtool mingw-w64-x86_64-cmake \
mingw-w64-x86_64-make mingw-w64-x86_64-perl mingw-w64-x86_64-python2 \
mingw-w64-x86_64-pkg-config mingw-w64-x86_64-unibilium gperf

Building in cmd.exe

Set your PATH to include the mingw64 tools

set PATH=c:\msys64\mingw64\bin;%PATH%

The following is not always required, but sometimes mingw32-make fails to invoke the correct compiler

set CC=gcc

Build using the MinGW Makefiles generator

mkdir .deps
cd .deps
cmake  -G "MinGW Makefiles" ..\third-party\
mingw32-make
cd ..
mkdir build
cd build
cmake -G "MinGW Makefiles" -DGPERF_PRG="C:\msys64\usr\bin\gperf.exe" ..
mingw32-make

Building inside the MSYS2 MinGW64 shell

To build from inside the MinGW64 shell install mingw64-x86_64-lua51-mpack and use the MSYS Makefiles generator.

mkdir .deps
cd .deps
cmake -G "MSYS Makefiles" -DUSE_BUNDLED_LUAROCKS=NO ../third-party
make
cd ..
mkdir build
cd build
cmake -G "MSYS Makefiles" ..
make

Currently there is no way to run tests and some development tasks inside the MSYS2 shell, because .bat files cannot be executed there, and path conversions do not work well with some of the lua tools.

mingw and python greenlet

see python-greenlet/greenlet#20

@alexeRadu
Copy link

I know that this is old but I tried. Do you know if anybody has built nvim on msys2/mingw? Or if there is any plan for such a build?

@equalsraf
Copy link
Author

Neovim does build for mingw, but the release version builds with MSVC. It has been a while and a lot has changed but this is the script that builds it for the CI - Some dependencies are installed via msys pacman,

https://github.com/neovim/neovim/blob/master/ci/build.ps1#L62

while the others are downloaded and built from source by recipes in the neovim source repo

https://github.com/neovim/neovim/blob/master/ci/build.ps1#L137

The neovim recipe uses msys2 to get a working build environment, but it doesn't really build from inside the msys2 shell.

Last i checked these instructions worked https://github.com/neovim/neovim/wiki/Building-Neovim#windows--msys2

@alexeRadu
Copy link

Thanks for the info. I want to create a neovim package for msys2 so I need it to build inside msys2 shell. There may be more steps involved but the info you gave me is very usefull. Thanks

@equalsraf
Copy link
Author

Thanks for the info. I want to create a neovim package for msys2 so I need it to build inside msys2 shell. There may be more steps involved but the info you gave me is very usefull. Thanks

From what i remember, the reason we did not build inside msys2 was because we ran into issues with luarocks (built in third-party/) and path handling inside msys, so we build third-party from outside. Its been a while but I suspect nvim itself could build with the correct cmake generator.

Things you can do to work around any issues or speed up your port

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment