LLVM Discussion Forums

Errors building index

Hi all,
Using clangd-10 on a cross-compiled kernel with yocto I can’t figure what prevent clangd to index the sources.
Here is a snapshot of some errors I can get:

[ ERROR ] 2020-10-22T13:59:07+0200 ] …ount_vidyVHHo/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” ‘I[13:59:07.059] Updating file /home/seb/git/dn_industry_linux/drivers/net/ethernet/freescale/fec_main.c with command \n[/home/seb/git/dn_industry_linux]\naarch64-poky-linux-gcc -target aarch64-poky-linux -Wp,-MD,drivers/net/ethernet/freescale/.fec_main.o.d -nostdinc -isystem /home/seb/build/toolchains/zeus_5.4_aarch64/sysroots/x86_64-pokysdk-linux/usr/lib/aarch64-poky-linux/gcc/aarch64-poky-linux/9.2.0/include -I./arch/arm64/include -I./arch/arm64/include/generated -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -DKASAN_SHADOW_SCALE_SHIFT=3 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mgeneral-regs-only -DCONFIG_AS_LSE=1 -DCONFIG_CC_HAS_K_CONSTRAINT=1 -fno-asynchronous-unwind-tables -Wno-psabi -mabi=lp64 -DKASAN_SHADOW_SCALE_SHIFT=3 -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned --sysroot=/home/seb/build/toolchains/zeus_5.4_aarch64/sysroots/aarch64-poky-linux -mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=1152 -DKBUILD_BASENAME=“fec_main” -DKBUILD_MODNAME=“fec” -c -o drivers/net/ethernet/freescale/fec_main.o drivers/net/ethernet/freescale/fec_main.c -fsyntax-only -resource-dir=/usr/lib/llvm-10/lib/clang/10.0.0\n’
[ ERROR ] 2020-10-22T13:59:07+0200 ] …ount_vidyVHHo/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “E[13:59:07.091] Could not build a preamble for file /home/seb/git/dn_industry_linux/drivers/net/ethernet/freescale/fec_main.c\n”

Then indexing keeps failing:
[ ERROR ] 2020-10-22T13:59:07+0200 ] …ount_vidyVHHo/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “E[13:59:07.543] Indexing net/mac80211/ht.c failed: Couldn’t build compiler instance\n”
[ ERROR ] 2020-10-22T13:59:07+0200 ] …ount_vidyVHHo/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “E[13:59:07.543] Indexing kernel/locking/rtmutex.c failed: Couldn’t build compiler instance\n”
[ ERROR ] 2020-10-22T13:59:07+0200 ] …ount_vidyVHHo/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “E[13:59:07.547] Indexing kernel/sched/wait_bit.c failed: Couldn’t build compiler instance\n”
[ ERROR ] 2020-10-22T13:59:07+0200 ] …ount_vidyVHHo/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “E[13:59:07.547] Indexing drivers/input/keyboard/adc-keys.mod.c failed: Couldn’t build compiler instance\n”
[ ERROR ] 2020-10-22T13:59:07+0200 ] …ount_vidyVHHo/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “E[13:59:07.564] Indexing net/bluetooth/af_bluetooth.c failed: Couldn’t build compiler instance\n”
[ ERROR ] 2020-10-22T13:59:07+0200 ] …ount_vidyVHHo/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “E[13:59:07.568] Indexing lib/syscall.c failed: Couldn’t build compiler instance\n”
[ ERROR ] 2020-10-22T13:59:07+0200 ] …ount_vidyVHHo/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “E[13:59:07.572] Indexing net/ipv6/route.c failed: Couldn’t build compiler instance\n”
[ ERROR ] 2020-10-22T13:59:07+0200 ] …ount_vidyVHHo/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “E[13:59:07.575] Indexing fs/ext2/super.c failed: Couldn’t build compiler instance\n”
[ ERROR ] 2020-10-22T13:59:

