ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.45k stars 2.81k forks source link

gcc7.2 / llvm 5 No Completions #2786

Closed ghost closed 7 years ago

ghost commented 7 years ago

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

Thank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.

Issue Details

A large project was recently updated to C++17 / gcc7.2, which broke my YCM tooling. I started a scratch workspace to update the support tooling to see if it fixed the issue. Seems like YCM can understand some standard C++ includes, but not much else. Thanks for any help.

Upstream Tools / Libraries

We have a gcc and g++ 7.2 build that we use, as well as boost 1.65.1 built against gcc 7. I used the gcc 7 compiler to perform the below

Built VIM

Compilation: /scratch/build_tools/gcc/gcc-7.2/bin/gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/scratch/usr/local//include -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1

Linking: /scratch/build_tools/gcc/gcc-7.2/bin/gcc -L/scratch/usr/local//lib -Wl,--as-needed -o vim -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lSM -lICE -lm -ltinfo -lelf -lnsl -lselinux -lacl -lattr -L/scratch/usr/local//lib -llua -L/scratch/usr/local/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic

Built Python 2.7.14

LD_FLAGS="-Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc/x86_64-pc-linux-gnu/7.2.0 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib64 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib" CC=/scratch/build_tools/gcc/gcc-7.2/bin/gcc CXX=/scratch/build_tools/gcc/gcc-7.2/bin/g++ ./configure --prefix=/scratch/usr/local/ --enable-shared

Built LLVM and Clang 5

Same cmake command for both.

CC=/scratch/build_tools/gcc/gcc-7.2/bin/gcc CXX=/scratch/build_tools/gcc/gcc-7.2/bin/g++ cmake -G Ninja -DPYTHON_LIBRARY=/scratch/usr/local/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/scratch/usr/local/include/python2.7/ -DPYTHON_EXECUTABLE=/scratch/usr/local/bin/python -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_SHARED_LIBRARY_LINK_C_FLAGS="-Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc/x86_64-pc-linux-gnu/7.2.0 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib64 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib" -DCMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS="-Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc/x86_64-pc-linux-gnu/7.2.0 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib64 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc/x86_64-pc-linux-gnu/7.2.0 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib64 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib" -DCMAKE_INSTALL_PREFIX=/scratch/usr/local/ ../

Updated YCM in Vundle and Built

CC=/scratch/build_tools/gcc/gcc-7.2/bin/gcc CXX=/scratch/build_tools/gcc/gcc-7.2/bin/g++ cmake -G Ninja -DPYTHON_LIBRARY=/scratch/usr/local/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/scratch/usr/local/include/python2.7/ -DPYTHON_EXECUTABLE=/scratch/usr/local/bin/python -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_SHARED_LIBRARY_LINK_C_FLAGS="-Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc/x86_64-pc-linux-gnu/7.2.0 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib64 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib" -DCMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS="-Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc/x86_64-pc-linux-gnu/7.2.0 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib64 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc/x86_64-pc-linux-gnu/7.2.0 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib/gcc -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib64 -Wl,-rpath /scratch/build_tools/gcc/gcc-7.2/lib" -DEXTERNAL_LIBCLANG_PATH=/scratch/usr/local/lib/libclang.so /scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/

Provide a clear description of the problem, including the following key questions:

Diagnostic data

