abingham / emacs-ycmd

Emacs client for ycmd, the code completion system.
MIT License
384 stars 46 forks source link

completion problem, which way to go? #468

Closed Mafeuser closed 6 years ago

Mafeuser commented 6 years ago

Hi I'm trying to run ycmd in fairly large project. Unfortunatelly no luck so far.

I'm running centos7 with llvm.6.0 (compilation from scratch). ycmd (github) emacs-ycmd (elpa repo) are the latest ones. I've built ycmd BOTH with AND without "--system-libclang". I'm also running gcc.7.2 from devtoolset-7.

When I'm in some class function member, and type 'this->' I get no completions, but instead in ycmd-server buffer I get:

RuntimeError: No completions found; errors in the file?

To diagnose the problem I just do the following:

bash$ clang++ --gcc-toolchain=/opt/rh/devtoolset-7/root/ -fsyntax-only <here_copy_of_all_the_flags_from_ycmd-show-debug-info_command_for_my_source_buffer> path/to/my/source/buffer.cpp
In file included from path/to/my/srource/buffer.cpp:18:                                                                                                                                                                                                                                                                                                             
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/unordered_map:41:                                                                                                                    
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/tuple:39:                                                                                                                            
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/array:39:                                                                                                                            
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/stdexcept:39:                                                                                                                        
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/string:52:                                                                                                                           
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/basic_string.h:6159:                                                                                                            
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/ext/string_conversions.h:41:                                                                                                         
/opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/cstdlib:75:15: fatal error: 'stdlib.h' file not found                                                                                                      
#include_next <stdlib.h>

BUT, when I remove the following from :

-isystem/usr/include

then the above error is REPLACED with series of other 20 errors, that look similar to the following:

/opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/cstdint:48:11: error: no member named 'int8_t' in the global namespace; did you mean 'wint_t'?
/opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/cstdint:53:11: error: no member named 'int_fast8_t' in the global namespace 

-isystem/usr/include flag comes from well known ycmd_global_conf.py script, or rather as a path within the result of "clang -v -E -x c++ - -stdlib=libc++" command

AS NEXT STEP, when I remove the following from :

-resource-dir=/home/user/ycmd/ycmd/../clang_includes

all the errors DISAPPEAR

The line above IMO is added by ycmd on its own.

I'm completely stuck, don't know which way to go.

please help!!!

Mafeuser commented 6 years ago

I've narrowed down the problem to some simple C++14 class. Here it is:

#include <unordered_map>                                                                                                                                                                                                                     

class Human                                                                                                                                                                                                                                  
{                                                                                                                                                                                                                                            
  public:                                                                                                                                                                                                                                    
    void fun();                                                                                                                                                                                                                              
};                                                                                                                                                                                                                                           

void Human::fun()                                                                                                                                                                                                                            
{                                                                                                                                                                                                                                            

}                                                                                                                                                                                                                                            

int main(int argc, char *argv[])                                                                                                                                                                                                             
{                                                                                                                                                                                                                                            

  return 0;                                                                                                                                                                                                                                  
}

flags from compile_commands.json for this file look like following:

    {                                                                                                                                                                                                                                        
        "arguments": [                                                                                                                                                                                                                       
            "c++",                                                                                                                                                                                                                           
            "-c",                                                                                                                                                                                                                            
            "-pthread",                                                                                                                                                                                                                      
            "-Wpedantic",                                                                                                                                                                                                                    
            "-Wall",                                                                                                                                                                                                                         
            "-O0",                                                                                                                                                                                                                           
            "-g",                                                                                                                                                                                                                            
            "-std=c++14",                                                                                                                                                                                                                    
            "-o",                                                                                                                                                                                                                            
            "14/p1.unordered",                                                                                                                                                                                                               
            "14/p1.unordered.cpp"                                                                                                                                                                                                            
        ],                                                                                                                                                                                                                                   
        "directory": "/home/user/git/CXX",                                                                                                                                                                                     
        "file": "14/p1.unordered.cpp"                                                                                                                                                                                                        
    },

thus 'M-x ycmd-show-debug-info' flags are:

"[u'clang++', u'-x', u'c++', u'-pthread', u'-Wpedantic', u'-Wall', u'-O0', u'-g', u'-std=c++14', u'-isystem/usr/local/include', u'-isystem/usr/local/ashare/llvm/llvm-6.0.0.cslux/lib64/clang/6.0.0/include', u'-isystem/usr/in
clude', u'-fspell-checking', u'-resource-dir=/home/user/ycmd/ycmd/../clang_includes', u'-fspell-checking']"

compilation brings the same problem (--gcc-toolchain=/opt/rh/devtoolset-7/root/ flag added by me (without it the problem remains, but then gcc.6.3.1 is chosen and I wanted to avoid it)):

$ clang++ --gcc-toolchain=/opt/rh/devtoolset-7/root/ -x c++ -pthread -Wpedantic -Wall -O0 -g -std=c++14 -isystem/usr/local/include -isystem/usr/local/ashare/llvm/llvm-6.0.0.cslux/lib64/clang/6.0.0/include -isystem\
/usr/include -fspell-checking -resource-dir=/home/user/ycmd/ycmd/../clang_includes -fspell-checking p1.unordered.cpp                                                                                                                         
In file included from p1.unordered.cpp:1:                                                                                                                                                                                                    
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/unordered_map:41:                                                                                                                    
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/tuple:39:                                                                                                                            
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/array:39:                                                                                                                            
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/stdexcept:39:                                                                                                                        
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/string:52:                                                                                                                           
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/basic_string.h:6159:                                                                                                            
In file included from /opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/ext/string_conversions.h:41:                                                                                                         
/opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/cstdlib:75:15: fatal error: 'stdlib.h' file not found                                                                                                      
#include_next <stdlib.h>                                                                                                                                                                                                                     
              ^~~~~~~~~~                                                                                                                                                                                                                     
1 error generated. 
Mafeuser commented 6 years ago

I've finally removed -resource-dir by modifying ycmd instead. Anyway, the problem seems to be related to ycmd, not emacs-ycmd, so IMO can be closed.

By the way, thank You very much for providing ycmd to emacs

abingham commented 6 years ago

OK, I'm glad you got this sorted out, and sorry I didn't respond earlier. I'm traveling right now and don't have much time to work on this stuff right now.