falcosecurity / libs

libsinsp, libscap, the kernel module driver, and the eBPF driver sources
https://falcosecurity.github.io/libs/
Apache License 2.0
227 stars 162 forks source link

cmake error:install TARGETS given target "scap" which does not exist in this directory. #1513

Closed YanjiangChen closed 10 months ago

YanjiangChen commented 10 months ago

cmake -DUSE_BUNDLED_DEPS=ON ../; -- Libs version: 0.14.0-409+c2fd308 -- Driver version: 6.1.0-409+c2fd308-driver -- Kernel version: 4.19.90-17.ky10.x86_64 -- Driver API version 8.0.0 -- Driver schema version 2.14.0 -- Configuring done -- Generating done -- Build files have been written to: /root/libs/build/googletest-download [100%] Built target googletest -- Using bundled uthash in '/root/libs/build/uthash-prefix/src/uthash/src' -- No strlcpy found, will use local definition -- No strlcat found, will use local definition -- Using bundled zlib in '/root/libs/build/zlib-prefix/src/zlib' -- Using bundled libelf: include'/root/libs/build/libelf-prefix/src/libelf/libelf', lib: /root/libs/build/libelf-prefix/src/libelf/libelf/libelf.a -- Using bundled protobuf in '/root/libs/build/protobuf-prefix/src/protobuf' -- Using bundled jsoncpp in '/root/libs/build/jsoncpp-prefix/src' CMake Error at cmake/modules/libscap.cmake:124 (install): install TARGETS given target "scap" which does not exist in this directory. Call Stack (most recent call first): CMakeLists.txt:109 (include)

-- Using bundled tbb in '/root/libs/build/tbb-prefix/src/tbb' -- Using bundled c-ares in '/root/libs/build/c-ares-prefix/src/c-ares' -- Using bundled openssl in '/root/libs/build/openssl-prefix/src/openssl' -- Using SSL for curl in '/root/libs/build/openssl-prefix/src/openssl/target' -- Using zlib for curl in '/root/libs/build/zlib-prefix/src/zlib' -- Using bundled curl in '/root/libs/build/curl-prefix/src/curl' -- Using bundled valijson in '/root/libs/build/valijson-prefix/src/valijson' -- Using bundled re2 in '/root/libs/build/re2-prefix/src/re2' -- Using bundled tinydir in '/root/libs/build/tinydir-prefix/src/tinydir' -- Using jsoncpp: include: /root/libs/build/jsoncpp-prefix/src/include/, lib: /root/libs/build/jsoncpp-prefix/src/lib/libjsoncpp.a -- Using re2: include: /root/libs/build/re2-prefix/src/re2/include, lib: /root/libs/build/re2-prefix/src/re2/lib/libre2.a -- Using bundled grpc in '/root/libs/build/grpc-prefix/src/grpc' -- Using jsoncpp: include: /root/libs/build/jsoncpp-prefix/src/include/, lib: /root/libs/build/jsoncpp-prefix/src/lib/libjsoncpp.a -- Download all scap-files from: https://download.falco.org/fixtures/libs/scap_files -- Downloading scap-file: https://download.falco.org/fixtures/libs/scap_files/kexec_arm64.scap -- Skipping download, file already present -- Downloading scap-file: https://download.falco.org/fixtures/libs/scap_files/kexec_x86.scap -- Skipping download, file already present CMake Error at cmake/modules/libsinsp.cmake:89 (install): install TARGETS given target "sinsp" which does not exist in this directory. Call Stack (most recent call first): CMakeLists.txt:110 (include)

CMake Warning at test/e2e/CMakeLists.txt:7 (message): e2etestscanonlyberunwiththeeBPFprobe

-- Configuring incomplete, errors occurred! See also "/root/libs/build/CMakeFiles/CMakeOutput.log". See also "/root/libs/build/CMakeFiles/CMakeError.log".

Andreagit97 commented 10 months ago

ei @YanjiangChen could you provide more info about your system? architecture, the cmake version used, ... Moreover, could you try a clean build with latest libs master https://github.com/falcosecurity/libs/commit/02877435e21afd7bdd6715ffd7c865a2f01ae682:

git clone https://github.com/falcosecurity/libs.git
cd libs
mkdir build && cd build
cmake -DUSE_BUNDLED_DEPS=On ..
YanjiangChen commented 10 months ago

