CloudNativeDataPlane / cndp

Cloud Native Data Plane (CNDP) is a collection of user space libraries to accelerate packet processing for cloud applications using AF_XDP sockets as the primary I/O..
BSD 3-Clause "New" or "Revised" License
90 stars 32 forks source link

make static_build=1 rebuild fails #202

Closed nwaples closed 2 years ago

nwaples commented 2 years ago

Using Ubuntu 20.04 setup using ansible

"/home/canopus/cndp/tools/cne-build.sh" clean static build Build environment variables and paths: CNE_SDK_DIR : /home/canopus/cndp CNE_TARGET_DIR : usr/local CNE_BUILD_DIR : /home/canopus/cndp/builddir CNE_DEST_DIR : /home/canopus/cndp PKG_CONFIG_PATH : /usr/lib64/pkgconfig build_path : /home/canopus/cndp/builddir target_path : /home/canopus/cndp/usr/local

*** Removing '/home/canopus/cndp/builddir' directory

Static build in '/home/canopus/cndp/builddir' Release build in '/home/canopus/cndp/builddir' Ninja build in '/home/canopus/cndp/builddir' buildtype='release' The Meson build system Version: 0.53.2 Source dir: /home/canopus/cndp Build dir: /home/canopus/cndp/builddir Build type: native build Program cat found: YES (/bin/cat) Project name: CNDP Project version: 22.08.0 C++ compiler for the host machine: c++ (gcc 9.4.0 "c++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0") C++ linker for the host machine: c++ ld.bfd 2.34 C compiler for the host machine: cc (gcc 9.4.0 "cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0") C linker for the host machine: cc ld.bfd 2.34 Host machine cpu family: x86_64 Host machine cpu: x86_64 Checking for size of "void *" : 8 meson.build:91: WARNING: Consider using the built-in debug option instead of using "-g". Has header "execinfo.h" : YES Found pkg-config: /usr/bin/pkg-config (0.29.1) Did not find CMake 'cmake' Found CMake: NO Run-time dependency libexecinfo found: NO (tried pkgconfig and cmake) Run-time dependency numa found: NO (tried pkgconfig and cmake) Run-time dependency libbsd found: YES 0.10.0 Run-time dependency json-c found: YES 0.13.1 Run-time dependency libpcap found: YES 1.9.1 Run-time dependency libnl-3.0 found: YES 3.4.0 Run-time dependency libnl-cli-3.0 found: YES 3.4.0 Run-time dependency libnl-route-3.0 found: YES 3.4.0 Run-time dependency libxdp found: NO (tried pkgconfig) Run-time dependency libbpf found: YES 0.3.0 Has header "linux/if_xdp.h" : YES Has header "bpf/xsk.h" : YES Has header "bpf/bpf.h" : YES Run-time dependency libbpf found: YES 0.3.0 Compiler for C supports arguments -muintr: NO Run-time dependency libdlb found: NO (tried pkgconfig) Compiler for C supports arguments -Wno-pedantic -Wpedantic: YES Compiler for C++ supports arguments -Wno-pedantic -Wpedantic: YES Compiler for C supports arguments -Wcast-qual: YES Compiler for C++ supports arguments -Wcast-qual: YES Compiler for C supports arguments -Wdeprecated: YES Compiler for C++ supports arguments -Wdeprecated: YES Compiler for C supports arguments -Wformat-nonliteral: YES Compiler for C++ supports arguments -Wformat-nonliteral: YES Compiler for C supports arguments -Wformat-security: YES Compiler for C++ supports arguments -Wformat-security: YES Compiler for C supports arguments -Wmissing-declarations: YES Compiler for C++ supports arguments -Wmissing-declarations: YES Compiler for C supports arguments -Wmissing-prototypes: YES Compiler for C++ supports arguments -Wmissing-prototypes: NO Compiler for C supports arguments -Wnested-externs: YES Compiler for C++ supports arguments -Wnested-externs: NO Compiler for C supports arguments -Wold-style-definition: YES Compiler for C++ supports arguments -Wold-style-definition: NO Compiler for C supports arguments -Wpointer-arith: YES Compiler for C++ supports arguments -Wpointer-arith: YES Compiler for C supports arguments -Wsign-compare: YES Compiler for C++ supports arguments -Wsign-compare: YES Compiler for C supports arguments -Wstrict-prototypes: YES Compiler for C++ supports arguments -Wstrict-prototypes: NO Compiler for C supports arguments -Wundef: YES Compiler for C++ supports arguments -Wundef: YES Compiler for C supports arguments -Wwrite-strings: YES Compiler for C++ supports arguments -Wwrite-strings: YES Compiler for C supports arguments -Wno-address-of-packed-member -Waddress-of-packed-member: YES Compiler for C++ supports arguments -Wno-address-of-packed-member -Waddress-of-packed-member: YES Compiler for C supports arguments -Wno-packed-not-aligned -Wpacked-not-aligned: YES Compiler for C++ supports arguments -Wno-packed-not-aligned -Wpacked-not-aligned: YES Compiler for C supports arguments -Wno-missing-field-initializers -Wmissing-field-initializers: YES Compiler for C++ supports arguments -Wno-missing-field-initializers -Wmissing-field-initializers: YES Fetching value of define "__SSE4_2" : 1 Fetching value of define "AES" : 1 Fetching value of define "PCLMUL" : 1 Fetching value of define "AVX" : 1 Fetching value of define "AVX2" : 1 Fetching value of define "AVX512F" : Fetching value of define "RDRND" : 1 Fetching value of define "RDSEED" : 1 Fetching value of define "AVX512F" : (cached) Fetching value of define "AVX512DQ" : Message: IPv4 dump output disabled Message: TCP support disabled Message: Enable support for punting to Linux kernel stack Message: TCP dump output disabled Configuring cne_build_config.h using configuration Fetching value of define "AVX2" : 1 (cached) Fetching value of define "AVX512F" : (cached) Fetching value of define "AVX512VL" : Fetching value of define "AVX512CD" : Fetching value of define "AVX512BW__" : Compiler for C supports arguments -mavx512f -mavx512vl -mavx512cd -mavx512bw: YES Compiler for C supports arguments -mavx512f -mavx512dq: YES Message: * have multiple avx512f and avx512dq Compiler for C supports arguments -mavx512bw: YES Compiler for C supports arguments -mavx512bw: YES Program python3 found: YES (/usr/bin/python3) Program doxygen found: YES (/usr/bin/doxygen) Program generate_doxygen.sh found: YES (/home/canopus/cndp/doc/api/generate_doxygen.sh) Program generate_examples.sh found: YES (/home/canopus/cndp/doc/api/generate_examples.sh) Program doxy-html-custom.sh found: YES (/home/canopus/cndp/doc/api/doxy-html-custom.sh) Configuring doxy-api.conf using configuration Program sphinx-build found: YES (/usr/bin/sphinx-build) Message: Fuzz tests require clang. Fuzz tests will not be built. Message: ** Missing Linux source code, not building afxdp_user example:/usr/src/linux-source-5.13.0 Library quicly found: NO Message: **** Quicly not found at /work/projects/intel/networking.dataplane/quicly Update meson_options.txt file. The quic-echo example cannot be built. Message: DLB test build missing library Program tools/mklib.sh found: YES (/home/canopus/cndp/tools/mklib.sh) Program cp found: YES (/bin/cp) Program cp found: YES (/bin/cp) Message: >>> Create pkg-config file Message: <<< Done pkg-config file Build targets in project: 69

Option default_library is: static [default: shared] Found ninja-1.10.0 at /usr/bin/ninja ninja: Entering directory /home/canopus/cndp/builddir' [75/309] Linking target lib/core/pmds/net/af_xdp/libpmd_af_xdp.so. FAILED: lib/core/pmds/net/af_xdp/libpmd_af_xdp.so cc -o lib/core/pmds/net/af_xdp/libpmd_af_xdp.so 'lib/core/pmds/net/af_xdp/3c1feb5@@pmd_af_xdp@sha/pmd_af_xdp.c.o' -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,libpmd_af_xdp.so -Wl,--no-as-needed -pthread -lm -ldl -lbsd -ljson-c -lpcap -lnl-3 -lnl-cli-3 -lnl-route-3 lib/core/osal/libcne_osal.a lib/core/log/libcne_log.a lib/core/mmap/libcne_mmap.a lib/core/cne/libcne_cne.a lib/core/kvargs/libcne_kvargs.a lib/core/pktdev/libcne_pktdev.a lib/core/mempool/libcne_mempool.a lib/core/ring/libcne_ring.a lib/core/pktmbuf/libcne_pktmbuf.a lib/common/uds/libcne_uds.a lib/core/xskdev/libcne_xskdev.a /usr/lib/libbpf.a /usr/lib/x86_64-linux-gnu/libelf.a /usr/lib/x86_64-linux-gnu/libz.a -Wl,--end-group '-Wl,-rpath,$ORIGIN/../../../osal:$ORIGIN/../../../log:$ORIGIN/../../../mmap:$ORIGIN/../../../cne:$ORIGIN/../../../kvargs:$ORIGIN/../../../pktdev:$ORIGIN/../../../mempool:$ORIGIN/../../../ring:$ORIGIN/../../../pktmbuf:$ORIGIN/../../../../common/uds:$ORIGIN/../../../xskdev' -Wl,-rpath-link,/home/canopus/cndp/builddir/lib/core/osal -Wl,-rpath-link,/home/canopus/cndp/builddir/lib/core/log -Wl,-rpath-link,/home/canopus/cndp/builddir/lib/core/mmap -Wl,-rpath-link,/home/canopus/cndp/builddir/lib/core/cne -Wl,-rpath-link,/home/canopus/cndp/builddir/lib/core/kvargs -Wl,-rpath-link,/home/canopus/cndp/builddir/lib/core/pktdev -Wl,-rpath-link,/home/canopus/cndp/builddir/lib/core/mempool -Wl,-rpath-link,/home/canopus/cndp/builddir/lib/core/ring -Wl,-rpath-link,/home/canopus/cndp/builddir/lib/core/pktmbuf -Wl,-rpath-link,/home/canopus/cndp/builddir/lib/common/uds -Wl,-rpath-link,/home/canopus/cndp/builddir/lib/core/xskdev /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libelf.a(elf_error.o): relocation R_X86_64_TPOFF32 againstglobal_error' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/lib/libbpf.a(libbpf.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status [84/309] Compiling C object 'lib/usr/clib/acl/ee741e7@@avx512_tmp@sta/acl_run_avx512.c.o'. ninja: build stopped: subcommand failed. make: *** [Makefile:46: rebuild] Error 1

KeithWiles commented 2 years ago

@manojgop looks like the patch that was applied to build both .a and .so for Rust builds breaks the normal static builds. I believe we will need to revert that patch, can you verify this is the case?

Thanks

manojgop commented 2 years ago

I raised PR for above issue

manojgop commented 2 years ago

Fix static build: Generate static library for pmds.

pmds uses constructor which runs before main function to register pmds. linker doesn't include any symbols from PMDs in the application binary if application doesn't explicitly use any symbols from PMD library. CNDP applications need not directly call any functions in pmd library and pmd library symbols is not included in application by linker. So pmds should linked as static whole-archive.

If both static/dynamic pmd library is present it creates conflict during linking stage and it throws error during CNDP static build. So to fix it we will generate only static libraries for pmds in static build.

build works in both cases:"make rebuild" and "make static_build=1 rebuild".

Note: shared libraries are still generated for other CNDP CNE libraries. For pmds we generate only static libraries in static build.

manojgop commented 2 years ago

@nwaples could you please verify if make static_build=1 rebuild works for you now.

nwaples commented 2 years ago

yes, all is good thanks