draios / sysdig

Linux system exploration and troubleshooting tool with first class support for containers
http://www.sysdig.com/
Other
7.78k stars 725 forks source link

Building sysdig fails with userspace/libscap/engine/kmod/scap_kmod.c:372:(.text+0x35c7): undefined reference to `scap_get_host_root' #2105

Closed johanneskastl closed 5 months ago

johanneskastl commented 5 months ago

Hi everyone,

I wanted to update the sysdig package for openSUSE. I managed to get all the dependencies built (valijson was new between 0.26.x and the current release).

However the build fails with this error, where I cannot find anything online. I guess I am missing a setting or a system package, do you have an idea for me? Or is this something for the falco-libs repository?

Thanks in advance! Johannes

 [   39s] [ 30%] Linking CXX static library libcri_v1alpha2.a
[   39s] cd /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/libsinsp && /usr/bin/cmake -P CMakeFiles/cri_v1alpha2.dir/cmake_clean_target.cmake
[   39s] cd /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/libsinsp && /usr/bin/cmake -E cmake_link_script CMakeFiles/cri_v1alpha2.dir/link.txt --verbose=1
[   39s] /usr/bin/ar qc libcri_v1alpha2.a "CMakeFiles/cri_v1alpha2.dir/cri-v1alpha2.pb.cc.o" "CMakeFiles/cri_v1alpha2.dir/cri-v1alpha2.grpc.pb.cc.o"
[   39s] /usr/bin/ranlib libcri_v1alpha2.a                                                                                                  
[   39s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'
[   39s] make[1]: Entering directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'
[   39s] [ 30%] Built target cri_v1alpha2
[   39s] make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'
[   39s] /usr/bin/make  -f libscap/engine/kmod/CMakeFiles/scap_engine_kmod.dir/build.make libscap/engine/kmod/CMakeFiles/scap_engine_kmod.dir/depend
[   39s] make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'                
[   39s] cd /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/abuild/rpmbuild/BUILD/sysdig-0.37.1 /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/falcosecurity-libs-repo/falcosecurity-libs-prefix/src/falcosecurity-libs/usersp
ace/libscap/engine/kmod /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/libscap/engine/kmod /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/libscap/engine/kmod/CMakeFiles/scap_engine_kmod.dir/DependInfo.cmake
[   39s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'          
[   39s] /usr/bin/make  -f libscap/engine/kmod/CMakeFiles/scap_engine_kmod.dir/build.make libscap/engine/kmod/CMakeFiles/scap_engine_kmod.dir/build
[   39s] make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'
[   39s] [ 31%] Building C object libscap/engine/kmod/CMakeFiles/scap_engine_kmod.dir/scap_kmod.c.o
[   39s] cd /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/libscap/engine/kmod && /usr/bin/cc -DCHISEL_TOOL_LIBRARY_NAME=\"sysdig\" -DHAS_CAPTURE -DHAVE_STRLCPY -DHAVE_SYS_SYSMACROS_H -DPLATFORM_NAME=\"Linux\" -DSCAP_HOSTNAME_ENV_VAR=\"SCAP_HOSTNAME\" -DSCAP_HOST_ROOT_ENV_VAR_NAM
E=\"HOST_ROOT\" -DSCAP_KERNEL_MODULE_NAME=\"scap\" -D_GNU_SOURCE -Dscap_engine_kmod_EXPORTS -I/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/driver/src -I/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/falcosecurity-libs-repo/falcosecurity-libs-prefix/src/falcosecurity-libs -I/ho
me/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/falcosecurity-libs-repo/falcosecurity-libs-prefix/src/falcosecurity-libs/userspace -I/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build -I/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/falcosecurity-libs-repo/falcosecurity-libs-prefix/src
/falcosecurity-libs/userspace/libscap/linux -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -Wall -ggdb   -O2 -g -DNDEBUG -fPIC -MD -MT libscap/engine/k
mod/CMakeFiles/scap_engine_kmod.dir/scap_kmod.c.o -MF CMakeFiles/scap_engine_kmod.dir/scap_kmod.c.o.d -o CMakeFiles/scap_engine_kmod.dir/scap_kmod.c.o -c /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/falcosecurity-libs-repo/falcosecurity-libs-prefix/src/falcosecurity-libs/usersp
ace/libscap/engine/kmod/scap_kmod.c
[   39s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'                                                                                                                                                                                                    
[   40s] make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'
[   40s] [ 30%] Linking C shared library libscap_engine_bpf.so     
[   40s] cd /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/libscap/engine/bpf && /usr/bin/cmake -E cmake_link_script CMakeFiles/scap_engine_bpf.dir/link.txt --verbose=1
[   40s] /usr/bin/cc -fPIC -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -Wall -ggdb   -O2 -g -DNDEBUG -flto=auto -Wl,--as-needed -Wl,--no-undefined -
Wl,-z,now -shared -Wl,-soname,libscap_engine_bpf.so.SOVERSION -o libscap_engine_bpf.so.SOVERSION CMakeFiles/scap_engine_bpf.dir/scap_bpf.c.o CMakeFiles/scap_engine_bpf.dir/attached_prog.c.o  ../../libscap_event_schema.a ../../linux/libscap_platform.a ../../libscap_engine_util.a ..
/../libscap_error.a /usr/lib64/libelf.so /usr/lib64/libz.so ../../libdriver_event_schema.a ../../libscap_platform_util.a
[   40s] cd /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/libscap/engine/bpf && /usr/bin/cmake -E cmake_symlink_library libscap_engine_bpf.so.SOVERSION libscap_engine_bpf.so.SOVERSION libscap_engine_bpf.so
[   40s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'
[   40s] make[1]: Entering directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'
[   40s] [ 31%] Built target scap_engine_bpf
[   40s] make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'
[   41s] make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'
[   41s] [ 31%] Linking C shared library libscap_engine_kmod.so
[   41s] cd /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/libscap/engine/kmod && /usr/bin/cmake -E cmake_link_script CMakeFiles/scap_engine_kmod.dir/link.txt --verbose=1
[   41s] /usr/bin/cc -fPIC -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -Wall -ggdb   -O2 -g -DNDEBUG -flto=auto -Wl,--as-needed -Wl,--no-undefined -
Wl,-z,now -shared -Wl,-soname,libscap_engine_kmod.so.SOVERSION -o libscap_engine_kmod.so.SOVERSION CMakeFiles/scap_engine_kmod.dir/scap_kmod.c.o  ../../libscap_event_schema.a ../../linux/libscap_platform.a ../../libscap_engine_util.a ../../libscap_error.a ../../libdriver_event_sch
ema.a ../../libscap_platform_util.a
[   41s] /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: /tmp/ccGfL7so.ltrans0.ltrans.o: in function `scap_kmod_init':
[   41s] /home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build/falcosecurity-libs-repo/falcosecurity-libs-prefix/src/falcosecurity-libs/userspace/libscap/engine/kmod/scap_kmod.c:372:(.text+0x35c7): undefined reference to `scap_get_host_root'
[   41s] collect2: error: ld returned 1 exit status
[   41s] make[2]: *** [libscap/engine/kmod/CMakeFiles/scap_engine_kmod.dir/build.make:106: libscap/engine/kmod/libscap_engine_kmod.so.SOVERSION] Error 1
[   41s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/sysdig-0.37.1/build'
[   41s] make[1]: *** [CMakeFiles/Makefile2:1015: libscap/engine/kmod/CMakeFiles/scap_engine_kmod.dir/all] Error 2
[   41s] make[1]: *** Waiting for unfinished jobs....
jasondellaluce commented 5 months ago

@FedeDP tagging you just to see if this rings a bell

FedeDP commented 5 months ago

No bell :( scap_get_host_root is declared in scap.h and defined in scap.c; i see that scap_kmod.c correctly includes #include <libscap/scap.h>, therefore the helper method should be visible.

@johanneskastl i think the issue shoud be opened against the falcosecurity libs repo anyway; can you? :) Thank you for reporting! I will try to reproduce this building in a opensuse docker container; can you share:

Thank you very much!

johanneskastl commented 5 months ago

Thanks for the replies, @jasondellaluce and @FedeDP !

I tried a different approach and packaged the falcolibs separately. I was able to build them successfully, without running into this issue. I'll try to get sysdig to build using that packaged version of the libs. Closing this for now.