github / codeql-cli-binaries

Binaries for the CodeQL CLI
Other
754 stars 112 forks source link

autobuild error for database create for C/C++ #121

Closed sofiaoreis closed 2 years ago

sofiaoreis commented 2 years ago

Hi! I'm trying to create a database with codeql for C/C++, but it always returns the following error no matter what source root I give to the command.

Here is the output of running it on torvalds/linux: codeql database create database/ --language=cpp --source-root=linux.

Initializing database at /Users/sofiaoreis/cmu-portugal/tenet/vulnerable/CVE-2011-3353/database.
Running build command: [/Users/sofiaoreis/codeql/codeql/cpp/tools/autobuild.sh]
[2022-04-08 14:32:39] [build-stderr] + TOOLS_DIR=/Users/sofiaoreis/codeql/codeql/cpp/tools
[2022-04-08 14:32:39] [build-stderr] + /Users/sofiaoreis/codeql/codeql/cpp/tools/detect_source_root
[2022-04-08 14:32:39] [build-stdout] detect_source_root: Using build system found in '.'
[2022-04-08 14:32:39] [build-stderr] ln: _lgtm_detected_source_root/.: File exists
[2022-04-08 14:32:39] [build-stderr] + '[' -L _lgtm_detected_source_root ']'
[2022-04-08 14:32:39] [build-stderr] ++ readlink _lgtm_detected_source_root
[2022-04-08 14:32:39] [build-stderr] + cd .
[2022-04-08 14:32:39] [build-stderr] + export CXXFLAGS=-fpermissive
[2022-04-08 14:32:39] [build-stderr] + CXXFLAGS=-fpermissive
[2022-04-08 14:32:39] [build-stderr] + configure_prefix_opt=
[2022-04-08 14:32:39] [build-stderr] + '[' -f configure.ac ']'
[2022-04-08 14:32:39] [build-stderr] + '[' -f configure.in ']'
[2022-04-08 14:32:39] [build-stderr] + '[' -f CMakeLists.txt ']'
[2022-04-08 14:32:39] [build-stderr] + '[' -f meson.build ']'
[2022-04-08 14:32:39] [build-stderr] + try_configure
[2022-04-08 14:32:39] [build-stderr] + build_dir=.
[2022-04-08 14:32:39] [build-stderr] + root_dir=.
[2022-04-08 14:32:39] [build-stderr] + grep -q 'AC_MSG_.* configure in a separate.* directory' configure.in configure.ac
[2022-04-08 14:32:39] [build-stderr] + for configure in configure configure.gnu
[2022-04-08 14:32:39] [build-stderr] + '[' -x configure ']'
[2022-04-08 14:32:39] [build-stderr] + for configure in configure configure.gnu
[2022-04-08 14:32:39] [build-stderr] + '[' -x configure.gnu ']'
[2022-04-08 14:32:39] [build-stderr] + rm -rf _lgtm_build_dir
[2022-04-08 14:32:39] [build-stderr] + for bootstrap in bootstrap.sh bootstrap autogen.sh
[2022-04-08 14:32:39] [build-stderr] + '[' -x bootstrap.sh ']'
[2022-04-08 14:32:39] [build-stderr] + '[' -f bootstrap.sh ']'
[2022-04-08 14:32:39] [build-stderr] + for bootstrap in bootstrap.sh bootstrap autogen.sh
[2022-04-08 14:32:39] [build-stderr] + '[' -x bootstrap ']'
[2022-04-08 14:32:39] [build-stderr] + '[' -f bootstrap ']'
[2022-04-08 14:32:39] [build-stderr] + for bootstrap in bootstrap.sh bootstrap autogen.sh
[2022-04-08 14:32:39] [build-stderr] + '[' -x autogen.sh ']'
[2022-04-08 14:32:39] [build-stderr] + '[' -f autogen.sh ']'
[2022-04-08 14:32:39] [build-stderr] + '[' -f wscript ']'
[2022-04-08 14:32:39] [build-stderr] + '[' -f Kbuild ']'
[2022-04-08 14:32:39] [build-stderr] + '[' -f Kconfig ']'
[2022-04-08 14:32:39] [build-stderr] + '[' -f configure.ac ']'
[2022-04-08 14:32:39] [build-stderr] + '[' -f configure.in ']'
[2022-04-08 14:32:39] [build-stderr] ++ echo './*.pro'
[2022-04-08 14:32:39] [build-stderr] + '[' './*.pro' '!=' './*.pro' ']'
[2022-04-08 14:32:39] [build-stderr] + exit 0
[2022-04-08 14:32:39] [build-stderr] + export VERBOSE=1
[2022-04-08 14:32:39] [build-stderr] + VERBOSE=1
[2022-04-08 14:32:39] [build-stderr] + '[' -L _lgtm_detected_source_root ']'
[2022-04-08 14:32:39] [build-stderr] ++ readlink _lgtm_detected_source_root
[2022-04-08 14:32:40] [build-stderr] + cd .
[2022-04-08 14:32:40] [build-stderr] + '[' -d _lgtm_build_dir ']'
[2022-04-08 14:32:40] [build-stderr] + '[' -f SConstruct ']'
[2022-04-08 14:32:40] [build-stderr] + '[' -f wscript ']'
[2022-04-08 14:32:40] [build-stderr] + '[' -f Makefile ']'
[2022-04-08 14:32:40] [build-stderr] + make
[2022-04-08 14:32:54] [build-stderr] /Users/sofiaoreis/cmu-portugal/tenet/vulnerable/CVE-2011-3353/linux/Makefile:670: include/config/auto.conf: No such file or directory
[2022-04-08 14:33:02] [build-stderr] /Users/sofiaoreis/cmu-portugal/tenet/vulnerable/CVE-2011-3353/linux/Makefile:707: include/config/auto.conf.cmd: No such file or directory
[2022-04-08 14:33:13] [build-stderr] ***
[2022-04-08 14:33:13] [build-stderr] *** Configuration file ".config" not found!
[2022-04-08 14:33:13] [build-stderr] ***
[2022-04-08 14:33:13] [build-stderr] *** Please run some configurator (e.g. "make oldconfig" or
[2022-04-08 14:33:13] [build-stderr] *** "make menuconfig" or "make xconfig").
[2022-04-08 14:33:13] [build-stderr] ***
[2022-04-08 14:33:13] [build-stderr] make[1]: /bin/false: No such file or directory
[2022-04-08 14:33:13] [build-stderr] make: *** [__sub-make] Segmentation fault: 11
[2022-04-08 14:33:13] [build-stderr] + '[' -f build.ninja ']'
[2022-04-08 14:33:13] [build-stderr] + '[' -d ../_lgtm_build_dir ']'
[2022-04-08 14:33:13] [build-stderr] + for f in build build.sh
[2022-04-08 14:33:13] [build-stderr] + '[' -x build ']'
[2022-04-08 14:33:13] [build-stderr] + for f in build build.sh
[2022-04-08 14:33:13] [build-stderr] + '[' -x build.sh ']'
[2022-04-08 14:33:13] [build-stderr] + '[' -f setup.py ']'
[2022-04-08 14:33:13] [build-stderr] + echo 'Semmle autobuild: no supported build system detected.'
[2022-04-08 14:33:13] [build-stderr] + exit 1
[2022-04-08 14:33:13] [build-stdout] Semmle autobuild: no supported build system detected.
[2022-04-08 14:33:13] [ERROR] Spawned process exited abnormally (code 1; tried to run: [/Users/sofiaoreis/codeql/codeql/tools/osx64/preload_tracer, /Users/sofiaoreis/codeql/codeql/cpp/tools/autobuild.sh])
A fatal error occurred: Exit status 1 from command: [/Users/sofiaoreis/codeql/codeql/cpp/tools/autobuild.sh]
$ codeql --version
CodeQL command-line toolchain release 2.8.5.
Copyright (C) 2019-2022 GitHub, Inc.
Unpacked in: /Users/sofiaoreis/codeql/codeql
   Analysis results depend critically on separately distributed query and
   extractor modules. To list modules that are visible to the toolchain,
   use 'codeql resolve qlpacks' and 'codeql resolve languages'.

What am I doing wrong? Thanks!

aibaars commented 2 years ago

CodeQL needs to compile C/C++ source code in order to analyze it. The error message Semmle autobuild: no supported build system detected is a little misleading. When looking at the output it looks like CodeQL detected a Makefile and ran make. Unfortunately make failed with the message Configuration file ".config" not found!. Most likely you need to run a "configure" step first.

The location of your home directory /Users and the error message /bin/false: No such file or directory suggest that you are using OSX. It may be hard to cross compile the Linux kernel on MacOS. Perhaps you could try using Docker (or a linux machine) instead.

sofiaoreis commented 2 years ago

Thanks for the tips!