2

I’m working on an embedded project that runs on an Infineon TriCore MCU. The certified TriCore‑GCC and its binary libraries are Windows‑only, but I do most work on Linux.

To get quick syntax checks and unit‑tests locally I compile application‑only sources with the host GCC using CMock to generate mocks so the test build doesn’t need the vendor libraries.

This gives me a compile_commands.json, but every entry looks like this (shortened):

{
  "file": "core1/src/main.c",
  "directory": ".../build/tests/core1",
  "command": "/usr/bin/cc -DTESTING \
     -Icore1/src \
     -Itests/mocks                <‑‑ generated mocks
     -Itests/mocks/core1/libs/
     -Itests/mocks/..."
}

clangd indexes the mock headers instead of the actual library headers. Jump‑to‑definition ends up in mock/xy.h instead of core1/xy.h.

Right now the only option I see is having a top-level .clangd file that defines the includes for each core using path matching, but this wouldn't allow clangd to index the code base if I am not mistaken.

Maybe someone has a better idea.

Thanks for the input!

2
  • This "quick syntax checks" compile_commands.json already seems like a hack, trying to do more seems like its digging the hole deeper. Are you able to compile with TriCore-GCC at all from your Linux machine? I would wonder about trying to generate a compile_commands.json with TriCore-GCC a wine. Your cmake build step might not work in wine, but that could be enough to run configure to get compile_commands.json Commented Jul 30 at 13:26
  • I've read this over but I'm not sure what the actual question is. What is the behaviour that you'd like to see? Commented Aug 9 at 19:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.