robin/laufey

tiny neovim fork for cozy coding

git clone https://git.robinwobin.dev/robin/laufey

Rawan Khaliddocs: WebAssembly build instructions #4054125d65d60b6

master
24.4 KiB615 linesraw
  • IMPORTANT: Before upgrading to a new version, always check for breaking changes.

Quick start

  1. Install build prerequisites on your system
  2. git clone https://github.com/neovim/neovim
  3. cd neovim
    • If you want the stable release, also run git checkout stable.
  4. make CMAKE_BUILD_TYPE=RelWithDebInfo
    • If you want to install to a custom location, set CMAKE_INSTALL_PREFIX. See also INSTALL.md.
    • On BSD, use gmake instead of make.
    • To build on Windows, see the Building on Windows section. MSVC (Visual Studio) is recommended.
  5. sudo make install
    • Default install location is /usr/local
    • On Debian/Ubuntu, instead of sudo make install, you can try cd build && cpack -G DEB && sudo dpkg -i nvim-linux-<arch>.deb (with <arch> either x86_64 or arm64) to build DEB-package and install it. This helps ensure clean removal of installed files. Note: This is an unsupported, "best-effort" feature of the Nvim build.

Notes:

  • From the repository's root directory, running make will download and build all the needed dependencies and put the nvim executable in build/bin.
  • Third-party dependencies (libuv, LuaJIT, etc.) are downloaded automatically to .deps/. See the FAQ if you have issues.
  • After building, you can run the nvim executable without installing it by running VIMRUNTIME=runtime ./build/bin/nvim.
  • If you plan to develop Neovim, install Ninja for faster builds. It will automatically be used.
  • Install ccache for faster rebuilds of Neovim. It's used by default. To disable it, use CCACHE_DISABLE=true make.

Running tests

See test/README.md.

Building

First make sure you installed the build prerequisites. Now that you have the dependencies, you can try other build targets explained below.

The build type determines the level of used compiler optimizations and debug information:

  • Release: Full compiler optimizations and no debug information. Expect the best performance from this build type. Often used by package maintainers.
  • Debug: Full debug information; few optimizations. Use this for development to get meaningful output from debuggers like GDB or LLDB. This is the default if CMAKE_BUILD_TYPE is not specified.
  • RelWithDebInfo ("Release With Debug Info"): Enables many optimizations and adds enough debug info so that when Neovim ever crashes, you can still get a backtrace.

So, for a release build, just use:

make CMAKE_BUILD_TYPE=Release

(Do not add a -j flag if ninja is installed! The build will be in parallel automatically.)

Afterwards, the nvim executable can be found in build/bin. To verify the build type after compilation, run:

./build/bin/nvim --version | grep ^Build

To install the executable to a certain location, use:

make CMAKE_INSTALL_PREFIX=$HOME/local/nvim install

CMake, our main build system, caches a lot of things in build/CMakeCache.txt. If you ever want to change CMAKE_BUILD_TYPE or CMAKE_INSTALL_PREFIX, run rm -rf build first. This is also required when rebuilding after a Git commit adds or removes files (including from runtime) — when in doubt, run make distclean (which is basically a shortcut for rm -rf build .deps).

By default (USE_BUNDLED=1), Neovim downloads and statically links its needed dependencies. In order to be able to use a debugger on these libraries, you might want to compile them with debug information as well:

<!-- THIS CAUSES SCREEN INTERFERENCE ``` make distclean VERBOSE=1 DEBUG=1 make deps ``` -->
make distclean
make deps

PUC Lua

To build with "PUC Lua" instead of LuaJit:

make CMAKE_EXTRA_FLAGS="-DPREFER_LUA=ON" DEPS_CMAKE_FLAGS="-DUSE_BUNDLED_LUAJIT=OFF -DUSE_BUNDLED_LUA=ON"

Build options

View the full list of CMake options defined in this project:

cmake -B build -LH

Building on Windows

Windows / MSVC

MSVC (Visual Studio) is the recommended way to build on Windows. These steps were confirmed as of 2023.

  1. Install Visual Studio (2017 or later) with the Desktop development with C++ workload.
  2. Open the Neovim project folder.
    • Visual Studio should detect the cmake files and automatically start building...
  3. Choose the nvim.exe (bin\nvim.exe) target and hit F5.
    • If the build fails, it may be because Visual Studio started the build with x64-{Debug,Release} before you switched the configuration to x86-Release.
      • Right-click CMakeLists.txt → Delete Cache.
      • Right-click CMakeLists.txt → Generate Cache.
    • If you see an "access violation" from ntdll, you can ignore it and continue.
  4. If you see an error like uv.dll not found, try the nvim.exe (Install) target. Then switch back to nvim.exe (bin\nvim.exe).

Windows / MSVC PowerShell

To build from the command line (i.e. invoke the cmake commands yourself),

  1. Ensure you have the Visual Studio environment variables, using any of the following: This is to make sure that luarocks finds the Visual Studio installation, and doesn't fall back to MinGW with errors like:
    'mingw32-gcc' is not recognized as an internal or external command
    
  2. From the "Developer PowerShell" or "Developer Command Prompt":
    cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=Release
    cmake --build .deps --config Release
    cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=Release
    cmake --build build --config Release
    • Omit --config Release if you want a debug build.
    • Omit -G Ninja to use the "Visual Studio" generator.

Windows / CLion

  1. Install CLion.
  2. Open the Neovim project in CLion.
  3. Select Build → Build All in 'Release'.

Windows / Cygwin

Since https://github.com/neovim/neovim/pull/36417 , building on Cygwin may be as easy as:

make && make install

If that fails, an alternative is:

  1. Install all dependencies the normal way.
  • The cygport repo contains Cygport files (e.g. APKBUILD, PKGBUILD) for all the dependencies not available in the Cygwin distribution, and describes any special commands or arguments needed to build. The Cygport definitions also try to describe the required dependencies for each one. Unless custom commands are provided, Cygport just calls autogen/cmake, make, make install, etc. in a clean and consistent way.
  • https://github.com/cascent/neovim-cygwin was built on Cygwin 2.9.0. Newer libuv should require slightly less patching. Some SSP stuff changed in Cygwin 2.10.0, so that might change things too when building Neovim.
  1. Build without "bundled" dependencies (except treesitter parsers).
    cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_BUNDLED=OFF -DUSE_BUNDLED_TS=ON
    cmake --build .deps
    cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
    cmake --build build

