github / codeql-cli-binaries

Binaries for the CodeQL CLI
Other
741 stars 104 forks source link

Building sgx-lkl under codeql fails. #34

Open matt-gretton-dann opened 4 years ago

matt-gretton-dann commented 4 years ago

This is based on the following LGTM ticket: https://discuss.lgtm.com/t/error-loading-shared-library-ld-linux-x86-64-so-2-no-such-file-or-directory-needed-by-opt-dist-tools-lib64trace-so/2944/4

Build sgx-lkl as follows:

sudo apt-get install make gcc g++ bc python xutils-dev bison flex libgcrypt20-dev libjson-c-dev automake autopoint autoconf pkgconf libtool libcurl4-openssl-dev libprotobuf-dev libprotobuf-c-dev protobuf-compiler protobuf-c-compiler libssl-dev
git clone https://github.com/lsds/sgx-lkl.git
cd sgx-lkl
git submodule init
git submodule update --recursive
 ~/codeql-releases/codeql-2.2.2/codeql/codeql database create /tmp/db-sgx-lkl -l cpp -c "make"

After a while the build fails:

[2020-06-15 11:15:28] [build] checking for C compiler default output file name... a.out
[2020-06-15 11:15:28] [build-err] configure: error: in `/home/mgretton/git-repos/sgx-lkl/third_party/popt':
[2020-06-15 11:15:28] [build-err] configure: error: cannot run C compiled programs.
[2020-06-15 11:15:28] [build-err] If you meant to cross compile, use `--host'.
[2020-06-15 11:15:28] [build-err] See `config.log' for more details.
[2020-06-15 11:15:28] [build-err] make[1]: *** [Makefile:74: /home/mgretton/git-repos/sgx-lkl/build/cryptsetup/lib/libpopt.a] Error 1
[2020-06-15 11:15:28] [build-err] make[1]: unlink: /home/mgretton/git-repos/sgx-lkl/third_party/popt: Is a directory
[2020-06-15 11:15:28] [build] checking whether the C compiler works... rm /home/mgretton/git-repos/sgx-lkl/third_party/popt
[2020-06-15 11:15:28] [build] make[1]: Leaving directory '/home/mgretton/git-repos/sgx-lkl/third_party'
[2020-06-15 11:15:28] [build-err] make: *** [Makefile:41: /home/mgretton/git-repos/sgx-lkl/build/cryptsetup/lib/libcryptsetup.a] Error 2
[2020-06-15 11:15:28] [ERROR] Spawned process exited abnormally (code 2; tried to run: [/home/mgretton/codeql-releases/codeql-2.2.2/codeql/tools/linux64/preload_tracer, make])
A fatal error occurred: Exit status 2 from command: [make]

Looking in the appropriate config.log (third_party/popt/config.log) has the following error message:

configure:3186: checking for C compiler default output file name
configure:3208: /home/mgretton/git-repos/sgx-lkl/build/host-musl/bin/musl-gcc  -O3 -fPIC -Wl,--dynamic-linker=/home/mgretton/git-repos/sgx-lkl/build/host-musl/lib/libc.so   conftest.c  >&5
configure:3212: $? = 0
configure:3250: result: a.out
configure:3269: checking whether the C compiler works
configure:3279: ./a.out
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /home/mgretton/codeql-releases/codeql-2.2.2/codeql/tools/linux64/lib64trace.so)
Error relocating /home/mgretton/codeql-releases/codeql-2.2.2/codeql/tools/linux64/lib64trace.so: __strdup: symbol not found
Error relocating /home/mgretton/codeql-releases/codeql-2.2.2/codeql/tools/linux64/lib64trace.so: __libc_dlopen_mode: symbol not found
Error relocating /home/mgretton/codeql-releases/codeql-2.2.2/codeql/tools/linux64/lib64trace.so: __libc_dlsym: symbol not found
Error relocating /home/mgretton/codeql-releases/codeql-2.2.2/codeql/tools/linux64/lib64trace.so: _dl_argv: symbol not found
configure:3283: $? = 127
configure:3290: error: in `/home/mgretton/git-repos/sgx-lkl/third_party/popt':
configure:3294: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.

This is a tracing issue.

NEXUS2345 commented 2 years ago

Is there any update on this? I'm encountering it in a Meson project. Trying to create symlinks hasn't fixed it.

https://github.com/ChipsandCheese/MemoryLatencyTest/runs/4346365370?check_suite_focus=true

criemen commented 2 years ago

The issue is that you're using a musl-based binary. CodeQL on Linux only supports glibc-based binaries. We are considering adding support for musl, but at the time we don't have concrete plans (or a timeline) yet.