Output of vim --version

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 20 2017 08:15:08)
Included patches: 1-1127
Compiled by user@host
Huge version with GTK2 GUI. Features included (+) or not (-):
+acl +file_in_path +mouse_sgr +tag_old_static
+arabic +find_in_path -mouse_sysmouse -tag_any_white
+autocmd +float +mouse_urxvt -tcl
+balloon_eval +folding +mouse_xterm +termguicolors
+browse -footer +multi_byte +terminal
++builtin_terms +fork() +multi_lang +terminfo
+byte_offset +gettext -mzscheme +termresponse
+channel -hangul_input +netbeans_intg +textobjects
+cindent +iconv +num64 +timers
+clientserver +insert_expand +packages +title
+clipboard +job +path_extra +toolbar
+cmdline_compl +jumplist -perl +user_commands
+cmdline_hist +keymap +persistent_undo +vertsplit
+cmdline_info +lambda +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak +python +viminfo
+cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con_gui +lua +rightleft +windows
+diff +menu -ruby +writebackup
+digraphs +mksession +scrollbind +X11
+dnd +modify_fname +signs -xfontset
-ebcdic +mouse +smartindent +xim
+emacs_tags +mouseshape +startuptime +xpm
+eval +mouse_dec +statusline +xsmp_interact
+ex_extra -mouse_gpm -sun_workshop +xterm_clipboard
+extra_search -mouse_jsbterm +syntax -xterm_save
+farsi +mouse_netterm +tag_binary
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/scratch/usr/local/share/vim"
Compilation: /scratch/build_tools/gcc/gcc-7.2/bin/gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/scratch/usr/local//include -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /scratch/build_tools/gcc/gcc-7.2/bin/gcc -L/scratch/usr/local//lib -Wl,--as-needed -o vim -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lSM -lICE -lm -ltinfo -lelf -lnsl -lselinux -lacl -lattr -L/scratch/usr/local//lib -llua -L/scratch/usr/local/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic

Place the output here, or a link to a gist.

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Client logfile: /tmp/ycm_zlbYYV.log
-- Server Python interpreter: /scratch/usr/local/bin/python
-- Server Python version: 2.7.14
-- Server has Clang support compiled in: True
-- Clang version: clang version 5.0.0 (tags/RELEASE_500/final)
-- No extra configuration file found
-- C-family completer debug information:
-- Compilation database path: /scratch/git/code
-- Flags: ['/scratch/build_tools/gcc/gcc-7.2/bin/g++', '-x', 'c++', '-DBOOST_ASIO_DISABLE_THREADS', '-DBOOST_SYSTEM_NO_DEPRECATED', '-D_GNU_SOURCE', '-I/scratch/git/code/core', '-isystem', '/scratch/build_tools/boost/boost_1.65.1_gcc-7.2-cpp17/include', '-isystem', '/scratch/git/code/build/sbe/src/sbe/sbe-tool/src/main/cpp', '-I/scratch/git/code/build/lib', '-I/scratch/git/code/lib', '-isystem', '/scratch/build_tools/Qt5-static-debug/qt-everywhere-opensource-src-5.7.0/qtbase/include', '-I/scratch/git/code/config', '-I/scratch/git/code/build/config', '-isystem', '/scratch/git/code/build/rapidjson/src/rapidjson/include,', '-isystem', '/scratch/build_tools/librdkafka/librdkafka-0.9.4.patch/include', '-isystem', '/scratch/git/code/build/rapidjson/src/rapidjson/include', '-isystem', '/scratch/build_tools/dpdk/41ad4c2/include/dpdk', '-std=c++17', '-Wall', '-Werror', '-pthread', '-march=sandybridge', '-Wno-implicit-fallthrough', '-fvisibility-inlines-hidden', '-O0', '-ggdb', '-resource-dir=/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../clang_includes', '-fspell-checking']
-- Server running at: http://127.0.0.1:49099
-- Server process ID: 28569
-- Server logfiles:
-- /tmp/ycmd_49099_stdout_pA90YR.log
-- /tmp/ycmd_49099_stderr_aaOSCy.log

Contents of YCM, ycmd and completion engine logfiles

YCM Log

2017-09-21 08:03:29,167 - ERROR - Unable to connect to server Traceback (most recent call last): File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 214, in HandleServerException yield File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/youcompleteme.py", line 227, in CheckIfServerIsReady 'ready' ) File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 68, in GetDataFromHandler timeout ) ) File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 180, in JsonFromFuture response = future.result() File "/scratch/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 404, in result return self.__get_result() File "/scratch/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 356, in __get_result raise self._exception ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=49099): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f3900594b90>: Failed to establish a new connection: [Errno 111] Connection refused',)) 2017-09-21 08:03:49,486 - ERROR - Error while handling server response Traceback (most recent call last): File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 214, in HandleServerException yield File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/completion_request.py", line 60, in RawResponse raise MakeServerException( e ) ServerError: RuntimeError: No completions found; errors in the file? 2017-09-21 08:03:50,064 - ERROR - Error while handling server response Traceback (most recent call last): File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 214, in HandleServerException yield File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/completion_request.py", line 53, in RawResponse self._response = JsonFromFuture( self._response_future ) File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 183, in JsonFromFuture raise MakeServerException( response.json() ) ServerError: RuntimeError: No completions found; errors in the file? 2017-09-21 08:03:51,249 - ERROR - Error while handling server response Traceback (most recent call last): File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 214, in HandleServerException yield File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/completion_request.py", line 53, in RawResponse self._response = JsonFromFuture( self._response_future ) File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 183, in JsonFromFuture raise MakeServerException( response.json() ) ServerError: RuntimeError: No completions found; errors in the file? 2017-09-21 08:03:51,424 - ERROR - Error while handling server response Traceback (most recent call last): File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 214, in HandleServerException yield File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/completion_request.py", line 53, in RawResponse self._response = JsonFromFuture( self._response_future ) File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 183, in JsonFromFuture raise MakeServerException( response.json() ) ServerError: RuntimeError: No completions found; errors in the file? 2017-09-21 08:03:51,594 - ERROR - Error while handling server response Traceback (most recent call last): File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 214, in HandleServerException yield File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/completion_request.py", line 53, in RawResponse self._response = JsonFromFuture( self._response_future ) File "/scratch/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 183, in JsonFromFuture raise MakeServerException( response.json() ) ServerError: RuntimeError: No completions found; errors in the file?

ycmd stderr

2017-09-21 08:03:49,082 - INFO - Adding ONE buffer identifier for file: /scratch/git//foo.cxx 2017-09-21 08:03:49,084 - INFO - Received completion request 2017-09-21 08:03:49,427 - INFO - Received completion request 2017-09-21 08:03:49,475 - ERROR - Exception from semantic completer (using general): Traceback (most recent call last): File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 103, in GetCompletions .ComputeCandidates( request_data ) ) File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/completers/completer.py", line 218, in ComputeCandidates candidates = self._GetCandidatesFromSubclass( request_data ) File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/completers/completer.py", line 231, in _GetCandidatesFromSubclass raw_completions = self.ComputeCandidatesInner( request_data ) File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 113, in ComputeCandidatesInner raise RuntimeError( NO_COMPLETIONS_MESSAGE ) RuntimeError: No completions found; errors in the file?

2017-09-21 08:03:50,010 - INFO - Received completion request Traceback (most recent call last): File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 862, in _handle return route.call(args) File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 1740, in wrapper rv = callback(*a, *ka) File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/watchdog_plugin.py", line 108, in wrapper return callback( args, kwargs ) File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/hmac_plugin.py", line 70, in wrapper body = callback( *args, **kwargs ) File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 103, in GetCompletions .ComputeCandidates( request_data ) ) File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/completers/completer.py", line 218, in ComputeCandidates candidates = self._GetCandidatesFromSubclass( request_data ) File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/completers/completer.py", line 231, in _GetCandidatesFromSubclass raw_completions = self.ComputeCandidatesInner( request_data ) File "/scratch/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 113, in ComputeCandidatesInner raise RuntimeError( NO_COMPLETIONS_MESSAGE )

OS version, distribution, etc.

Centos 6

Linux 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

puremourning commented 7 years ago

Thanks for the detailed report!

Does it work if you pass --gcc-toolchain to libclang by including that in your flags?

the system STL on RH6 is very old, and not c++11 compliant. if your standard library is not the system one, you have to tell clang where to look.

We use RHEL and devtoolset, and we have to pass --gcc-toolchain=/opt/rh/devtoolset-6/usr (or something like that).

In any case, would you mind including the output of :YcmDiags to see if it is saying things like not able to find <string> etc.

chenjie199234 commented 7 years ago

I have the same problem on my archlinux. I'm using the system libclang. gcc7.2/clang5

ghost commented 7 years ago

@puremourning I can give it a shot but it probably will have to wait til next week. This is a work project and I can limp along with using vim basically as an unintelligent text editor for now.

Previously I was running YCM against LLVM/Clang 3.9 that I built using gcc5 - this is what the project was built against before the gcc7 upgrade. I didn't do anything special with --gcc-toolchain, basically just the same process above for building those tools.

I have a backup machine still running the clang 3.9 setup, and when I upgrade the project and re-generate the compilation database (so it has g++7 in the compile commands), the YCM plugin running against clang 3.9 is also broken in the same way (logs say no completions available due to errors in the file).

Will post the output of diagnostics shortly.

ghost commented 7 years ago

Here is the output for a test file. Notable is that we use gcc decimal, which gave me trouble when I tried to build the project using clang a while back for better errors (largely obviated now by the move to gcc7).

It still seems to not know anything about boost types, though the YCM auto-compile will suggest e.g. boost::format as a completion, it just then tells me it is a made up type and can't jump to the definition.

Also such statements like auto x = std::chrono::nanoseconds{100} are getting flagged.

2 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal|251 col 5 error| constructor cannot be redeclared 3 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal|233 col 36 error| invalid suffix 'DF' on floating constant 4 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal|316 col 47 error| unknown machine mode 'DD' 5 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal|337 col 5 error| constructor cannot be redeclared 6 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal|319 col 36 error| invalid suffix 'dd' on floating constant 7 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal|402 col 48 error| unknown machine mode 'TD' 8 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal|424 col 5 error| constructor cannot be redeclared 9 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal|405 col 37 error| invalid suffix 'DL' on floating constant 10 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal.h|127 col 22 error| invalid suffix 'DF' on floating constant 11 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal.h|131 col 26 error| invalid suffix 'DF' on floating constant 12 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal.h|145 col 22 error| invalid suffix 'DF' on floating constant 13 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal.h|149 col 26 error| invalid suffix 'DF' on floating constant 14 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal.h|163 col 22 error| invalid suffix 'DD' on floating constant 15 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal.h|167 col 26 error| invalid suffix 'DD' on floating constant 16 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal.h|181 col 22 error| invalid suffix 'DD' on floating constant 17 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal.h|185 col 26 error| invalid suffix 'DD' on floating constant 18 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal.h|199 col 22 error| invalid suffix 'DL' on floating constant 19 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/decimal/decimal.h|203 col 26 error| invalid suffix 'DL' on floating constant (FixIt available) 20 TestFile.cxx|54 col 25 error| cannot initialize a value of type 'boost::format' (aka 'int') with an lvalue of type 'const char *' 21 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/ratio|271 col 37 error| no member named 'value' in 'std::static_sign<1000000000>' 22 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/ratio|274 col 29 error| no member named 'value' in 'std::static_abs<1000000000>' 23 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/ratio|276 col 21 error| non-type template argument is not a constant expression 24 TestFile.cxx|82 col 73 error| invalid operands to binary expression ('std::chrono::_V2::system_clock::time_point' (aka 'time_point<std::chrono::_V2::system_clock, duration<long, ratio<1, 1000000000> > >') and 'std::chrono::high_resolution_clock::time_point' (aka 'time_point<std::chrono::_V2::system_clock, duration<long, ratio<1, 1000000000> > >')) 25 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/ratio|271 col 37 error| no member named 'value' in 'std::static_sign<1000>' 26 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/ratio|274 col 29 error| no member named 'value' in 'std::static_abs<1000>' 27 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/ratio|276 col 21 error| non-type template argument is not a constant expression 28 TestFile.cxx|83 col 34 error| no matching constructor for initialization of 'std::chrono::milliseconds' (aka 'duration<long, ratio<1, 1000> >') 29 TestFile.cxx|85 col 29 error| no matching constructor for initialization of 'std::chrono::milliseconds' (aka 'duration<long, ratio<1, 1000> >') 30 /scratch/build_tools/gcc/gcc-7.2/include/c++/7.2.0/chrono|426 col 11 error| no matching conversion for functional-style cast from 'long' to 'std::chrono::duration<long, std::ratio<1, 1000000000> >'

