build: use libpcap only from pkg-config
RFC PATCH 1/1 build: use libpcap only from pkg-config
All recent linux distro's - including RHEL 8 and Ubuntu 18.04 - provide a pkg-config file for libpcap, and using other methods of finding the library can cause issues when cross-compiling, so we can limit build support for pcap versions without a .pc file.
--- config/meson.build | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
config/meson.build +1 -7
@@ -163,13 +163,7 @@ if libbsd.found() endif # check for pcap -pcap_dep = dependency('pcap', required: false) -if pcap_dep.found() - # pcap got a pkg-config file only in 1.9.0 and before that meson uses - # an internal pcap-config finder, which is not compatible with - # cross-compilation, so try to fallback to find_library - pcap_dep = cc.find_library('pcap', required: false) -endif +pcap_dep = dependency('libpcap', required: false, method: 'pkg-config') if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep) dpdk_conf.set('RTE_PORT_PCAP', 1) dpdk_extra_ldflags += '-lpcap'
Signature · 1 line
2.25.1
Quoted 19 lines · Bruce Richardson
All recent linux distro's - including RHEL 8 and Ubuntu 18.04 - provide a pkg-config file for libpcap, and using other methods of finding the library can cause issues when cross-compiling, so we can limit build support for pcap versions without a .pc file.
Signed-off-by Bruce Richardson <[email protected]>--- config/meson.build | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)config/meson.build +0
-1@@ -163,13 +163,7 @@ if libbsd.found() endif # check for pcap -pcap_dep = dependency('pcap', required: false)
config/meson.build if libbsd.found() · line 169
Quoted 10 lines
config/meson.build +1
-6-if pcap_dep.found() - # pcap got a pkg-config file only in 1.9.0 and before that meson uses - # an internal pcap-config finder, which is not compatible with - # cross-compilation, so try to fallback to find_library - pcap_dep = cc.find_library('pcap', required: false) -endif +pcap_dep = dependency('libpcap', required: false, method: 'pkg-config') if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep) dpdk_conf.set('RTE_PORT_PCAP', 1) dpdk_extra_ldflags += '-lpcap'
Just sending this as an RFC for consideration, since I hit problems with the pcap code when testing 32-bit (x32) builds, and remembered having hit it previously too.
Does anyone see an issue with limiting our pcap detection to pkg-config only in this case?
/Bruce
Quoted 35 lines · Bruce Richardson
Quoted 19 lines · Bruce Richardson
All recent linux distro's - including RHEL 8 and Ubuntu 18.04 - provide a pkg-config file for libpcap, and using other methods of finding the library can cause issues when cross-compiling, so we can limit build support for pcap versions without a .pc file.
Signed-off-by Bruce Richardson <[email protected]>--- config/meson.build | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)config/meson.build +0
-1@@ -163,13 +163,7 @@ if libbsd.found() endif # check for pcap -pcap_dep = dependency('pcap', required: false)config/meson.build if libbsd.found() · line 169
Quoted 10 lines
config/meson.build +1
-6-if pcap_dep.found() - # pcap got a pkg-config file only in 1.9.0 and before that meson uses - # an internal pcap-config finder, which is not compatible with - # cross-compilation, so try to fallback to find_library - pcap_dep = cc.find_library('pcap', required: false) -endif +pcap_dep = dependency('libpcap', required: false, method: 'pkg-config') if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep) dpdk_conf.set('RTE_PORT_PCAP', 1) dpdk_extra_ldflags += '-lpcap'Just sending this as an RFC for consideration, since I hit problems with the pcap code when testing 32-bit (x32) builds, and remembered having hit it previously too.
Quoted 4 lines
Does anyone see an issue with limiting our pcap detection to pkg-config only in this case?
/Bruce
Sadly it's not yet available in Debian stable:
https://packages.debian.org/buster/amd64/libpcap0.8-dev/filelist
Also for Ubuntu 18.04, it's only available with the bionic-updates repository, and only for the past month - it shipped without it.
I'm absolutely keen on using only pkg-config (so much that I did the packaging changes myself to ship it in libpcap-dev [1][2]) but perhaps in the interest of compatibility it's better to wait next year, so that the new Debian stable supports it, and the Ubuntu 18.04 LTS fix had the chance to rollout everywhere?
Signature · 5 lines
Kind regards, Luca Boccassi [1] http://changelogs.ubuntu.com/changelogs/pool/main/libp/libpcap/libpcap_1.8.1-6ubuntu1.18.04.2/changelog [2] https://metadata.ftp-master.debian.org/changelogs//main/libp/libpcap/libpcap_1.9.1-4_changelog
Quoted 45 lines · Luca Boccassi
Quoted 35 lines · Bruce Richardson
Quoted 19 lines · Bruce Richardson
All recent linux distro's - including RHEL 8 and Ubuntu 18.04 - provide a pkg-config file for libpcap, and using other methods of finding the library can cause issues when cross-compiling, so we can limit build support for pcap versions without a .pc file.
Signed-off-by Bruce Richardson <[email protected]>--- config/meson.build | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)config/meson.build +0
-1@@ -163,13 +163,7 @@ if libbsd.found() endif # check for pcap -pcap_dep = dependency('pcap', required: false)config/meson.build if libbsd.found() · line 169
Quoted 10 lines
config/meson.build +1
-6-if pcap_dep.found() - # pcap got a pkg-config file only in 1.9.0 and before that meson uses - # an internal pcap-config finder, which is not compatible with - # cross-compilation, so try to fallback to find_library - pcap_dep = cc.find_library('pcap', required: false) -endif +pcap_dep = dependency('libpcap', required: false, method: 'pkg-config') if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep) dpdk_conf.set('RTE_PORT_PCAP', 1) dpdk_extra_ldflags += '-lpcap'Just sending this as an RFC for consideration, since I hit problems with the pcap code when testing 32-bit (x32) builds, and remembered having hit it previously too.
Quoted 4 lines
Does anyone see an issue with limiting our pcap detection to pkg-config only in this case?
/Bruce
Sadly it's not yet available in Debian stable:
https://packages.debian.org/buster/amd64/libpcap0.8-dev/filelist
Quoted 9 lines
Also for Ubuntu 18.04, it's only available with the bionic-updates repository, and only for the past month - it shipped without it.
I'm absolutely keen on using only pkg-config (so much that I did the packaging changes myself to ship it in libpcap-dev [1][2]) but perhaps in the interest of compatibility it's better to wait next year, so that the new Debian stable supports it, and the Ubuntu 18.04 LTS fix had the chance to rollout everywhere?
Thanks, that's exactly the sort of feedback I was looking for!
It seems to be the pcap-config support in meson which causes cross-building issues, so I wonder would it still work ok if we changed this to only use pkg-config for the initial search and then use find-library if that failed?
# check for pcap
-pcap_dep = dependency('pcap', required: false)
-if pcap_dep.found()
- # pcap got a pkg-config file only in 1.9.0 and before that meson uses
- # an internal pcap-config finder, which is not compatible with
- # cross-compilation, so try to fallback to find_library
+pcap_dep = dependency('libpcap', required: false, method: 'pkg-config')
+if not pcap_dep.found()
+ # pcap got a pkg-config file only in 1.9.0
pcap_dep = cc.find_library('pcap', required: false)
endifQuoted 63 lines · Bruce Richardson
Quoted 45 lines · Luca Boccassi
Quoted 35 lines · Bruce Richardson
Quoted 19 lines · Bruce Richardson
All recent linux distro's - including RHEL 8 and Ubuntu 18.04 - provide a pkg-config file for libpcap, and using other methods of finding the library can cause issues when cross-compiling, so we can limit build support for pcap versions without a .pc file.
Signed-off-by Bruce Richardson <[email protected]>--- config/meson.build | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)config/meson.build +0
-1@@ -163,13 +163,7 @@ if libbsd.found() endif # check for pcap -pcap_dep = dependency('pcap', required: false)config/meson.build if libbsd.found() · line 169
Quoted 10 lines
config/meson.build +1
-6-if pcap_dep.found() - # pcap got a pkg-config file only in 1.9.0 and before that meson uses - # an internal pcap-config finder, which is not compatible with - # cross-compilation, so try to fallback to find_library - pcap_dep = cc.find_library('pcap', required: false) -endif +pcap_dep = dependency('libpcap', required: false, method: 'pkg-config') if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep) dpdk_conf.set('RTE_PORT_PCAP', 1) dpdk_extra_ldflags += '-lpcap'Just sending this as an RFC for consideration, since I hit problems with the pcap code when testing 32-bit (x32) builds, and remembered having hit it previously too.
Quoted 4 lines
Does anyone see an issue with limiting our pcap detection to pkg-config only in this case?
/Bruce
Sadly it's not yet available in Debian stable:
https://packages.debian.org/buster/amd64/libpcap0.8-dev/filelist
Quoted 9 lines
Also for Ubuntu 18.04, it's only available with the bionic-updates repository, and only for the past month - it shipped without it.
I'm absolutely keen on using only pkg-config (so much that I did the packaging changes myself to ship it in libpcap-dev [1][2]) but perhaps in the interest of compatibility it's better to wait next year, so that the new Debian stable supports it, and the Ubuntu 18.04 LTS fix had the chance to rollout everywhere?
Thanks, that's exactly the sort of feedback I was looking for!
It seems to be the pcap-config support in meson which causes cross-building issues, so I wonder would it still work ok if we changed this to only use pkg-config for the initial search and then use find-library if that failed?
# check for pcap
config/meson.build if libbsd.found()
Quoted 10 lines
config/meson.build +3
-5-pcap_dep = dependency('pcap', required: false) -if pcap_dep.found() - # pcap got a pkg-config file only in 1.9.0 and before that meson uses - # an internal pcap-config finder, which is not compatible with - # cross-compilation, so try to fallback to find_library +pcap_dep = dependency('libpcap', required: false, method: 'pkg-config') +if not pcap_dep.found() + # pcap got a pkg-config file only in 1.9.0 pcap_dep = cc.find_library('pcap', required: false) endif
That would be fine - is the 'method' option supported in the minimum version we support right now?
Signature · 2 lines
Kind regards, Luca Boccassi
Quoted 63 lines · Luca Boccassi
Quoted 62 lines · Bruce Richardson
Quoted 45 lines · Luca Boccassi
Quoted 35 lines · Bruce Richardson
Quoted 19 lines · Bruce Richardson
All recent linux distro's - including RHEL 8 and Ubuntu 18.04 - provide a pkg-config file for libpcap, and using other methods of finding the library can cause issues when cross-compiling, so we can limit build support for pcap versions without a .pc file.
Signed-off-by Bruce Richardson <[email protected]>--- config/meson.build | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)config/meson.build +0
-1@@ -163,13 +163,7 @@ if libbsd.found() endif # check for pcap -pcap_dep = dependency('pcap', required: false)config/meson.build if libbsd.found() · line 169
Quoted 10 lines
config/meson.build +1
-6-if pcap_dep.found() - # pcap got a pkg-config file only in 1.9.0 and before that meson uses - # an internal pcap-config finder, which is not compatible with - # cross-compilation, so try to fallback to find_library - pcap_dep = cc.find_library('pcap', required: false) -endif +pcap_dep = dependency('libpcap', required: false, method: 'pkg-config') if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep) dpdk_conf.set('RTE_PORT_PCAP', 1) dpdk_extra_ldflags += '-lpcap'Just sending this as an RFC for consideration, since I hit problems with the pcap code when testing 32-bit (x32) builds, and remembered having hit it previously too.
Quoted 4 lines
Does anyone see an issue with limiting our pcap detection to pkg-config only in this case?
/Bruce
Sadly it's not yet available in Debian stable:
https://packages.debian.org/buster/amd64/libpcap0.8-dev/filelist
Quoted 9 lines
Also for Ubuntu 18.04, it's only available with the bionic-updates repository, and only for the past month - it shipped without it.
I'm absolutely keen on using only pkg-config (so much that I did the packaging changes myself to ship it in libpcap-dev [1][2]) but perhaps in the interest of compatibility it's better to wait next year, so that the new Debian stable supports it, and the Ubuntu 18.04 LTS fix had the chance to rollout everywhere?
Thanks, that's exactly the sort of feedback I was looking for!
It seems to be the pcap-config support in meson which causes cross-building issues, so I wonder would it still work ok if we changed this to only use pkg-config for the initial search and then use find-library if that failed?
Quoted 15 lines
config/meson.build if libbsd.found()
Quoted 11 lines
# check for pcapconfig/meson.build +3
-5-pcap_dep = dependency('pcap', required: false) -if pcap_dep.found() - # pcap got a pkg-config file only in 1.9.0 and before that meson uses - # an internal pcap-config finder, which is not compatible with - # cross-compilation, so try to fallback to find_library +pcap_dep = dependency('libpcap', required: false, method: 'pkg-config') +if not pcap_dep.found() + # pcap got a pkg-config file only in 1.9.0 pcap_dep = cc.find_library('pcap', required: false) endifThat would be fine - is the 'method' option supported in the minimum version we support right now?
I tried building with meson 0.47 and didn't get any errors so it should be ok, though the reference guide doesn't explicitly say what version it's supported in. I think even if unsupported in 0.47, the keyword arg would just be ignored.
I'll do up a non-RFC v2 so.
PATCH v2 1/1 build: skip detecting libpcap via pcap-config
In reply to Bruce RichardsonWhen compiling for a slightly different architecture, e.g. 32-bit on 64-bit systems using CFLAGS rather than a cross-file, the pcap-config utility can often return parameters that are unusable for the build in question, i.e. providing the native 64-bit library paths rather than checking for 32-bit equivalent.
Since many distros now include a version of libpcap with a pkg-config file, and for those that don't find-library should work ok as a fallback, we can explicitly just use pkg-config in the dependency search, causing meson to skip trying to use pcap-config.
--- config/meson.build | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
config/meson.build +3 -5
@@ -163,11 +163,9 @@ if libbsd.found() endif # check for pcap -pcap_dep = dependency('pcap', required: false) -if pcap_dep.found() - # pcap got a pkg-config file only in 1.9.0 and before that meson uses - # an internal pcap-config finder, which is not compatible with - # cross-compilation, so try to fallback to find_library +pcap_dep = dependency('libpcap', required: false, method: 'pkg-config') +if not pcap_dep.found() + # pcap got a pkg-config file only in 1.9.0 pcap_dep = cc.find_library('pcap', required: false) endif if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v2] build: skip detecting libpcap via pcap-config
Quoted 25 lines · Bruce Richardson
When compiling for a slightly different architecture, e.g. 32-bit on 64-bit systems using CFLAGS rather than a cross-file, the pcap-config utility can often return parameters that are unusable for the build in question, i.e. providing the native 64-bit library paths rather than checking for 32-bit equivalent.
Since many distros now include a version of libpcap with a pkg-config file, and for those that don't find-library should work ok as a fallback, we can explicitly just use pkg-config in the dependency search, causing meson to skip trying to use pcap-config.
Signed-off-by Bruce Richardson <[email protected]>--- config/meson.build | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)config/meson.build +0
-1@@ -163,11 +163,9 @@ if libbsd.found() endif # check for pcap -pcap_dep = dependency('pcap', required: false)
config/meson.build if libbsd.found() · line 171
Quoted 10 lines
config/meson.build +3
-4-if pcap_dep.found() - # pcap got a pkg-config file only in 1.9.0 and before that meson uses - # an internal pcap-config finder, which is not compatible with - # cross-compilation, so try to fallback to find_library +pcap_dep = dependency('libpcap', required: false, method: 'pkg-config') +if not pcap_dep.found() + # pcap got a pkg-config file only in 1.9.0 pcap_dep = cc.find_library('pcap', required: false) endif if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
Signature · 2 lines
Kind regards, Luca Boccassi
Re: [dpdk-dev] [PATCH v2] build: skip detecting libpcap via pcap-config
Quoted 8 lines · Luca Boccassi
Quoted 6 lines · Bruce Richardson
When compiling for a slightly different architecture, e.g. 32-bit on 64-bit systems using CFLAGS rather than a cross-file, the pcap-config utility can often return parameters that are unusable for the build in question, i.e. providing the native 64-bit library paths rather than checking for 32-bit equivalent.
Quoted 5 lines
Quoted 5 lines
Since many distros now include a version of libpcap with a pkg-config file, and for those that don't find-library should work ok as a fallback, we can explicitly just use pkg-config in the dependency search, causing meson to skip trying to use pcap-config.
Quoted 2 lines
Quoted 1 line
Signed-off-by Bruce Richardson <[email protected]>Reviewed-by Luca Boccassi <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v2] build: skip detecting libpcap via pcap-config
In reply to Bruce RichardsonQuoted 7 lines · Bruce Richardson
When compiling for a slightly different architecture, e.g. 32-bit on 64-bit systems using CFLAGS rather than a cross-file, the pcap-config utility can often return parameters that are unusable for the build in question, i.e. providing the native 64-bit library paths rather than checking for 32-bit equivalent.
Quoted 6 lines
Since many distros now include a version of libpcap with a pkg-config file, and for those that don't find-library should work ok as a fallback, we can explicitly just use pkg-config in the dependency search, causing meson to skip trying to use pcap-config.
Signed-off-by Bruce Richardson <[email protected]>
I also hit (this?) issue on a fc32 with both 32-bit and 64-bit pcap installed. Can you confirm?
If so, we might want to backport this as I get the same problem with v19.11.4.
# rpm -q libpcap libpcap-1.9.1-3.fc32.x86_64 libpcap-1.9.1-3.fc32.i686 # rpm -q meson meson-0.55.3-1.fc32.noarch
# meson --reconfigure build The Meson build system Version: 0.55.3 Source dir: /root/dpdk Build dir: /root/dpdk/build Build type: native build Program cat found: YES Project name: DPDK Project version: 20.11.0-rc0 C compiler for the host machine: cc (gcc 10.2.1 "cc (GCC) 10.2.1 20200723 (Red Hat 10.2.1-1)") C linker for the host machine: cc ld.bfd 2.34-5 Host machine cpu family: x86_64 Host machine cpu: x86_64 Program pkg-config found: YES Program gen-pmdinfo-cfile.sh found: YES Program list-dir-globs.py found: YES Program check-symbols.sh found: YES Program options-ibverbs-static.sh found: YES Program binutils-avx512-check.sh found: YES Program python3 found: YES (/usr/bin/python3) Program cat found: YES Program ../buildtools/symlink-drivers-solibs.sh found: YES (/bin/sh /root/dpdk/config/../buildtools/symlink-drivers-solibs.sh) Checking for size of "void *" : 8 Library m found: YES Library numa found: NO Library libfdt found: NO Found pkg-config: /usr/bin/pkg-config (1.6.3) Found CMake: /usr/bin/cmake (3.17.4) Run-time dependency libbsd found: NO (tried pkgconfig and cmake) pcap-config found: YES (/usr/bin/pcap-config)
config/meson.build:166:0: ERROR: Could not get return value of pcap_lib_version()
A full log can be found at /root/dpdk/build/meson-logs/meson-log.txt
# cat /root/dpdk/build/meson-logs/meson-log.txt [...] Determining dependency 'libpcap' with pkg-config executable '/usr/bin/pkg-config' PKG_CONFIG_PATH: Called `/usr/bin/pkg-config --modversion libpcap` -> 1
pcap-config binary missing from cross or native file, or env var undefined. Trying a default pcap-config fallback at pcap-config pcap-config found: YES (/usr/bin/pcap-config)
None of 'CC_LD' are defined in the environment, not changing global flags. Running compile:
Working directory: /root/dpdk/build/meson-private/tmp15ks2yx6 Command line: cc
/root/dpdk/build/meson-private/tmp15ks2yx6/testfile.c -o /root/dpdk/build/meson-private/tmp15ks2yx6/output.exe -pipe -D_FILE_OFFSET_BITS=64 -O0 -Wl,--start-group -lpcap -Wl,--end-group
Code:
#include <pcap.h>
#include <stdio.h>
int main(void) {
printf ("%s", (char*) pcap_lib_version());
return 0;
}Compiler stdout:
Compiler stderr:
/usr/bin/ld: skipping incompatible/usr/lib/gcc/x86_64-redhat-linux/10/../../../libpcap.so when searching for -lpcap/usr/bin/ld: skipping incompatible /lib/libpcap.so when searching for -lpcap /usr/bin/ld: skipping incompatible /usr/lib/libpcap.so when searching for -lpcap /usr/bin/ld: cannot find -lpcap
collect2: error: ld returned 1 exit status
Could not compile test file /root/dpdk/build/meson-private/tmp15ks2yx6/testfile.c: 1
config/meson.build:166:0: ERROR: Could not get return value of pcap_lib_version()
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v2] build: skip detecting libpcap via pcap-config
Quoted 14 lines · David Marchand
Quoted 12 lines · Bruce Richardson
When compiling for a slightly different architecture, e.g. 32-bit on 64-bit systems using CFLAGS rather than a cross-file, the pcap-config utility can often return parameters that are unusable for the build in question, i.e. providing the native 64-bit library paths rather than checking for 32-bit equivalent.
Since many distros now include a version of libpcap with a pkg-config file, and for those that don't find-library should work ok as a fallback, we can explicitly just use pkg-config in the dependency search, causing meson to skip trying to use pcap-config.
Quoted 5 lines
Quoted 1 line
Signed-off-by Bruce Richardson <[email protected]>I also hit (this?) issue on a fc32 with both 32-bit and 64-bit pcap installed. Can you confirm?
It looks to be the same general issue. Does adding this patch fix things? When compiling 32-bit on 64-bit you generally need to be sure to set PKG_CONFIG_LIBDIR in your environment to point to the appropriate path. It might also serve to fix things in this instance, if not set.
Quoted 2 lines
If so, we might want to backport this as I get the same problem with v19.11.4.
Good idea, I don't think it will break anything.
/Bruce
Re: [dpdk-dev] [PATCH v2] build: skip detecting libpcap via pcap-config
In reply to Bruce Richardson+CC stable for consideration
Quoted 11 lines · Bruce Richardson
When compiling for a slightly different architecture, e.g. 32-bit on 64-bit systems using CFLAGS rather than a cross-file, the pcap-config utility can often return parameters that are unusable for the build in question, i.e. providing the native 64-bit library paths rather than checking for 32-bit equivalent.
Since many distros now include a version of libpcap with a pkg-config file, and for those that don't find-library should work ok as a fallback, we can explicitly just use pkg-config in the dependency search, causing meson to skip trying to use pcap-config.
Quoted 27 lines
Signed-off-by Bruce Richardson <[email protected]>--- config/meson.build | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)config/meson.build +3
-5@@ -163,11 +163,9 @@ if libbsd.found() endif # check for pcap -pcap_dep = dependency('pcap', required: false) -if pcap_dep.found() - # pcap got a pkg-config file only in 1.9.0 and before that meson uses - # an internal pcap-config finder, which is not compatible with - # cross-compilation, so try to fallback to find_library +pcap_dep = dependency('libpcap', required: false, method: 'pkg-config') +if not pcap_dep.found() + # pcap got a pkg-config file only in 1.9.0 pcap_dep = cc.find_library('pcap', required: false) endif if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)Signature · 1 line
2.25.1