[dpdk-dev] [PATCH] Fix linking errors when CONFIG_RTE_BUILD_SHARED_LIB is enabled

Tetsuya Mukawa mukawa at igel.co.jp
Thu Oct 2 04:48:37 CEST 2014


(2014/10/01 20:56), Thomas Monjalon wrote:
> 2014-10-01 06:50, Neil Horman:
>> On Wed, Oct 01, 2014 at 01:27:03PM +0900, mukawa at igel.co.jp wrote:
>>> When CONFIG_RTE_BUILD_SHARED_LIB is enabled, linking errors occured
>>> while compiling. It seems those errors are caused by wrong link order
>>> of some libraries. The patch fixes it like following.
>>>
>>> 1. librte_eal
>>> 2. librte_malloc
>>> 3. librte_mempool
>>> 4. librte_ring
>>> 5. librte_pmd_bond
>>> 6. librte_kvargs
>>>
>> I'm not sure why thats necesecary.  We add a --start-group/--end-group pair
>> halfway through this makefile.  If we just encompassed the entire set of
>> libraries in that group, order would be irrelevant.
> I don't see any error.
> Please Tetsuya, could you describe how you test and what is the error message?
>
> Thanks
Thank you for testing.
I have confirmed '--start-group/--end-groups' is specified while
compiling, but I am still seeing the error.

Here is what I actually did.

----------------------------------------------------------------------

<< Show my environment >>
$ uname -a
Linux eris 3.13.0-29-generic #53-Ubuntu SMP Wed Jun 4 21:00:20 UTC 2014
x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:    14.04
Codename:    trusty
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib
--enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --disable-libmudflap --enable-plugin
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)

<< Compile DPDK >>
$ git clone git://dpdk.org/dpdk
$ cd dpdk
$ vi config/common_linuxapp
CONFIG_RTE_BUILD_SHARED_LIB=y
$ T=x86_64-native-linuxapp-gcc make install V=1

.......

== Build app/test-acl
gcc -Wp,-MD,./.main.o.d.tmp -m64 -pthread -fPIC  -march=native
-DRTE_MACHINE_CPUFLAG_SSE -DRTE_MACHINE_CPUFLAG_SSE2
-DRTE_MACHINE_CPUFLAG_SSE3 -DRTE_MACHINE_CPUFLAG_SSSE3
-DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MACHINE_CPUFLAG_SSE4_2
-DRTE_MACHINE_CPUFLAG_AES -DRTE_MACHINE_CPUFLAG_PCLMULQDQ
-DRTE_MACHINE_CPUFLAG_AVX -DRTE_MACHINE_CPUFLAG_F16C
-DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2,RTE_CPUFLAG_AES,RTE_CPUFLAG_PCLMULQDQ,RTE_CPUFLAG_AVX,RTE_CPUFLAG_F16C 
-I/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/include -include
/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/include/rte_config.h -W
-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wold-style-definition -Wpointer-arith
-Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral
-Wformat-security -Wundef -Wwrite-strings   -o main.o -c
/home/mukawa/tmp/dpdk/app/test-acl/main.c
gcc -m64 -pthread -fPIC  -march=native -DRTE_MACHINE_CPUFLAG_SSE
-DRTE_MACHINE_CPUFLAG_SSE2 -DRTE_MACHINE_CPUFLAG_SSE3
-DRTE_MACHINE_CPUFLAG_SSSE3 -DRTE_MACHINE_CPUFLAG_SSE4_1
-DRTE_MACHINE_CPUFLAG_SSE4_2 -DRTE_MACHINE_CPUFLAG_AES
-DRTE_MACHINE_CPUFLAG_PCLMULQDQ -DRTE_MACHINE_CPUFLAG_AVX
-DRTE_MACHINE_CPUFLAG_F16C
-DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2,RTE_CPUFLAG_AES,RTE_CPUFLAG_PCLMULQDQ,RTE_CPUFLAG_AVX,RTE_CPUFLAG_F16C 
-I/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/include -include
/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/include/rte_config.h -W
-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wold-style-definition -Wpointer-arith
-Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral
-Wformat-security -Wundef -Wwrite-strings  -Wl,-Map=testacl.map,--cref
-o testacl main.o -Wl,-export-dynamic
-L/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/lib 
-L/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/lib
-Wl,--whole-archive -Wl,-lrte_distributor -Wl,-lrte_kni
-Wl,-lrte_pipeline -Wl,-lrte_table -Wl,-lrte_port -Wl,-lrte_timer
-Wl,-lrte_hash -Wl,-lrte_lpm -Wl,-lrte_power -Wl,-lrte_acl
-Wl,-lrte_meter -Wl,-lrte_sched -Wl,-lm -Wl,-lrt -Wl,--start-group
-Wl,-lrte_kvargs -Wl,-lrte_mbuf -Wl,-lrte_ip_frag -Wl,-lethdev
-Wl,-lrte_malloc -Wl,-lrte_mempool -Wl,-lrte_ring -Wl,-lrte_eal
-Wl,-lrte_cmdline -Wl,-lrte_cfgfile -Wl,-lrte_pmd_bond -Wl,-lrt -Wl,-lm
-Wl,-lgcc_s -Wl,-ldl -Wl,--end-group -Wl,--no-whole-archive
/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/lib/librte_eal.so:
undefined reference to `rte_mempool_lookup'
/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/lib/librte_eal.so:
undefined reference to `rte_mempool_create'

<< Reproduce the issue with same options >>
$ cd x86_64-native-linuxapp-gcc/build/app/test-acl/
$ gcc -Wp,-MD,./.main.o.d.tmp -m64 -pthread -fPIC  -march=native
-DRTE_MACHINE_CPUFLAG_SSE -DRTE_MACHINE_CPUFLAG_SSE2
-DRTE_MACHINE_CPUFLAG_SSE3 -DRTE_MACHINE_CPUFLAG_SSSE3
-DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MACHINE_CPUFLAG_SSE4_2
-DRTE_MACHINE_CPUFLAG_AES -DRTE_MACHINE_CPUFLAG_PCLMULQDQ
-DRTE_MACHINE_CPUFLAG_AVX -DRTE_MACHINE_CPUFLAG_F16C
-DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2,RTE_CPUFLAG_AES,RTE_CPUFLAG_PCLMULQDQ,RTE_CPUFLAG_AVX,RTE_CPUFLAG_F16C 
-I/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/include -include
/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/include/rte_config.h -W
-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wold-style-definition -Wpointer-arith
-Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral
-Wformat-security -Wundef -Wwrite-strings   -o main.o -c
/home/mukawa/tmp/dpdk/app/test-acl/main.c
mukawa at eris:~/tmp/dpdk/x86_64-native-linuxapp-gcc/build/app/test-acl$
gcc -m64 -pthread -fPIC  -march=native -DRTE_MACHINE_CPUFLAG_SSE
-DRTE_MACHINE_CPUFLAG_SSE2 -DRTE_MACHINE_CPUFLAG_SSE3
-DRTE_MACHINE_CPUFLAG_SSSE3 -DRTE_MACHINE_CPUFLAG_SSE4_1
-DRTE_MACHINE_CPUFLAG_SSE4_2 -DRTE_MACHINE_CPUFLAG_AES
-DRTE_MACHINE_CPUFLAG_PCLMULQDQ -DRTE_MACHINE_CPUFLAG_AVX
-DRTE_MACHINE_CPUFLAG_F16C
-DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2,RTE_CPUFLAG_AES,RTE_CPUFLAG_PCLMULQDQ,RTE_CPUFLAG_AVX,RTE_CPUFLAG_F16C 
-I/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/include -include
/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/include/rte_config.h -W
-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wold-style-definition -Wpointer-arith
-Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral
-Wformat-security -Wundef -Wwrite-strings  -Wl,-Map=testacl.map,--cref
-o testacl main.o -Wl,-export-dynamic
-L/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/lib 
-L/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/lib
-Wl,--whole-archive -Wl,-lrte_distributor -Wl,-lrte_kni
-Wl,-lrte_pipeline -Wl,-lrte_table -Wl,-lrte_port -Wl,-lrte_timer
-Wl,-lrte_hash -Wl,-lrte_lpm -Wl,-lrte_power -Wl,-lrte_acl
-Wl,-lrte_meter -Wl,-lrte_sched -Wl,-lm -Wl,-lrt -Wl,--start-group
-Wl,-lrte_kvargs -Wl,-lrte_mbuf -Wl,-lrte_ip_frag -Wl,-lethdev
-Wl,-lrte_malloc -Wl,-lrte_mempool -Wl,-lrte_ring -Wl,-lrte_eal
-Wl,-lrte_cmdline -Wl,-lrte_cfgfile -Wl,-lrte_pmd_bond -Wl,-lrt -Wl,-lm
-Wl,-lgcc_s -Wl,-ldl -Wl,--end-group -Wl,--no-whole-archive
/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/lib/librte_eal.so:
undefined reference to `rte_mempool_lookup'
/home/mukawa/tmp/dpdk/x86_64-native-linuxapp-gcc/lib/librte_eal.so:
undefined reference to `rte_mempool_create'
collect2: error: ld returned 1 exit status

----------------------------------------------------------------------

I just enabled the following option, then compile DPDK.
CONFIG_RTE_BUILD_SHARED_LIB
Is this collect to compile PMDs as dynamic link libraries?

With the option, all libraries include are compiled as dynamic link library.
Does "--start-group/--end-group" options work with dynamic link libraries?

Regards,
Tetsuya



More information about the dev mailing list