-
Notifications
You must be signed in to change notification settings - Fork 99
Setting up irony mode on Windows
Two options for building the server binary are described here: Msys2, or natively using the Visual Studio compiler.
Prerequisites: Msys2, and MinGW packages.
clang and cmake were installed through Msys2/MinGW's pacman and are at standard locations. These are the steps taken to get irony-mode to work.
-
git clone https://github.com/Sarcasm/irony-mode.git ~/irony-mode
-
Open a mingw{32, 64} shell.
cd
into the irony-modeserver
sub-directory,mkdir build
as the project requires out of source build. -
The find module that comes with this project should be able to find libclang, which is called clang.dll in MinGW Packages.
cd build cmake -G "MSYS Makefiles" .. make -j 4
In case it finds the static libclang.a
, also distributed with the clang
package, and fails to build, you've to make it point to the clang.dll
available in the /mingw{32, 64}/bin
directory.
cmake -DLIBCLANG_LIBRARY=/mingw64/bin/clang.dll -G 'MSYS Makefiles' ..
-
Make sure the path to clang.dll is in emacs' exec_path and shell PATH. Note that the emacs here is Windows native. Following is what is in my
site-start.el
:(setenv "PATH" (concat "C:\\alt\\msys32\\usr\\bin" ";" "C:\\alt\\msys32\\mingw32\\bin" ";" (getenv "PATH") ) ) (setq exec-path (append '("c:/alt/msys32/usr/bin" "c:/alt/msys32/mingw32/bin") exec-path))
-
Install the native windows version of clang and cmake, choosing 32 bit or 64 bit versions as appropriate. Ensure that they're on the PATH (the installers will offer to do this for you). Verify at a fresh command prompt using
where libclang
andcmake --help
-
Install the Visual C++ Build Tools 2015 (link). These provide the command line tools such as the compiler and Visual Studio build system, without needed a full Visual Studio install. If you already have VS installed, then you can use that.
-
git clone https://github.com/Sarcasm/irony-mode.git ~/irony-mode
-
Open "Visual C++ 2015 x64 Native Build Tools Command Prompt" - a start menu/screen shortcut will have been created by the installer.
-
Change directory to the server subdirectory of your irony mode checkout
-
md build
thencd build
-
cmake -G "Visual Studio 14 2015 Win64" ..
-
MSBuild IronyMode.sln /p:Configuration=Release
-
The output will be found in bin/Release/irony-server.exe
This guide assumes a Windows native version of emacs.
-
Move the built executable to the new directory
.emacs.d/irony/bin/irony-server.exe
-
Install irony-mode through MELPA.
-
It appears that libclang (clang.dll) does not get the same default include paths as clang executables.
clang++ -E -x c++ - -v < NUL
will give you a list of the include paths that clang knows by default. Add them to .clang_complete if they are not already there so libclang knows them too. -
While last item might now give one great completion candidates, the more likely outcome is that one will cry over the delay (30+ seconds is common) in getting these suggestions. Read issue #131 for the sordid details. The tl;dr is:
(setq w32-pipe-read-delay 0)
will take out the bulk of the delay and make Irony again a happy experience on Windows. I have not observed any deleterious effects from the new settings but there is no guarantee these settings won't break something else on one's system.
For the curious: the two Emacs related bugs are reported here: the important one and the less so. It is possible the imminent 24.4 release will set these defaults to better values as the current settings seem to be leftover from Windows 9x days! The reason this bites Irony particularly hard is that the completer often returns multi-megabyte results to Emacs. The default delay is set at 50ms, and the pipe buffer size is 4K. That means with default settings Emacs adds at least an additional delay of 2M/4K*50ms = 25 seconds to transfer 2M bytes of data from the completer on Windows.
In addition the 24.3 version of Emacs will freeze often while using irony-mode. For details see the same issue #131 thread. Emacs 24.4 works correctly and official Windows binary release is expected to be out soon.