CLangCodeModel, libclang command line arguments and cross-compiling



  • Hello.
    I'm using Qt Creator 4.9.2 in a C++ CMake project, that can be both built as a desktop application and as web assembly for a browser (using Emscripten, emcc). The project relies heavily on modern C++17 features, so I have to use CLang code model in IDE.
    I was able to setup the build process by adding additional compilator and a kit, everything builds just fine.
    However, code completion doesn't seem to work when switching to emcc toolchain.
    I was able to find this guide and look through libclang debug messages:
    https://wiki.qt.io/Qt_Creator_Clang_Code_Model
    Looks like CLangCodeModel catches some ugly emcc-related command line arguments (like --preload-file, -s WASM=1 and so on) and quits with error. I get the following message for every file:

    Parsing <literraly, any file>:   0.0000 (100.0%)   0.0000 (100.0%)   0.0000 (100.0%)  
    Parsing <literraly, any file> failed: CXError_Failure
    

    When I switch to desktop compiler (gcc or clang), I get some output, for example - list of include paths. All autocomplete features work fine.

    Another thing: I have to use emcc with some additional libraries, that is not a part of system, but resides somewhere under /home directory. I have to pass some special environment variables and CMake values like EMSCRIPTEN="/home/..." and CMAKE_TOOLCHAIN_FILE="...". As a result, Code Model misses some obvious headers like <vector> or <memory> (std namespace is completely ignored).

    Is there a way to manipulpate libclang command line arguments?
    How can I understand why it stops with CXError_Failure?
    Can I make it independent of the compiler I use?

    I don't want to switch to another IDE. I've tried sublme text (it uses 6 CPU cores for around 10 minutes to parse source files) and CLion (I'm not familiar with it, and it will require additional time to master).

    Thanks.


Log in to reply