abingham / emacs-ycmd

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

emacs ycmd fails at C/C++ completion #166

Closed naseer closed 9 years ago

naseer commented 9 years ago

Error in *Messages*

REQUEST [error] Error (error) while connecting to http://127.0.0.1:53686/completions.
Exception while fetching candidates: No completions found; errors in the file?

*ycmd-server* buffer

2015-03-27 15:24:30,892 - INFO - Received completion request
 2015-03-27 15:24:30,892 - DEBUG - Using filetype completion: False
 2015-03-27 15:24:31,222 - INFO - Received completion request
 2015-03-27 15:24:31,223 - DEBUG - Using filetype completion: False
 2015-03-27 15:24:31,251 - INFO - Received completion request
 2015-03-27 15:24:31,253 - DEBUG - Using filetype completion: False
 2015-03-27 15:24:32,034 - INFO - Received completion request
 2015-03-27 15:24:32,035 - DEBUG - Using filetype completion: True
 libclang: crash detected during parsing: {
   'source_filename' : '/local/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display/libhwcomposer/hwc.cpp'
   'command_line_args' : ['-Wall', '-Wextra', '-Wc++98-compat', '-Wno-long-long', '-Wno-variadic-macros', '-fexceptions', '-fno-rtti', '-fno-strict-aliasing', '-fPIE', '-fpic', '-DNDEBUG', '-DANDROID', '-DUSE_CLANG_COMPLETER', '-std=c++11'\
 , '-x c++', '-I/local/mnt/workspace/naseer/LA.BF64.1/ .', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libgralloc', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/l\
 iboverlay', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libhwcomposer', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libcopybit', '-I/local/mnt/workspace/naseer/\
 LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libqdutils', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libexternal', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/d\
 isplay/libqservice', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libvirtual', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libhdmi', '-isystem/local/mnt/workspac\
 e/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/system/core/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/libhardware/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/lib\
 hardware_legacy/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/ril/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/libnativehelper/include', '-isystem/local/mnt/workspace\
 /naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/arch-arm/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/k\
 ernel/common', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/kernel/arch-arm', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libstdc/include', '-isystem/local/mnt/workspace/nase\
 er/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libstdc/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libm/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libm/include/arm'\
 , '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libthread_db/include/', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/frameworks/native/include', '-isystem/local/mnt/workspace/naseer/LA.BF6\
 4.1/ $ANDROID_BUILD_TOP/frameworks/native/opengl/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/frameworks/av/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/frameworks/base/inclu\
 de', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/out/target/product/$TARGET_PRODUCT/obj/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/out/target/product/$TARGET_PRODUCT/obj/KERNEL_OBJ/\
 usr/include', '-isystem', '/local/mnt/workspace/naseer/installs/ycmd/ycmd/../clang_includes'],
   'unsaved_files' : [('/local/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display/libhwcomposer/hwc.cpp', '...', 37243)],
   'options' : 143,
 }
 Traceback (most recent call last):
   File "/local/mnt/workspace/naseer/installs/ycmd/third_party/bottle/bottle.py", line 861, in _handle
     return route.call(**args)
   File "/local/mnt/workspace/naseer/installs/ycmd/third_party/bottle/bottle.py", line 1734, in wrapper
     rv = callback(*a, **ka)
   File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/watchdog_plugin.py", line 100, in wrapper
     return callback( *args, **kwargs )
   File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/hmac_plugin.py", line 54, in wrapper
     body = callback( *args, **kwargs )
   File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/handlers.py", line 100, in GetCompletions
     completer.ComputeCandidates( request_data ),
   File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/completers/completer.py", line 158, in ComputeCandidates
     candidates = self._GetCandidatesFromSubclass( request_data )
   File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/completers/completer.py", line 173, in _GetCandidatesFromSubclass
     raw_completions = self.ComputeCandidatesInner( request_data )
   File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 101, in ComputeCandidatesInner
     raise RuntimeError( NO_COMPLETIONS_MESSAGE )
 RuntimeError: No completions found; errors in the file?
 2015-03-27 15:24:34,267 - INFO - Received event notification
 2015-03-27 15:24:34,268 - DEBUG - Event name: FileReadyToParse
 2015-03-27 15:24:34,268 - INFO - Adding buffer identifiers for file: /local/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display/libhwcomposer/hwc.cpp
 libclang: crash detected during parsing: {
   'source_filename' : '/local/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display/libhwcomposer/hwc.cpp'
   'command_line_args' : ['-Wall', '-Wextra', '-Wc++98-compat', '-Wno-long-long', '-Wno-variadic-macros', '-fexceptions', '-fno-rtti', '-fno-strict-aliasing', '-fPIE', '-fpic', '-DNDEBUG', '-DANDROID', '-DUSE_CLANG_COMPLETER', '-std=c++11'\
 , '-x c++', '-I/local/mnt/workspace/naseer/LA.BF64.1/ .', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libgralloc', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/l\
 iboverlay', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libhwcomposer', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libcopybit', '-I/local/mnt/workspace/naseer/\
 LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libqdutils', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libexternal', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/d\
 isplay/libqservice', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libvirtual', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libhdmi', '-isystem/local/mnt/workspac\
 e/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/system/core/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/libhardware/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/lib\
 hardware_legacy/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/ril/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/libnativehelper/include', '-isystem/local/mnt/workspace\
 /naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/arch-arm/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/k\
 ernel/common', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/kernel/arch-arm', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libstdc/include', '-isystem/local/mnt/workspace/nase\
 er/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libstdc/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libm/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libm/include/arm'\
 , '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libthread_db/include/', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/frameworks/native/include', '-isystem/local/mnt/workspace/naseer/LA.BF6\
 4.1/ $ANDROID_BUILD_TOP/frameworks/native/opengl/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/frameworks/av/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/frameworks/base/inclu\
 de', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/out/target/product/$TARGET_PRODUCT/obj/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/out/target/product/$TARGET_PRODUCT/obj/KERNEL_OBJ/\
 usr/include', '-isystem', '/local/mnt/workspace/naseer/installs/ycmd/ycmd/../clang_includes'],
   'unsaved_files' : [('/local/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display/libhwcomposer/hwc.cpp', '...', 37243)],
   'options' : 143,
 }