I’m using a compile_commands.json generated using the ./scripts/gen_compile_commands.py and it seems ok, here is an entry on which indexing fails:
{
“command”: “aarch64-poky-linux-gcc -Wp,-MD,arch/arm64/kvm/.regmap.o.d -nostdinc -isystem /home/seb/build/toolchains/zeus_5.4_aarch64/sysroots/x86_64-pokysdk-linux/usr/lib/aarch64-poky-linux/gcc/aarch64-poky-linux/9.2.0/include -I./arch/arm64/include -I./arch/arm64/include/generated -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -DKASAN_SHADOW_SCALE_SHIFT=3 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mgeneral-regs-only -DCONFIG_AS_LSE=1 -DCONFIG_CC_HAS_K_CONSTRAINT=1 -fno-asynchronous-unwind-tables -Wno-psabi -mabi=lp64 -DKASAN_SHADOW_SCALE_SHIFT=3 -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned --sysroot=/home/seb/build/toolchains/zeus_5.4_aarch64/sysroots/aarch64-poky-linux -mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=1152 -I ./arch/arm64/kvm -I ./virt/kvm/arm/vgic -DKBUILD_BASENAME=’“regmap”’ -DKBUILD_MODNAME=’“kvm”’ -c -o arch/arm64/kvm/regmap.o arch/arm64/kvm/regmap.c”,
“directory”: “/home/seb/git/dn_industry_linux”,
“file”: “arch/arm64/kvm/regmap.c”
},

FYI, I use neovim with built-in LSP support. It works w/o issues in other cross-compiled projects but fails with linux kernel/yocto.

Thanks,
Seb

Could you pass --log=verbose to clangd and paste the full log in here?

Hi,
Here is the log (could not attached as new user on this forum…)
However using neovim lsp config, it seems the background indexing option is not working anymore when I added the verbose log.
local nvim_lsp = require’nvim_lsp’
nvim_lsp.clangd.setup{
cmd = {“clangd”, “–log=verbose”, “–background-index”};
}

