Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
906 stars 99 forks source link

How to setup irony to use MSVC compile options? #280

Open mambolevis opened 8 years ago

mambolevis commented 8 years ago

Hi Guillaume, After building the irony-server.exe using cmake Visual Studio 14 2015 Win64 and setting up (company, yasnippet, irony and company-irony), I tested it in a very basic project and the completion using system headers is working fast and properly. In order to continue the setup of the C++ environment in emacs (windows), I would like to listen your advice/recommendation in the following points:

  1. How can I verify were the system headers are taken from? I don't know (even that it is working) where the headers are taken. I need to be sure that irony search msvs headers.
  2. I tried to setup project includes using .clang_complete but it didn't work. How can I do that? -I/inc
  3. I would like to have code navigation using either (ggtags, helm-gtags, rtags or company-gtags) the point is that I don't know which can be used on windows?

Bellow can you see, project structure, main.cpp and an extract of the init.el file with my currently setup of (company, yasnippet, irony and company-irony).

Thanks Levis

------project structure basic_project_root -> inc ----> std_lib_facilities.h -> main.cpp -> emacs_Shell.bat -> .clang_complete

// main.cpp

include

include

include "std_lib_facilities.h"

int main(int argc, char *argv[]) { std::string s1; s1 = "hello world"; s1.append(" desde kassel"); std::cout << "s1 = " << s1 << "\n"; //------------- keep_window_open(); return 0; }

;;; init.el (use-package company :ensure t :config (global-company-mode))

(use-package yasnippet :ensure t :init (progn (setq yas-verbosity 3) (yas-global-mode 1)) :config (yas-reload-all))

(use-package irony :commands irony-mode :init (setq w32-pipe-read-delay 0) (add-hook 'c-mode-hook 'irony-mode) (add-hook 'c++-mode-hook 'irony-mode) ;;(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options) :config ;(setq company-minimum-prefix-length 0) (use-package flycheck-irony :config (add-hook 'flycheck-mode-hook 'flycheck-irony-setup)))

(use-package company-irony :config (add-to-list 'company-backends 'company-irony))

;; Add yasnippet support for all company backends ;; https://github.com/syl20bnr/spacemacs/pull/179 (defvar company-mode/enable-yas t "Enable yasnippet for all backends.")

(defun company-mode/backend-with-yas (backend) "Company and yasnippet with BACKEND as argumet." (if (or (not company-mode/enable-yas) (and (listp backend) (member 'company-yasnippet backend))) backend (append (if (consp backend) backend (list backend)) '(:with company-yasnippet))))

(setq company-backends (mapcar #'company-mode/backend-with-yas company-backends))

Sarcasm commented 8 years ago

I don't really use irony on Windows (actually I don't really use Windows), I just test the bare minimum because there is no good reason not to support it. User @3246251196 seems to use it more seriously and may give you some advices maybe.

I'm not sure but I think, libclang will pick up the MSVC headers if you have enabled the MSVC environment in your emacs, that is for example to setup vcvars.bat then launch emacs in from this terminal.

I tried to setup project includes using .clang_complete but it didn't work. How can I do that? -I/inc

I would expect a simple .clang_complete to work like on Linux, I think I tried it on irony-server.

I would like to have code navigation using either (ggtags, helm-gtags, rtags or company-gtags) the point is that I don't know which can be used on windows?

I do not use this and I don't know either, sorry.

3246251196 commented 8 years ago

Hi,

Yes I do use Windows since our hands are tied to do so at work. I use GNU/Linux at home. This - in a way - is handy since I have some knowledge of the different OS for setting up Emacs IDE like environment.

Anyway, to answer your question on code navigation; I very, very often use cscope and etags to navigate around my projects at work. You can get a Windows cscope binary and ctags binary. I have an alias or a bash function (we use MinGW / msys at work )which will run something like:

function doMyTags
{
    find . -type f -regex ".*\.\(cpp\|h\)" > cscope.files
    cscope -bq -i cscope.file
    etags - < cscope.files
}

I load up something like xcscope.el in my emacs init file and now I can just run M-x cscope-find-global-definition etc etc (map these to keys if you want). And I can run M-. on symbols to use the TAGS file.

So, for the first question about the include files and Clang. This is actually quite complex.

221

As @Sarcasm points to - the source code for Clang tries to help as much as possible (at least in the version linked to in that thread). It will try to look for the Visual Studio include files.

I must say: until recently I just assumed that the correct include files were getting picked up for me. This is actually not true in my case... I tried to use std::to_string which did not show up. It was not because I had not issued a std=c++11 flag, it was because, even though c++11 was enabled, clang has - all this time - been using the include file from MinGW. I actually need to work on this, but I think it should be fairly simple to fix; I just have not had time since we are switching machines at work. I wil test this out soon and report back.

Anyway, you can see which include files Clang looks for by issuing a -v flag to the clang compiler. For instance, create a simple hello world application. Run something like

clang++.exe -v main.c -o out 

It will list the directories it looks in. Generally, for us unfortunate enough to use Windows it will not look in the MSVC include directory first. But this should be solvable.

Go back to your hello world application and run

clang++.exe -v -isystem /some/random/path -o out

This time you will notice that /some/random/path is the first directory to be searched for in the output of the clang compiler. I have not actually tried this yet but I will soon.

I think I did try this because I only had a short amount of time and I was getting other errors. But I am almost sure that was because I also need to supply the windows SDK header includes to be searched also! Again, I will report on this soon.

Putting a .clang_complete file is all I have ever done in my projects for Windows (we use MSVC also at work) - even though I avoid it and do all my IDE in emacs at all costs - except for the debugging. I have to say, MSVC is a nice debugger. So I have a F key I press which will open the current source file in the correct .sln file and it just loads MSVC ide.

It should be enough to have something like:

-I/path/to/BOOSTforexample
-I/path/to/someOtherLibraryHeaders
-D_SOMEDEF_
-std=c++11

BTW, i have never used vcvars or told emacs about the Windows environment. It would be nice to have a link to setting this up maybe. https://github.com/llvm-mirror/clang/blob/2abbec88f288baf3c2dc2c2f67a63f6cba3a41e7/lib/Driver/MSVCToolChain.cpp#L431-L493

When looking at this, again, it seems like using that batch file would help but I would need to look at the documentation. Plus, I think just inserting the includes manually (the SDK/VC dirs) would work since that is all the code seems to be doing. I will report back.

Sarcasm commented 8 years ago

BTW, i have never used vcvars or told emacs about the Windows environment. It would be nice to have a link to setting this up maybe.

Are you asking for a how-to on this? I have some notes on my Windows which I can share (maybe on the Wiki).

3246251196 commented 8 years ago

When I had time at the office I ttried opening up a CMD windows. I then ran vcvarsall.bat for amd64. Sure, this sets all the environment like the INCLUDE variables. But when I tried to compile with clang the -v still shows that it took the mingw includes first. In fact nothing from INCLUDEs was even searched for in output of -v.

A link to your notes would sure be nice.

Thanks.

mambolevis commented 8 years ago

Hi,

Let me first tell you that the solution suggested for @3246251196 to navigate through the code using cscope and etags is working properly. Now I can jump using M-. and M-* to come back. It works for project headers but with system headers not jet (this allow me to introduce the second part)

In relation to the priority of irony to search system headers, I make some experiments today in order to reproduced was @3246251196 suggested. In fact when compiling clang++.exe -v main.cpp -o out the headers search is: _#include "..." search starts here:

include <...> search starts here:

C:\MinGW\lib\gcc\mingw32\4.5.2\include\c++ C:\MinGW\lib\gcc\mingw32\4.5.2\include\c++\mingw32 C:\MinGW\lib\gcc\mingw32\4.5.2\include\c++\backward C:\Program Files\LLVM-3.7.1\bin..\lib\clang\3.7.1\include C:\MinGW\lib\gcc\mingw32\4.5.2\include C:\MinGW\lib\gcc\mingw32\4.5.2\include-fixed C:\MinGW\include End of search list._

If the following option clang++.exe -v -isystem C:/home/projects/basic_project -v main.cpp -o out is used, the results are: _#include "..." search starts here:

include <...> search starts here:

C:/home/projects/basicproject C:\MinGW\lib\gcc\mingw32\4.5.2\include\c++ C:\MinGW\lib\gcc\mingw32\4.5.2\include\c++\mingw32 C:\MinGW\lib\gcc\mingw32\4.5.2\include\c++\backward C:\Program Files\LLVM-3.7.1\bin..\lib\clang\3.7.1\include C:\MinGW\lib\gcc\mingw32\4.5.2\include C:\MinGW\lib\gcc\mingw32\4.5.2\include-fixed C:\MinGW\include End of search list.

It confirms that MSVC headers are not listed. Additionally, I am using all the time a batch file to lunch emacs and setup the environment variables: _@set project_dir=%cd% @set PATH=%PATH%;%project_dir% @set environment_dir= c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin @cd /d %environment_dir% @call vcvars32.bat ::------------------------------------------- @cd /d %projectdir% @prompt $p$$g$s ::------------------------------------------- @call emacs --debug-init @%COMSPEC% /K_

I verify exec-path in emacs and the VC enviroment variables are visible for emacs and it means that irony are not seeing these variables.

There are two projects that should have the solution to the problem (I suppose that, it looks like) https://github.com/yaruopooner/ac-clang https://github.com/yaruopooner/msvc

Yes, the link with the notes is an excellent idea. Thank you!

Sarcasm commented 8 years ago

Ok, so one can actually forget about calling vcvars.bat manually apparently, Clang will find the things on its own.

You are looking at the output of clang++.exe, but a better candidate when you want MSVC-like things is to look at clang-cl.exe.

In my case I got this:

$ clang-cl.exe -v -c test.c
clang-cl.exe -v -c ../projects/test.c
clang version 3.5.0 (217039)
Target: i686-pc-windows-msvc
Thread model: posix
 "C:\Program Files (x86)\LLVM\bin\clang-cl.exe" -cc1 -triple i686-pc-windows-msvc <snip...> test.c
clang -cc1 version 3.5.0 based upon LLVM 3.5.0 default target i686-pc-windows-gnu
#include "..." search starts here:
#include <...> search starts here:
 C:\Program Files (x86)\LLVM\bin\..\lib\clang\3.5.0\include
 C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
 C:\Program Files (x86)\Windows Kits\8.1\include
End of search list.
...

Compared with clang++.exe:

clang++.exe -v -c ../projects/test.c
clang++.exe -v -c ../projects/test.c
clang version 3.5.0 (217039)
Target: i686-pc-windows-gnu
Thread model: posix
clang++.exe: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
 "C:\Program Files (x86)\LLVM\bin\clang++.exe" -cc1 -triple i686-pc-windows-gnu <snip...> test.c
clang -cc1 version 3.5.0 based upon LLVM 3.5.0 default target i686-pc-windows-gnu
....
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.7.1/include/c++"
...
#include "..." search starts here:
#include <...> search starts here:
 C:\Program Files (x86)\LLVM\bin\..\lib\clang\3.5.0\include
 C:\Program Files (x86)\LLVM\bin\..\lib\clang\3.5.0\../../../include
End of search list.

You can see that clang-cl uses a different triple, you can get the msvc stuff by doing this:

clang++.exe -v -target i686-pc-windows-msvc -c test.c

Then you may want to add the following flags too for better MSVC compatibility:

 -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -fdelayed-template-parsing

Also taken from the clang-cl.exe -v output.

3246251196 commented 8 years ago

@Sarcasm

That looks very useful. I can only try at work next week.

How does the invocation of clang-cl work in relation to completions in a buffer with irony-mode minor? I know that irony-mode will trigger clang to provide completions. I know that clang must compile the file/project for this to happen - but, will it use clang or clang-cl ?

Cheers.

Also, -fms-extensions (yes, I was having unknown __w64 issues with Clang at work today when I quickly tried this before going home and this flag has came up as a solution.

I think if we find a suitable solution in this thread then we can add the information to the main page in the Windows section. For example, the minimum flags that should be in .clang_complete when using MSVC (not necessarily minimum, but "suggested starting point").

Sarcasm commented 8 years ago

How does the invocation of clang-cl work in relation to completions in a buffer with irony-mode minor?

The two aren't really related.

know that irony-mode will trigger clang to provide completions. I know that clang must compile the file/project for this to happen - but, will it use clang or clang-cl ?

Not exactly:

  1. irony-server does not really compile, it just parses (-fsyntax-only), it does not generate output files (.o, .S or such)
  2. irony-server is not using clang, it is more like this (I'm simplifying things here but that should not matter):
    • there exists a libclang which is a compiler as a library, it provides compiler informations through a library
    • there exists clang, an executable that uses libclang to produce objects/binaries
    • there exists irony-server which is an executable using libclang to produce completions
    • there exists clang-cl which uses libclang and is mostly like clang but uses special command lines arguments by default to support msvc-style arguments (e.g /DFOO=1) and has msvc-compatible option enable by default (e.g: -fms-compatibility)

So for irony-server on Windows we may want to reproduce some parts of the special arguments that clang-cl uses.


Also as another information that could be useful, if you want irony-mode to support cl-style compile options, that is /nologo /EHsc h-DFOO=1, for example compile options you generated automatically based on clang-cl output, you can tell libclang to understand them by using the following flag as an early argument --driver-mode=cl.

E.g (not tested!):

clang++.exe -Imydir -DFOO=1 --driver-mode=cl /nologo /DWIN32 /D_WINDOWS /W3 /GR /EHsc /EHs-c- /D_HAS_EXCEPTIONS=0 foo.cpp
mambolevis commented 8 years ago

@Sarcasm I modify my emacs_Shell.bat to call environment variables msvc x64, then, I run clang-cl.exe -v -o out main.cpp -o main.exe and the result is:

clang-cl.exe -v -o out main.cpp -o main.exe
clang version 3.7.1 (tags/RELEASE_371/final)
Target: x86_64-w64-windows-msvc
Thread model: posix
....
#include "..." search starts here:
#include <...> search starts here:
 C:\Program Files\LLVM-3.7.1\bin\..\lib\clang\3.7.1\include
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt
 C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt
End of search list.
In file included from main.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\string:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\istream:6:

Now, I am playing with the includes and compiler flags in the .clang_complete file. I added of course the suggested flag: -target i686-pc-windows-msvc -I/inc Irony works as always but I still don't know were the headers are taken. I try the following: The root of my project is now the disc, c:. Then, I create a the TAGS file to search all headers in my disc. I added this #include <math.h> in my project and then use M-. to go to the definition. In the minibuffer appeared the following question: Find tag (default math): I pressed enter and the jump was to the file: C:\cygwin64\lib\gcc\i686-pc-cygwin\4.9.2\include\c++\i686-pc-cygwin\bits\c++config.h.

Sarcasm commented 8 years ago

The tags files and irony mode are totally unrelated, neither of them uses the intelligence of the other. What I gave you, is a mean to get irony-server/libclang to use the msvc headers, that is all.

mambolevis commented 8 years ago

Thanks. I setup .clang_complete flags as follows:

-target i686-pc-windows-msvc
-fms-extensions
-fms-compatibility
-fms-compatibility-version=17.00
-fdelayed-template-parsing
-I/inc

To be sure that .clan_compile file is loaded, I use(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options) , I reinforced the call of the environment variables and the tests with the clan_cl.exe and clang++.exe are also considering msvc headers (like in your tests). Nonetheless, the completion (in my case) is not seeing msvc headers, for instance, std::unique_ptr is not working. Please let me know if you obtained completion of std::unique_ptr in your tests.

3246251196 commented 8 years ago

For unique pointer you have included <memory>

. I think you need to set -std=c++11 in clang complete also.

3246251196 commented 8 years ago

Included 《memory》 **

Sarcasm commented 8 years ago

It is one flag, command line argument per line.

You should put -target and i686-pc-windows-msvc on their own line.

Bad:

-target i686-pc-windows-msvc
-fms-extensions
-fms-compatibility
-fms-compatibility-version=17.00
-fdelayed-template-parsing
-I/inc

Good:

-target
i686-pc-windows-msvc
-fms-extensions
-fms-compatibility
-fms-compatibility-version=17.00
-fdelayed-template-parsing
-I/inc

To be sure that .clan_compile file is loaded

it is .clang_complete, make sure you get the file right.

You can check the compile options with M-x irony-cdb-menu RET.

mambolevis commented 8 years ago

Hi, now it is working, thanks!! Important: 1) It was not necessary to add -std=c++11, it works just with the last suggestion from @Sarcasm. Now, I get completion from std::unique_ptr and std::to_string cool. 2) It is necessary to call environment variables for msvc (either x86 or x64). 3) I tested without calling environment variables, and the following error appeared: image

Sarcasm commented 8 years ago

2) It is necessary to call environment variables for msvc (either x86 or x64).

are you talking about vcvars here?

3) I tested without calling environment variables, and the following error appeared:

This happens even in simple setup, e.g: when not using any external headers?

3246251196 commented 8 years ago

[Interesting. I am getting the same assertion failure regardless.

clang++.exe -v
clang version 3.7.1 (tags/RELEASE_371/final)
Target: i686-pc-windows-gnu
Thread model: posix

Here are my steps to test this (Windows 7 64):

Run cmd prompt,

then:

echo %INCLUDE%
--> %INCLUDE%

then:

call C:\Users\dix9yok>call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\vcvars64.bat"

then:

echo %INCLUDE%
--> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE;C:\Program Files(x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\8.1\include\shared;C:\Program Files (x86)\Windows Kits\8.1\include\um;C:\Program Files (x86)\Windows Kits\8.1\include\winrt;

then:

c:\emacs-24.5\bin\runemacs.exe

then (when in Emacs - which automatically open up to a bash session for me; I cd into root of a project)

echo $INCLUDE
-->  C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\8.1\include\shared;C:\Program Files (x86)\Windows Kits\8.1\include\um;C:\Program Files (x86)\Windows Kits\8.1\include\winrt;

then

cat .clang_complete

-->  -target
i686-pc-windows-msvc
-fms-extensions
-fms-compatibility
-fms-compatibility-version=17.00
-fdelayed-template-parsing
-I/inc
-D_MSC_VER
-DWITH_UNIT_TESTS
-D_DEBUG
-std=c++11
-IMULTIPLEINCLUDESHERETO_BOOST_AND_OTHER_THINGS

then

Open a file which triggers my autoparse function - then the assertion seen above comes

====

after trying with a simple project I can confirm that it does work. Unfortunately it does not for the project at work which is really where I need it.

mambolevis commented 8 years ago

@Sarcasm

are you talking about vcvars here?

yes, either (x86 or x64)

This happens even in simple setup, e.g: when not using any external headers?

yes, it happens with the simple setup which in my case is:

-target
i686-pc-windows-msvc

@3246251196 the -std=c++11 compiler flag doesn't exist in msvc, probably you can suprime it.

3246251196 commented 8 years ago

@mambolevis

Hi, this is without -std=c++11 I still get the same issue. I have not played around with it for very long so I will see what happens tomorrow. It would be nice if there was more information in the error message from clang - I will search

Sarcasm commented 8 years ago

It's possible that my research stopped at a similar issue when I tried these kind of experiments a few months ago.

It may be interesting to check if clang-cl outputs more useful flags or to start debugging libclang, build it, debug it...

I have the feeling that the code causing the assert is something about the precompiled preamble maybe you can try to change irony-server to disable this feature and see if it works better. In server/src/TUManager.cpp:

@@ -48,7 +48,7 @@ TUManager::TUManager()
   // significantly slower.
   //
   // -- https://github.com/Sarcasm/irony-mode/issues/4
-  if (CINDEX_VERSION < 6) {
+  if (true) {
     parseTUOptions_ &= ~CXTranslationUnit_PrecompiledPreamble;
   }
 }

Something else if that does not change anything is to do the same with another CXTranslationUnit_DetailedPreprocessingRecord:

@@ -48,8 +48,9 @@ TUManager::TUManager()
   // significantly slower.
   //
   // -- https://github.com/Sarcasm/irony-mode/issues/4
-  if (CINDEX_VERSION < 6) {
+  if (true) {
     parseTUOptions_ &= ~CXTranslationUnit_PrecompiledPreamble;
+    parseTUOptions_ &= ~CXTranslationUnit_DetailedPreprocessingRecord;
   }
 }

Also I would be curious to test with CXTranslationUnit_Incomplete enabled.

3246251196 commented 8 years ago

Okay the problem has been solved.

@Sarcasm

Firstly, the source of the issue is due to our method of building at work. Basically, the source code includes a header file that is generated. To cut a long story short, when I develop I am including a header file that is not yet built.

The solution: Yes, I can use your suggested patches (I tried each permutation; i.e. I firstly tried just true-ing the condition, etc until I essentially had):

@@ -48,8 +48,9 @@ TUManager::TUManager()
   // significantly slower.
   //
   // -- https://github.com/Sarcasm/irony-mode/issues/4
-  if (CINDEX_VERSION < 6) {
+  if (true) {
     parseTUOptions_ &= ~CXTranslationUnit_PrecompiledPreamble;
+    parseTUOptions_ &= ~CXTranslationUnit_DetailedPreprocessingRecord;
+    //I assume this is how to enable your last mentioned augmentation:
+    parseTUOptions_ |= CXTranslationUnit_Incomplete;
   }
 }

However, the ultimate solution is to really fix the issue. So, now I generate the header file (which is a separate project) and include it into the .clang_complete file, now I can revert the patch above (i.e. go back to an unchanged irony-server TUManager.cpp source) and when I open a random file in the project it parses the project/file without the assertion.

The good thing, here, is that by not applying those augmentations in the patch clang/irony is a lot quicker! (as indicated in the comments in TUManager.cpp)

Lastly, I did not need to run the vcvars*.bat - from what I have seen, the Clang source code guesses the right directories anyway! It is perhaps better to establish the environment properly though.

@Sarcasm I think we should include the bare minimum .clang_complete flags in the Documentation page IF using MSVC. It would also be good to link this ticket to other Windows tickets but more importantly rename the title of the thread to Irony And Visual Studio or something like that.

Donc, c'est bien et merci!

mambolevis commented 8 years ago

@3246251196 Hi, very good news. Thanks. What are the minimum .clang_complete flags according to your last tests?

3246251196 commented 8 years ago

@Sarcasm I modify my emacs_Shell.bat to call environment variables msvc x64, then, I run clang-cl.exe -v -o out main.cpp -o main.exe and the result is:

clang-cl.exe -v -o out main.cpp -o main.exe clang version 3.7.1 (tags/RELEASE_371/final) Target: x86_64-w64-windows-msvc

@mambolevis @Sarcasm I am actually curious how your setup works at all. The output suggests that you are using 64 bit version of Clang. Irony needs to either be manually told to build in a 64 bit context or... ? I am a little confused and would like to find out. How did you link to 64 bit clang?

Thank you.

Sarcasm commented 8 years ago

Is there a question for me in there?

FYI I created a wiki page for now: https://github.com/Sarcasm/irony-mode/wiki/Setting-up-irony-mode-on-Windows-using-MSVC

Would be nice to sum up cleanly the findings so far.

@3246251196:

3246251196 commented 8 years ago

@Sarcasm How can I change the parameters to clang-cl.exe ? It seems to be hardcoded to use -fsm-extention=18. But, I need to change it to 19.

More testing is necessary for 2015 MSVC because I am having problems with this one

Cheers.

mambolevis commented 8 years ago

@3246251196

I am actually curious how your setup works at all. The output suggests that you are using 64 bit version of Clang. Irony needs to either be manually told to build in a 64 bit context or... ? I am a little confused and would like to find out. How did you link to 64 bit clang?

I made just the following steps:

Sarcasm commented 8 years ago

I'm not sure but I think it will depend on the MSVC version it detected. Is your version of Clang recent enough for MSVC 2015 ? If yes, maybe the autodetection is not 100% correct and you may have to setup MSVC vars to the version you are interested in. -fsm-extention=18

How can I change the parameters to clang-cl.exe ? It seems to be hardcoded to use -fsm-extention=18. But, I need to change it to 19.

I'm not sure. I think

Seem to happen in lib/Driver/MSVCToolChain.cpp / lib/Driver/Tools.cpp Of interest might be visualstudio::getMSVCVersion(), it seems to default to 18 if the guessing logic does not work. Would be nice to know what is the proper way. Maybe you have to set -fms-compatibility-version=<value> or -fmsc-version (http://clang.llvm.org/docs/UsersManual.html#id7).

3246251196 commented 8 years ago

@mambolevis

Hi,

I have no access interactive or not to irony-server-install-prefix.

I made just the following steps:

Download LLVM-3.7.1-win64.exe binaries
Build irony-server.exe with cmake Visual Studio 14 2015 Win64
If you build irony-server outside (like in my case) don't forget to setup irony-server-install-prefix That's all, nothing especial.

I have never yet been able to build 64 bit version.

`irony-install-server

It defauls to:

cmake -DCMAKE_INSTALL_PREFIX\=c\:/Users/dix9yok/.emacs.d/irony/ c\:/Users/dix9yok/.emacs.d/irony-mode/server && cmake --build . --use-stderr --config Release --target install

I change to

cmake -DCMAKE_INSTALL_PREFIX\=c\:/Users/dix9yok/.emacs.d/irony/ c\:/Users/dix9yok/.emacs.d/irony-mode/server && cmake -G "Visual Studio 14 2015 Win64" --build . --use-stderr --config Release --target install

And get

CMake Error: The source directory "C:/Users/dix9yok/AppData/Local/Temp/install" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
mambolevis commented 8 years ago

@3246251196 I only use the CMake GUI.

3246251196 commented 8 years ago

@mambolevis I just love the simplicity of Unix-like and good old Makefiles.

Can you tell me step-by-step how to build irony mode 64 bit using MSVC2015 using the GUI please?

Thank you : )

mambolevis commented 8 years ago

@3246251196

  1. setup source code and build directory image
  2. press configure image
  3. Setup to adjust the red zone, press configure again (red messages disappear) and press generate image
  4. Open visual studio 2015 and install it.
3246251196 commented 8 years ago

@mambolevis Thank you, however, I cannot see the same options as you. For example, I do not see EMACS_EXECUTABLE etc. But, anyway, for now I can use the 32 bit version

@Sarcasm Mon copain, is it possible to add a function such as install-irony-server-64 which will install the 64 bit version: I am thinking this will mean re-writing the CMAKE stuff a little bit though. Basically, if you can tell me why my version above (inserting -G "Visual Studio 14 2015 Win64") did not work that would be great. I would prefer to start using the 64 bit Clang/Irony.

Also, my observations so far: I think, if you are using irony-mode with Windows and MSVC you should always be in the VS environment context. So, now, to run emacs I actually run a batch file that looks something like:

title rjdEmacs

echo "Establishing Visual Studio variables..."
call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat" amd64

echo "Running emacs..."
c:\emacs-24.5\bin\runemacs.exe -fs

You can risk not running the batch file, but then Clang is guessing I think - best to be safe.

I am having difficulty with BOOST 1.60 in this new setup. I am getting the assertion failure and this is no doubt due to the errors that clang is producing. Clearly there are some flags that you should pass using .clang_complete in order for clang to see the boost headers in a MSVC context properly. For example, I am currently getting:

debug: complete: 15 diagnostic(s)
d:/development/External/boost_1_60_0\boost/type_traits/has_nothrow_constructor.hpp:26:84: error: use of undeclared identifier 'is_default_constructible'
d:/development/External/boost_1_60_0\boost/type_traits/has_nothrow_constructor.hpp:26:114: error: 'T' does not refer to a value
d:/development/External/boost_1_60_0\boost/type_traits/has_nothrow_constructor.hpp:26:17: note: declared here
d:/development/External/boost_1_60_0\boost/type_traits/has_nothrow_constructor.hpp:26:84: error: no member named 'value' in the global namespace
d:/development/External/boost_1_60_0\boost/type_traits/has_nothrow_constructor.hpp:26:117: error: expected class name
d:/development/External/boost_1_60_0\boost/type_traits/has_nothrow_assign.hpp:64:7: error: use of undeclared identifier 'is_assignable'
d:/development/External/boost_1_60_0\boost/type_traits/has_nothrow_assign.hpp:64:32: error: 'T' does not refer to a value
d:/development/External/boost_1_60_0\boost/type_traits/has_nothrow_assign.hpp:51:20: note: declared here
d:/development/External/boost_1_60_0\boost/type_traits/has_nothrow_assign.hpp:64:7: error: expected expression
d:/development/External/boost_1_60_0\boost/type_traits/has_nothrow_assign.hpp:66:6: error: expected class name
d:/development/External/boost_1_60_0\boost/type_traits/has_trivial_assign.hpp:28:7: error: use of undeclared identifier 'is_assignable'
d:/development/External/boost_1_60_0\boost/type_traits/has_trivial_assign.hpp:28:32: error: 'T' does not refer to a value
d:/development/External/boost_1_60_0\boost/type_traits/has_trivial_assign.hpp:25:23: note: declared here
d:/development/External/boost_1_60_0\boost/type_traits/has_trivial_assign.hpp:28:7: error: expected expression
d:/development/External/boost_1_60_0\boost/type_traits/has_trivial_assign.hpp:32:6: error: expected class name

For now, I can actually get around this issue by going to the slower route and applying the patch:

    if (true) {
    parseTUOptions_ &= ~CXTranslationUnit_PrecompiledPreamble;
    parseTUOptions_ &= ~CXTranslationUnit_DetailedPreprocessingRecord;
    parseTUOptions_ |= CXTranslationUnit_Incomplete;

It is slower, for sure, but it is not too bad - and I think CXTranslationUnit_Incomplete seems to speed things up; I guess irony gets completions a little quicker with this?

I will just need to see which flags I am required to use in order to satisfy boost in the project.

I'm not sure but I think it will depend on the MSVC version it detected. Is your version of Clang recent enough for MSVC 2015 ? If yes, maybe the autodetection is not 100% correct and you may have to setup MSVC vars to the version you are interested in. -fsm-extention=18

How can I change the parameters to clang-cl.exe ? It seems to be hardcoded to use -fsm-extention=18. But, I need to change it to 19.

I'm not sure. I think

Seem to happen in lib/Driver/MSVCToolChain.cpp / lib/Driver/Tools.cpp Of interest might be visualstudio::getMSVCVersion(), it seems to default to 18 if the guessing logic does not work. Would be nice to know what is the proper way. Maybe you have to set -fms-compatibility-version= or -fmsc-version (http://clang.llvm.org/docs/UsersManual.html#id7).

The flags are changed by just running clang-cl.exe -fms=WHATEVER - I am not sure why that didn't work the first time. But that is cleared up now

could you confirm that the --driver-mode=cl bit works? If that works it means we could generate the compilation database automatically more easily on Windows
as you suggested I changed the title

I have not tested this yet. I will do when I get a change. I do not know where to put this with respect to the .clang_complete file.

Cheers.

mambolevis commented 8 years ago

@3246251196

Thank you, however, I cannot see the same options as you. For example, I do not see EMACS_EXECUTABLE etc. But, anyway, for now I can use the 32 bit version

Hi, it is rare because I didn't add anything, it just works. Question: are you cloning irony-mode from the github repository? Perhaps, I didn't mention that my first step is (to clone irony from the master repository). But I really don't know if it has a relationship.

Sarcasm commented 8 years ago

Mon copain, is it possible to add a function such as install-irony-server-64 which will install the 64 bit version: I am thinking this will mean re-writing the CMAKE stuff a little bit though. Basically, if you can tell me why my version above (inserting -G "Visual Studio 14 2015 Win64") did not work that would be great. I would prefer to start using the 64 bit Clang/Irony.

Yesterday evening I tried to make it work in 64 Bits but I was not able to in a satisfying way so I gave up, sorry. :) I used to be able to build irony with clang-cl + ninja, which is what I tried first but I realized there is no way to tell the cmake Ninja generator to build in 64 bit, I tried to load the vcvarsall.bat x64 environment but that did not work.

In the end, I think I was able to compile with MSBuild.exe but I was unsatisfied because the libclang builtin headers weren't found or something like that.

I thought it will be a fun time but in the end nothing worked like I wanted in x86_64 :(.

Also, my observations so far: I think, if you are using irony-mode with Windows and MSVC you should always be in the VS environment context. So, now, to run emacs I actually run a batch file that looks something like:

I think I came to the same conclusion a few month ago but I was not sure. Would be nice to know and say so in the wiki, your script might be handy in there.

It is slower, for sure, but it is not too bad - and I think CXTranslationUnit_Incomplete seems to speed things up; I guess irony gets completions a little quicker with this?

Oh, I stumbled upon this flag by chance, I would be really interested to know it's implications, if what you say is true it's worth considering adding it.

Do you actually need all of the flags to be in this configuration for boost to work or could you reduce this to just one flag?

I have not tested this yet. I will do when I get a change. I do not know where to put this with respect to the .clang_complete file.

It's a flag like any other, you can put it at some place and then after it use Windows-style flags.

E.g:

-DFOO=1
--driver-mode=cl
/DBAR=1
3246251196 commented 8 years ago

Yesterday evening I tried to make it work in 64 Bits but I was not able to in a satisfying way so I gave up, sorry. :) I used to be able to build irony with clang-cl + ninja, which is what I tried first but I realized there is no way to tell the cmake Ninja generator to build in 64 bit, I tried to load the vcvarsall.bat x64 environment but that did not work.

In the end, I think I was able to compile with MSBuild.exe but I was unsatisfied because the libclang builtin headers weren't found or something like that.

I thought it will be a fun time but in the end nothing worked like I wanted in x86_64 :(.

Okay, I know how you feel - things are so much nicer in Unix-like land!

I think I came to the same conclusion a few month ago but I was not sure. Would be nice to know and say so in the wiki, your script might be handy in there.

Will we be adding a Microsoft style page to this?

Do you actually need all of the flags to be in this configuration for boost to work or could you reduce this to just one flag?

Which flags are you referring to?

It's a flag like any other, you can put it at some place and then after it use Windows-style flags.

E.g:

-DFOO=1 --driver-mode=cl /DBAR=1

I can confirm that this does work. So I have something like:

-target
i686-pc-windows-msvc
-fms-extensions
-fms-compatibility
-fms-compatibility-version=19
-fdelayed-template-parsing
-ferror-limit=0
--driver-mode=cl
/MP
/GS
/analyze-
/W4
/wd"4250"
/wd"4512"
/wd"4100"
/wd"4592"
/Zc:wchar_t
/ID:\SomePath\ToSomething

I did notice, though, that whilst MS lets you do:

/I "D:\SomePath"

clang will insist on:

/ID:\SomePath

As for the boost issue, I will just have to ask around. I will update soon.

I wonder if there is a way to use standard irony-source: i.e. the version that uses the quicker pre-ambles WHILST avoiding the assertion failure without recompiling Clang.

Sarcasm commented 8 years ago

Will we be adding a Microsoft style page to this?

what do you mean? I'm talking about putting the script in the wiki page here: https://github.com/Sarcasm/irony-mode/wiki/Setting-up-irony-mode-on-Windows-using-MSVC

I did notice, though, that whilst MS lets you do:

/I "D:\SomePath"

clang will insist on:

/ID:\SomePath

you mean in .clang_complete? You did not forget to put one flag per line like this (also quotes aren't needed):

/I
D:\SomePath

As for the boost issue, I will just have to ask around. I will update soon.

Yes please do, I'm not sure Clang is really tested on Windows. On the command line you have the same issue?

3246251196 commented 8 years ago

what do you mean? I'm talking about putting the script in the wiki page here: https://github.com/Sarcasm/irony-mode/wiki/Setting-up-irony-mode-on-Windows-using-MSVC

Yes, I see that - that is good. Perhaps I can contribute to it?

you mean in .clang_complete? You did not forget to put one flag per line like this (also quotes aren't needed):

That is interesting because my .clang_complete works for me. So I do not use a new line for the include and it works fine. I guess it is best to be proper. I am just reporting what I have found which is: not only are the quotes not needed - they will not work.

Yes please do, I'm not sure Clang is really tested on Windows. On the command line you have the same issue?

I have, just this minute before leaving the office, recompiled irony-mode and reverted TUManager.cpp. Everything is now working perfectly with VS 2015 and I am getting no problems. I copied the MS compiler flags VERBATIM as they were in our MS Studio project (only, I took out the quotes etc) and it all works fine.

Cheers.

Sarcasm commented 8 years ago

Yes, I see that - that is good. Perhaps I can contribute to it?

Yes I want you to :), it's an open wiki, you should have access to modify it already, just put your finding in here.

I am just reporting what I have found which is: not only are the quotes not needed - they will not work.

yes it makes perfect sense.

Each line of the .clang_complete is trimmed and then passed as argv[1], argv[2], ...argv[n] to an exec()-like function. There is no shell expansion going here or anything, it means quote will be literally passed down. If arguments have space (e.g: a path) it will be accepted without modification (except end of line is trimmed).

In your example, yes it make sense that /ID:\SomePath works and the other does not. This one is one argument. On the other hand /I "D:\SomePath" is 2 arguments and each one should be on its own line. Moreover, there is no quotes needed because we are not in a shell.

I copied the MS compiler flags VERBATIM as they were in our MS Studio project (only, I took out the quotes etc) and it all works fine.

that's really good to hear!

mambolevis commented 8 years ago

@3246251196 Hi, I was very busy adapting my build system to emacs :), but I am following your emails. If I understood, you have solved the assertion failed problem, it is not required to call the vcvars and the "minimum" flags are well recognized. Could you summarize the steps you followed to get the final solution? Thanks.

3246251196 commented 8 years ago

@3246251196 Hi, I was very busy adapting my build system to emacs :), but I am following your emails. If I understood, you have solved the assertion failed problem, it is not required to call the vcvars and the "minimum" flags are well recognized. Could you summarize the steps you followed to get the final solution? Thanks.

My finding so far suggest that it is definitely best to run vcvarsall.bat and then launch emacs so it has the correct environment settings. If you look at the example batch file that I run that will take care of everything.

I am actually not sure why things all of a sudden worked, it would be nice to find out why. The main thing I changed was using the exact compiler options/flags that we run for our project at work (I got these from within the HORRID MSVC2015 ide and right clicking on the main project and looking somewhere for the options). So, in my .clang_complete I have something like:

-target i686-pc-windows-msvc -fms-extensions -fms-compatibility -fms-compatibility-version=19 -fdelayed-template-parsing -ferror-limit=0 --driver-mode=cl /MP /GS /analyze- /W4 /wd"4250" /wd"4512" /wd"4100" /wd"4592" /Zc:wchar_t /ID:\SomePath\ToSomething

This corrected the problem. I am not at work now so I cannot remember the rest of the flags (the quoted example is truncated). But there must have been something that satisfied something.

In summary:

Launch emacs after establishing the vcvarsall.bat amd64 environment. And, it is always best to use the exact flags you use in VS for Clang - but, of course, you will need:

-target i686-pc-windows-msvc -fms-extensions -fms-compatibility -fms-compatibility-version=19 -fdelayed-template-parsing --driver-mode=cl

At the top.

Are you having problems at the minute?

mambolevis commented 8 years ago

@3246251196 Hi, nice summary! I think you can include (in the wiki) a the summary of your discussion with @Sarcasm about the TUManager modification to solve the "assertion failed" problem. It will complete the picture.

From my side everything is working. I am just curios with the way emacs searches for project include files. It uses the path of the main.cpp as reference and not the project root. In this example project image I need to setup the .clang_complete file as follows: -I../inc but I expected something like: -I/inc Questions: How do you use relative paths in your projects? Is it possible to use the root of the project as reference? Regards

Sarcasm commented 8 years ago

It's strange, the path are supposed to be relative to the .clang_complete. What is the working directory in M-x irony-cdb-menu RET?

mambolevis commented 8 years ago

Yes, the working directory is project root:

Compilation Database: irony-cdb-clang-complete

  Working Directory: c:/home/projects/basic_project/
  Compile Options:   -target i686-pc-windows-msvc -fms-extensions -fms-compatibility -fms-compatibility-version=19 -fdelayed-template-parsing -I../inc --driver-mode=cl

Nonetheless, when I open the main.cpp, the default-directory is:

default-directory is a variable defined in `C source code'.
Its value is "c:/home/projects/basic_project/src/"
Local in buffer main.cpp; global value is nil

and for that reason, I need to use -I../inc

Sarcasm commented 8 years ago

In irony--adjust-compile-options I'm adding -working-directory WORK-DIR to the end of the compile options. It may not be understood once we enter the cl mode with --driver-mode=cl. Would be interesting to confirm this, then to find if there is a cl equivalent or make irony more aware of this special option.

mambolevis commented 8 years ago

In irony--adjust-compile-options I'm adding -working-directory WORK-DIR to the end of the compile options. It may not be understood once we enter the cl mode with --driver-mode=cl. Would be interesting to confirm this, then to find if there is a cl equivalent or make irony more aware of this special option.

Ok, just let me know when can I test it.

@Sarcasm and @3246251196 On the other hand, I am trying to add company-irony-c-headers to have the complete C++ setup but I don't know if it is possible to use what clang/irony already can see. My current setup (still not working) is:

(use-package company-irony-c-headers
  :ensure t
  :after company
  :init 
  (add-to-list 'company-backends '(company-irony-c-headers company-irony)))

Do you have any suggestion or recommendation?

Sarcasm commented 8 years ago

Ok, just let me know when can I test it.

Well you can test it today.

If you use clang.exe: Take the compile options from your .clang_complete, add -working-directory c:/home/projects/basic_project/ but call this from another directory c:/home/projects/basic_project/src/.

clang.exe -target i686-pc-windows-msvc -fms-extensions -fms-compatibility -fms-compatibility-version=19 -fdelayed-template-parsing -I../inc --driver-mode=cl -working-directory c:/home/projects/basic_project/ main.cpp

This apparently does not work. Then you can try to change the order of the arguments like this:

clang.exe -target i686-pc-windows-msvc -fms-extensions -fms-compatibility -fms-compatibility-version=19 -fdelayed-template-parsing -I../inc  -working-directory c:/home/projects/basic_project/ --driver-mode=cl main.cpp

I would expect this to work.

3246251196 commented 8 years ago
@Sarcasm and @3246251196
On the other hand, I am trying to add company-irony-c-headers to have the complete C++ setup but I don't know if it is possible to use what clang/irony already can see. My current setup (still not working) is:

(use-package company-irony-c-headers
  :ensure t
  :after company
  :init 
  (add-to-list 'company-backends '(company-irony-c-headers company-irony)))

Do you have any suggestion or recommendation?

Hi, I never knew that Irony supported completion of header files. Personally, I just use company-c-headers. So it looks something like this in my .emacs file:

(setq company-backends '(company-c-headers

Then

'(company-c-headers-path-system (quote ("/usr/include/" "/usr/local/include/" "/usr/include/c++/4.8/")))
 '(company-c-headers-path-user (quote ("/home/rjd/Documents/KIND/model/inc/" "/home/rjd/Documents/KIND/parser/inc/" "/home/rjd/Documents/KIND/md5/inc/" "/home/rjd/Documents/KIND/ppmodel/inc/" "/home/rjd/Documents/KIND/common/inc/" ".")))

This results in header file completions for me. If there is a reason to use the irony-mode version please let me know.

Cheers.

PS: The example I gave are on my home GNU/Linux machine - not my Windows work environment. But the only difference between is that at work:

'(company-c-headers-path-system (quote ("C:\Progam Files (x86)\Micro .....")))
 '(company-c-headers-path-user (quote ("D:\MyWorkDir\Inc1" "D:\MyWorkDir\Inc2" .. . . )))
mambolevis commented 8 years ago

@Sarcasm Hi, the result of my tests. But first lets divide my report in three parts: 1) completion 2) compilation and 3) linking image 1) completion 1.1 The following .clang_complete setup works without problems

 -target
i686-pc-windows-msvc
-fms-extensions
-fms-compatibility
-fms-compatibility-version=19
-fdelayed-template-parsing
-I../inc
--driver-mode=cl

1.2 The following .clang_complete setup works without problems

-target
i686-pc-windows-msvc
-fms-extensions
-fms-compatibility
-fms-compatibility-version=19
-fdelayed-template-parsing
-I../inc
-working-directory "c:/home/projects/basic_project/"
--driver-mode=cl

1.3 If I change (1.2 setup) the flag -I../incby -Iincor -I/inc the completion did not find the include file.

2) compilation To remember: The main.cpp file is open and the default-directory is c:/home/projects/basic_project/src/ 2.1 The following command line works without problems

