Clangd in Torizon Core Builder

Hello,

I’ve been trying to get good intellisense in VSCode for developing kernel modules.

I finally got there!

the Microsoft C/C++ extension wasn’t what I needed… clangd was.

To make it work, I had to:

  1. source tcb with a persistent folder, not a docker volume
  2. get the .config from my device and put it in the linux directory (maybe not needed?)
  3. run make with a compile_commands.json flag
  4. create some symlinks
  5. etc.

I’m not (yet) entirely sure the minimal steps to make it work.

My question: can this be done on the Toradex side to make things easier for all of us?

More info: I’m running VSCode in WSL. I installed clangd and the LLVM clangd extension. Once I got the configs right, I now get:

  1. No error squiggles (see #4)
  2. F12 support to jump to definitions from my .c files
  3. F12 to jump to includes
  4. Squiggles on my own errors!!!

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


Based on the available documentation, I can see you’re working on improving the development experience for kernel modules with TorizonCore Builder. While the current documentation doesn’t specifically address clangd integration, there are several relevant aspects to your workflow.

Current TorizonCore Builder Workflow

The standard process for building external kernel modules with TorizonCore Builder involves using the kernel build_module command(1). The documentation shows this basic workflow:

$ torizoncore-builder kernel build_module hello-mod

(1)

Addressing Your Development Environment Needs

Your approach of using persistent folders instead of Docker volumes aligns with some documented practices. The documentation mentions that TorizonCore Builder can work with local directories for various customizations(2).

For the .config file you mentioned, the kernel configuration process is documented in the BSP build instructions, where the kernel config can be obtained and applied(3):

$ cp kernel-config ~/linux && cd ~/linux 
$ mv kernel-config .config 
$ make olddefconfig

(3)

Potential Integration Opportunities

Your suggestion about improving IDE support is valuable. Currently, the documentation focuses on the build process itself rather than development environment integration. The compile_commands.json generation you mentioned is a standard approach for enabling better IDE support with clangd.

Recommendation

I’d suggest sharing your specific workflow and configuration details on the Toradex Community where other developers and Toradex engineers can evaluate the feasibility of integrating such improvements into the official toolchain. This would help determine if similar IDE integration features could be added to TorizonCore Builder or documented as best practices.

Your experience with clangd providing better IntelliSense than the Microsoft C/C++ extension for kernel module development could be valuable for other developers facing similar challenges.

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Hello Toradex Team,

How would I take it to the next level to request that you implement some of these steps in Torizon Core Builder to facilitate clangd “intellisense” and other features?

I think I have a reproducible roadmap to get things working in Torizon Core Builder and VSCode to be able to generate (for example) a “compile_commands.json” file for an out-of-tree kernel module so that VSCode can become a truly lovely coding experience..

Kevin

Feature Request Pathways for TorizonCore Builder

Your clangd integration work sounds like a valuable enhancement for the kernel module development experience. Here are the best ways to propose this feature to Toradex:

1. Community Discussion

Start a discussion on the Toradex Community where you can:

  • Share your detailed workflow and configuration steps (1)
  • Demonstrate the benefits with before/after comparisons
  • Get feedback from other developers who might benefit from this enhancement
  • Allow Toradex engineers to evaluate the technical feasibility

2. GitHub Feature Request

Since TorizonCore Builder is actively developed, you can:

  • Check the official Toradex repositories on GitHub for existing issues or feature requests
  • Submit a detailed feature request with your implementation approach
  • Include specific technical requirements for compile_commands.json generation

3. Documentation Enhancement

Your work could potentially be integrated as:

  • An additional command in TorizonCore Builder (like kernel generate-compile-commands) (2)
  • Enhanced Visual Studio Code integration documentation (1)
  • Best practices for IDE setup with kernel module development (3)

4. What to Include in Your Proposal

When presenting your feature request, include:

  • Reproducible steps for your current workaround
  • Technical specifications for the compile_commands.json generation
  • Benefits analysis showing improved developer productivity
  • Integration points where this could fit into existing TorizonCore Builder commands (2)

The current TorizonCore Builder already supports various development workflow enhancements (1), so your clangd integration could be a natural extension of these capabilities.

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Hi @kdubious,

Sorry for the delayed response.

I have already shared your request with the Torizon team. They will address it when possible, but at this moment, we can’t provide an estimated timeline.

Besides that, the steps given by the Toradex AI are correct, you could also follow them.

Best regards.

Sounds good. I will try to get some notes organized to help them out.

Is the Github repo the best place for that?

Hi @kdubious!

Yes, you can use the GitHub for that.

Best regards.