Open student433 opened 2 weeks ago
Implementing a new target in the clang frontend (excluding support for actually generating code) is relatively easy: you update llvm/include/llvm/TargetParser/Triple.h to parse your triple, then add a file describing your target to clang/lib/Basic/Targets/, then update clang/lib/Basic/Targets.cpp to construct your target.
(If you just need predefines, it's probably simpler to just specify them with "-D", but having a real target lets you mess with other stuff, like the widths of builtin types.)
In terms of upstreaming, I don't think we have any existing targets without a corresponding backend, but I don't think we have a formal policy stating whether we'd accept a target like this. Start a thread on discourse.llvm.org if you want to seriously pursue this.
clangd doesn't have any builtin support for parsing command-line flags in any style besides clang/clang-cl. You'll need to translate the flags yourself.
1. System Information:
MCU Series: F280015x
2. Problem Description:
We currently use a CMake project over the TI C2000 MCU and would like to deploy clangd for code analysis. The include paths are picked up by clangd after manually adjusting
compile_commands.json
flags for them to be recognized by clangd. Since predefined macros are picked up by clangd using target information, we are at a dead end situation as there is currently no support for the TI C2000 Family. We currently use the triple target definitionmsp430-none-eabi
for a little help as it also comes from TI and resolve some basic pre-defines but we are still far away from our destination.Hence, my questions are:
Would it be possible to upstream support for the C2000 Family over clangd? or otherwise, what would we need to do to add this support?
Since even the
compile_commands.json
commands are not recognized as it does not have gcc-style argument flags, is there a way for clangd to overcome this? Our compiler command looks like this :C:\\ti\\ccs1281\\ccs\\tools\\compiler\\ti-cgt-c2000_22.6.1.LTS\\bin\\cl2000.exe --compile_only --c_file=C:\\Users\\eclipse-workspace\\can_echo\\source\\can_transmit_receive.c -DNDEBUG --include_path=C:\\Users\\eclipse-workspace\\can_echo\\device\\driverlib --include_path=C:\\Users\\eclipse-workspace\\can_echo\\device --include_path=C:\\Users\\eclipse-workspace\\can_echo\\device\\driverlib\\inc --include_path=C:\\Users\\eclipse-workspace\\can_echo\\syscfg --include_path=C:\\ti\\ccs1281\\ccs\\tools\\compiler\\ti-cgt-c2000_22.6.1.LTS\\include -v28 -ml -mt --opt_level=off --define=_FLASH --define=_LAUNCHXL_F2800157 --diag_suppress=10063 --gen_func_subsections=on --abi=eabi --output_file=can_echo.c.obj
Thanks!