chenjie199234 commented 7 years ago

My include in my project

iostream fstream string vector

Here is the :YcmDiags

/usr/include/c++/7.2.0/cstdlib|75 col 15 error| 'stdlib.h' file not found /usr/include/c++/7.2.0/bits/std_abs.h|38 col 15 error| 'stdlib.h' file not found /usr/include/c++/7.2.0/bits/std_abs.h|52 col 11 error| no member named 'abs' in the global namespace /usr/include/c++/7.2.0/cstdlib|124 col 11 error| no member named 'div_t' in the global namespace /usr/include/c++/7.2.0/cstdlib|125 col 11 error| no member named 'ldiv_t' in the global namespace /usr/include/c++/7.2.0/cstdlib|127 col 11 error| no member named 'abort' in the global namespace /usr/include/c++/7.2.0/cstdlib|128 col 11 error| no member named 'atexit' in the global namespace /usr/include/c++/7.2.0/cstdlib|131 col 11 error| no member named 'at_quick_exit' in the global namespace /usr/include/c++/7.2.0/cstdlib|134 col 11 error| no member named 'atof' in the global namespace /usr/include/c++/7.2.0/cstdlib|135 col 11 error| no member named 'atoi' in the global namespace /usr/include/c++/7.2.0/cstdlib|136 col 11 error| no member named 'atol' in the global namespace /usr/include/c++/7.2.0/cstdlib|137 col 11 error| no member named 'bsearch' in the global namespace /usr/include/c++/7.2.0/cstdlib|138 col 11 error| no member named 'calloc' in the global namespace /usr/include/c++/7.2.0/cstdlib|139 col 11 error| no member named 'div' in the global namespace /usr/include/c++/7.2.0/cstdlib|140 col 11 error| no member named 'exit' in the global namespace /usr/include/c++/7.2.0/cstdlib|141 col 11 error| no member named 'free' in the global namespace /usr/include/c++/7.2.0/cstdlib|142 col 11 error| no member named 'getenv' in the global namespace /usr/include/c++/7.2.0/cstdlib|143 col 11 error| no member named 'labs' in the global namespace /usr/include/c++/7.2.0/cstdlib|144 col 11 error| no member named 'ldiv' in the global namespace Projects/ServerArchitecture/Common/config.h|9 col 7 error| no template named 'vector' in namespace 'std' Projects/ServerArchitecture/Common/config.h|10 col 7 error| no template named 'vector' in namespace 'std' Projects/ServerArchitecture/Common/config.h|11 col 7 error| no template named 'vector' in namespace 'std' Projects/ServerArchitecture/Common/config.h|48 col 8 error| no member named 'cerr' in namespace 'std' Projects/ServerArchitecture/Common/config.h|62 col 11 error| no member named 'cerr' in namespace 'std' Projects/ServerArchitecture/Common/config.h|73 col 10 error| no member named 'cerr' in namespace 'std' Projects/ServerArchitecture/Common/config.h|79 col 9 error| no member named 'cerr' in namespace 'std' Projects/ServerArchitecture/Common/config.h|86 col 10 error| no member named 'cerr' in namespace 'std' Projects/ServerArchitecture/Common/config.h|94 col 9 error| no member named 'cerr' in namespace 'std' Projects/ServerArchitecture/Common/config.h|99 col 9 error| no member named 'cerr' in namespace 'std' Projects/ServerArchitecture/Common/config.h|106 col 15 error| implicit instantiation of undefined template 'std::basic_fstream<char, std::char_traits >'

Here is my global extra config file

