Skip to content

CDT fails to generate correct commands in compile_commands.json file #1130

Open
@dc42

Description

@dc42

Using Eclipse CDT 4.35.0 (build ID 20250306-0812) under Windows, cross compiling for ARM gcc. When the LSP editor is selected and logging is enabled, the output in the console window is as follows:

I[14:59:50.488] clangd version 18.1.8
I[14:59:50.488] Features: windows
I[14:59:50.488] PID: 36888
I[14:59:50.488] Working directory: C:\Users\David\eclipse\cpp-2024-06\eclipse
I[14:59:50.488] argv[0]: C:\Program Files\LLVM\bin\clangd.exe
I[14:59:50.488] argv[1]: --clang-tidy
I[14:59:50.488] argv[2]: --background-index
I[14:59:50.488] argv[3]: --completion-style=detailed
I[14:59:50.488] argv[4]: --pretty
I[14:59:50.488] argv[5]: --query-driver=C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\13.2 Rel1\bin\*g++.exe,C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\13.2 Rel1\bin\*gcc.exe
I[14:59:50.488] argv[6]: --function-arg-placeholders=1
I[14:59:50.493] Starting LSP over stdin/stdout
I[14:59:50.938] <-- initialize("1")
I[14:59:50.941] --> reply:initialize("1") 2 ms
I[14:59:51.018] <-- initialized
I[14:59:51.033] <-- textDocument/didOpen
I[14:59:51.036] --> textDocument/publishDiagnostics
I[14:59:51.036] <-- textDocument/documentLink("2")
I[14:59:51.036] Loaded compilation database from C:\Eclipse\Firmware-3.6\RRFLibraries\SAME70_RTOS\compile_commands.json
I[14:59:51.036] <-- textDocument/semanticTokens/full("3")
I[14:59:51.038] --> window/workDoneProgress/create(0)
I[14:59:51.038] Enqueueing 43 commands for indexing
I[14:59:51.042] <-- textDocument/inlayHint("4")
E[14:59:51.042] System include extraction: driver arm-none-eabi- not found in PATH
I[14:59:51.046] ASTWorker building file C:\Eclipse\Firmware-3.6\RRFLibraries\src\General\SimpleMath.cpp version 1 with command 
[C:/Eclipse/Firmware-3.6/RRFLibraries]
"C:\\Program Files\\LLVM\\bin\\arm-none-eabi-" -std=gnu++17 -D__SAME70Q21__ -DRTOS "-IC:\\Eclipse\\Firmware-3.6\\FreeRTOS\\src\\include" "-IC:\\Eclipse\\Firmware-3.6\\FreeRTOS\\src\\portable\\GCC\\ARM_CM7\\r0p1" -O2 -Wall -c -mcpu=cortex-m7 -mthumb -fno-math-errno -mfpu=fpv5-d16 -mfloat-abi=hard -mfp16-format=ieee -mno-unaligned-access -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fno-exceptions -nostdlib -Wundef -Wdouble-promotion -fsingle-precision-constant -Wa,-ahl=$*.s -o C:/Eclipse/Firmware-3.6/RRFLibraries/SAME70_RTOS/src/General/SimpleMath.o "-resource-dir=C:\\Program Files\\LLVM\\lib\\clang\\18" -- "C:\\Eclipse\\Firmware-3.6\\RRFLibraries\\src\\General\\SimpleMath.cpp"
I[14:59:51.060] <-- reply(0)
I[14:59:51.060] --> $/progress
I[14:59:51.060] --> $/progress
I[14:59:51.094] --> textDocument/publishDiagnostics
I[14:59:51.095] Loaded compilation database from C:\Eclipse\Firmware-3.6\FreeRTOS\SAME51\compile_commands.json
I[14:59:51.161] --> $/progress
I[14:59:51.161] --> $/progress
I[14:59:51.161] --> $/progress
I[14:59:51.161] --> $/progress
I[14:59:51.161] --> $/progress
I[14:59:51.161] --> $/progress
I[14:59:51.161] --> $/progress
I[14:59:51.161] --> $/progress
I[14:59:51.161] --> $/progress
I[14:59:51.161] --> $/progress
I[14:59:51.161] --> $/progress
I[14:59:51.162] --> $/progress
I[14:59:51.162] --> $/progress
I[14:59:51.162] --> $/progress
I[14:59:51.162] --> $/progress
I[14:59:51.162] --> $/progress
I[14:59:51.162] --> $/progress
I[14:59:51.162] --> $/progress
E[14:59:51.172] System include extraction: driver m-none-eabi- not found in PATH
E[14:59:51.172] System include extraction: driver m-none-eabi- not found in PATH
E[14:59:51.172] System include extraction: driver m-none-eabi- not found in PATH
E[14:59:51.172] System include extraction: driver m-none-eabi- not found in PATH
E[14:59:51.172] System include extraction: driver m-none-eabi- not found in PATH
E[14:59:51.172] System include extraction: driver m-none-eabi- not found in PATH
...

The errors appear to be because the compile_commands.json file does not contain the G++ or GCC command, just the prefix. Here is the start of compile_commands.json:

[
  {
    "directory": "C:/Eclipse/Firmware-3.6/RepRapFirmware",
    "command": "arm-none-eabi- -std\u003dgnu++17 -D__SAME70Q20B__ -DRTOS -DDUET3_MB6HC -DMQTTC_PAL_FILE\u003d\"Networking/MQTT/mqtt_pal.h\" -D_XOPEN_SOURCE -I\"C:\\Eclipse\\Firmware-3.6\\LibTinyusb\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\" -I\"C:\\Eclipse\\Firmware-3.6\\FreeRTOS\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\\src\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\\src\\SAM4S_4E_E70\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\\src\\SAM4S_4E_E70\\asf\\common\\utils\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\\src\\SAM4S_4E_E70\\asf\\sam\\utils\\cmsis\\same70\\include\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\\src\\arm\\CMSIS\\5.4.0\\CMSIS\\Core\\Include\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\\src\\SAM4S_4E_E70\\SAME70\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\\src\\SAM4S_4E_E70\\asf\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\\src\\SAM4S_4E_E70\\asf\\sam\\utils\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\\src\\SAM4S_4E_E70\\asf\\sam\\utils\\preprocessor\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\\src\\SAM4S_4E_E70\\asf\\sam\\utils\\header_files\" -I\"C:\\Eclipse\\Firmware-3.6\\CoreN2G\\src\\SAM4S_4E_E70\\asf\\sam\\drivers\" -I\"C:\\Eclipse\\Firmware-3.6\\RepRapFirmware\\src\" -I\"C:\\Eclipse\\Firmware-3.6\\RepRapFirmware\\src\\Hardware\\SAME70\" -I\"C:\\Eclipse\\Firmware-3.6\\RepRapFirmware\\src\\Networking\" -I\"C:\\Eclipse\\Firmware-3.6\\RepRapFirmware\\src\\Networking\\LwipEthernet\\Lwip\" -I\"C:\\Eclipse\\Firmware-3.6\\RepRapFirmware\\src\\Networking\\LwipEthernet\\Lwip\\src\\include\" -I\"C:\\Eclipse\\Firmware-3.6\\RepRapFirmware\\src\\Networking\\MQTT\\MQTT_C\\include\" -I\"C:\\Eclipse\\Firmware-3.6\\WiFiSocketServerRTOS\\src\\include\" -I\"C:\\Eclipse\\Firmware-3.6\\FreeRTOS\\src\\include\" -I\"C:\\Eclipse\\Firmware-3.6\\FreeRTOS\\src\\portable\\GCC\\ARM_CM7\\r0p1\" -I\"C:\\Eclipse\\Firmware-3.6\\RRFLibraries\\src\" -I\"C:\\Eclipse\\Firmware-3.6\\CANlib\\src\" -O2 -Wall -c -mcpu\u003dcortex-m7 -mthumb -fno-math-errno -mfpu\u003dfpv5-d16 -mfloat-abi\u003dhard -mfp16-format\u003dieee -mno-unaligned-access -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fexceptions -nostdlib -Wundef -Wdouble-promotion -Werror\u003dreturn-type -Wsuggest-override -fsingle-precision-constant \"-Wa,-ahl\u003d$*.s\" -fstack-usage -o \"C:/Eclipse/Firmware-3.6/RepRapFirmware/Duet3_MB6HC/src/Accelerometers/Accelerometers.o\" \"C:/Eclipse/Firmware-3.6/RepRapFirmware/src/Accelerometers/Accelerometers.cpp\"",
    "file": "C:/Eclipse/Firmware-3.6/RepRapFirmware/src/Accelerometers/Accelerometers.cpp"
  },
  {

This is the tools setup I am using:

Image

where ArmGccPath is a build variable containing the path to the version of gcc that this workspace uses, for example:

Image

The .cproject file is available at https://github.com/Duet3D/RepRapFirmware/blob/3.6-dev/.cproject. The make utility in use is the one provided by MSYS2.

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