CLion 2025.1 does not find header files or symbols with CMake profile using custom compiler config and toolchain file

CLion 2025.1 does not find the header files (message of “Cannot find declaration to go to”) or symbols in a CMake project when using a CMake profile with custom compiler config yaml and CMake toolchain file for an embedded device. The CMake target in this case is a library rather than an executable. Also, in the bottom right corner of the status bar, “Context | Loading …” is perpetually present.

This is not the case in CLion 2024.3. Header file and symbol analysis work as expected. In the status bar, “Context | <no context>” is present.

I am using the Linux builds of both CLion 2025.1 and 2024.3

0

Hello!

This is not the case in CLion 2024.3. Header file and symbol analysis work as expected. In the status bar, “Context | <no context>” is present.

Actually, <no context> means that CLion failed to identify the proper resolve context for the file, which indicates that CLion doesn't understand your project.

  1. Please do Tools | CMake | Reset Cache and Reload Project and provide the entire output from the CMake tool window.
  2. Please check your custom compiler as described in https://www.jetbrains.com/help/clion/custom-compilers.html#check-custom-compiler and provide the result of the Show Compiler Info action.
0

Hi Anna,

Thank you for your reply. I should mention that I am using a embeddded device cross-compiler (Microchip XC8). I believe this compiler is based on Clang.

Regarding your request, please see below.

1.

/home/kamil/Software/clion-2024.3.2/bin/cmake/linux/x64/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/opt/microchip/xc8/v3.00/bin/xc8-cc -G "Unix Makefiles" -D ROTA_TARGET_PLATFORM:STRING=PIC18 -D USER_TOOLCHAIN_FILE:PATH=/home/kamil/Rotalabs/repos/rotalib/platform/microchip/pic18.cmake -D MICROCHIP_MCU:STRING=PIC18F57Q84 -D ROTA_TARGET_FAMILY:STRING=Q84 --toolchain /home/kamil/Rotalabs/repos/rotalib/cmake-microchip/toolchain.cmake -D ROTA_PLATFORM_MICROCHIP_DFP_PATH:PATH=/opt/microchip/mplabx/v6.25/packs/Microchip/PIC18F-Q_DFP/1.27.449/xc8 -S /home/kamil/Rotalabs/repos/rotalib -B /home/kamil/Rotalabs/repos/rotalib/cmake-build-microchip-xc8-debug
-- User toolchain file "/home/kamil/Rotalabs/repos/rotalib/platform/microchip/pic18.cmake" included.
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Configuring done (0.8s)
-- Generating done (0.0s)
-- Build files have been written to: /home/kamil/Rotalabs/repos/rotalib/cmake-build-microchip-xc8-debug
[Finished]

2.

Compiler info for 'Pid.c' in configuration 'rota | Microchip-XC8-Debug' for language C
Compiler kind: Custom Defined Compiler path: /opt/microchip/xc8/v3.00/bin/xc8-cc
Custom Compiler: Microchip XC8
Compiler switches:
    -D_18F57Q84
    -D__PICC18__
    -I/home/kamil/Rotalabs/repos/rotalib/include
    -mcpu=18F57Q84
    -std=c99
    --nofallback
    -fno-short-double
    -fno-short-float
    -memi=wordwrite
    -fasmfile
    -maddrqual=ignore
    -xassembler-with-cpp
    -mwarn=-3
    -Wa,-a
    -ginhx32
    -Wl,--data-init
    -mno-keep-startup
    -mno-download
    -mno-default-config-bits
    -gdwarf-3
    -mstack=compiled:auto:auto:auto
    -mdfp=/opt/microchip/mplabx/v6.25/packs/Microchip/PIC18F-Q_DFP/1.27.449/xc8
    -O0
    -Og
Compiler info:
Defines:
#define __PICC18__
#define __XC
#define __XC8
#define _HAS_INT24
#define _OMNI_CODE_
#define __XC__
#define __XC8__
#define _18F57Q84
Features:
    CXX_CONSTEXPR=false
    CXX_NULLPTR=false
    CXX_AUTO_TYPE=false
    C_AUTO_TYPE=false
    CXX_GENERIC_LAMBDAS=false
    CXX_RAW_STRING_LITERALS=false
    C_NULLPTR=false
    C_STATIC_ASSERT=false
    CXX_USER_LITERALS=false
    CXX_BINARY_LITERALS=false
    CXX_NONSTATIC_MEMBER_INIT=false
    C_CONSTEXPR=false
    CXX_OVERRIDE_CONTROL=false
    CXX_EXCEPTIONS=false
    CXX_RETURN_TYPE_DEDUCTION=false
    CXX_GENERALIZED_INITIALIZERS=false
Implicit includes:

Header Search paths:
    Pointer: file:///home/kamil/Rotalabs/repos/rotalib/include
    Pointer: file:///opt/microchip/xc8/v3.00/pic/include
    Pointer: file:///opt/microchip/xc8/v3.00/pic/include/c99
    Pointer: file:///opt/microchip/xc8/v3.00/pic/include/proc
