Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating CodeQL database without compiling the project #5303

Closed
adriaanjacobs opened this issue Mar 1, 2021 · 2 comments
Closed

Generating CodeQL database without compiling the project #5303

adriaanjacobs opened this issue Mar 1, 2021 · 2 comments
Labels
question Further information is requested

Comments

@adriaanjacobs
Copy link

[C/C++]

This is more of a nice-to-have/curiosity question, but I was wondering if it would be possible (either right now or in the future) to generate CodeQL databases without actually compiling the project? I'm working on some compiler instrumentation task and using CodeQL's excellent taint analysis to automatically detect certain patterns and provide automatic mediation inside the compiler. However, from a user experience standpoint the process of compiling the same code twice (first to generate the database, then a second time with a modified compiler to run the analysis and instrument the code) to produce a single instrumented executable is quite strange.

Does CodeQL actually need to run the compiler or is looking at the invocations sufficient (i.e. make --dry-run)? Up until now, I thought the generated binaries where simply a side-effect for CodeQL to be able to look at the compiler invocations and also serve as a kind of sanity check that the code is in fact compilable. But now I was wondering, does it use any of the generated files in the extraction process?

@adriaanjacobs adriaanjacobs added the question Further information is requested label Mar 1, 2021
@hmakholm
Copy link
Contributor

hmakholm commented Mar 1, 2021

I'm afraid the compiler does need to be run.

CodeQL does not actually use the object code produced by the compiler, but the way it finds out the compiler is running is by intercepting system calls from the build system that create child processes, and checking whether one of them is a compiler invocation. That way we can support a wider variety of build systems -- for example ones that don't print out the compiler command lines before it executes them like make does, or ones that generate .c or .h files on the fly but immediately delete them after the compiler has run. But it does mean some work during the build will be wasted.

@amir734jj
Copy link

amir734jj commented May 1, 2024

@hmakholm this is the issue I am facing, for large projects I wish there was a way to pass the output of build to codeql instead of letter codeql invoking it. Using --command with cpp project is very very slow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants