Closed nwaples closed 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
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.
@nwaples could you please verify if make static_build=1 rebuild
works for you now.
yes, all is good thanks
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
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 against
global_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