Windows / MSYS2 / MinGW

  1. From the MSYS2 shell, install these packages:

    pacman -S \
        mingw-w64-ucrt-x86_64-gcc \
        mingw-w64-x86_64-{cmake,make,ninja,diffutils}
  2. From the Windows Command Prompt (cmd.exe), set up the PATH and build.

    set PATH=c:\msys64\ucrt64\bin;c:\msys64\usr\bin;%PATH%
  3. You have two options:

    • Build using cmake and Ninja generator:
      cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
      cmake --build .deps
      cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
      cmake --build build
      If you cannot install neovim with ninja install due to permission restriction, you can install neovim in a directory you have write access to.
      cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
      cmake --build .deps
      cmake -B build -G Ninja -D CMAKE_INSTALL_PREFIX=C:\nvim -D CMAKE_BUILD_TYPE=RelWithDebInfo
      cmake --build build
    • Or, alternatively, you can use mingw32-make:
      mingw32-make deps
      mingw32-make CMAKE_BUILD_TYPE=RelWithDebInfo
      :: Or you can do the previous command specifying a custom prefix
      :: (Default is C:\Program Files (x86)\nvim)
      :: mingw32-make CMAKE_BUILD_TYPE=RelWithDebInfo CMAKE_INSTALL_PREFIX=C:\nvim
      mingw32-make install

Windows WSL

Build Ubuntu/Debian linux binary on WSL (Windows Subsystem for Linux).

# Install build prerequisites
sudo apt-get install ninja-build gettext cmake build-essential

# Build the linux binary in WSL
make CMAKE_BUILD_TYPE=RelWithDebInfo

# Install the linux binary in WSL (with `<arch>` either `x86_64` or `arm64`)
cd build && cpack -G DEB && sudo dpkg -i nvim-linux-<arch>.deb

# Verify the installation
nvim --version && which nvim # should be debug build in /usr/bin/nvim

Note: If you encounter linker errors or segfaults during the build, Windows libraries in your PATH may be interfering. Use a clean PATH to avoid conflicts:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" make CMAKE_BUILD_TYPE=RelWithDebInfo

Localization

Localization build

Translations are turned off by default. Enable by building Nvim with the CMake flag ENABLE_TRANSLATIONS=ON. Doing this will create .mo files in build/src/nvim/po. Example:

make CMAKE_EXTRA_FLAGS="-DENABLE_TRANSLATIONS=ON"
  • If you see msgfmt: command not found, you need to install gettext. On most systems, the package is just called gettext.

Localization check

To check the translations for $LANG, run make -C build check-po-$LANG. Examples:

cmake --build build --target check-po-de
cmake --build build --target check-po-pt_BR
  • check-po-$LANG generates a detailed report in ./build/src/nvim/po/check-${LANG}.log. (The report is generated by nvim, not by msgfmt.)

Localization update

To update the src/nvim/po/$LANG.po file with the latest strings, run the following:

cmake --build build --target update-po-$LANG
  • Note: Run src/nvim/po/cleanup.vim after updating.

Compiler options