0

Here is some output from the backend log file:

14:56:23.368 |W| RangeableContainer            | :1                 | Attempt to remove invalid range
14:56:23.369 |W| RiderMarkupHost               | :1                 | Invalid Highlighter. id: 'ReSharper Parameter Name Hint Action', range: (-1 - -1)
14:56:23.369 |W| RiderMarkupHost               | :1                 | Invalid Highlighter. id: 'ReSharper Parameter Name Hint Action', range: (-1 - -1)
14:56:23.466 |W| RadResolveContextIndicator    | :1                 | DoUpdateRdModel: Cannot resolve the context for /home/kamil/Rotalabs/repos/rotalib/src/Container/List.c
14:56:23.467 |V| DaemonImpl                    | :1                 | Removing daemon from document [50447774 - /home/kamil/Rotalabs/repos/rotalib/src/Container/List.c]
14:56:23.467 |V| DaemonImpl                    | :1                 | No daemon process for document [50447774 - /home/kamil/Rotalabs/repos/rotalib/src/Container/List.c] 7020124f-9ffc-4ac3-8f3d-aab8e0240759(Miscellaneous Files)-13/f:List.c/l:src?Container?List.c
14:56:23.467 |V| DaemonImpl                    | :1                 | CreateDaemonForDocument 7020124f-9ffc-4ac3-8f3d-aab8e0240759(Miscellaneous Files)-13/f:List.c/l:src?Container?List.c [50447774 - /home/kamil/Rotalabs/repos/rotalib/src/Container/List.c] by StateWithDescription
14:56:23.467 |V| DaemonImpl                    | :1                 | Schedule RaiseDaemonStateChanged for [50447774 - /home/kamil/Rotalabs/repos/rotalib/src/Container/List.c] 7020124f-9ffc-4ac3-8f3d-aab8e0240759(Miscellaneous Files)-13/f:List.c/l:src?Container?List.c
14:56:23.467 |V| DaemonImpl                    | :1                 | DaemonStateChanged: /home/kamil/Rotalabs/repos/rotalib/src/Container/List.c DISABLED Analysis is not supported: Unable to find a project file to use. Indicator: Off Analysis is not supported: Unable to find a project file to use, Process: OFF
14:56:23.468 |V| RadDaemonHost                 | :1                 | DaemonState -> DISABLED, HighlightingProgressState -> OFF, Document: /home/kamil/Rotalabs/repos/rotalib/src/Container/List.c
14:56:23.468 |V| AsyncCommitServiceImpl        | :1                 | Execute after commit actions
14:56:23.468 |V| DaemonImpl                    | :1                 | DaemonStateChanged: /home/kamil/Rotalabs/repos/rotalib/src/Container/List.c DISABLED Analysis is not supported: Unable to find a project file to use. Indicator: Off Analysis is not supported: Unable to find a project file to use, Process: OFF
14:56:23.468 |V| RadDaemonHost                 | :1                 | DaemonState -> DISABLED, HighlightingProgressState -> OFF, Document: /home/kamil/Rotalabs/repos/rotalib/src/Container/List.c

 

Here is the custom compiler config yaml file:

 

compilers:

  - description: Microchip XC8
    match-sources: ".*\\.c"
    match-language: C
    match-compiler-exe: "(.*/)?xc8-cc(\\.exe)?"
    code-insight-target-name: pic
    include-dirs:
      - "${compiler-exe-dir}/../pic/include"
      - "${compiler-exe-dir}/../pic/include/c99"
      - "${compiler-exe-dir}/../pic/include/proc"
    defines:
      __XC8:
      __XC:
      __XC__:
      _HAS_INT24:
      _OMNI_CODE_:
      __XC8__:

 

Also, please note that I manually set CMAKE_C_COMPILER_WORKS equal to TRUE in my toolchain file in order to skip the CMake compiler checks. These checks fail as CMake does not have full platform/compiler support implemented for this target.

0

Please note that this issue persists with CLion 2025.2.3.

Are there any other log files or debug log settings that may be useful in diagnosing this issue?

0

These checks fail as CMake does not have full platform/compiler support implemented for this target.

Krogozinski, do I understand correctly that the xc8-cc compiler isn't supported by CMake? 

If so, then CLion won't be able to properly provide code insight features in this case.

0

Anna Falevskaya thanks for your reply. 

This is correct. The xc8-cc is not supported by CMake by default. A custom toolchain file is required, which also includes the command set(CMAKE_C_COMPILER_WORKS TRUE). This allows CMake to proceed with the build environment generation, but it bypasses C compiler determination, features etc (in Modules/CMakeCompilerIdDetection.cmake and Modules/CMakeDetermineCompilerId.cmake and other CMake modules).

I am working on integrating xc8-cc support in CMake. If I manage to pass the Test CMake run without errors (see below), will code insight work? Are there any other tests that I should do, or log files that I should monitor?

0

请先登录再写评论。