Open lukash opened 1 week ago
Turns out the clangd wrapper script:
$ cat /nix/store/0vwmhvjdkli5jz8aygdb6psn9nar660h-clang-tools-18.1.8/bin/clangd
#!/nix/store/1xhds5s320nfp2022yjah1h7dpv8qqns-bash-5.2p32/bin/sh
buildcpath() {
local path after
while (( $# )); do
case $1 in
-isystem)
shift
path=$path${path:+':'}$1
;;
-idirafter)
shift
after=$after${after:+':'}$1
;;
esac
shift
done
echo $path${after:+':'}$after
}
export CPATH=${CPATH}${CPATH:+':'}$(buildcpath ${NIX_CFLAGS_COMPILE} \
$(</nix/store/qg9s4a1473skkrsrh1nykfvxm6w5p23d-clang-wrapper-18.1.8/nix-support/libc-cflags)):/nix/store/qg9s4a1473skkrsrh1nykfvxm6w5p23d-clang-wrapper-18.1.8/resource-root/include
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}${CPLUS_INCLUDE_PATH:+':'}$(buildcpath ${NIX_CFLAGS_COMPILE} \
$(</nix/store/qg9s4a1473skkrsrh1nykfvxm6w5p23d-clang-wrapper-18.1.8/nix-support/libcxx-cxxflags) \
$(</nix/store/qg9s4a1473skkrsrh1nykfvxm6w5p23d-clang-wrapper-18.1.8/nix-support/libc-cflags)):/nix/store/qg9s4a1473skkrsrh1nykfvxm6w5p23d-clang-wrapper-18.1.8/resource-root/include
exec -a "$0" /nix/store/maa8li4ybxv6hb2k23n4akqdk609fh1r-clang-18.1.8/bin/$(basename $0) "$@"
Adds include paths to clangd
via environmental variables (CPATH
and CPLUS_INCLUDE_PATH
). These include paths are unwanted for ARM compilation and break clangd
, with wrong include paths the language server doesn't work properly.
Have you tried pkgsCross.arm-embedded.buildPackages.clang-tools
Fails to compile:
error: builder for '/nix/store/b90h9vb6hlhfx1sgpwzshq1l8sb4dxvj-compiler-rt-libc-arm-none-eabi-17.0.6.drv' failed with exit code 1;
last 10 log lines:
> In file included from /build/compiler-rt-src-17.0.6/compiler-rt/lib/builtins/arm/sync_fetch_and_max_4.S:14:
> /build/compiler-rt-src-17.0.6/compiler-rt/lib/builtins/arm/sync-ops.h:22:2: error: #error DMB is only supported on ARMv6+
> 22 | #error DMB is only supported on ARMv6+
> | ^~~~~
> [121/163] Building C object lib/builtins/CMakeFiles/clang_rt.builtins-arm.dir/truncdfhf2.c.obj
> [122/163] Building C object lib/builtins/CMakeFiles/clang_rt.builtins-arm.dir/clear_cache.c.obj
> [123/163] Building C object lib/builtins/CMakeFiles/clang_rt.builtins-arm.dir/udivdi3.c.obj
> [124/163] Building C object lib/builtins/CMakeFiles/clang_rt.builtins-arm.dir/umoddi3.c.obj
> [125/163] Building C object lib/builtins/CMakeFiles/clang_rt.builtins-arm.dir/udivmoddi4.c.obj
> ninja: build stopped: subcommand failed.
For full logs, run 'nix log /nix/store/b90h9vb6hlhfx1sgpwzshq1l8sb4dxvj-compiler-rt-libc-arm-none-eabi-17.0.6.drv'.
error: 1 dependencies of derivation '/nix/store/84m5zmi8mbky1w820br75qiar08ni6b1-arm-none-eabi-clang-wrapper-17.0.6.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mnpp04ng9sh54hlkgyzabyv4hfd78i9b-clang-tools-17.0.6.drv' failed to build
error: 1 dependencies of derivation '/nix/store/3614i6ylbwdp6pzcrpj23wppxbrj9ak2-nix-shell-env.drv' failed to build
direnv: nix-direnv: Evaluating current devShell failed. Falling back to previous environment!
direnv: using flake /home/lu/dev/nixcfg/dev/
warning: Git tree '/home/lu/dev/nixcfg' is dirty
warning: Git tree '/home/lu/dev/nixcfg' is dirty
direnv: nix-direnv: Renewed cache
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +GETTEXTDATADIRS_FOR_BUILD +HOST_PATH +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_BUILD_CORES +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_DIRENV_DID_FALLBACK +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_LDFLAGS +NIX_SHELL_ID +NIX_STORE +NM +OBJCOPY +OBJDUMP +QMAKE +QMAKEMODULES +QMAKEPATH +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +XML_CATALOG_FILES +__structuredAttrs +buildInputs +buildPhase +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +dontAddDisableDepTrack +mesonFlags +name +nativeBuildInputs +out +outputs +patches +phases +preferLocalBuild +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~PATH ~XDG_DATA_DIRS
I also tried version 18 and that one took several hours to compile llvm to then fail on the same error (the above failed immediately).
I don't think it even makes sense to use cross-compiled clang-tools.
Describe the bug
clangd
extracts x86_64 desktop include flags fromarm-none-eabi-gcc
, e.g. a python include, QT includes etc.Reported as clangd issue: https://github.com/clangd/clangd/issues/2181
After some discussion there it seems likely there is some weird NixOS interaction causing this.
This is what the
arm-none-eabi-gcc
prints:Expected behavior
On ARM embedded include flags are extracted by
clangd
.Notify maintainers
@Patryk27
Metadata
Add a :+1: reaction to issues you find important.