To see the chain of includes, use the -H option (#918):

echo '#include "./src/nvim/buffer.h"' | \
> clang -I.deps/usr/include -Isrc -std=c99 -P -E -H - 2>&1 >/dev/null | \
> grep -v /usr/
  • grep -v /usr/ is used to filter out system header files.
  • -save-temps can be added as well to see expanded macros or commented assembly.

Custom Makefile

You can customize the build process locally by creating a local.mk, which is referenced at the top of the main Makefile. It's listed in .gitignore, so it can be used across branches. A new target in local.mk overrides the default make-target.

Here's a sample local.mk which adds a target to force a rebuild but does not override the default-target:

all:

rebuild:
	rm -rf build
	make

Third-party dependencies

Reference the Debian package (or alternatively, the Homebrew formula) for the precise list of dependencies/versions.

To build the bundled dependencies using CMake:

cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build .deps

By default the libraries and headers are placed in .deps/usr. Now you can build Neovim:

cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build

Build without "bundled" dependencies

  1. Manually install the dependencies:
    • libuv libluv libutf8proc luajit lua-lpeg tree-sitter tree-sitter-c tree-sitter-lua tree-sitter-markdown tree-sitter-query tree-sitter-vim tree-sitter-vimdoc unibilium
  2. Run CMake:
    cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
    cmake --build build
    If all the dependencies are not available in the package, you can use only some of the bundled dependencies as follows (example of using ninja):
    cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_BUNDLED=OFF -DUSE_BUNDLED_TS=ON
    cmake --build .deps
    cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
    cmake --build build
  3. Run make, ninja, or whatever build tool you told CMake to generate.
    • Using ninja is strongly recommended.
  4. If treesitter parsers are not bundled, they need to be available in a parser/ runtime directory (e.g. /usr/share/nvim/runtime/parser/).

Build offline

On systems with old or missing libraries, without network access, you may want to build with bundled dependencies. This is supported as follows.

  1. On a network-enabled machine, do either of the following, to get the dependency sources in .deps in a form that the build will work with:
    • Fetch https://github.com/neovim/deps/tree/master/src into .deps/build/src/. (https://github.com/neovim/deps/tree/master/src is an auto-updated, "cleaned up", snapshot of .deps/build/src/).
    • Run make deps to generate .deps/, then clean it up using these commands.
  2. Copy the prepared .deps to the isolated machine (without network access).
  3. Build with USE_EXISTING_SRC_DIR enabled, on the isolated machine:
    make deps DEPS_CMAKE_FLAGS=-DUSE_EXISTING_SRC_DIR=ON
    make

Build without unibilium

Unibilium is the only dependency which is licensed under LGPLv3 (there are no GPLv3-only dependencies). This library is used for loading the terminfo database at runtime, and can be disabled if the internal definitions for common terminals are good enough. To avoid this dependency, build with support for loading custom terminfo at runtime, use

make CMAKE_EXTRA_FLAGS="-DENABLE_UNIBILIUM=0" DEPS_CMAKE_FLAGS="-DUSE_BUNDLED_UNIBILIUM=0"

To confirm at runtime that unibilium was not included, check has('terminfo') == 1.

Build with specific "bundled" dependencies

Example of building with specific bundled and non-bundled dependencies:

make DEPS_CMAKE_FLAGS="-DUSE_BUNDLED=OFF -DUSE_BUNDLED_LUV=ON -DUSE_BUNDLED_TS=ON -DUSE_BUNDLED_LIBUV=ON"

Build static binary (Linux)

  1. Use a linux distribution which uses musl C. We will use Alpine Linux but any distro with musl should work. (glibc does not support static linking)
  2. Run make passing the STATIC_BUILD variable: make CMAKE_EXTRA_FLAGS="-DSTATIC_BUILD=1"

In case you are not using Alpine Linux you can use a container to do the build the binary:

podman run \
  --rm \
  -it \
  -v "$PWD:/workdir" \
  -w /workdir \
  alpine:latest \
  sh -c 'apk add build-base cmake coreutils curl gettext-tiny-dev git linux-headers && make CMAKE_EXTRA_FLAGS="-DSTATIC_BUILD=1"'

The resulting binary in build/bin/nvim will have all the dependencies statically linked:

build/bin/nvim: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, BuildID[sha1]=b93fa8e678d508ac0a76a2e3da20b119105f1b2d, with debug_info, not stripped

Build prerequisites

General requirements (see #1469):

  • Clang or GCC version 4.9+
  • CMake version 3.16+, built with TLS/SSL support
    • Optional: Get the latest CMake from https://cmake.org/download/
      • Provides a shell script which works on most Linux systems. After running it, ensure the resulting cmake binary is in your $PATH so the Nvim build will find it.

Platform-specific requirements are listed below.

Ubuntu / Debian

sudo apt-get install ninja-build gettext cmake curl build-essential git

RHEL / Fedora

sudo dnf -y install ninja-build cmake gcc make gettext curl glibc-gconv-extra git

openSUSE

sudo zypper install ninja cmake gcc-c++ gettext-tools curl git

Arch Linux

sudo pacman -S base-devel cmake ninja curl git

Alpine Linux

apk add build-base cmake coreutils curl gettext-tiny-dev git

Void Linux

xbps-install base-devel cmake curl git

NixOS / Nix

Starting from NixOS 18.03, the Neovim binary resides in the neovim-unwrapped Nix package (the neovim package being just a wrapper to setup runtime options like Ruby/Python support):

cd path/to/neovim/src

Drop into nix-shell to pull in the Neovim dependencies:

nix-shell '<nixpkgs>' -A neovim-unwrapped

Configure and build:

rm -rf build && cmakeConfigurePhase
buildPhase

Tests are not available by default, because of some unfixed failures. You can enable them via adding this package in your overlay:

  neovim-dev = (super.pkgs.neovim-unwrapped.override  {
    doCheck=true;
  }).overrideAttrs(oa:{
    cmakeBuildType="debug";

    nativeBuildInputs = oa.nativeBuildInputs ++ [ self.pkgs.valgrind ];
    shellHook = ''
      export NVIM_PYTHON_LOG_LEVEL=DEBUG
      export NVIM_LOG_FILE=/tmp/log
      export VALGRIND_LOG="$PWD/valgrind.log"
    '';
  });

and replacing neovim-unwrapped with neovim-dev:

nix-shell '<nixpkgs>' -A neovim-dev

A flake for Neovim is hosted at nix-community/neovim-nightly-overlay, with 3 packages:

  • neovim to run the nightly
  • neovim-debug to run the package with debug symbols
  • neovim-developer to get all the tools to develop on neovim

Thus you can run Neovim nightly with nix run github:nix-community/neovim-nightly-overlay. Similarly to develop on Neovim: nix run github:nix-community/neovim-nightly-overlay#neovim-developer.

To use a specific version of Neovim, you can pass --override-input neovim-src . to use your current directory, or a specific SHA1 like --override-input neovim-src github:neovim/neovim/89dc8f8f4e754e70cbe1624f030fb61bded41bc2.

Haiku

Some deps can be pulled from haiku repos, the rest need "bundled" deps:

cmake -DUSE_BUNDLED_LIBUV=OFF -DUSE_BUNDLED_UNIBILIUM=OFF -DUSE_BUNDLED_LUAJIT=OFF -B .deps ./cmake.deps
make -C .deps

FreeBSD

sudo pkg install cmake gmake sha wget gettext curl git

If you get an error regarding a sha256sum mismatch, where the actual SHA-256 hash is e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855, then this is your issue (that's the sha256sum of an empty file).

OpenBSD

doas pkg_add gmake cmake curl gettext-tools git ninja

While ninja is technically optional, the build is likely to fail without it. This is because cmake will use make in that case, and the bundled LuaJIT requires gmake. Instead of installing ninja, you could work around this by installing luajit and disabling the bundled LuaJIT:

gmake DEPS_CMAKE_FLAGS="-DUSE_BUNDLED_LUAJIT=0"

Another workaround is to edit cmake/Deps.cmake and comment out the line set(MAKE_PRG "$(MAKE)"). This will leave MAKE_PRG set to gmake, so LuaJIT will be built with gmake.

macOS

macOS / Homebrew

  1. Install Xcode Command Line Tools: xcode-select --install
  2. Install Homebrew
  3. Install Neovim build dependencies:
    brew install ninja cmake gettext curl git
  • Note: If you see Wget certificate errors (for older macOS versions less than 10.10):
    brew install curl-ca-bundle
    echo CA_CERTIFICATE=$(brew --prefix curl-ca-bundle)/share/ca-bundle.crt >> ~/.wgetrc
  • Note: If you see 'stdio.h' file not found, try the following:
    open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

macOS / MacPorts

  1. Install Xcode Command Line Tools: xcode-select --install
  2. Install MacPorts
  3. Install Neovim build dependencies:
    sudo port install ninja cmake gettext git
  • Note: If you see Wget certificate errors (for older macOS versions less than 10.10):
    sudo port install curl-ca-bundle
    echo CA_CERTIFICATE=/opt/local/share/curl/curl-ca-bundle.crt >> ~/.wgetrc
  • Note: If you see 'stdio.h' file not found, try the following:
    open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Building for older macOS versions

From a newer macOS version, to build for older macOS versions, you will have to set the macOS deployment target:

make CMAKE_BUILD_TYPE=Release MACOSX_DEPLOYMENT_TARGET=10.13 DEPS_CMAKE_FLAGS="-DCMAKE_CXX_COMPILER=$(xcrun -find c++)"

Note that the C++ compiler is explicitly set so that it can be found when the deployment target is set.

Building with zig

Prerequisites

  • zig 0.16.x

Instructions

  • Build the editor: zig build, run it with ./zig-out/bin/nvim
  • Complete installation with runtime: zig build install --prefix ~/.local
  • Tests:
    • zig build functionaltest to run all functionaltests
    • zig build functionaltest -- test/functional/autocmd/bufenter_spec.lua to run the tests in one file
    • zig build unittest to run all unittests
    • zig build oldtest to run all oldtests

Using system dependencies

See "Available System Integrations" in zig build -h to see available system integrations. Enabling an integration, e.g. zig build -fsys=utf8proc will use the system's installation of utf8proc.

zig build --system deps_dir will enable all integrations and turn off dependency fetching. This requires you to pre-download the dependencies which don't have a system integration into deps_dir (at the time of writing these are ziglua and the built-in tree-sitter parsers). You have to create subdirectories whose names are the respective package's hash under deps_dir and unpack the dependencies inside that directory - ziglua should go under deps_dir/zlua-0.1.0-hGRpC1dCBQDf-IqqUifYvyr8B9-4FlYXqY8cl7HIetrC and so on. Hashes should be taken from build.zig.zon.

See the prepare function of this PKGBUILD for an example.

Cross-compiling

Cross-compilation is not fully supported, but we collect notes here for reference (improvements welcome). Also relevant for webassembly (WASM) build.

  • cmake: Set NVIM_HOST_PRG so that the docs and tags generation works without depending on the target binary.
  • zig build: cross-compilation is often enabled by just setting -Dtarget, e.g. from a linux host:
     zig build -Dtarget=aarch64-macos
    
    will automatically compile a host lua for use during build. The "-Dhost={target_string}" option can be used to override the platform for running binaries during compile-time. use "-Dhost=native" to force cross-compiling or "-Dhost=" (empty string) to assume that target binaries can run on the host during the build process (e.g. if target is x86 on a x86_64 system, or if emulation set up with binfmt or similar)

WebAssembly (experimental)

Neovim can be cross-compiled to WebAssembly using the wasm32-emscripten target.

  • Requires the Emscripten SDK (emsdk).
  • After installing and activating it, pass its sysroot to -Demscripten-sysroot, e.g. $EMSDK/upstream/emscripten/cache/sysroot.

To build the WebAssembly target:

zig build nvim_bin \
  -Dtarget=wasm32-emscripten \
  -Demscripten-sysroot=$EMSDK/upstream/emscripten/cache/sysroot

This currently produces:

  • nvim.wasm, the WebAssembly module.
  • nvim.js, the JavaScript loader generated by Emscripten.
1- **IMPORTANT**: Before upgrading to a new version, **always check for [breaking changes](https://neovim.io/doc/user/news.html#news-breaking).**
2
3
4## Quick start
5
61. Install [build prerequisites](#build-prerequisites) on your system
72. `git clone https://github.com/neovim/neovim`
83. `cd neovim`
9    - If you want the **stable release**, also run `git checkout stable`.
104. `make CMAKE_BUILD_TYPE=RelWithDebInfo`
11    - If you want to install to a custom location, set `CMAKE_INSTALL_PREFIX`. See also [INSTALL.md](./INSTALL.md#install-from-source).
12    - On BSD, use `gmake` instead of `make`.
13    - To build on Windows, see the [Building on Windows](#building-on-windows) section. _MSVC (Visual Studio) is recommended._
145. `sudo make install`
15    - Default install location is `/usr/local`
16    - On Debian/Ubuntu, instead of `sudo make install`, you can try `cd build && cpack -G DEB && sudo dpkg -i nvim-linux-<arch>.deb` (with `<arch>` either `x86_64` or `arm64`) to build DEB-package and install it. This helps ensure clean removal of installed files. Note: This is an unsupported, "best-effort" feature of the Nvim build.
17
18**Notes**:
19- From the repository's root directory, running `make` will download and build all the needed dependencies and put the `nvim` executable in `build/bin`.
20- Third-party dependencies (libuv, LuaJIT, etc.) are downloaded automatically to `.deps/`. See the [FAQ](https://neovim.io/doc/user/faq.html#faq-build) if you have issues.
21- After building, you can run the `nvim` executable without installing it by running `VIMRUNTIME=runtime ./build/bin/nvim`.
22- If you plan to develop Neovim, install [Ninja](https://ninja-build.org/) for faster builds. It will automatically be used.
23- Install [ccache](https://ccache.dev/) for faster rebuilds of Neovim. It's used by default. To disable it, use `CCACHE_DISABLE=true make`.
24
25## Running tests
26
27See [test/README.md](https://github.com/neovim/neovim/blob/master/test/README.md).
28
29## Building
30
31First make sure you installed the [build prerequisites](#build-prerequisites). Now that you have the dependencies, you can try other build targets explained below.
32
33The _build type_ determines the level of used compiler optimizations and debug information:
34
35- `Release`: Full compiler optimizations and no debug information. Expect the best performance from this build type. Often used by package maintainers.
36- `Debug`: Full debug information; few optimizations. Use this for development to get meaningful output from debuggers like GDB or LLDB. This is the default if `CMAKE_BUILD_TYPE` is not specified.
37- `RelWithDebInfo` ("Release With Debug Info"): Enables many optimizations and adds enough debug info so that when Neovim ever crashes, you can still get a backtrace.
38
39So, for a release build, just use:
40
41```bash
42make CMAKE_BUILD_TYPE=Release
43```
44(Do not add a `-j` flag if `ninja` is installed! The build will be in parallel automatically.)
45
46Afterwards, the `nvim` executable can be found in `build/bin`. To verify the build type after compilation, run:
47
48```bash
49./build/bin/nvim --version | grep ^Build
50```
51
52To install the executable to a certain location, use:
53
54```bash
55make CMAKE_INSTALL_PREFIX=$HOME/local/nvim install
56```
57
58CMake, our main build system, caches a lot of things in `build/CMakeCache.txt`. If you ever want to change `CMAKE_BUILD_TYPE` or `CMAKE_INSTALL_PREFIX`, run `rm -rf build` first. This is also required when rebuilding after a Git commit adds or removes files (including from `runtime`) — when in doubt, run `make distclean` (which is basically a shortcut for `rm -rf build .deps`).
59
60By default (`USE_BUNDLED=1`), Neovim downloads and statically links its needed dependencies. In order to be able to use a debugger on these libraries, you might want to compile them with debug information as well:
61
62<!-- THIS CAUSES SCREEN INTERFERENCE
63```
64make distclean
65VERBOSE=1 DEBUG=1 make deps
66```
67-->
68```bash
69make distclean
70make deps
71```
72
73### PUC Lua
74
75To build with "PUC Lua" instead of LuaJit:
76```bash
77make CMAKE_EXTRA_FLAGS="-DPREFER_LUA=ON" DEPS_CMAKE_FLAGS="-DUSE_BUNDLED_LUAJIT=OFF -DUSE_BUNDLED_LUA=ON"
78```
79
80### Build options
81
82View the full list of CMake options defined in this project:
83```bash
84cmake -B build -LH
85```
86
87## Building on Windows
88
89### Windows / MSVC
90
91**MSVC (Visual Studio) is the recommended way to build on Windows.** These steps were confirmed as of 2023.
92
931. Install [Visual Studio](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community) (2017 or later) with the _Desktop development with C++_ workload.
94    - On 32-bit Windows, you will need [this workaround](https://developercommunity.visualstudio.com/content/problem/212989/ninja-binary-format.html).
952. Open the Neovim project folder.
96    - Visual Studio should detect the cmake files and automatically start building...
973. Choose the `nvim.exe (bin\nvim.exe)` target and hit F5.
98    - If the build fails, it may be because Visual Studio started the build with `x64-{Debug,Release}` before you switched the configuration to `x86-Release`.
99      - Right-click _CMakeLists.txt → Delete Cache_.
100      - Right-click _CMakeLists.txt → Generate Cache_.
101    - If you see an "access violation" from `ntdll`, you can ignore it and continue.
1024. If you see an error like `uv.dll not found`, try the `nvim.exe (Install)` target. Then switch back to `nvim.exe (bin\nvim.exe)`.
103
104### Windows / MSVC PowerShell
105
106To build from the command line (i.e. invoke the `cmake` commands yourself),
107
1081. Ensure you have the Visual Studio environment variables, using any of the following:
109    - Using the [Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell](https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022)
110    - Invoking `Import-VisualStudioVars` in PowerShell from [this PowerShell module](https://github.com/Pscx/Pscx)
111    - Invoking `VsDevCmd.bat` in Command Prompt
112      ```
113      VsDevCmd.bat -arch=x64
114      ```
115   This is to make sure that `luarocks` finds the Visual Studio installation, and doesn't fall back to MinGW with errors like:
116   ```
117   'mingw32-gcc' is not recognized as an internal or external command
118   ```
1192. From the "Developer PowerShell" or "Developer Command Prompt":
120   ```bash
121   cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=Release
122   cmake --build .deps --config Release
123   cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=Release
124   cmake --build build --config Release
125   ```
126    - Omit `--config Release` if you want a debug build.
127    - Omit `-G Ninja` to use the "Visual Studio" generator.
128
129### Windows / CLion
130
1311. Install [CLion](https://www.jetbrains.com/clion/).
1322. Open the Neovim project in CLion.
1333. Select _Build → Build All in 'Release'_.
134
135### Windows / Cygwin
136
137Since https://github.com/neovim/neovim/pull/36417 , building on Cygwin may be as easy as:
138```bash
139make && make install
140```
141
142If that fails, an alternative is:
143
1441. Install all dependencies the normal way.
145  - The `cygport` repo contains Cygport files (e.g. `APKBUILD`, `PKGBUILD`) for all the dependencies not available in the Cygwin distribution, and describes any special commands or arguments needed to build. The Cygport definitions also try to describe the required dependencies for each one. Unless custom commands are provided, Cygport just calls `autogen`/`cmake`, `make`, `make install`, etc. in a clean and consistent way.
146  - https://github.com/cascent/neovim-cygwin was built on Cygwin 2.9.0. Newer `libuv` should require slightly less patching. Some SSP stuff changed in Cygwin 2.10.0, so that might change things too when building Neovim.
1472. Build without "bundled" dependencies (except treesitter parsers).
148   ```bash
149   cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_BUNDLED=OFF -DUSE_BUNDLED_TS=ON
150   cmake --build .deps
151   cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
152   cmake --build build
153   ```
154
155### Windows / MSYS2 / MinGW
156
1571. From the MSYS2 shell, install these packages:
158   ```bash
159   pacman -S \
160       mingw-w64-ucrt-x86_64-gcc \
161       mingw-w64-x86_64-{cmake,make,ninja,diffutils}
162   ```
1632. From the Windows Command Prompt (`cmd.exe`), set up the `PATH` and build.
164
165   ```cmd
166   set PATH=c:\msys64\ucrt64\bin;c:\msys64\usr\bin;%PATH%
167   ```
1683. You have two options:
169    - Build using `cmake` and `Ninja` generator:
170      ```cmd
171      cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
172      cmake --build .deps
173      cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
174      cmake --build build
175      ```
176      If you cannot install neovim with `ninja install` due to permission restriction, you can install neovim in a directory you have write access to.
177      ```cmd
178      cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
179      cmake --build .deps
180      cmake -B build -G Ninja -D CMAKE_INSTALL_PREFIX=C:\nvim -D CMAKE_BUILD_TYPE=RelWithDebInfo
181      cmake --build build
182      ```
183    - Or, alternatively, you can use `mingw32-make`:
184      ```cmd
185      mingw32-make deps
186      mingw32-make CMAKE_BUILD_TYPE=RelWithDebInfo
187      :: Or you can do the previous command specifying a custom prefix
188      :: (Default is C:\Program Files (x86)\nvim)
189      :: mingw32-make CMAKE_BUILD_TYPE=RelWithDebInfo CMAKE_INSTALL_PREFIX=C:\nvim
190      mingw32-make install
191      ```
192
193### Windows WSL
194
195Build Ubuntu/Debian linux binary on [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) (Windows Subsystem for Linux).
196
197```bash
198# Install build prerequisites
199sudo apt-get install ninja-build gettext cmake build-essential
200
201# Build the linux binary in WSL
202make CMAKE_BUILD_TYPE=RelWithDebInfo
203
204# Install the linux binary in WSL (with `<arch>` either `x86_64` or `arm64`)
205cd build && cpack -G DEB && sudo dpkg -i nvim-linux-<arch>.deb
206
207# Verify the installation
208nvim --version && which nvim # should be debug build in /usr/bin/nvim
209```
210
211**Note**: If you encounter linker errors or segfaults during the build, Windows libraries in your PATH may be interfering. Use a clean PATH to avoid conflicts:
212
213```bash
214PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" make CMAKE_BUILD_TYPE=RelWithDebInfo
215```
216
217## Localization
218
219### Localization build
220
221Translations are turned off by default. Enable by building Nvim with the CMake flag `ENABLE_TRANSLATIONS=ON`.
222Doing this will create `.mo` files in `build/src/nvim/po`. Example:
223
224```bash
225make CMAKE_EXTRA_FLAGS="-DENABLE_TRANSLATIONS=ON"
226```
227
228* If you see `msgfmt: command not found`, you need to install [`gettext`](http://en.wikipedia.org/wiki/Gettext). On most systems, the package is just called `gettext`.
229
230### Localization check
231
232To check the translations for `$LANG`, run `make -C build check-po-$LANG`. Examples:
233
234```bash
235cmake --build build --target check-po-de
236cmake --build build --target check-po-pt_BR
237```
238
239- `check-po-$LANG` generates a detailed report in `./build/src/nvim/po/check-${LANG}.log`. (The report is generated by `nvim`, not by `msgfmt`.)
240
241### Localization update
242
243To update the `src/nvim/po/$LANG.po` file with the latest strings, run the following:
244
245```bash
246cmake --build build --target update-po-$LANG
247```
248
249- **Note**: Run `src/nvim/po/cleanup.vim` after updating.
250
251## Compiler options
252
253To see the chain of includes, use the `-H` option ([#918](https://github.com/neovim/neovim/issues/918)):
254
255```bash
256echo '#include "./src/nvim/buffer.h"' | \
257> clang -I.deps/usr/include -Isrc -std=c99 -P -E -H - 2>&1 >/dev/null | \
258> grep -v /usr/
259```
260
261- `grep -v /usr/` is used to filter out system header files.
262- `-save-temps` can be added as well to see expanded macros or commented assembly.
263
264## Custom Makefile
265
266You can customize the build process locally by creating a `local.mk`, which is referenced at the top of the main `Makefile`. It's listed in `.gitignore`, so it can be used across branches. **A new target in `local.mk` overrides the default make-target.**
267
268Here's a sample `local.mk` which adds a target to force a rebuild but *does not* override the default-target:
269
270```make
271all:
272
273rebuild:
274	rm -rf build
275	make
276```
277
278## Third-party dependencies
279
280Reference the [Debian package](https://packages.debian.org/sid/source/neovim) (or alternatively, the [Homebrew formula](https://github.com/Homebrew/homebrew-core/blob/master/Formula/n/neovim.rb)) for the precise list of dependencies/versions.
281
282To build the bundled dependencies using CMake:
283
284```bash
285cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
286cmake --build .deps
287```
288
289By default the libraries and headers are placed in `.deps/usr`. Now you can build Neovim:
290
291```bash
292cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
293cmake --build build
294```
295
296### Build without "bundled" dependencies
297
2981. Manually install the dependencies:
299    - libuv libluv libutf8proc luajit lua-lpeg tree-sitter tree-sitter-c tree-sitter-lua tree-sitter-markdown tree-sitter-query tree-sitter-vim tree-sitter-vimdoc unibilium
3002. Run CMake:
301   ```bash
302   cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
303   cmake --build build
304   ```
305   If all the dependencies are not available in the package, you can use only some of the bundled dependencies as follows (example of using `ninja`):
306   ```bash
307   cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_BUNDLED=OFF -DUSE_BUNDLED_TS=ON
308   cmake --build .deps
309   cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
310   cmake --build build
311   ```
3123. Run `make`, `ninja`, or whatever build tool you told CMake to generate.
313    - Using `ninja` is strongly recommended.
3144. If treesitter parsers are not bundled, they need to be available in a `parser/` runtime directory (e.g. `/usr/share/nvim/runtime/parser/`).
315
316### Build offline
317
318On systems with old or missing libraries, *without* network access, you may want
319to build *with* bundled dependencies. This is supported as follows.
320
3211. On a network-enabled machine, do either of the following, to get the
322   dependency sources in `.deps` in a form that the build will work with:
323    - Fetch https://github.com/neovim/deps/tree/master/src into `.deps/build/src/`.
324      (https://github.com/neovim/deps/tree/master/src is an auto-updated, "cleaned up", snapshot of `.deps/build/src/`).
325    - Run `make deps` to generate `.deps/`, then clean it up using [these commands](https://github.com/neovim/neovim/blob/1c12073db6c64eb365748f153f96be9b0fe61070/.github/workflows/build.yml#L67-L74).
3262. Copy the prepared `.deps` to the isolated machine (without network access).
3273. Build with `USE_EXISTING_SRC_DIR` enabled, on the isolated machine:
328   ```bash
329   make deps DEPS_CMAKE_FLAGS=-DUSE_EXISTING_SRC_DIR=ON
330   make
331   ```
332
333### Build without unibilium
334
335Unibilium is the only dependency which is licensed under LGPLv3 (there are no
336GPLv3-only dependencies). This library is used for loading the terminfo database at
337runtime, and can be disabled if the internal definitions for common terminals
338are good enough. To avoid this dependency, build with support for loading
339custom terminfo at runtime, use
340
341```bash
342make CMAKE_EXTRA_FLAGS="-DENABLE_UNIBILIUM=0" DEPS_CMAKE_FLAGS="-DUSE_BUNDLED_UNIBILIUM=0"
343```
344
345To confirm at runtime that unibilium was not included, check `has('terminfo') == 1`.
346
347### Build with specific "bundled" dependencies
348
349Example of building with specific bundled and non-bundled dependencies:
350
351```bash
352make DEPS_CMAKE_FLAGS="-DUSE_BUNDLED=OFF -DUSE_BUNDLED_LUV=ON -DUSE_BUNDLED_TS=ON -DUSE_BUNDLED_LIBUV=ON"
353```
354
355### Build static binary (Linux)
356
3571. Use a linux distribution which uses musl C. We will use Alpine Linux but any distro with musl should work. (glibc does not support static linking)
3582. Run make passing the `STATIC_BUILD` variable: `make CMAKE_EXTRA_FLAGS="-DSTATIC_BUILD=1"`
359
360In case you are not using Alpine Linux you can use a container to do the build the binary:
361
362```bash
363podman run \
364  --rm \
365  -it \
366  -v "$PWD:/workdir" \
367  -w /workdir \
368  alpine:latest \
369  sh -c 'apk add build-base cmake coreutils curl gettext-tiny-dev git linux-headers && make CMAKE_EXTRA_FLAGS="-DSTATIC_BUILD=1"'
370```
371
372The resulting binary in `build/bin/nvim` will have all the dependencies statically linked:
373
374```
375build/bin/nvim: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, BuildID[sha1]=b93fa8e678d508ac0a76a2e3da20b119105f1b2d, with debug_info, not stripped
376```
377
378## Build prerequisites
379
380General requirements (see [#1469](https://github.com/neovim/neovim/issues/1469#issuecomment-63058312)):
381
382- Clang or GCC version 4.9+
383- CMake version 3.16+, built with TLS/SSL support
384  - Optional: Get the latest CMake from https://cmake.org/download/
385    - Provides a shell script which works on most Linux systems. After running it, ensure the resulting `cmake` binary is in your $PATH so the Nvim build will find it.
386
387Platform-specific requirements are listed below.
388
389### Ubuntu / Debian
390
391```bash
392sudo apt-get install ninja-build gettext cmake curl build-essential git
393```
394
395### RHEL / Fedora
396
397```bash
398sudo dnf -y install ninja-build cmake gcc make gettext curl glibc-gconv-extra git
399```
400
401### openSUSE
402
403```bash
404sudo zypper install ninja cmake gcc-c++ gettext-tools curl git
405```
406
407### Arch Linux
408
409```bash
410sudo pacman -S base-devel cmake ninja curl git
411```
412
413### Alpine Linux
414
415```bash
416apk add build-base cmake coreutils curl gettext-tiny-dev git
417```
418
419### Void Linux
420
421```bash
422xbps-install base-devel cmake curl git
423```
424
425### NixOS / Nix
426
427Starting from NixOS 18.03, the Neovim binary resides in the `neovim-unwrapped` Nix package (the `neovim` package being just a wrapper to setup runtime options like Ruby/Python support):
428
429```bash
430cd path/to/neovim/src
431```
432
433Drop into `nix-shell` to pull in the Neovim dependencies:
434
435```bash
436nix-shell '<nixpkgs>' -A neovim-unwrapped
437```
438
439Configure and build:
440
441```bash
442rm -rf build && cmakeConfigurePhase
443buildPhase
444```
445
446Tests are not available by default, because of some unfixed failures. You can enable them via adding this package in your overlay:
447```nix
448  neovim-dev = (super.pkgs.neovim-unwrapped.override  {
449    doCheck=true;
450  }).overrideAttrs(oa:{
451    cmakeBuildType="debug";
452
453    nativeBuildInputs = oa.nativeBuildInputs ++ [ self.pkgs.valgrind ];
454    shellHook = ''
455      export NVIM_PYTHON_LOG_LEVEL=DEBUG
456      export NVIM_LOG_FILE=/tmp/log
457      export VALGRIND_LOG="$PWD/valgrind.log"
458    '';
459  });
460```
461and replacing `neovim-unwrapped` with `neovim-dev`:
462```bash
463nix-shell '<nixpkgs>' -A neovim-dev
464```
465
466A flake for Neovim is hosted at [nix-community/neovim-nightly-overlay](https://github.com/nix-community/neovim-nightly-overlay/), with 3 packages:
467- `neovim` to run the nightly
468- `neovim-debug` to run the package with debug symbols
469- `neovim-developer` to get all the tools to develop on `neovim`
470
471Thus you can run Neovim nightly with `nix run github:nix-community/neovim-nightly-overlay`.
472Similarly to develop on Neovim: `nix run github:nix-community/neovim-nightly-overlay#neovim-developer`.
473
474To use a specific version of Neovim, you can pass `--override-input neovim-src .` to use your current directory,
475or a specific SHA1 like `--override-input neovim-src github:neovim/neovim/89dc8f8f4e754e70cbe1624f030fb61bded41bc2`.
476
477### Haiku
478
479Some deps can be pulled from haiku repos, the rest need "bundled" deps:
480```bash
481cmake -DUSE_BUNDLED_LIBUV=OFF -DUSE_BUNDLED_UNIBILIUM=OFF -DUSE_BUNDLED_LUAJIT=OFF -B .deps ./cmake.deps
482make -C .deps
483```
484
485### FreeBSD
486
487```bash
488sudo pkg install cmake gmake sha wget gettext curl git
489```
490
491If you get an error regarding a `sha256sum` mismatch, where the actual SHA-256 hash is `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`, then this is your issue (that's the `sha256sum` of an empty file).
492
493### OpenBSD
494
495```bash
496doas pkg_add gmake cmake curl gettext-tools git ninja
497```
498
499While `ninja` is technically optional, the build is likely to fail without it. This is because `cmake` will use `make` in that case, and the bundled LuaJIT requires `gmake`. Instead of installing `ninja`, you could work around this by installing `luajit` and disabling the bundled LuaJIT:
500
501```bash
502gmake DEPS_CMAKE_FLAGS="-DUSE_BUNDLED_LUAJIT=0"
503```
504
505Another workaround is to edit `cmake/Deps.cmake` and comment out the line `set(MAKE_PRG "$(MAKE)")`. This will leave `MAKE_PRG` set to `gmake`, so LuaJIT will be built with `gmake`.
506
507### macOS
508
509#### macOS / Homebrew
510
5111. Install Xcode Command Line Tools: `xcode-select --install`
5122. Install [Homebrew](http://brew.sh)
5133. Install Neovim build dependencies:
514    ```bash
515    brew install ninja cmake gettext curl git
516    ```
517  - **Note**: If you see Wget certificate errors (for older macOS versions less than 10.10):
518    ```bash
519    brew install curl-ca-bundle
520    echo CA_CERTIFICATE=$(brew --prefix curl-ca-bundle)/share/ca-bundle.crt >> ~/.wgetrc
521    ```
522  - **Note**: If you see `'stdio.h' file not found`, try the following:
523    ```bash
524    open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
525    ```
526
527#### macOS / MacPorts
528
5291. Install Xcode Command Line Tools: `xcode-select --install`
5302. Install [MacPorts](http://www.macports.org)
5313. Install Neovim build dependencies:
532    ```bash
533    sudo port install ninja cmake gettext git
534    ```
535  - **Note**: If you see Wget certificate errors (for older macOS versions less than 10.10):
536    ```bash
537    sudo port install curl-ca-bundle
538    echo CA_CERTIFICATE=/opt/local/share/curl/curl-ca-bundle.crt >> ~/.wgetrc
539    ```
540  - **Note**: If you see `'stdio.h' file not found`, try the following:
541    ```bash
542    open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
543    ```
544
545#### Building for older macOS versions
546
547From a newer macOS version, to build for older macOS versions, you will have to set the macOS deployment target:
548
549```
550make CMAKE_BUILD_TYPE=Release MACOSX_DEPLOYMENT_TARGET=10.13 DEPS_CMAKE_FLAGS="-DCMAKE_CXX_COMPILER=$(xcrun -find c++)"
551```
552
553Note that the C++ compiler is explicitly set so that it can be found when the deployment target is set.
554
555## Building with zig
556
557### Prerequisites
558
559- zig 0.16.x
560
561### Instructions
562
563- Build the editor: `zig build`, run it with `./zig-out/bin/nvim`
564- Complete installation with runtime: `zig build install --prefix ~/.local`
565- Tests:
566  - `zig build functionaltest` to run all functionaltests
567  - `zig build functionaltest -- test/functional/autocmd/bufenter_spec.lua` to run the tests in one file
568  - `zig build unittest` to run all unittests
569  - `zig build oldtest` to run all oldtests
570
571#### Using system dependencies
572
573See "Available System Integrations" in `zig build -h` to see available system integrations. Enabling an integration, e.g. `zig build -fsys=utf8proc` will use the system's installation of utf8proc.
574
575`zig build --system deps_dir` will enable all integrations and turn off dependency fetching. This requires you to pre-download the dependencies which don't have a system integration into `deps_dir` (at the time of writing these are ziglua and the built-in tree-sitter parsers). You have to create subdirectories whose names are the respective package's hash under `deps_dir` and unpack the dependencies inside that directory - ziglua should go under `deps_dir/zlua-0.1.0-hGRpC1dCBQDf-IqqUifYvyr8B9-4FlYXqY8cl7HIetrC` and so on. Hashes should be taken from `build.zig.zon`.
576
577See the `prepare` function of [this `PKGBUILD`](https://git.sr.ht/~chinmay/nvim_build/tree/26364a4cf9b4819f52a3e785fa5a43285fb9cea2/item/PKGBUILD#L90) for an example.
578
579## Cross-compiling
580
581Cross-compilation is not fully supported, but we collect notes here for reference (improvements welcome).
582Also relevant for webassembly (WASM) build.
583
584- cmake: Set `NVIM_HOST_PRG` so that the docs and tags generation works without
585  depending on the target binary.
586- zig build: cross-compilation is often enabled by just setting -Dtarget, e.g. from a linux host:
587  ```
588   zig build -Dtarget=aarch64-macos
589  ```
590  will automatically compile a host lua for use during build. The
591  "-Dhost={target_string}" option can be used to override the platform for
592  running binaries during compile-time. use "-Dhost=native" to force
593  cross-compiling or "-Dhost=" (empty string) to assume that target binaries
594  can run on the host during the build process (e.g. if target is x86 on a
595  x86_64 system, or if emulation set up with binfmt or similar)
596
597### WebAssembly (experimental)
598
599Neovim can be cross-compiled to WebAssembly using the `wasm32-emscripten` target.
600
601- Requires the [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) (`emsdk`).
602- After installing and activating it, pass its sysroot to `-Demscripten-sysroot`, e.g. `$EMSDK/upstream/emscripten/cache/sysroot`.
603
604To build the WebAssembly target:
605
606```bash
607zig build nvim_bin \
608  -Dtarget=wasm32-emscripten \
609  -Demscripten-sysroot=$EMSDK/upstream/emscripten/cache/sysroot
610```
611
612This currently produces:
613
614- `nvim.wasm`, the WebAssembly module.
615- `nvim.js`, the JavaScript loader generated by Emscripten.