[dpdk] Fix build, dependencies, usage (#26188)

* Fix static-or-shared patch

* Don't build docs for debug

* Fix dependencies

* Fix tools fixup

* Usage is via 'pkg_check_modules'

* Move docs

* Update versions
This commit is contained in:
Kai Pastor 2022-08-19 22:53:12 +02:00 committed by GitHub
parent 479e1bd846
commit df75e76ff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 163 additions and 208 deletions

View File

@ -1,133 +1,81 @@
diff --git a/config/meson.build b/config/meson.build
index 7134e80..a77f533 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -57,7 +57,9 @@ eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
# driver .so files often depend upon the bus drivers for their connect bus,
# e.g. ixgbe depends on librte_bus_pci. This means that the bus drivers need
# to be in the library path, so symlink the drivers from the main lib directory.
-if not is_windows
+if get_option('default_library') == 'static'
+ # skip
+elif not is_windows
meson.add_install_script('../buildtools/symlink-drivers-solibs.sh',
get_option('libdir'), pmd_subdir_opt)
elif meson.version().version_compare('>=0.55.0')
diff --git a/drivers/meson.build b/drivers/meson.build
index 1d8123b00c..2de654692d 100644
index 1d8123b..36ab3c0 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -126,14 +126,15 @@ foreach subpath:subdirs
if not build
break
endif
- if not is_variable('shared_rte_' + d)
+ if get_option('default_library') == 'static' and is_variable('static_rte_' + d)
+ static_deps += [get_variable('static_rte_' + d)]
+ elif get_option('default_library') == 'shared' and is_variable('shared_rte_' + d)
+ shared_deps += [get_variable('shared_rte_' + d)]
+ else
build = false
reason = 'missing internal dependency, "@0@"'.format(d)
message('Disabling @1@ [@2@]: missing internal dependency "@0@"'
.format(d, name, 'drivers/' + drv_path))
- else
- shared_deps += [get_variable('shared_rte_' + d)]
- static_deps += [get_variable('static_rte_' + d)]
endif
endforeach
endif
@@ -158,6 +159,7 @@ foreach subpath:subdirs
@@ -180,7 +180,7 @@ foreach subpath:subdirs
include_directories: includes,
dependencies: static_deps,
c_args: cflags,
- install: true)
+ install: get_option('default_library') == 'static')
install_headers(headers)
+ if get_option('default_library') == 'static'
# generate pmdinfo sources by building a temporary
# lib and then running pmdinfogen on the contents of
# that lib. The final lib reuses the object files and
@@ -220,6 +222,13 @@ foreach subpath:subdirs
# now build the shared driver
version_map = '@0@/@1@/version.map'.format(meson.current_source_dir(), drv_path)
@@ -220,6 +220,7 @@ foreach subpath:subdirs
endif
endif
+ static_dep = declare_dependency(
+ include_directories: includes,
+ dependencies: static_deps)
+ dpdk_drivers += static_lib
+ set_variable('static_@0@'.format(lib_name), static_dep)
+
+ else
+ if get_option('default_library') == 'shared'
shared_lib = shared_library(lib_name, sources,
objects: objs,
include_directories: includes,
@@ -237,14 +246,10 @@ foreach subpath:subdirs
@@ -237,9 +238,13 @@ foreach subpath:subdirs
shared_dep = declare_dependency(link_with: shared_lib,
include_directories: includes,
dependencies: shared_deps)
- static_dep = declare_dependency(
- include_directories: includes,
- dependencies: static_deps)
+ set_variable('shared_@0@'.format(lib_name), shared_dep)
+ endif
static_dep = declare_dependency(
include_directories: includes,
dependencies: static_deps)
+ if get_option('default_library') == 'static'
+ shared_dep = static_dep
+ endif
- dpdk_drivers += static_lib
+ endif
dpdk_drivers += static_lib
- set_variable('shared_@0@'.format(lib_name), shared_dep)
- set_variable('static_@0@'.format(lib_name), static_dep)
dependency_name = ''.join(lib_name.split('rte_'))
if developer_mode
message('drivers/@0@: Defining dependency "@1@"'.format(
diff --git a/drivers/net/octeontx/base/meson.build b/drivers/net/octeontx/base/meson.build
index 8e5e8c1b55..39593cd8a6 100644
--- a/drivers/net/octeontx/base/meson.build
+++ b/drivers/net/octeontx/base/meson.build
@@ -10,7 +10,7 @@ sources = [
depends = ['ethdev', 'mempool_octeontx']
static_objs = []
foreach d: depends
- if not is_variable('shared_rte_' + d)
+ if get_option('default_library') == 'shared' and not is_variable('shared_rte_' + d)
subdir_done()
endif
static_objs += get_variable('static_rte_' + d)
diff --git a/lib/meson.build b/lib/meson.build
index 24adbe44c9..e614ec57af 100644
index 24adbe4..eef6e93 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -146,14 +146,15 @@ foreach l:libraries
if not build
break
endif
- if not is_variable('shared_rte_' + d)
+ if get_option('default_library') == 'static'
+ static_deps += [get_variable('static_rte_' + d)]
+ elif is_variable('shared_rte_' + d)
+ shared_deps += [get_variable('shared_rte_' + d)]
+ else
build = false
reason = 'missing internal dependency, "@0@"'.format(d)
message('Disabling @1@ [@2@]: missing internal dependency "@0@"'
.format(d, name, 'lib/' + l))
- else
- shared_deps += [get_variable('shared_rte_' + d)]
- static_deps += [get_variable('static_rte_' + d)]
endif
endforeach
@@ -185,6 +186,7 @@ foreach l:libraries
endif
cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l
+ if get_option('default_library') == 'static'
# first build static lib
static_lib = static_library(libname,
sources,
@@ -246,6 +248,10 @@ foreach l:libraries
@@ -192,7 +192,7 @@ foreach l:libraries
c_args: cflags,
dependencies: static_deps,
include_directories: includes,
- install: true)
+ install: get_option('default_library') == 'static')
static_dep = declare_dependency(
include_directories: includes,
dependencies: static_deps)
@@ -246,6 +246,7 @@ foreach l:libraries
output: name + '.sym_chk')
endif
+ dpdk_static_libraries = [static_lib] + dpdk_static_libraries
+ set_variable('static_rte_' + name, static_dep)
+
+ else
+ if get_option('default_library') == 'shared'
shared_lib = shared_library(libname,
sources,
objects: objs,
@@ -262,10 +268,10 @@ foreach l:libraries
@@ -262,6 +263,9 @@ foreach l:libraries
dependencies: shared_deps)
dpdk_libraries = [shared_lib] + dpdk_libraries
- dpdk_static_libraries = [static_lib] + dpdk_static_libraries
-
+ else
+ shared_dep = static_dep
+ endif
dpdk_static_libraries = [static_lib] + dpdk_static_libraries
set_variable('shared_rte_' + name, shared_dep)
- set_variable('static_rte_' + name, static_dep)
+
+ endif
+
if developer_mode
message('lib/@0@: Defining dependency "@1@"'.format(l, name))
endif

View File

@ -0,0 +1,65 @@
diff --git a/config/meson.build b/config/meson.build
index 0dde249..64f7d1c 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -181,12 +181,10 @@ if meson.is_cross_build() and not meson.get_cross_property('numa', true)
find_libnuma = false
endif
if find_libnuma
- numa_dep = cc.find_library('numa', required: false)
- if numa_dep.found() and cc.has_header('numaif.h')
+ numa_dep = dependency('numa', method: 'pkg-config')
+ if numa_dep.found()
dpdk_conf.set10('RTE_HAS_LIBNUMA', true)
has_libnuma = 1
- add_project_link_arguments('-lnuma', language: 'c')
- dpdk_extra_ldflags += '-lnuma'
endif
endif
@@ -211,8 +209,6 @@ if libarchive.found()
# Push libarchive link dependency at the project level to support
# statically linking dpdk apps. Details at:
# https://inbox.dpdk.org/dev/20210605004024.660267a1@sovereign/
- add_project_link_arguments('-larchive', language: 'c')
- dpdk_extra_ldflags += '-larchive'
endif
# check for libbsd
diff --git a/lib/eal/linux/meson.build b/lib/eal/linux/meson.build
index 65f2ac6..3e023f8 100644
--- a/lib/eal/linux/meson.build
+++ b/lib/eal/linux/meson.build
@@ -23,5 +23,6 @@ sources += files(
deps += ['kvargs', 'telemetry']
if has_libnuma == 1
+ ext_deps += numa_dep
dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
endif
diff --git a/lib/eal/meson.build b/lib/eal/meson.build
index 056beb9..04bd3fe 100644
--- a/lib/eal/meson.build
+++ b/lib/eal/meson.build
@@ -29,6 +29,9 @@ endif
if dpdk_conf.has('RTE_USE_LIBBSD')
ext_deps += libbsd
endif
+if dpdk_conf.has('RTE_HAS_LIBARCHIVE')
+ ext_deps += libarchive
+endif
if cc.has_function('getentropy', prefix : '#include <unistd.h>')
cflags += '-DRTE_LIBEAL_USE_GETENTROPY'
endif
diff --git a/lib/vhost/meson.build b/lib/vhost/meson.build
index bc72720..83970c7 100644
--- a/lib/vhost/meson.build
+++ b/lib/vhost/meson.build
@@ -6,6 +6,7 @@ if not is_linux
reason = 'only supported on Linux'
endif
if has_libnuma == 1
+ ext_deps += numa_dep
dpdk_conf.set10('RTE_LIBRTE_VHOST_NUMA', true)
endif
if (toolchain == 'gcc' and cc.version().version_compare('>=8.3.0'))

View File

@ -33,6 +33,7 @@ vcpkg_from_github(
HEAD_REF main
PATCHES
enable-either-static-or-shared-build.patch
fix-dependencies.patch
remove-examples-src-from-datadir.patch
stop-building-apps.patch)
@ -44,10 +45,12 @@ macro(append_bool_option feature_name option_name)
endif()
endmacro()
set(DPDK_OPTIONS "")
append_bool_option("docs" "enable_docs")
append_bool_option("kmods" "enable_kmods")
append_bool_option("tests" "tests")
append_bool_option("trace" "enable_trace_fp")
string(REPLACE "-Denable_docs=true" "-Denable_docs=false" DPDK_OPTIONS_DEBUG "${DPDK_OPTIONS}")
list(APPEND PYTHON_PACKAGES pyelftools)
if("docs" IN_LIST FEATURES)
@ -55,32 +58,31 @@ if("docs" IN_LIST FEATURES)
endif()
x_vcpkg_get_python_packages(PYTHON_VERSION "3" PACKAGES ${PYTHON_PACKAGES})
vcpkg_configure_meson(SOURCE_PATH ${SOURCE_PATH} OPTIONS
-Ddisable_drivers=regex/cn9k -Dexamples= ${DPDK_OPTIONS})
vcpkg_configure_meson(SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-Ddisable_drivers=regex/cn9k
-Dexamples=
OPTIONS_RELEASE
${DPDK_OPTIONS}
OPTIONS_DEBUG
${DPDK_OPTIONS_DEBUG}
)
vcpkg_install_meson()
vcpkg_copy_tools(TOOL_NAMES dpdk-devbind.py dpdk-pmdinfo.py dpdk-telemetry.py
dpdk-hugepages.py AUTO_CLEAN)
set(tools dpdk-devbind.py dpdk-pmdinfo.py dpdk-telemetry.py dpdk-hugepages.py)
if("tests" IN_LIST FEATURES)
list(APPEND tools dpdk-test)
endif()
vcpkg_copy_tools(TOOL_NAMES ${tools} AUTO_CLEAN)
vcpkg_fixup_pkgconfig()
vcpkg_find_acquire_program(PKGCONFIG)
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/unofficial-${PORT}-config.cmake.in"
"${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-config.cmake"
@ONLY)
if("docs" IN_LIST FEATURES)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/dpdk")
file(RENAME "${CURRENT_PACKAGES_DIR}/share/doc/dpdk" "${CURRENT_PACKAGES_DIR}/share/dpdk/doc")
endif()
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share" "${CURRENT_PACKAGES_DIR}/share/doc")
file(
INSTALL "${SOURCE_PATH}/license/README"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}"
RENAME copyright)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-config-version.cmake"
VERSION ${PORT_VERSION}
COMPATIBILITY AnyNewerVersion)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${SOURCE_PATH}/license/README" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -1,74 +0,0 @@
# By default CMAKE_PREFIX_PATH, which contains the VCPKG_INSTALLED_DIR, will be
# appended to the pkg-config search path. Because it is appending and not
# prepeding, system packages may be found first. Specifically prepending the
# vcpkg_pkg_config_path to ENV{PKG_CONFIG_PATH} will prioritize the vcpkg
# packages.
if(NOT VCPKG_PREFER_SYSTEM_LIBS)
if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES
"^[Dd][Ee][Bb][Uu][Gg]$")
set(path_suffix "/debug")
else()
set(path_suffix "")
endif()
set(backup_env_pkg_config_path "$ENV{PKG_CONFIG_PATH}")
# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
# libdpdk.pc and libdpdk-libs.pc are installed to this path
set(ENV{PKG_CONFIG_PATH}
"${_IMPORT_PREFIX}${path_suffix}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}"
)
else()
unset(backup_env_pkg_config_path)
endif()
if(DEFINED ENV{PKG_CONFIG})
set(PKG_CONFIG_EXECUTABLE "$ENV{PKG_CONFIG}")
else()
set(PKG_CONFIG_EXECUTABLE "@PKGCONFIG@")
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBDPDK REQUIRED libdpdk>=@PORT_VERSION@)
if(DEFINED backup_env_pkg_config_path)
set(ENV{PKG_CONFIG_PATH} "${backup_env_pkg_config_path}")
endif()
mark_as_advanced(
LIBDPDK_STATIC_INCLUDE_DIRS
LIBDPDK_INCLUDE_DIRS
LIBDPDK_STATIC_CFLAGS
LIBDPDK_CFLAGS
LIBDPDK_STATIC_LDFLAGS
LIBDPDK_LDFLAGS
LIBDPDK_VERSION)
add_library(unofficial::@PORT@::dpdk INTERFACE IMPORTED)
unset(LIBDPDK_FOUND)
if(@VCPKG_LIBRARY_LINKAGE@ STREQUAL "static")
set(INCLUDE_DIRS "${LIBDPDK_STATIC_INCLUDE_DIRS}")
# https://bechsoftware.com/2021/12/05/configuring-dpdk-projects-with-cmake/
target_compile_options(unofficial::@PORT@::dpdk
INTERFACE ${LIBDPDK_STATIC_CFLAGS})
target_link_libraries(unofficial::@PORT@::dpdk
INTERFACE ${LIBDPDK_STATIC_LDFLAGS})
else()
set(INCLUDE_DIRS "${LIBDPDK_INCLUDE_DIRS}")
target_compile_options(unofficial::@PORT@::dpdk INTERFACE ${LIBDPDK_CFLAGS})
target_link_libraries(unofficial::@PORT@::dpdk INTERFACE ${LIBDPDK_LDFLAGS})
endif()
target_include_directories(unofficial::@PORT@::dpdk INTERFACE ${INCLUDE_DIRS})
find_package_handle_standard_args(
unofficial-@PORT@
REQUIRED_VARS INCLUDE_DIRS LIBDPDK_STATIC_CFLAGS LIBDPDK_CFLAGS
LIBDPDK_STATIC_LDFLAGS LIBDPDK_LDFLAGS
VERSION_VAR LIBDPDK_VERSION)

View File

@ -1,4 +1,6 @@
The package dpdk is compatible with built-in CMake targets:
find_package(unofficial-dpdk REQUIRED CONFIG)
target_link_libraries(main PRIVATE unofficial::dpdk::dpdk)
The package dpdk can be imported via CMake FindPkgConfig module:
find_package(PkgConfig)
pkg_check_modules(DPDK REQUIRED IMPORTED_TARGET libdpdk)
target_link_libraries(main PRIVATE PkgConfig::DPDK)

View File

@ -1,13 +1,17 @@
{
"name": "dpdk",
"version-string": "22.03",
"port-version": 1,
"port-version": 2,
"description": "A set of libraries and drivers for fast packet processing",
"homepage": "https://www.dpdk.org/",
"documentation": "https://doc.dpdk.org/guides/index.html",
"license": "BSD-3-Clause",
"supports": "linux | freebsd",
"dependencies": [
{
"name": "libarchive",
"default-features": false
},
{
"name": "numactl",
"platform": "linux"
@ -32,7 +36,10 @@
"tests": {
"description": "Build and install tests",
"dependencies": [
"libarchive"
{
"name": "libarchive",
"default-features": false
}
]
},
"trace": {

View File

@ -1970,7 +1970,7 @@
},
"dpdk": {
"baseline": "22.03",
"port-version": 1
"port-version": 2
},
"dpp": {
"baseline": "10.0.16",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "f6b3f2c2e194013731669b4b6996026bd5611c15",
"version-string": "22.03",
"port-version": 2
},
{
"git-tree": "215be1cdd87b890d105bc8c5cb3e2e5d9a054038",
"version-string": "22.03",