justmao945 / vim-clang

Clang completion plugin for vim
ISC License
357 stars 47 forks source link

Using LLVM-3.8.0-win64.exe with vim_clang #95

Open Pinaki82 opened 8 years ago

Pinaki82 commented 8 years ago

The binary distribution of llvm 3.8 is built with MS VC++ and it targets VC++ by default. This is a problem for the llvm users from the past who used TDM or other MinGWw64 binary along with vim_clang+clang. Without configuring this new setup will cause several errors. There is a workaround though. I got it from google. Google: configure clang 3.8 for mingw LLVM 3.8.0 clang binary for Windows targets VC++ http://comments.gmane.org/gmane.comp.compilers.clang.devel/47991

And the answer is:

You can explicitly specify the target triple, like this:

clang -target i686-pc-windows-gnu (or x86_64-pc-windows-gnu)

-Nico

I use a global file for vim_clang, and the current (correct) configuration is:

%userprofile%.vim_clang_includes -target x86_64-pc-windows-gnu -IC:\xtralibs -IC:\xtralibs\appu -IC:\xtralibs\yxml11 -IC:\xtralibs\IUP\include -IC:\xtralibs\LIBXLS~1.0_X\LIBXLS~1\include\libxls

I set up a plugin "vim_clang_setup.vim" with the following configuration:

let g:clang_dotfile = '$HOME/.vim_clang_includes' let g:clang_format_auto = 0 " Style can be LLVM, Google, Chromium, Mozilla, WebKit " let g:clang_format_style = 'LLVM' let g:clang_include_sysheaders = 1 let g:clang_include_sysheaders_from_gcc = 1 let g:clang_cpp_options = '-std=gnu++11' let g:clang_verbose_pmenu = 1

For the syntastic users: I also have a plugin setup for syntastic "syntastic_setup.vim" with the following configuration:

:menu Plugin.Syntastic.auto\ syntax\ check\ on/off\ Toggle:-\ \ \ \ :\SyntasticToggleMode :::SyntasticToggleMode :menu Plugin.Syntastic.Errors\ Window:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ :\Errors :::Errors :menu Plugin.Syntastic.Manully\ check\ errors\ now:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ :\SyntasticCheck :::SyntasticCheck :menu Plugin.Syntastic.Show\ info:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ :\SyntasticInfo :::SyntasticInfo :menu Plugin.Syntastic.Reset\ Syntastic:-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ :\SyntasticReset :::SyntasticReset

" ~~~~~~~~~~ " ~~~~~~~~~~ set statusline+=%#warningmsg# set statusline+=%{SyntasticStatuslineFlag()} set statusline+=%*

let g:syntastic_c_checkers=['gcc', 'cppcheck', 'clang_check'] let g:syntastic_cpp_checkers=['gcc', 'cppcheck', 'clang_check'] " ~~~~~~~~~~~~~~~~~ " A few option for C/C++ GCC " ~~~~~~~~~~~~~~~~~ let g:syntastic_c_compiler_options = '-W -Wall -Wextra -pedantic -ansi -std=gnu99' let g:syntastic_cpp_compiler_options = '-W -Wall -Wextra -pedantic -ansi -std=gnu++98 -std=gnu++11 -std=gnu++14' let g:syntastic_aggregate_errors = 1 let g:syntastic_always_populate_loc_list = 1 " let g:syntastic_auto_loc_list = 0 let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 0 let g:syntastic_enable_signs=1 let g:syntastic_cpp_check_header = 1 let g:syntastic_cpp_remove_include_errors = 1 " first get the include dirs " http://stackoverflow.com/questions/344317/where-does-gcc-look-for-c-and-c-header-files " gcc -print-prog-name=cc1plus -v " gcc -print-prog-name=cc1 -v " ~~~~~~~~~~~~~~~~~ let g:syntastic_cpp_config_file = $HOME . '/.syntastic_cpp_config' " ~~~~~~~~~~~~~~~~~ let g:syntastic_c_config_file = $HOME . '/.syntastic_c_config' " ~~~~~~~~~~~~~~~~~ let g:syntastic_clang_check_config_file = $HOME . '/.syntastic_clang_check_config' " ~~~~~~~~~~~~~~~~~ " * Ue the following line whenever you get into trouble with syntastic * " g:syntastic_c_errorformat='%m' " let g:syntastic_debug = 1 " let g:syntastic_debug = 3 " ~~~~~~~~~~~~~~~~~ let g:syntastic_c_check_header = 1 let g:syntastic_cpp_check_header = 1

And the ".syntastic_clang_check_config" contains exactly:

%userprofile%.syntastic_clang_check_config -W -Wall -Wextra -pedantic -target x86_64-pc-windows-gnu -IC:\xtralibs -IC:\xtralibs\appu -IC:\xtralibs\yxml11 -IC:\xtralibs -IC:\xtralibs\IUP\include -IC:\xtralibs\LIBXLS~1.0_X\LIBXLS~1\include\libxls

I intensionally wrote 'x86_64-pc-windows-gnu' at the next line, this is how syntastic is recognizing the flag: -target x86_64-pc-windows-gnu, I checked it with let g:syntastic_debug = 1.

This is not an issue with vim_clang rather this is an information. I hope this information will be helpful to those who were using llvm 3.7.1 with mingw and do not want to compile clang with mingw themselves. Thanks.

justmao945 commented 8 years ago

Thank you @Pinaki82 for your information. 😄 Eh,,, can we make a nice patch ?..

Pinaki82 commented 8 years ago

We can pass an option to the compilation flags specified by the user. Like: let g:clang_380_win = -target x86_64-pc-windows-gnu or, let g:clang_380_mingww64 = 1, and redirect this to clang as -target x86_64-pc-windows-gnu flag. This way it can be fixed. Oh!, thanks for your reply.