clangd not finding gnu/stubs-32.h when using emscripten

99 views Asked by At

Clangd returns this error if I include anything when using a compile_commands.json generated by CMake with flags from emcc --cflags.

Despite the error, the program compiles without any issue.

In included file: 'gnu/stubs-32.h' file not found clang (pp_file_not_found) [1, 10]

src/CMakeLists.txt

if(EMSCRIPTEN)
  execute_process(COMMAND emcc --cflags
      OUTPUT_VARIABLE EM_CFLAGS)
    set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${EM_CFLAGS}")
endif()

compile_commands.json

[
  {
    "directory": "/home/truff/.local/src/snake/em_build",
    "command": "/nix/store/6snfm5hzf45d88z6mw5msgdqrwwhnl30-emscripten-3.1.47/share/emscripten/emcc -I/home/truff/.local/src/snake/src/snake  -s USE_SDL=2 -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/home/truff/.local/src/snake/.cache/sysroot -resource-dir=/nix/store/ccsz1s9qvk46q2qs3lxjlsqyyg62l9sa-emscripten-llvm-3.1.47/lib/clang/16/ -idirafter/home/truff/.local/src/snake/.cache/sysroot/include -iwithsysroot/include/c++/v1 -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat\n -o src/CMakeFiles/snake.dir/Main.c.o -c /home/truff/.local/src/snake/src/Main.c",
    "file": "/home/truff/.local/src/snake/src/Main.c",
    "output": "src/CMakeFiles/snake.dir/Main.c.o"
  }
]

if I remove -target wasm32-unknown-emscripten the error goes away but the __EMSCRIPTEN__ macro gets undefined.

I tried creating ./include/gnu/stubs-32.h but it now creates

In included file: "This header is only meant to be used on x86 and x64 architecture" clang (pp_hash_error) [1, 10]
0

There are 0 answers