Skip to content

From Qtcreator 17 (and 18), and with Ubuntu 24.04, clangd highlight errors everywhere #550

@doisyg

Description

@doisyg

With Qtcreator 16 with the ROS plugin, everything works very well.
However when updating to any superior version (tried 17 and 18) it seems clangd has trouble making sense of the workspace and almost all my code is highlighted in red.
Potentially related (not sure), it seems there is a syntax error in the flags passed to GCC (the COLLECT_GCC_OPTIONS var).
Logs from stating qtcreator in a terminal:

/opt/qt-creator/bin/qtcreator
qt.core.qobject.connect: QObject::connect: No such signal ProjectExplorer::ProjectExplorerPlugin::settingsChanged()
qt.core.qobject.connect: QObject::connect:  (receiver name: 'ROSProjectManager__Internal__ROSColconStep')
qt.core.qobject.connect: QObject::connect: No such signal ProjectExplorer::ProjectExplorerPlugin::settingsChanged()
qt.core.qobject.connect: QObject::connect:  (receiver name: 'ROSProjectManager__Internal__ROSColconStep')
SOFT ASSERT [18:31:56.920]: /home/qt/work/build/qt-creator/src/plugins/projectexplorer/gcctoolchain.cpp:220: Compiler feature detection failure.
The command "/bin/g++ '-O2 -g -DNDEBUG -std=gnu++17' -x c++ -E -v -" terminated with exit code 1.
Standard error output was:
Using built-in specs.
COLLECT_GCC=/bin/g++
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 13.3.0-6ubuntu2~24.04' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-13-fG75Ri/gcc-13-13.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-13-fG75Ri/gcc-13-13.3.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04) 
COLLECT_GCC_OPTIONS='-O2 -g -DNDEBUG -std=gnu++17' '-E' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-linux-gnu/13/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE - -mtune=generic -march=x86-64 -O2 -g -DNDEBUG -std=gnu++17 -D_FORTIFY_SOURCE=3 -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -dumpbase -
cc1plus: error: argument to ‘-O’ should be a non-negative integer, ‘g’, ‘s’, ‘z’ or ‘fast’
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/13"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/include-fixed/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/13
 /usr/include/x86_64-linux-gnu/c++/13
 /usr/include/c++/13/backward
 /usr/lib/gcc/x86_64-linux-gnu/13/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.

Standard output was:
# 0 "<stdin>"

SOFT ASSERT [18:31:56.923]: /home/qt/work/build/qt-creator/src/plugins/projectexplorer/gcctoolchain.cpp:220: Compiler feature detection failure.
The command "/bin/g++ '-O2 -g -DNDEBUG -std=gnu++17 -fPIC' -x c++ -E -v -" terminated with exit code 1.
Standard error output was:
Using built-in specs.
COLLECT_GCC=/bin/g++
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 13.3.0-6ubuntu2~24.04' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-13-fG75Ri/gcc-13-13.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-13-fG75Ri/gcc-13-13.3.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04) 
COLLECT_GCC_OPTIONS='-O2 -g -DNDEBUG -std=gnu++17 -fPIC' '-E' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-linux-gnu/13/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE - -mtune=generic -march=x86-64 -O2 -g -DNDEBUG -std=gnu++17 -fPIC -D_FORTIFY_SOURCE=3 -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -dumpbase -
cc1plus: error: argument to ‘-O’ should be a non-negative integer, ‘g’, ‘s’, ‘z’ or ‘fast’
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/13"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/include-fixed/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/13
 /usr/include/x86_64-linux-gnu/c++/13
 /usr/include/c++/13/backward
 /usr/lib/gcc/x86_64-linux-gnu/13/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.

Standard output was:
# 0 "<stdin>"

SOFT ASSERT [18:31:56.933]: /home/qt/work/build/qt-creator/src/plugins/projectexplorer/gcctoolchain.cpp:634: Compiler feature detection failure.
The command "/bin/g++ -x c++ -E -dM '-O2 -g -DNDEBUG -std=gnu++17' -" terminated with exit code 1.
Standard error output was:
cc1plus: error: argument to ‘-O’ should be a non-negative integer, ‘g’, ‘s’, ‘z’ or ‘fast’

SOFT ASSERT [18:31:56.933]: "false && "__cplusplus is not predefined, assuming latest C++ we support."" in /home/qt/work/build/qt-creator/src/plugins/projectexplorer/toolchain.cpp:537
SOFT ASSERT [18:31:56.938]: /home/qt/work/build/qt-creator/src/plugins/projectexplorer/gcctoolchain.cpp:634: Compiler feature detection failure.
The command "/bin/g++ -x c++ -E -dM '-O2 -g -DNDEBUG -std=gnu++17 -fPIC' -" terminated with exit code 1.
Standard error output was:
cc1plus: error: argument to ‘-O’ should be a non-negative integer, ‘g’, ‘s’, ‘z’ or ‘fast’

SOFT ASSERT [18:31:56.938]: "false && "__cplusplus is not predefined, assuming latest C++ we support."" in /home/qt/work/build/qt-creator/src/plugins/projectexplorer/toolchain.cpp:537

Disappears when switching back to QtCreator 16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions