Reputation: 12263
I am trying to install DPDK
on Alpine Linux. I am running Alpine Linux in the Docker. Here are the steps I am using:
docker pull alpine
docker run -it alpine /bin/sh
wget https://git.dpdk.org/dpdk-stable/snapshot/dpdk-stable-16.11.8.tar.gz
tar -xzf dpdk-stable-16.11.8.tar.gz
cd dpdk-stable-16.11.8
apk add --no-cache make gcc libc-dev bsd-compat-headers linux-headers musl-dev
apk add numactl-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
make install T=x86_64-native-linuxapp-gcc
Installation fails with the following errors and warnings:
make[5]: Nothing to be done for 'depdirs'.
Configuration done
== Build lib
== Build lib/librte_compat
== Build lib/librte_eal
== Build lib/librte_eal/common
== Build lib/librte_eal/linuxapp
== Build lib/librte_eal/linuxapp/eal
CC eal_hugepage_info.o
/dpdk/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c: In function 'clear_hugedir':
/dpdk/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c:229:8: warning: implicit declaration of function 'openat'; did you mean 'popen'? [-Wimplicit-function-declaration] fd = openat(dir_fd, dirent->d_name, O_RDONLY); ^~~~~~ popen
/dpdk/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c:229:8: warning: nested extern declaration of 'openat' [-Wnested-externs]
/dpdk/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c:229:39: error: 'O_RDONLY' undeclared (first use in this function) fd = openat(dir_fd, dirent->d_name, O_RDONLY); ^~~~~~~~ /dpdk/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c:229:39: note: each undeclared identifier is reported only once for each function it appears in
/dpdk/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c: In function 'eal_hugepage_info_init':
/dpdk/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c:320:26: warning: implicit declaration of function 'open'; did you mean 'popen'? [-Wimplicit-function-declaration] hpi->lock_descriptor = open(hpi->hugedir, O_RDONLY); ^~~~ popen
/dpdk/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c:320:26: warning: nested extern declaration of 'open' [-Wnested-externs]
/dpdk/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c:320:45: error: 'O_RDONLY' undeclared (first use in this function) hpi->lock_descriptor = open(hpi->hugedir, O_RDONLY); ^~~~~~~~
make[7]: *** [/dpdk/dpdk-stable-16.11.8/mk/internal/rte.compile-pre.mk:140: eal_hugepage_info.o] Error 1
make[6]: *** [/dpdk/dpdk-stable-16.11.8/mk/rte.subdir.mk:63: eal] Error 2
make[5]: *** [/dpdk/dpdk-stable-16.11.8/mk/rte.subdir.mk:63: linuxapp] Error 2
make[4]: *** [/dpdk/dpdk-stable-16.11.8/mk/rte.subdir.mk:63: librte_eal] Error 2
make[3]: *** [/dpdk/dpdk-stable-16.11.8/mk/rte.sdkbuild.mk:80: lib] Error 2
make[2]: *** [/dpdk/dpdk-stable-16.11.8/mk/rte.sdkroot.mk:127: all] Error 2
make[1]: *** [/dpdk/dpdk-stable-16.11.8/mk/rte.sdkinstall.mk:86: pre_install] Error 2
make: *** [/dpdk/dpdk-stable-16.11.8/mk/rte.sdkroot.mk:101: install] Error 2
UPDATE 1
I fixed some of the errors but now new errors appear. Here are the updated steps:
docker pull alpine
docker run -it alpine /bin/sh
wget https://git.dpdk.org/dpdk-stable/snapshot/dpdk-stable-16.11.8.tar.gz
tar -xzf dpdk-stable-16.11.8.tar.gz
cd dpdk-stable-16.11.8
apk add --no-cache make gcc libc-dev bsd-compat-headers linux-headers musl-dev
apk add numactl-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
#include <fcntl.h>
to lib/librte_eal/common/include/rte_common.h
CFLAGS += -D_GNU_SOURCE
to lib/librte_eal/linuxapp/eal/Makefile
make install T=x86_64-native-linuxapp-gcc
Installation now fails with the following errors:
make[5]: Nothing to be done for 'depdirs'. Configuration done
== Build lib
== Build lib/librte_compat
== Build lib/librte_eal
== Build lib/librte_eal/common
== Build lib/librte_eal/linuxapp
== Build lib/librte_eal/linuxapp/eal
CC eal_vfio_mp_sync.o
/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c: In function 'vfio_mp_sync_send_fd':
/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c:75:17: error: 'struct cmsghdr' has no member named '__cmsg_data' memcpy((chdr).__cmsg_data, &(fd), sizeof(fd));\ ^
/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c:187:2: note: in expansion of macro 'FD_TO_CMSGHDR' FD_TO_CMSGHDR(fd, *chdr); ^~~~~~~~~~~~~
/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c: In function 'vfio_mp_sync_receive_fd':
/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c:78:24: error: 'struct cmsghdr' has no member named '__cmsg_data' memcpy(&(fd), (chdr).__cmsg_data, sizeof(fd)) ^
/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c:228:2: note: in expansion of macro 'CMSGHDR_TO_FD' CMSGHDR_TO_FD(*chdr, fd); ^~~~~~~~~~~~~
make[7]: *** [/dpdk-stable-16.11.8/mk/internal/rte.compile-pre.mk:140: eal_vfio_mp_sync.o] Error 1
make[6]: *** [/dpdk-stable-16.11.8/mk/rte.subdir.mk:63: eal] Error 2
make[5]: *** [/dpdk-stable-16.11.8/mk/rte.subdir.mk:63: linuxapp] Error 2
make[4]: *** [/dpdk-stable-16.11.8/mk/rte.subdir.mk:63: librte_eal] Error 2
make[3]: *** [/dpdk-stable-16.11.8/mk/rte.sdkbuild.mk:80: lib] Error 2
make[2]: *** [/dpdk-stable-16.11.8/mk/rte.sdkroot.mk:127: all] Error 2
make[1]: *** [/dpdk-stable-16.11.8/mk/rte.sdkinstall.mk:86: pre_install] Error 2
make: *** [/dpdk-stable-16.11.8/mk/rte.sdkroot.mk:101: install] Error 2
If you take a look at the /usr/include/x86_64-linux-gnu/bits/socket.h
, struct cmsghdr
is defined as following:
/* Structure used for storage of ancillary data object information. */
struct cmsghdr
{
size_t cmsg_len;
/* Length of data in cmsg_data plus length
of cmsghdr structure.
!! The type should be socklen_t but the
definition of the kernel is incompatible
with this. */
int cmsg_level; /* Originating protocol. */
int cmsg_type; /* Protocol specific type. */
#if __glibc_c99_flexarr_available
__extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */
#endif
};
What is __glibc_c99_flexarr_available
? Can I somehow make this available?
UPDATE 2
I tried to use this instead of musl-dev
but the error remains the same.
Then as suggested, I installed glibc
on my Alpine Linux to use it instead of musl
. Follow the steps here. Now I am getting errors like this:
In file included from /dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal.c:48:0:
/usr/include/limits.h:124:26: fatal error: limits.h: No such file or directory
# include_next
Upvotes: 2
Views: 1605
Reputation: 12263
Finally, after some time and lots of workarounds I have managed to install DPDK on Alpine Linux i.e. on a Docker container running Alpine Linux.
Here is a Dockerfile I created (comments are inline):
FROM alpine:latest
ARG DPDK_VER=16.11.8
ARG KERNEL_VER=4.9.4
RUN wget https://git.dpdk.org/dpdk-stable/snapshot/dpdk-stable-$DPDK_VER.tar.gz && \
tar -xzf dpdk-stable-$DPDK_VER.tar.gz && \
\
# Install Alpine packages
apk add --no-cache make gcc linux-headers bsd-compat-headers binutils coreutils diffutils && \
apk add --no-cache gettext bash grep sed texinfo perl util-linux vim build-base libexecinfo libexecinfo-dev && \
apk add --no-cache abuild bc cmake ncurses-dev ca-certificates wget && \
apk add numactl-dev --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted && \
\
# Enable usage of High Precision Timers
sed -i "/\b\(CONFIG_RTE_LIBEAL_USE_HPET\|n\)\b/d" /dpdk-stable-$DPDK_VERSION/config/common_base && \
sed -ie '/CONFIG_RTE_LOG_HISTORY=256/a CONFIG_RTE_LIBEAL_USE_HPET=y' /dpdk-stable-$DPDK_VERSION/config/common_base && \
\
# Add following lines / workarounds to header files
sed -ie '/int cmsg_type;/a unsigned char __cmsg_data;' /usr/include/bits/socket.h && \
sed -i.old '1s;^;#include <fcntl.h>\n;' /dpdk-stable-$DPDK_VER/lib/librte_eal/common/include/rte_common.h && \
sed -ie '/#define _VNIC_DEVCMD_H_/a typedef u32 u_int32_t;' /dpdk-stable-$DPDK_VER/drivers/net/enic/base/vnic_devcmd.h && \
\
# Prevent usage of the header files on /usr/include/fortify path by deleting them
# Instead of them header files from /usr/include path will be used
rm -rf /usr/include/fortify/* && \
\
# Add CFLAGS += -D_GNU_SOURCE to the following Makefiles
cd /dpdk-stable-$DPDK_VER && \
sed -ie '/CFLAGS/a CFLAGS += -D_GNU_SOURCE' lib/librte_ring/Makefile && \
sed -ie '/CFLAGS/a CFLAGS += -D_GNU_SOURCE' lib/librte_mempool/Makefile && \
sed -ie '/CFLAGS/a CFLAGS += -D_GNU_SOURCE' lib/librte_mbuf/Makefile && \
sed -ie '/CFLAGS/a CFLAGS += -D_GNU_SOURCE' lib/librte_timer/Makefile && \
sed -ie '/CFLAGS/a CFLAGS += -D_GNU_SOURCE' lib/librte_net/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_eal/linuxapp/eal/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_ether/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_cryptodev/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_vhost/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_hash/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_lpm/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_acl/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_ip_frag/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_sched/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_distributor/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_kni/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_port/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_table/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_pipeline/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' lib/librte_reorder/Makefile && \
\
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/af_packet/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/bonding/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/cxgbe/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/e1000/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/ena/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/enic/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/fm10k/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/i40e/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/ixgbe/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/bnxt/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/null/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/qede/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/ring/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/virtio/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/vmxnet3/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/net/vhost/Makefile && \
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' drivers/crypto/null/Makefile && \
\
# Enable tests for compiling
sed -ie '/EXECENV_LDLIBS += -ldl/a EXECENV_LDLIBS += -lexecinfo' mk/exec-env/linuxapp/rte.vars.mk && \
sed -ie '/#include <string.h>/a #include <features.h>' lib/librte_eal/linuxapp/eal/eal_pci_uio.c && \
sed -ie '/#define OFF_MAX/a static inline void outb_p (unsigned char __value, unsigned short int __port) { __asm__ __volatile__ ("outb %b0,%w1\\noutb %%al,$0x80": :"a" (__value), "Nd" (__port)); }' lib/librte_eal/linuxapp/eal/eal_pci_uio.c && \
sed -ie '/#define OFF_MAX/a static inline void outw_p (unsigned short int __value, unsigned short int __port) { __asm__ __volatile__ ("outw %w0,%w1\\noutb %%al,$0x80": :"a" (__value), "Nd" (__port)); }' lib/librte_eal/linuxapp/eal/eal_pci_uio.c && \
sed -ie '/#define OFF_MAX/a static inline void outl_p (unsigned int __value, unsigned short int __port) { __asm__ __volatile__ ("outl %0,%w1\\noutb %%al,$0x80": :"a" (__value), "Nd" (__port)); }' lib/librte_eal/linuxapp/eal/eal_pci_uio.c && \
# - test
sed -ie '/LDLIBS += -lm/a LDLIBS += -lrte_pmd_ring -lrte_pmd_null' app/test/Makefile && \
# - test-acl
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' app/test-acl/Makefile && \
# - test-pipeline
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' app/test-pipeline/Makefile && \
# - test-pmd
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' app/test-pmd/Makefile && \
sed -ie '/DEPDIRS-y += lib drivers/a LDLIBS += -lrte_pmd_ixgbe' app/test-pmd/Makefile && \
sed -ie '/typedef uint16_t streamid_t/a typedef unsigned int uint;' app/test-pmd/testpmd.h && \
# - proc_info
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' app/proc_info/Makefile && \
# - pdump
sed -ie '/CFLAGS += $(WERROR_FLAGS)/a CFLAGS += -D_GNU_SOURCE' app/pdump/Makefile && \
cd / && \
\
# Install missing Alpine Linux kernel modules
wget -nv -P /srv https://www.kernel.org/pub/linux/kernel/v4.x/linux-$KERNEL_VER.tar.gz && \
tar -C /srv -zxf /srv/linux-$KERNEL_VER.tar.gz && \
cd /srv/linux-$KERNEL_VER && \
make defconfig && \
([ ! -f /proc/1/root/proc/config.gz ] || zcat /proc/1/root/proc/config.gz > .config) && \
echo 'CONFIG_USB=m' >> .config && \
echo 'CONFIG_USB_HID=m' >> .config && \
echo 'CONFIG_USB_SUPPORT=y' >> .config && \
echo 'CONFIG_USB_COMMON=m' >> .config && \
echo 'CONFIG_USB_ARCH_HAS_HCD=y' >> .config && \
echo 'CONFIG_USB_DEFAULT_PERSIST=y' >> .config && \
echo 'CONFIG_USBIP_CORE=m' >> .config && \
echo 'CONFIG_USBIP_VHCI_HCD=m' >> .config && \
echo 'CONFIG_USBIP_VHCI_HC_PORTS=8' >> .config && \
echo 'CONFIG_USBIP_VHCI_NR_HCS=1' >> .config && \
echo 'CONFIG_USBIP_HOST=m' >> .config && \
sed -i'.bak' '/hcd->amd_resume_bug/{s/^/\/\//;n;s/^/\/\//}' ./drivers/usb/core/hcd-pci.c && \
make oldconfig && \
make modules_prepare && \
make modules && \
make modules_install && \
make clean && \
cd / && \
\
# Install DPDK
mkdir /dpdk-build && \
cd dpdk-stable-$DPDK_VER && \
make install T=x86_64-native-linuxapp-gcc RTE_KERNELDIR=/srv/linux-$KERNEL_VER DESTDIR=/dpdk-build
I hope this will save someone's time :)
Upvotes: 3
Reputation: 18571
It seems DPDK is not compatible to musl libc, so you'll probably have a very hard time fixing errors one by one. Having to manually add preprocessor defines and includes to CFLAGS seems like a bad sign.
The last error is such a libc incompatiblity:
/dpdk-stable-16.11.8/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c:78:24: error: 'struct cmsghdr' has no member named '__cmsg_data' memcpy(&(fd), (chdr).__cmsg_data, sizeof(fd))
In my glibc (Ubuntu 16.04), cmsghdr
is defined as follows in bits/socket.h
:
/* Structure used for storage of ancillary data object information. */
struct cmsghdr
{
size_t cmsg_len; /* Length of data in cmsg_data plus length
of cmsghdr structure.
!! The type should be socklen_t but the
definition of the kernel is incompatible
with this. */
int cmsg_level; /* Originating protocol. */
int cmsg_type; /* Protocol specific type. */
#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
__extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */
#endif
};
Note the definition of __cmsg_data
at the end.
In musl, cmsghdr
is defined as:
struct cmsghdr {
socklen_t cmsg_len;
int __pad1;
int cmsg_level;
int cmsg_type;
};
Note the missing __cmsg_data
field.
Upvotes: 3