[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “I[09:18:39.356] Enqueueing 0 commands for indexing\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “I[09:18:39.366] Updating file /home/seb/git/industry_linux/drivers/net/ethernet/freescale/fec_main.c with command inferred from drivers/net/ethernet/freescale/fec_main.c\n[/home/seb/git/dn_industry_linux]\naarch64-poky-linux-gcc -target aarch64-poky-linux -Wp,-MD,drivers/net/ethernet/freescale/.fec_main.o.d -nostdinc -isystem /home/seb/build/toolchains/zeus_5.4_aarch64/sysroots/x86_64-pokysdk-linux/usr/lib/aarch64-poky-linux/gcc/aarch64-poky-linux/9.2.0/include -I./arch/arm64/include -I./arch/arm64/include/generated -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -DKASAN_SHADOW_SCALE_SHIFT=3 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -mgeneral-regs-only -DCONFIG_AS_LSE=1 -DCONFIG_CC_HAS_K_CONSTRAINT=1 -fno-asynchronous-unwind-tables -Wno-psabi -mabi=lp64 -DKASAN_SHADOW_SCALE_SHIFT=3 -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned --sysroot=/home/seb/build/toolchains/zeus_5.4_aarch64/sysroots/aarch64-poky-linux -mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=1152 -DKBUILD_BASENAME=“fec_main” -DKBUILD_MODNAME=“fec” -c -std=gnu89 /home/seb/git/industry_linux/drivers/net/ethernet/freescale/fec_main.c -fsyntax-only -resource-dir=/usr/lib/llvm-10/lib/clang/10.0.0\nI[09:18:39.366] Couldn’t set working directory when creating compiler invocation.\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.395] Ignored diagnostic. optimization flag ‘-fmerge-constants’ is not supported\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” ‘V[09:18:39.395] Driver produced command: cc1 -cc1 -triple aarch64-poky-linux -fsyntax-only -disable-free -disable-llvm-verifier -discard-value-names -main-file-name fec_main.c -mrelocation-model static -mthread-model posix -fno-delete-null-pointer-checks -mllvm -warn-stack-size=2048 -mframe-pointer=non-leaf -relaxed-aliasing -mdisable-tail-calls -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -target-cpu generic -target-feature -fp-armv8 -target-feature -crypto -target-feature -neon -target-feature -sha2 -target-feature -aes -target-abi lp64 -fallow-half-arguments-and-returns -dwarf-column-info -fno-split-dwarf-inlining -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -nostdsysteminc -nobuiltininc -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -dependency-file drivers/net/ethernet/freescale/.fec_main.o.d -MT fec_main.o -sys-header-deps -isystem /home/seb/build/toolchains/zeus_5.4_aarch64/sysroots/x86_64-pokysdk-linux/usr/lib/aarch64-poky-linux/gcc/aarch64-poky-linux/9.2.0/include -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -I ./arch/arm64/include -I ./arch/arm64/include/generated -I ./include -I ./arch/arm64/include/uapi -I ./arch/arm64/include/generated/uapi -I ./include/uapi -I ./include/generated/uapi -D KERNEL -D KASAN_SHADOW_SCALE_SHIFT=3 -D CONFIG_AS_LSE=1 -D CONFIG_CC_HAS_K_CONSTRAINT=1 -D KASAN_SHADOW_SCALE_SHIFT=3 -D KBUILD_BASENAME=“fec_main” -D KBUILD_MODNAME=“fec” -isysroot /home/seb/build/toolchains/zeus_5.4_aarch64/sysroots/aarch64-poky-linux -fmacro-prefix-map=./= -O2 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -Wno-psabi -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -std=gnu89 -fdebug-compilation-dir /home/seb/git/industry_linux -ferror-limit 19 -fmessage-length 0 -fwrapv -stack-protector 2 -fno-signed-char -fwchar-type=short -fno-signed-wchar -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -vectorize-loops -vectorize-slp -faddrsig -x c /home/seb/git/industry_linux/drivers/net/ethernet/freescale/fec_main.c\n’
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.395] Building first preamble for /home/seb/git/industry_linux/drivers/net/ethernet/freescale/fec_main.c\nV[09:18:39.396] Ignored diagnostic. unknown warning option ‘-Wno-psabi’\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.396] Ignored diagnostic. unknown warning option ‘-Wno-frame-address’; did you mean ‘-Wno-address’?\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.397] Ignored diagnostic. unknown warning option ‘-Wno-format-truncation’\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.397] Ignored diagnostic. unknown warning option ‘-Wno-format-overflow’; did you mean ‘-Wno-shift-overflow’?\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.399] Ignored diagnostic. unknown warning option ‘-Wno-unused-but-set-variable’; did you mean ‘-Wno-unused-const-variable’?\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.400] Ignored diagnostic. unknown warning option ‘-Wno-stringop-truncation’; did you mean ‘-Wno-string-conversion’?\nV[09:18:39.401] Ignored diagnostic. unknown warning option ‘-Werror=designated-init’; did you mean ‘-Werror=deprecated-copy’?\nV[09:18:39.402] Ignored diagnostic. unknown warning option ‘-Wno-packed-not-aligned’; did you mean ‘-Wno-over-aligned’?\nI[09:18:39.402] Couldn’t set working directory when building the preamble.\nE[09:18:39.402] Could not build a preamble for file /home/seb/git/industry_linux/drivers/net/ethernet/freescale/fec_main.c\nI[09:18:39.403] Couldn’t set working directory when building the preamble.\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.403] Ignored diagnostic. unknown warning option ‘-Wno-psabi’\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.403] Ignored diagnostic. unknown warning option ‘-Wno-frame-address’; did you mean ‘-Wno-address’?\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.404] Ignored diagnostic. unknown warning option ‘-Wno-format-truncation’\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.405] Ignored diagnostic. unknown warning option ‘-Wno-format-overflow’; did you mean ‘-Wno-shift-overflow’?\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.406] Ignored diagnostic. unknown warning option ‘-Wno-unused-but-set-variable’; did you mean ‘-Wno-unused-const-variable’?\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.407] Ignored diagnostic. unknown warning option ‘-Wno-stringop-truncation’; did you mean ‘-Wno-string-conversion’?\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.408] Ignored diagnostic. unknown warning option ‘-Werror=designated-init’; did you mean ‘-Werror=deprecated-copy’?\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.409] Ignored diagnostic. unknown warning option ‘-Wno-packed-not-aligned’; did you mean ‘-Wno-over-aligned’?\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “I[09:18:39.409] --> textDocument/publishDiagnostics\n”
[ ERROR ] 2020-10-23T09:18:39+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “V[09:18:39.409] >>> {“jsonrpc”:“2.0”,“method”:“textDocument/publishDiagnostics”,“params”:{“diagnostics”:[{“code”:“drv_unknown_argument”,“message”:“Unknown argument: ‘-fno-var-tracking-assignments’”,“range”:{“end”:{“character”:0,“line”:0},“start”:{“character”:0,“line”:0}},“severity”:1,“source”:“clang”},{“code”:“drv_unknown_argument”,“message”:“Unknown argument: ‘-fconserve-stack’”,“range”:{“end”:{“character”:0,“line”:0},“start”:{“character”:0,“line”:0}},“severity”:1,“source”:“clang”},{“code”:“drv_unknown_argument”,“message”:“Unknown argument: ‘-mstack-protector-guard=sysreg’”,“range”:{“end”:{“character”:0,“line”:0},“start”:{“character”:0,“line”:0}},“severity”:1,“source”:“clang”},{“code”:“drv_unknown_argument”,“message”:“Unknown argument: ‘-mstack-protector-guard-reg=sp_el0’”,“range”:{“end”:{“character”:0,“line”:0},“start”:{“character”:0,“line”:0}},“severity”:1,“source”:“clang”},{“code”:“drv_unknown_argument”,“message”:“Unknown argument: ‘-mstack-protector-guard-offset=1152’”,“range”:{“end”:{“character”:0,“line”:0},“start”:{“character”:0,“line”:0}},“severity”:1,“source”:“clang”}],“uri”:“file:///home/seb/git/industry_linux/drivers/net/ethernet/freescale/fec_main.c”}}\n\n”
[ ERROR ] 2020-10-23T09:18:58+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” ‘V[09:18:58.841] <<< {“id”:2,“jsonrpc”:“2.0”,“method”:“shutdown”}\n\n’
[ ERROR ] 2020-10-23T09:18:58+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” ‘I[09:18:58.841] <-- shutdown(2)\nI[09:18:58.841] --> reply:shutdown(2) 0 ms\nV[09:18:58.841] >>> {“id”:2,“jsonrpc”:“2.0”,“result”:null}\n\n’
[ ERROR ] 2020-10-23T09:18:58+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” ‘V[09:18:58.842] <<< {“jsonrpc”:“2.0”,“method”:“exit”}\n\nI[09:18:58.842] <-- exit\n’
[ ERROR ] 2020-10-23T09:18:58+0200 ] …ount_viIGEyZK/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “I[09:18:58.842] LSP finished, exiting with status 0\n”

The problem seems to be originating from:

I[09:18:39.402] Couldn’t set working directory when building the preamble.
E[09:18:39.402] Could not build a preamble for file /home/seb/git/industry_linux/drivers/net/ethernet/freescale/fec_main.c
I[09:18:39.403] Couldn’t set working directory when building the preamble.

Are you using a compile_commands.json that was generated for your project, on that specific computer? Because compile_commands.json is path sensitive. So if you generate it for a check-out of a project on a separate directory, or different machine, they might not work.
Could you attach some entries from your compile_commands.json? Specifically the one for /home/seb/git/industry_linux/drivers/net/ethernet/freescale/fec_main.c would be even better.

The working directory mentioned in the compile_commands.json is likely /home/seb/git/dn_industry_linux whereas project root is at /home/seb/git/industry_linux, hence the discrepency.

Regarding the “I[09:18:39.356] Enqueueing 0 commands for indexing\n”, I need full logs, these are missing lots of important context from the top of the log file (you can still drop the one log line for textDocument/didOpen, which contains the source code information). In addition to that it would also be great if you can tell how the project layout looks like. Specifically the directories you have a compile_flags/compile_commands.

Hi,

Sorry the previous logs were not meaningful, I forgot the re-generate the kernel build and I run the kernel scripts on a wrongly configured build. That’s why the indexer wasn’t working anymore.

Here are cleaner logs.
Top

[ ERROR ] 2020-10-23T13:53:24+0200 ] …ount_viTTkW9A/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “I[13:53:24.079] clangd version 10.0.0-4ubuntu1 \nI[13:53:24.079] PID: 122232\nI[13:53:24.079] Working directory: /home/seb/git/industry_linux\nI[13:53:24.079] argv[0]: clangd\nI[13:53:24.079] argv[1]: --log=verbose\nI[13:53:24.079] argv[2]: --background-index\nI[13:53:24.079] argv[3]: --query-driver=/home/seb/build/toolchains/**/bin/arm-none-eabi-, /home/seb/build/toolchains/_aarch64/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-*\nI[13:53:24.079] Starting LSP over stdin/stdout\n”
[ ERROR ] 2020-10-23T13:53:24+0200 ] …ount_viTTkW9A/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” ‘V[13:53:24.084] <<< {“id”:1,“jsonrpc”:“2.0”,“method”:“initialize”,“params”:{“capabilities”:{“offsetEncoding”:[“utf-8”,“utf-16”],“textDocument”:{“completion”:{“editsNearCursor”:true}},“workspace”:{“configuration”:true}},“initializationOptions”:{},“processId”:122176,“rootPath”:"/home/seb/git/industry_linux",“rootUri”:“file:///home/seb/git/industry_linux”,“trace”:“off”}}\n\n’
[ ERROR ] 2020-10-23T13:53:24+0200 ] …ount_viTTkW9A/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” “I[13:53:24.084] <-- initialize(1)\n”
[ ERROR ] 2020-10-23T13:53:24+0200 ] …ount_viTTkW9A/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” ‘I[13:53:24.085] --> reply:initialize(1) 1 ms\nV[13:53:24.085] >>> {“id”:1,“jsonrpc”:“2.0”,“result”:{“capabilities”:{“codeActionProvider”:true,“completionProvider”:{“resolveProvider”:false,“triggerCharacters”:[".",">",":"]},“declarationProvider”:true,“definitionProvider”:true,“documentFormattingProvider”:true,“documentHighlightProvider”:true,“documentLinkProvider”:{“resolveProvider”:false},“documentOnTypeFormattingProvider”:{“firstTriggerCharacter”:"\n",“moreTriggerCharacter”:[]},“documentRangeFormattingProvider”:true,“documentSymbolProvider”:true,“executeCommandProvider”:{“commands”:[“clangd.applyFix”,“clangd.applyTweak”]},“hoverProvider”:true,“referencesProvider”:true,“renameProvider”:true,“selectionRangeProvider”:true,“signatureHelpProvider”:{“triggerCharacters”:["(",","]},“textDocumentSync”:2,“typeHierarchyProvider”:true,“workspaceSymbolProvider”:true},“offsetEncoding”:“utf-8”}}\n\n’

