Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-28201

QtCreator doesn't pass mkspec compiler parameters to clangd compile_commands.json

    XMLWordPrintable

Details

    • 049c2cf6f3 (qt-creator/qt-creator/master) 049c2cf6f3 (qt-creator/qt-creator/9.0)

    Description

      Since QtCreator is using clangd for the code model we always had a huge count of false errors in our project when having our ARM target Kit selected. Today I found out that this was caused by QtCreator not passing the parameters of the specified mkspec file to the generated compile_commands.json file.

      This causes QtCreator to include different files than the clangd code model expects, which causes a lot of false error messages. See attached errors.png. It also generates a lot of "cannot initialize object parameter of type ... with expression of type ..." errors like seen in https://bugreports.qt.io/browse/QTCREATORBUG-28016. But those I could not reproduce in the sample project and I can't share the code of our real project.

      When adding the parameters in the .pro file through "QMAKE_CXXFLAGS +=", they are added to the compile_commands.json file (see arguments.png) and the code model works perfectly fine.

      In our case the problem was, that our target is hard-floating, but since the parameter "-mfloat-abi=hard", which is defined in our mkspec linux-oe-g++ was not passed into the compile_commands.json it did not work correctly.

      I think QtCreator should pass all CXXFlags which are effective for compile also to the clangd compile_commands.json file.

      Attachments

        1. arguments.png
          arguments.png
          14 kB
        2. clangd-test.zip
          0.7 kB
        3. errors.png
          errors.png
          36 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kandeler Christian Kandeler
              markus_s Markus Steinhilber
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes