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

CodeQL CLI faild in docker container: Could not auto-detect a suitable build method #1196

Closed
FaiqueAli opened this issue Aug 19, 2022 · 4 comments

Comments

@FaiqueAli
Copy link

Hi Guys,
I am exploring codeql cli to use in my c++ project.
I am able to generate .sarif file on my local machine but when I execute the same code in a windows docker container to create the codeql database I am getting an error by using the below command..

codeql database create --language=cpp "C:\\xxx\\DB-codeql"

[build-stdout] CodeQL C++ autobuilder
[build-stdout] Working directory: C:\xxx
[build-stdout] Attempting to locate build script
[build-stderr] Error: Could not auto-detect a suitable build method
[ERROR] Spawned process exited abnormally (code 1; tried to run: [C:\codeql\tools\win64\tracer.exe,
C:\codeql\tools\win64\runner.exe, cmd.exe, /C, type, NUL, &&, C:\codeql\cpp\tools\autobuild.cmd])
A fatal error occurred: Exit status 1 from command: [C:\codeql\tools\win64\runner.exe, cmd.exe, /C, type, NUL, &&,
C:\codeql\cpp\tools\autobuild.cmd]

also highlights

[build-stderr] Error: Could not auto-detect a suitable build method

I am using cmake -G "MSYS Makefiles" ../ and make to build my project

I found the issue over the internet but could not get any fix.

@smowton
Copy link
Contributor

smowton commented Aug 19, 2022

This means looking at the current working directory there was no obvious way to build your code -- a Makefile, CMakeLists.txt or similar. Given the ../ I'm guessing your working directory is an empty build subdir? If so, try using the -c option to specify a build command: here -c 'cmake -G "MSYS Makefiles" ../' -c make seems like it would do. Also because you're running database create from within a build directory you'll need to use -s to specify your source root and therefore which .c/cpp/h files to consider as user code. Here -s .. seems like it should do.

@FaiqueAli
Copy link
Author

Thank you for your valuable comments I am now able to build using script but once it finish the compilation of the code it pops up another error..

No source code was seen and extracted to C:\xxx.
This can occur if the specified build commands failed to compile or process any code.

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.

I am using the GNU MinGW compiler to compile my code.
it seems that the MinGW compiler version 12.2.0(GNU) is not supported by codeql see here

I also have seen some other post saying that I need to modify my codeql configuration file

codeql/cpp/tools/win64/compiler-tracing.spec

.
but I am not sure how can I modify in a container also how to define my compile name in this configuration file..

could you please let me know what are the possibilities for this to generate codeQL database.

Thanks :)

@aibaars
Copy link
Collaborator

aibaars commented Aug 23, 2022

@FaiqueAli shall we close this issue and continue on github/codeql#10132 ?

@FaiqueAli
Copy link
Author

yes sure..

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

No branches or pull requests

3 participants