[ ERROR ] 2020-10-23T13:53:24+0200 ] …ount_viTTkW9A/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:428 ] “rpc” “clangd” “stderr” 'V[13:53:24.152] System include extraction: not whitelisted driver /home/seb/git/industry_linux/aarch64-poky-linux-gcc

This doesn’t seem good, this is not the path of the toolchain. The toolchain is in /home/seb/build/toolchains/*_aarch64/ which is in the PATH variable where I run neovim.
The compile_commands.json doesn’t contain the full toolchain path as the compiler is called w/o any path.

After that the indexer scan keeps failing with messages like:
[13:53:24.154] Failed to load shard: /home/seb/git/industry_linux/drivers/acpi/container.c

Thanks,
Seb

Here is the additional information you asked:

Compile command for fec_main.c
  {
    "command": "aarch64-poky-linux-gcc -Wp,-MD,drivers/net/ethernet/freescale/.fec_main.o.d  -nostdinc -isystem /home/seb/build/toolchains/zeus_5.4_aarch64/sysroots/x86_64-pokysdk-linux/usr/lib/aarch64-poky-linux/gcc/aarch64-poky-linux/9.2.0/include -I./arch/arm64/include -I./arch/arm64/include/generated  -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -DKASAN_SHADOW_SCALE_SHIFT=3 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mgeneral-regs-only -DCONFIG_AS_LSE=1 -DCONFIG_CC_HAS_K_CONSTRAINT=1 -fno-asynchronous-unwind-tables -Wno-psabi -mabi=lp64 -DKASAN_SHADOW_SCALE_SHIFT=3 -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned --sysroot=/home/seb/build/toolchains/zeus_5.4_aarch64/sysroots/aarch64-poky-linux -mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=1152    -DKBUILD_BASENAME='\"fec_main\"' -DKBUILD_MODNAME='\"fec\"' -c -o drivers/net/ethernet/freescale/fec_main.o drivers/net/ethernet/freescale/fec_main.c", 
    "directory": "/home/seb/git/industry_linux", 
    "file": "drivers/net/ethernet/freescale/fec_main.c"
  }, 

The toolchain is located in /home/seb/build/toolchains/zeus_5.4_aarch64/sysroots/aarch64-poky-linux
The toolchain environment script, sets up the PATH with the toolchain location, and also the compiler environment variables (CC, CXX, etc...)

The sources are located in /home/seb/git/industry_linux where the compile_commands.json

Also if that can help, the project has some host code compiled with host gcc and these files were correctly indexed:
Compile command for one of these file:
  {
    "command": "gcc -Wp,-MD,scripts/dtc/.dtc.o.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89     -I ./scripts/dtc/libfdt -DNO_YAML  -c -o scripts/dtc/dtc.o scripts/dtc/dtc.c", 
    "directory": "/home/seb/git/industry_linux", 
    "file": "scripts/dtc/dtc.c"
  }, 

Also if that may help as well:
LSP client: NVIM v0.5.0-767-g0f590ae2a
Clangd version: 10.0.0-4ubuntu1

Thanks !

Hi,

For now I switched to ccls and had no issue with various cross-compilation toolchains…
In addition the need to set query-driver is not very practical when using many different toolchains.
However, I’d be happy to help in debugging the problems I’m facing here.