clang.exe -target i686-pc-windows-msvc -fms-extensions -fms-compatibility -fms-compatibility-version=19 -fdelayed-template-parsing -I../inc main.cpp -o main.exe

Compilation finished at Mon Feb 15 09:57:36

2.2 If I add--driver-mode=clthe compilation failed:

clang.exe -target i686-pc-windows-msvc -fms-extensions -fms-compatibility -fms-compatibility-version=19 -fdelayed-template-parsing -I../inc --driver-mode=cl main.cpp -o main.exe
clang.exe: error: unknown argument: '-target'
clang.exe: error: unknown argument: '-fms-extensions'
clang.exe: error: unknown argument: '-fms-compatibility'
clang.exe: error: unknown argument: '-fdelayed-template-parsing'
clang.exe: error: no such file or directory: 'i686-pc-windows-msvc'

Compilation exited abnormally with code 1 at Mon Feb 15 10:03:54

2.3.1 Now I add -working-directory "c:/home/projects/basic_project/" and change -Iinc. It works only if main.cpp is located at project root.

clang.exe -v -target i686-pc-windows-msvc -fms-extensions -fms-compatibility -fms-compatibility-version=19 -fdelayed-template-parsing -working-directory c:/home/projects/basic_project/ -Iinc main.cpp -o main.exe
clang version 3.7.1 (tags/RELEASE_371/final)
Target: i686-pc-windows-msvc
Thread model: posix
clang.exe: error: no such file or directory: 'c:/home/projects/basic_project/main.cpp'

Compilation exited abnormally with code 1 at Mon Feb 15 10:39:07

2.3.2 Same command line as 2.3.1 but , I just put a copy of the main.cpp at project root (Notice that there are two copies of the main.cpp; one at src and another at project root). In this case the command line works without problem:

clang.exe -target i686-pc-windows-msvc -fms-extensions -fms-compatibility -fms-compatibility-version=19 -fdelayed-template-parsing -working-directory c:/home/projects/basic_project/ -Iinc main.cpp -o main.exe

Compilation finished at Mon Feb 15 10:47:25

3) Linking I started to play with the object files generation and linker flags. Until know object files are created in a default folder and the linker also uses default flags. The final main.exe is created in the src folder where the main.cpp is located.

The idea is to control everything (directories, compiler and linker flags) like I made in my build system which is makefile based.

mambolevis commented 8 years ago

@3246251196 Danke schön.

Sarcasm commented 8 years ago

1.2 The following .clang_complete setup works without problems

-target
i686-pc-windows-msvc
-fms-extensions
-fms-compatibility
-fms-compatibility-version=19
-fdelayed-template-parsing
-I../inc
-working-directory "c:/home/projects/basic_project/"
--driver-mode=cl

1.3 If I change (1.2 setup) the flag -I../inc by -Iinc or -I/inc the completion did not find the include file.

Come on! There is one rule with the .clang_complete, it's one flag per line (and also no shell quotting, it will not work), so you should test exactly the following file (please note the change at -working-directory line):

-target
i686-pc-windows-msvc
-fms-extensions
-fms-compatibility
-fms-compatibility-version=19
-fdelayed-template-parsing
-I../inc
-working-directory
c:/home/projects/basic_project/
--driver-mode=cl

Could you re-test 1.3 with these 2 changes? By the way -I/inc should not work, the one of interest is -Iinc.


Regarding

2.2 If I add--driver-mode=clthe compilation failed:

Interesting (and disappointing) results.

2.3.1 an 2.3.2 are interesting. I guess with an absolute path for main.cpp it is okay. irony sends full path for the file so that should be fine.