github / github/codeql

How to extract source files when using a special compiler (e.g. TMS320C2000 C/C++ Compiler)?

Open
#8,453 18 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 15h
Merged PRs (30d)
141

Description

When I first created a database by `codeql-cli` for C/C++ source files for some embedded system software codes generated by [Code Composer Studio](https://www.ti.com/tool/CCSTUDIO), it failed to extract any source file even though the `gmake` build process ran successfully.

I found the root cause is that the `makefile` takes TMS320C2000 C/C++ Compiler as the compiler for the project. Even when I only have the `helloworld.c` as:

```c
int main() {
return 0;
}
```

`build.sh` as

```sh
"C:\ti\ccs1100\ccs\tools\compiler\ti-cgt-c2000_21.6.0.LTS\bin\cl2000" helloworld.c
```

And run the command as:

```sh
codeql database create cpp-database-01 --language=cpp --command="bash build.sh"
```

No source file can be extracted and the error message shows:

```
No source code was seen and extracted to ****
This can occur if the specified build commands failed to compile or process any code.
- Confirm that there is some source code for the specified language in the project.
- For codebases written in Go, JavaScript, TypeScript, and Python, do not specify

an explicit --command.
- For other languages, the --command must specify a "clean" build which compiles
all the source code files without reusing existing build artefacts.
(base)
```

I guess the extractor in `codeql` fails to monitor the compilation process of TMS320C2000 C/C++ Compiler, which technically can be traced as it has similar usages to take source/lib/include files with other compilers (e.g., `gcc`, `clang`).

I really want to apply `codeql` on those codes compiled by some special compilers to do some security analysis, but get stock with the extraction of source files. How can I fix the problem? Can I change some extractor configuration? Or if there is any direction to modify the source code of `codeql` to generalize the compiler requirement? Or can I add the source files to the database manually?

Thank you very much.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.