The problem is still not solved after using the latest version。

I also encountered another problem when executing cmake

install TARGETS given target "sinsp" which does not exist in this directory.

The following is the prompt in CMakeError:

Determining if the pthread_create exist failed with the following output: Change Dir: /root/libs/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/gmake" "cmTC_97567/fast" /usr/bin/gmake -f CMakeFiles/cmTC_97567.dir/build.make CMakeFiles/cmTC_97567.dir/build gmake[1]: 进入目录“/root/libs/build/CMakeFiles/CMakeTmp” Building C object CMakeFiles/cmTC_97567.dir/CheckSymbolExists.c.o /usr/bin/cc -Wall -ggdb -o CMakeFiles/cmTC_97567.dir/CheckSymbolExists.c.o -c /root/libs/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c Linking C executable cmTC_97567 /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_97567.dir/link.txt --verbose=1 /usr/bin/cc -Wall -ggdb CMakeFiles/cmTC_97567.dir/CheckSymbolExists.c.o -o cmTC_97567 /usr/bin/ld: CMakeFiles/cmTC_97567.dir/CheckSymbolExists.c.o: in function main': /root/libs/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8: undefined reference topthread_create' collect2: 错误:ld 返回 1 gmake[1]: [CMakeFiles/cmTC_97567.dir/build.make:87:cmTC_97567] 错误 1 gmake[1]: 离开目录“/root/libs/build/CMakeFiles/CMakeTmp” gmake: [Makefile:121:cmTC_97567/fast] 错误 2

Determining if the include file sys/mkdev.h exists failed with the following output: Change Dir: /root/libs/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/gmake" "cmTC_8b47c/fast" /usr/bin/gmake -f CMakeFiles/cmTC_8b47c.dir/build.make CMakeFiles/cmTC_8b47c.dir/build gmake[1]: 进入目录“/root/libs/build/CMakeFiles/CMakeTmp” Building C object CMakeFiles/cmTC_8b47c.dir/CheckIncludeFile.c.o /usr/bin/cc -Wall -ggdb -o CMakeFiles/cmTC_8b47c.dir/CheckIncludeFile.c.o -c /root/libs/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c /root/libs/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: 致命错误:sys/mkdev.h:没有那个文件或目录

include <sys/mkdev.h>

      ^~~~~~~~~~~~~

编译中断。 gmake[1]: [CMakeFiles/cmTC_8b47c.dir/build.make:66:CMakeFiles/cmTC_8b47c.dir/CheckIncludeFile.c.o] 错误 1 gmake[1]: 离开目录“/root/libs/build/CMakeFiles/CMakeTmp” gmake: [Makefile:121:cmTC_8b47c/fast] 错误 2

The following is the system information: cmake version==3.12.1, architecture is x86_64, system is kylin,maybe you haven't heard of it, similar to centos, rhel..

YanjiangChen commented 10 months ago

The problem is solved. The cmake version is too low. I have updated the cmake version

Andreagit97 commented 10 months ago

ok thank you! just out of curiosity which cmake version did you use before?

YanjiangChen commented 10 months ago

cmake version is 3.12.1, Thank you for your help

YanjiangChen commented 10 months ago

make drvier errr: /root/libs/build/driver/src/ppm_events.c: 在函数‘ppm_copy_from_user’中: /root/libs/build/driver/src/ppm_events.c:94:48: 错误:宏“access_ok”传递了 3 个参数,但只需要 2 个 if (likely(ppm_access_ok(VERIFY_READ, from, n))) ^ In file included from ./include/linux/export.h:45:0, from ./include/linux/linkage.h:7, from ./arch/x86/include/asm/cache.h:5, from ./include/linux/cache.h:6, from ./include/linux/time.h:5, from ./include/linux/compat.h:10, from /root/libs/build/driver/src/ppm_events.c:13: /root/libs/build/driver/src/ppm_events.c:50:41: 错误:‘access_ok’ undeclared (first use in this function); did you mean ‘access_flags’?

define ppm_access_ok(type, addr, size) access_ok(type, addr, size)

                                     ^

./include/linux/compiler.h:76:40: 附注:in definition of macro ‘likely’

define likely(x) __builtin_expect(!!(x), 1)

                                    ^

