Skip to content

Instantly share code, notes, and snippets.

@equalsraf
Last active January 2, 2020 02:17
Show Gist options
  • Save equalsraf/c52c2261ff3671ccbd32 to your computer and use it in GitHub Desktop.
Save equalsraf/c52c2261ff3671ccbd32 to your computer and use it in GitHub Desktop.
Cross Compile Neovim

Before you start you need a Mingw-w64 toolchain for Linux, try installing the mingw-w64 package (Ubuntu, Suse, Fedora?) or get it from the Mingw-w64 website.

Build dependencies

$ mkdir deps-mingw
$ cd deps-mingw
$ cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw32-w64-cross-travis.toolchain.cmake ../third-party/
$ make
$ cd ..

Build Neovim

$ mkdir build-mingw
$ cd build-mingw
$ cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw32-w64-cross-travis.toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-DMIN_LOG_LEVEL=0 -pg" -DDEPS_PREFIX=../deps-mingw/usr ..
$ make
$ wine bin/nvim.exe

You may get some errors (like missing dlls) when running, but this depends on your Mingw toolchain. Just copy the missing dll into the bin/ folder.

FYI: the terminal interface IS broken, so there wont be any output - but you can use one of the Neovim GUIs

Debugging

$ wine /usr/i686-w64-mingw32/sys-root/mingw/bin/gdbserver.exe :0 bin/nvim.exe
Process bin/nvim.exe created; pid = 36
Listening on port 47612

or alternatively

$ winedbg --gdb --no-start bin/nvim.exe

And them connect to gdbserver

$ gdb bin/nvim.exe 
GNU gdb (GDB; openSUSE 13.1) 7.6.50.20130731-cvs
(...)
(gdb) target remote localhost:47612
Remote debugging using localhost:47612
warning: Could not load shared library symbols for 12 libraries, e.g. C:\windows\system32\kernel32.dll.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
0x7b862737 in ?? ()

from here on out, it is regular gdb, use continue (not run) to start executing.

TODO

  • Windows system DLL symbols are not available

Known issues

Linking fails, with an error finding -lrt, -ldl, -lnsl - this seems to happen when an existing version of libuv is already installed (and the linking options are picked up from pkg-config). It is not clear why pkg-config is being used for the cross compile though.

@kiedtl
Copy link

kiedtl commented Jan 2, 2020

@GentleFly (I know, really late to the party, but couldn't help commenting anyway.)

You're missing libuv. You've got to install it first with your package manager.

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