flags = [ '-Wall', '-Wextra', '-Werror', '-fexceptions', '-DNDEBUG', '-std=c++11', '-x', 'c++', '-isystem', '/usr/include', '-isystem', '/usr/local/include', '-isystem', '/usr/include/c++/7.2.0', '-isystem', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1', '-isystem', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include', ]

bstaletic commented 7 years ago

I just built gcc-7.2.0. I get proper completions with thte following extra conf:

def FlagsForFile( filename ):
  return { 'flags': [
    '-Wall',
'-Wextra',
'-Werror',
'-fexceptions',
'-DNDEBUG',
'-std=c++11',
'-x',
'c++',
'-isystem',
'/usr/include',
'-isystem',
'/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include',
'-isystem',
'/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include-fixed',
'-isystem',
 '/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/include/g++-v6',
'-isystem',
  '/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/include/g++-v6/x86_64-pc-linux-gnu',
'-isystem',
   '/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/include/g++-v6/backward',
] }

As for std::chrono completion failing, well there is an error. #include <chrono> is missing.

bstaletic commented 7 years ago

Actually, I do get no matching constructor for initialization of 'std::chrono::nanoseconds' (aka 'duration<long, ratio<1, 1000000000> >').

puremourning commented 7 years ago

Forgiv me if i am being blind, but i don’t see —gcc-toolchain in any of your flags

bstaletic commented 7 years ago

There was none. But even after adding that flag, the error remained the same.

bstaletic commented 7 years ago

For what it's worrth, I get the same behaviour on gcc 6.4.0.

puremourning commented 7 years ago

Well whatever, this is either an installation/flags issue or an incompatibility between clang and gcc. Not something we can fix?

Can someone confirm with c-index-test?

bstaletic commented 7 years ago

For me there are completions, but the diagnostics are wrong. What should I check with c-index-test and how?

puremourning commented 7 years ago

Actually you could just try compiling it with clang5 ? Do you get same diags?

bstaletic commented 7 years ago

No, compiling with clang++ 5.0 works fine.

On Sep 23, 2017 6:01 PM, "Ben Jackson" notifications@github.com wrote:

Actually you could just try compiling it with clang5 ? Do you get same diags?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Valloric/YouCompleteMe/issues/2786#issuecomment-331645544, or mute the thread https://github.com/notifications/unsubscribe-auth/AHbkU2uN7OHE3O7L9YyQFE-G5w3zZutWks5slStCgaJpZM4PfPWH .

puremourning commented 7 years ago

For info, i do not have issues with std:chrono::nanoseconds on devtoolset-6 (gcc 6.3) on centos 7 and centos 6.8

puremourning commented 7 years ago

I also cannot repro with devtoolset-7 (gcc 7.1.1) on centos 7.

So I am yet convinced that this isn't a YCM issue...

chenjie199234 commented 7 years ago

gcc 7.1 and clang 4 has no problem!Before i update to gcc 7.2 and clang 5,i was using gcc 7.1 and clang 4,everything was fine! the problem happened when update to gcc 7.2 and clang5

ghost commented 7 years ago

@puremourning @bstaletic sorry just to clarify, when you ask to compile with clang5, you mean the ycmd plugin or the project itself? Thanks

bstaletic commented 7 years ago

@arosenberger I've been doing both, i.e. compiling ycmd and a simple source file itself.

To be fair, I'm not convinced this is a bug on YCM/ycmd side of thing.

chenjie199234 commented 7 years ago

this is clang5 ' s problem! i changed clang5 to clang3.9 everything is fine now!

bstaletic commented 7 years ago

this is clang5 ' s problem!

I think we should close this as it is not a bug on our end. @puremourning, you be the judge.

puremourning commented 7 years ago

I’ve not managed to reproduce the issue. When you say you changed clang to 3.9, what exactly did you do. There really aren’t clear repro steps here, so I’m not confident we fully understand this. If clang can build your project, libclang should too. Though it sometimes needs more flags as the clang driver has more logic for finding sysroots etc.

ghost commented 7 years ago