/root/libs/build/driver/src/ppm_events.c:94:13: 附注:in expansion of macro ‘ppm_access_ok’ if (likely(ppm_access_ok(VERIFY_READ, from, n))) ^~~~~ /root/libs/build/driver/src/ppm_events.c:50:41: 附注:每个未声明的标识符在其出现的函数内只报告一次

define ppm_access_ok(type, addr, size) access_ok(type, addr, size)

                                     ^

./include/linux/compiler.h:76:40: 附注:in definition of macro ‘likely’

define likely(x) __builtin_expect(!!(x), 1)

                                    ^

/root/libs/build/driver/src/ppm_events.c:94:13: 附注:in expansion of macro ‘ppm_access_ok’ if (likely(ppm_access_ok(VERIFY_READ, from, n))) ^~~~~ /root/libs/build/driver/src/ppm_events.c: 在函数‘ppm_strncpy_from_user’中: /root/libs/build/driver/src/ppm_events.c:129:54: 错误:宏“access_ok”传递了 3 个参数,但只需要 2 个 if (!ppm_access_ok(VERIFY_READ, from, bytes_to_read)) { ^ /root/libs/build/driver/src/ppm_events.c:50:41: 错误:‘access_ok’ undeclared (first use in this function); did you mean ‘access_flags’?

define ppm_access_ok(type, addr, size) access_ok(type, addr, size)

                                     ^

/root/libs/build/driver/src/ppm_events.c:129:8: 附注:in expansion of macro ‘ppm_access_ok’ if (!ppm_access_ok(VERIFY_READ, from, bytes_to_read)) { ^~~~~ make[6]: [scripts/Makefile.build:304:/root/libs/build/driver/src/ppm_events.o] 错误 1 make[5]: [Makefile:1598:module/root/libs/build/driver/src] 错误 2 make[5]: 离开目录“/usr/src/kernels/4.19.90-52.22.v2207.ky10.x86_64” make[4]: [Makefile:18:all] 错误 2 make[4]: 离开目录“/root/libs/build/driver/src” make[3]: [driver/CMakeFiles/driver.dir/build.make:57:driver/CMakeFiles/driver] 错误 2 make[3]: 离开目录“/root/libs/build” make[2]: [CMakeFiles/Makefile2:793:driver/CMakeFiles/driver.dir/all] 错误 2 make[2]: 离开目录“/root/libs/build” make[1]: [CMakeFiles/Makefile2:800:driver/CMakeFiles/driver.dir/rule] 错误 2 make[1]: 离开目录“/root/libs/build” make: *** [Makefile:268:driver] 错误 2

kernel version is 4.19.90-52.22

YanjiangChen commented 10 months ago

After modifying the ppm_events.c file, the compilation is successful, but it cannot be run.

Error: Driver supports API version 8.0.0, but running version needs 5.0.0

Andreagit97 commented 10 months ago

it seems like you are compiling the libraries using an old version different from master(5.0.0 means this is an old code version, actual API version is 8.0.0).

If you compile everything using the master commit all should work out of the box like i wrote here https://github.com/falcosecurity/libs/issues/1513#issuecomment-1829615843

YanjiangChen commented 10 months ago

What I pulled is the code of the master branch. The ko generated by make driver is indeed unusable, but the falco code is not the latest.

YanjiangChen commented 10 months ago

falco version is 0.36.2, libs version is master latest

YanjiangChen commented 10 months ago

I modified this paragraph(in this libs/build/driver/src/ppm_events.c). It originally looked like this.

define ppm_access_ok(type, addr, size) access_ok(type, addr, size)

Because it couldn't be compiled, this error was reported.: /root/libs/build/driver/src/ppm_events.c:94:13: 附注:in expansion of macro ‘ppm_access_ok’ if (likely(ppm_access_ok(VERIFY_READ, from, n))) ^~~~~ /root/libs/build/driver/src/ppm_events.c: 在函数‘ppm_strncpy_from_user’中: /root/libs/build/driver/src/ppm_events.c:129:54: 错误:宏“access_ok”传递了 3 个参数,但只需要 2 个 if (!ppm_access_ok(VERIFY_READ, from, bytes_to_read)) {

After the modification, it looked like this.

define ppm_access_ok(type, addr, size) access_ok(addr, size)

Then the compiled version could not be loaded and the following error was reported: Error: Driver supports API version 8.0.0, but running version needs 5.0.0

YanjiangChen commented 10 months ago

I have compiled falco and it runs fine, thanks for your help