abingham commented 9 years ago

Just so I remember this in the future: there's very little we can do about libclang crashing, but we might be able to give the user feedback when something like this happens. Maybe even just directing them to the *Messages* buffer would be a good start.

naseer commented 9 years ago

@abingham I think this is an emacs-ycmd issue - comparing the flags below, it appears that the environment variable is not correctly expanded from python in emacs and the paths sent to clang are incorrect

Flags from vim

-- Flags for /local2/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display/libhwcomposer/hwc.cpp loaded from /usr2/naseer/bin/ycm_extra_conf.py:
-- ['-Wall', '-Wextra', '-Wc++98-compat', '-Wno-long-long', '-Wno-variadic-macros', '-fexceptions', '-fno-rtti', '-fno-strict-aliasing', '-fPIE', '-fpic', '-DNDEBUG', '-DANDROID', '-DUSE_CLANG_COMPLETER', '-std=c++11', '-x', 'c++', '-I', '/
usr2/naseer/bin/.', '-I', '/local2/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display//libgralloc', '-I', '/local2/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display//liboverlay', '-I', '/local2/mnt/workspace/naseer/LA.BF64.1/hardware/q
com/display//libhwcomposer', '-I', '/local2/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display//libcopybit', '-I', '/local2/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display//libqdutils', '-I', '/local2/mnt/workspace/naseer/LA.BF64.1/h
ardware/qcom/display//libexternal', '-I', '/local2/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display//libqservice', '-I', '/local2/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display//libvirtual', '-I', '/local2/mnt/workspace/naseer/LA.
BF64.1/hardware/qcom/display//libhdmi', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/system/core/include', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/hardware/libhardware/include', '-isystem', '/local2/mnt/workspace/naseer/L
A.BF64.1/hardware/libhardware_legacy/include', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/hardware/ril/include', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/libnativehelper/include', '-isystem', '/local2/mnt/workspace/nasee
r/LA.BF64.1/bionic/libc/arch-arm/include', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/bionic/libc/include', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/bionic/libc/kernel/common', '-isystem', '/local2/mnt/workspace/naseer/L
A.BF64.1/bionic/libc/kernel/arch-arm', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/bionic/libstdc++/include', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/bionic/libstdc++/include', '-isystem', '/local2/mnt/workspace/naseer/L
A.BF64.1/bionic/libm/include', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/bionic/libm/include/arm', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/bionic/libthread_db/include/', '-isystem', '/local2/mnt/workspace/naseer/LA.BF6
4.1/frameworks/native/include', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/frameworks/native/opengl/include', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/frameworks/av/include', '-isystem', '/local2/mnt/workspace/naseer/LA.
BF64.1/frameworks/base/include', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/out/target/product/msm8994/obj/include', '-isystem', '/local2/mnt/workspace/naseer/LA.BF64.1/out/target/product/msm8994/obj/KERNEL_OBJ/usr/include', '-isys
tem', '/usr2/naseer/dotfiles/vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../clang_includes']

Flags from emacs

libclang: crash detected during parsing: {                                                                                                                                                                                                     
   'source_filename' : '/local/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display/libhwcomposer/hwc.cpp'                                                                                                                                      
   'command_line_args' : ['-Wall', '-Wextra', '-Wc++98-compat', '-Wno-long-long', '-Wno-variadic-macros', '-fexceptions', '-fno-rtti', '-fno-strict-aliasing', '-fPIE', '-fpic', '-DNDEBUG', '-DANDROID', '-DUSE_CLANG_COMPLETER', '-std=c++11'\
 , '-x c++', '-I/local/mnt/workspace/naseer/LA.BF64.1/ .', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libgralloc', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/l\
 iboverlay', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libhwcomposer', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libcopybit', '-I/local/mnt/workspace/naseer/\
 LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libqdutils', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libexternal', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/d\
 isplay/libqservice', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libvirtual', '-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libhdmi', '-isystem/local/mnt/workspac\
 e/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/system/core/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/libhardware/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/lib\
 hardware_legacy/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/ril/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/libnativehelper/include', '-isystem/local/mnt/workspace\
 /naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/arch-arm/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/k\
 ernel/common', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libc/kernel/arch-arm', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libstdc/include', '-isystem/local/mnt/workspace/nase\
 er/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libstdc/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libm/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libm/include/arm'\
 , '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/bionic/libthread_db/include/', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/frameworks/native/include', '-isystem/local/mnt/workspace/naseer/LA.BF6\
 4.1/ $ANDROID_BUILD_TOP/frameworks/native/opengl/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/frameworks/av/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/frameworks/base/inclu\
 de', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/out/target/product/$TARGET_PRODUCT/obj/include', '-isystem/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/out/target/product/$TARGET_PRODUCT/obj/KERNEL_OBJ/\
 usr/include', '-isystem', '/local/mnt/workspace/naseer/installs/ycmd/ycmd/../clang_includes'],                                                                                                                                                 
   'unsaved_files' : [('/local/mnt/workspace/naseer/LA.BF64.1/hardware/qcom/display/libhwcomposer/hwc.cpp', '...', 37233)],                                                                                                                     
   'options' : 143,                                                                                                                                                                                                                             
 }     
naseer commented 9 years ago

My ycm_extra_conf.py

flags = [                                                                        
'-Wall',                                                                         
'-Wextra',                                                                       
'-Wc++98-compat',                                                                
'-Wno-long-long',                                                                
'-Wno-variadic-macros',                                                          
'-fexceptions',                                                                  
'-fno-rtti',                                                                     
'-fno-strict-aliasing',                                                          
'-fPIE',                                                                         
'-fpic',                                                                         
'-DNDEBUG',                                                                      
'-DANDROID',                                                                     
#'-march=armv7-a',                                                               
'-DUSE_CLANG_COMPLETER',                                                         
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which   
# language to use when compiling headers. So it will guess. Badly. So C++        
# headers will be compiled as C headers. You don't want that so ALWAYS specify   
# a "-std=<something>".                                                          
# For a C project, you would set this to something like 'c99' instead of         
# 'c++11'.                                                                       
'-std=c++11',                                                                    
# ...and the same thing goes for the magic -x option which specifies the         
# language that the files to be compiled are written in. This is mostly          
# relevant for c++ headers.                                                      
# For a C project, you would set this to 'c' instead of 'c++'.                   
'-x', 'c++',                                                                     
'-I', '.'                                                                        
]                                                                                

if (os.getenv('ANDROID_BUILD_TOP')):                                             
    hqd_path = '/hardware/qcom/display/'                                                              
    print hqd_path                                                               
    androidflags = [                                                             
    '-I', os.getenv('ANDROID_BUILD_TOP') + hqd_path + '/libgralloc',             
    '-I', os.getenv('ANDROID_BUILD_TOP') + hqd_path + '/liboverlay',             
    '-I', os.getenv('ANDROID_BUILD_TOP') + hqd_path + '/libhwcomposer',          
    '-I', os.getenv('ANDROID_BUILD_TOP') + hqd_path + '/libcopybit',             
    '-I', os.getenv('ANDROID_BUILD_TOP') + hqd_path + '/libqdutils',             
    '-I', os.getenv('ANDROID_BUILD_TOP') + hqd_path + '/libexternal',            
    '-I', os.getenv('ANDROID_BUILD_TOP') + hqd_path + '/libqservice',            
    '-I', os.getenv('ANDROID_BUILD_TOP') + hqd_path + '/libvirtual',             
    '-I', os.getenv('ANDROID_BUILD_TOP') + hqd_path + '/libhdmi',                
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/system/core/include',         
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/hardware/libhardware/include',
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/hardware/libhardware_legacy/include',
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/hardware/ril/include',        
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/libnativehelper/include',     
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/bionic/libc/arch-arm/include',
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/bionic/libc/include',         
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/bionic/libc/kernel/common',   
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/bionic/libc/kernel/arch-arm', 
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/bionic/libstdc++/include',    
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/bionic/libstdc++/include',    
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/bionic/libm/include',         
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/bionic/libm/include/arm',     
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/bionic/libthread_db/include/',
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/frameworks/native/include',   
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/frameworks/native/opengl/include',
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/frameworks/av/include',       
    '-isystem', os.getenv('ANDROID_BUILD_TOP') + '/frameworks/base/include',     
    '-isystem', os.getenv('OUT') + '/obj/include',                               
    '-isystem', os.getenv('OUT') + '/obj/KERNEL_OBJ/usr/include',                
    ]                                                                            
    flags = flags + androidflags
naseer commented 9 years ago

CC @Valloric for info

abingham commented 9 years ago

I'm not sure how emacs-ycmd (or emacs at all) could be responsible for expanding environment variables in Python. All that emacs-ycmd does is tell ycmd where the extra-config is and that it should be loaded. After that it's up to ycmd to "do the right thing" with the values in there.

It might be that ANDROID_BUILD_TOP isn't defined correctly in the emacs environment. If you use M-x getenv, what value (if any) do you see for ANDRDOID_BUILD_TOP? It seems like it must be set to something, otherwise the path in your ycm_extra_conf.py that sets all of the androidflags wouldn't get followed. Based on the error message from libclang, it looks like it is being followed.

Have you tried reconstructing the problematic command line manually to see if it produces a crash?

abingham commented 9 years ago

I have to admit that I'm pretty baffled by the libclang output. For example, it includes things like:

-I/local/mnt/workspace/naseer/LA.BF64.1/ $ANDROID_BUILD_TOP/hardware/qcom/display/libgralloc

I don't understand why $ANDROID_BUILD_TOP is in there, as opposed to the expansion of that variable. You're explicitly calling os.getenv() which ought to expand it.

There are a few things you might try that would clean up (what are to me) some oddities in your extra config. First, use os.path.join() rather than string addition to construct paths. Second, I think you want -I/path/elements/ to be a single value rather than having -I be a separate flag from its associated path. I don't expect that these changes will fix the problem, but they'll certainly remove some noise from the system.

naseer commented 9 years ago

@abingham - I was just trying to follow the convention here - https://github.com/Valloric/ycmd/blob/master/examples/.ycm_extra_conf.py#L44-L52

I agree with you now that this is not emacs specific - but I still don't know how it works with vim. I will try changing the paths as you suggest. One issue I faced yesterday was that changing the ycm_extra_conf.py didn't take any effect on the current project - I'm not sure if there is a cached version somewhere that it reads from.

naseer commented 9 years ago

Using os.path.join seems to have resolved the clang crash - Thanks for the suggestion :+1:

Now I'm hitting this error in some completions (subclasses) - again, this works fine in vim :(

Traceback (most recent call last):                                                                                                                                                                                                              
  File "/local/mnt/workspace/naseer/installs/ycmd/third_party/bottle/bottle.py", line 861, in _handle                                                                                                                                           
    return route.call(**args)                                                                                                                                                                                                                   
  File "/local/mnt/workspace/naseer/installs/ycmd/third_party/bottle/bottle.py", line 1734, in wrapper                                                                                                                                          
    rv = callback(*a, **ka)                                                                                                                                                                                                                     
  File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/watchdog_plugin.py", line 100, in wrapper                                                                                                                                        
    return callback( *args, **kwargs )                                                                                                                                                                                                          
  File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/hmac_plugin.py", line 54, in wrapper                                                                                                                                             
    body = callback( *args, **kwargs )                                                                                                                                                                                                          
  File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/handlers.py", line 100, in GetCompletions                                                                                                                                        
    completer.ComputeCandidates( request_data ),                                                                                                                                                                                                
  File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/completers/completer.py", line 158, in ComputeCandidates                                                                                                                         
    candidates = self._GetCandidatesFromSubclass( request_data )                                                                                                                                                                                
  File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/completers/completer.py", line 173, in _GetCandidatesFromSubclass                                                                                                                
    raw_completions = self.ComputeCandidatesInner( request_data )                                                                                                                                                                               
  File "/local/mnt/workspace/naseer/installs/ycmd/ycmd/../ycmd/completers/cpp/clang_completer.py", line 101, in ComputeCandidatesInner                                                                                                          
    raise RuntimeError( NO_COMPLETIONS_MESSAGE )                                                                                                    
naseer commented 9 years ago

The above issue happens only with spacemacs, not with a clean emacs configuration, will debug further in spacemacs, I guess this bug can be considered closed except for showing the right error message.

abingham commented 9 years ago

OK, I'll close this and reference it in a new defect specifically focused on improved error messages. Thanks for working with me on this, and I hope we get everything resolved with spacemacs!