@puremourning I still have the problem. I'm not sure what @chenjie199234 is referring to other than a lot of exclamation points. I can try again to compile the 3.9 tooling, but our project runs std=c++17 now (with some of the features in use already), so I think I will still have problems. Will try this morning and report back.

chenjie199234 commented 7 years ago

@arosenberger Im using the system libclang.

cmake -G "Unix Makefile" -DUSE_SYSTEM_LIBCLANG=ON . ~/path/to/ycm cmake --build . --target ycm_core

flags = [ '-Wall', '-Wextra', '-Werror', '-fexceptions', '-DNDEBUG', '-std=c++11', '-x', 'c++', '-isystem', '/usr/include', '-isystem', '/usr/local/include', '-isystem', '/usr/include/c++/7.2.0', ] gcc version is 7.2.0 the different is that: if the clang version is not 5.YCM has no problem! if the clang version is 5.YCM has problems!

ghost commented 7 years ago

Tried this with clang6, added --gcc-toolchain. It still can't figure out most anything related to std::chrono or using aliases. I found a blog post where the author showed how to specify a ycm extra conf file where you could add extra flags to existing compilation database flags for a file. I did that and got a couple of issues cleaned up, but this just seems like it isn't going to go away. Hopefully I will move off this ancient RH6 box in the near future.

puremourning commented 7 years ago

If it makes a difference I use YCM completely successfully with RHEL 6 literally every day. I build clang from source and like against that using a command like env EXTRA_CMAKE_ARGS=‘-DPATH_TO_LLVM_ROOT=/path/to/llvm’ ./install.py —all —system-libclang And our extra conf asks the make system for the flags for clang and adds —gcc-toolchain=/opt/RH/devtoolset-2/usr (we use devtoolset-2,but devtoolset-6 also works)

Full disclosure i also use custom builds of vim and python3. I also maintain a ycmd build against python2 on the same platform.

ghost commented 7 years ago

@puremourning yea I ran against a locally built clang 3.9 for a long time. The change to gcc7.2 and std=c++17 broke my tooling, which is what sent me on this odyssey thinking if I upgraded my local llvm/clang that I'd be back in business

puremourning commented 7 years ago

There is a possibility that clang 5 is just not compatible with gcc7.2’s standard library ?

ghost commented 7 years ago

Tried with clang 6 from trunk today. Still no joy. But yes it's possible, I haven't found many online resources talking about it yet since it's so new.

ghost commented 7 years ago

Regardless I don't think its YCM like you said, seems to be a problem with clang and gcc at this point.

puremourning commented 7 years ago

I think i told a fib. I just checked my extra conf here and we actually do ask clang for the system include paths, like this:

def LoadSystemIncludes():
    regex = re.compile(ur'(?:\#include \<...\> search starts here\:)(?P<list>.*?)(?:End of search list)', re.DOTALL)
    process = subprocess.Popen(['clang', 
                                '-v', 
                                '-E', 
                                '-x', 
                                'c++', 
                                '--gcc-toolchain=/opt/rh/devtoolset-2/root/usr',
                                '-'], 
                                stdin=subprocess.PIPE, 
                                stdout=subprocess.PIPE, 
                                stderr=subprocess.PIPE)

    process_out, process_err = process.communicate('')

    output = process_out + process_err;
    includes = [];
    for p in re.search(regex, output).group('list').split('\n'):
        p = p.strip();
        if len(p) > 0 and p.find('(framework directory)') < 0:
            includes.append(p);
    return includes;

#
# Completion doesn't work with the C++ standard library headers (from
# YouCompleteMe docs), using the following to get the system paths:
# clang -v -E -x c++ --gcc-toolchain=/opt/rh/devtoolset-2/root/usr -
#
system_includes = LoadSystemIncludes()

def FlagsForFile( filename, **kwargs ):
    flags = DoCleverThingsWithMakefile( ... )
    # ...
    local_includes += [ [ '-isystem', d ] for d in system_includes ]

    #...
    return {
      'flags': flags 
               + ['-I', os.path.dirname(filename)] 
               + local_includes,
    }
ghost commented 7 years ago

Thanks, that seemed to do the trick.

SternAndrew commented 6 years ago

I tried this solution to fix a RHEL distro and found that the [[]] in the python script wasn't quite correct. I'm putting my instructions of building along with my updated section below.


Setup the YCM C++ completion from scratch along with vim and cmake

# Use the default Python and Python development packages

# Build the current version of vim using the default python and the devtoolset-6 compiler
cd ~/vimsrc/
make clean
git pull origin master
./configure --prefix=$HOME/vim80python --enable-pythoninterp
make clean
make -j8
make install
cd ~/vim80python/

# Build the current version of cmake using the devtoolset-6 compiler
mkdir cmakesrc
cd cmakesrc
wget https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz
tar -xvzf cmake-3.10.2.tar.gz
cd cmake-3.10.2/
./bootstrap --prefix=$HOME/cmakebin
make -j8
make install

# Add the plugins for 'Valloric/YouCompleteMe' and 'rdnetto/YCM-Generator', { 'branch': 'stable'} to .vimrc
# Erase the current YCM inside your ~/.vim/bundle directory
rm -rf YouCompleteMe
# Start vim and :PluginUpdate and/or :PlugUpdate
# Installs both plugins and rebuilds the YouCompleteMe directory inside .vim/bundle

# After the plugin for YCM is installed run the default install of the C++ completer along with the node.js
completer
cd ~/.vim/bundle
cd YouCompleteMe/
./install.py --clang-completer --js-completer

# Build the completion for C++ using the explicit libclang that was built.
mkdir ~/ycm_build
cd ~/ycm_build/
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Release -DEXTERNAL_LIBCLANG_PATH=/pathtoclanglibrary/libclang.so -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
make -j8

# Startup vim after sourcing the environment
# Execute :YcmGenerateConfig within vim to build a .ycm_extra_conf.py file in your directory where your source code lives.
# Edit the .ycm_extra_conf.py file to add in the pathing that is needed
# Update .ycm_extra_conf.py with the following code to add the include pathing to the search path when doing completions
# Also update the flags variable at the top of the file to include your compilation flags that would be used for a clang build
# Also add -Ipath lines for each additional include directory that is needed to the flags lines.
# At the top of the file add import re and import subprocess since they are needed.
# Here are the replacement sections
def LoadSystemIncludes():
    regex = re.compile(ur'(?:\#include \<...\> search starts here\:)(?P<list>.*?)(?:End of search list)', re.DOTALL)
   process = subprocess.Popen(['clang',
                                '-v',
                                '-E',
                                '-x',
                                'c++',
                                '--gcc-toolchain=/opt/rh/devtoolset-6/root/usr',
                                '-'],
                                stdin=subprocess.PIPE,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)

    process_out, process_err = process.communicate('')

    output = process_out + process_err;
    includes = [];
    for p in re.search(regex, output).group('list').split('\n'):
        p = p.strip();
        if len(p) > 0 and p.find('(framework directory)') < 0:
            includes.append(p);
    return includes;

def FlagsForFile( filename, **kwargs ):
  system_includes = LoadSystemIncludes()
  local_includes = []
  for d in system_includes:
    local_includes += ['-isystem']
    local_includes += [ d ]
  print "Local includes"
  print local_includes

  if database:
    # Bear in mind that compilation_info.compiler_flags_ does NOT return a
    # python list, but a "list-like" StringVec object
    compilation_info = GetCompilationInfoForFile( filename )
    if not compilation_info:
      return None

    final_flags = MakeRelativePathsInFlagsAbsolute(
      compilation_info.compiler_flags_,
      compilation_info.compiler_working_dir_ )
  else:
    relative_to = DirectoryOfThisScript()
    final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )

  print "final_flags"
  print final_flags
  final_flags += local_includes
  print "final_flags with includes"
  print final_flags

  return {
    'flags': final_flags,
    'do_cache': True
  }