examples/l2fwd-cat: check compatibility of dependency lib
Subsystems (2)
PATCH 1/1 examples/l2fwd-cat: check compatibility of dependency lib
The meson find_library() function can sometimes return incompatible libraries which are unsuitable for linking. For example, after installing the native x86 pqos library on my system, arm64 builds started trying (and failing) to build the l2fwd-cat example app. Fix this incorrect detection in our build files by checking that the found pqos library can actually be used to link apps.
--- examples/l2fwd-cat/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/l2fwd-cat/meson.build +1 -1
@@ -7,7 +7,7 @@ # DPDK instance, use 'make' pqos = cc.find_library('pqos', required: false) -build = pqos.found() +build = (pqos.found() and cc.links('int main(void) { return 0; }', dependencies: pqos)) if not build subdir_done() endif
Signature · 1 line
2.48.1
PATCH v2 1/1 build: validate libraries returned from meson find function
The meson find_library() API call sometimes finds a library that is actually incompatible with the current build, for example, returning a 64-bit library when doing a 32-bit build. To avoid problems with this, check each library returned from a find_library() call and treat the library as unfound if its incompatible.
This checking is not necessary (or should not be necessary) for dependencies got using pkg-config, since the .pc files for each build type are stored in a different directory on the system.
---
v2: expanded the scope of the patch from just fixing the one instance
I hit, to changing things globally to try and avoid any future issues.
--- config/meson.build | 15 ++++++---- drivers/baseband/acc/meson.build | 30 +++++++++++++++---- drivers/baseband/turbo_sw/meson.build | 30 +++++++++++++++---- drivers/common/mlx5/linux/meson.build | 4 +-- drivers/common/mlx5/windows/meson.build | 2 +- drivers/ml/cnxk/meson.build | 6 +++- drivers/net/af_xdp/meson.build | 3 ++ drivers/net/mana/meson.build | 2 +- drivers/net/mlx4/meson.build | 2 +- drivers/net/pcap/meson.build | 6 +++- drivers/power/amd_uncore/meson.build | 2 +- drivers/raw/ifpga/meson.build | 2 +- examples/l2fwd-cat/meson.build | 2 +- examples/l2fwd-keepalive/meson.build | 2 +- .../vm_power_manager/guest_cli/meson.build | 2 +- examples/vm_power_manager/meson.build | 2 +- lib/eal/windows/meson.build | 24 +++++++++++---- meson.build | 3 ++ 18 files changed, 105 insertions(+), 34 deletions(-)
config/meson.build +10 -5
@@ -208,7 +208,8 @@ if not is_windows endif # on some OS, maths functions are in a separate library -if cc.find_library('m', required : false).found() +math_dep = cc.find_library('m', required : false) +if math_dep.found() and cc.links(min_c_code, dependencies: math_dep) # some libs depend on maths lib add_project_link_arguments('-lm', language: 'c') dpdk_extra_ldflags += '-lm'
@@ -235,7 +236,7 @@ if meson.is_cross_build() and not meson.get_external_property('numa', true) endif if find_libnuma numa_dep = cc.find_library('numa', required: false) - if numa_dep.found() and cc.has_header('numaif.h') + if numa_dep.found() and cc.has_header('numaif.h') and cc.links(min_c_code, dependencies: numa_dep) dpdk_conf.set10('RTE_HAS_LIBNUMA', true) has_libnuma = true add_project_link_arguments('-lnuma', language: 'c')
@@ -245,7 +246,7 @@ endif has_libfdt = false fdt_dep = cc.find_library('fdt', required: false) -if fdt_dep.found() and cc.has_header('fdt.h') +if fdt_dep.found() and cc.has_header('fdt.h') and cc.links(min_c_code, dependencies: fdt_dep) dpdk_conf.set10('RTE_HAS_LIBFDT', true) has_libfdt = true add_project_link_arguments('-lfdt', language: 'c')
@@ -253,7 +254,7 @@ if fdt_dep.found() and cc.has_header('fdt.h') endif libexecinfo = cc.find_library('execinfo', required: false) -if libexecinfo.found() +if libexecinfo.found() and cc.links(min_c_code, dependencies: libexecinfo) add_project_link_arguments('-lexecinfo', language: 'c') dpdk_extra_ldflags += '-lexecinfo' endif
@@ -288,7 +289,8 @@ if not pcap_dep.found() # pcap got a pkg-config file only in 1.9.0 pcap_dep = cc.find_library(pcap_lib, required: false) endif -if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep) +if (pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep) + and cc.links(min_c_code, dependencies: pcap_dep)) dpdk_conf.set('RTE_HAS_LIBPCAP', 1) dpdk_extra_ldflags += '-l@0@'.format(pcap_lib) endif
@@ -296,6 +298,9 @@ endif # for clang 32-bit compiles we need libatomic for 64-bit atomic ops if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false atomic_dep = cc.find_library('atomic', required: true) + if not cc.links(min_c_code, dependencies: atomic_dep) + error('broken dependency, "libatomic"') + endif add_project_link_arguments('-latomic', language: 'c') dpdk_extra_ldflags += '-latomic' endif
drivers/baseband/acc/meson.build +25 -5
@@ -5,11 +5,31 @@ dep_dec5g = dependency('flexran_sdk_ldpc_decoder_5gnr', required: false) if dep_dec5g.found() - ext_deps += cc.find_library('stdc++', required: true) - ext_deps += cc.find_library('irc', required: true) - ext_deps += cc.find_library('imf', required: true) - ext_deps += cc.find_library('ipps', required: true) - ext_deps += cc.find_library('svml', required: true) + stdcpp_dep = cc.find_library('stdc++', required: true) + if not cc.links(min_c_code, dependencies: stdcpp_dep) + error('broken dependency, "libstdc++"') + endif + ext_deps += stdcpp_dep + irc_dep = cc.find_library('irc', required: true) + if not cc.links(min_c_code, dependencies: irc_dep) + error('broken dependency, "libirc"') + endif + ext_deps += irc_dep + imf_dep = cc.find_library('imf', required: true) + if not cc.links(min_c_code, dependencies: imf_dep) + error('broken dependency, "libimf"') + endif + ext_deps += imf_dep + ipps_dep = cc.find_library('ipps', required: true) + if not cc.links(min_c_code, dependencies: ipps_dep) + error('broken dependency, "libipps"') + endif + ext_deps += ipps_dep + svml_dep = cc.find_library('svml', required: true) + if not cc.links(min_c_code, dependencies: svml_dep) + error('broken dependency, "libsvml"') + endif + ext_deps += svml_dep ext_deps += dep_dec5g ext_deps += dependency('flexran_sdk_ldpc_encoder_5gnr', required: true) ext_deps += dependency('flexran_sdk_LDPC_ratematch_5gnr', required: true)
drivers/baseband/turbo_sw/meson.build +25 -5
@@ -6,11 +6,31 @@ dep_turbo = dependency('flexran_sdk_turbo', required: false) dep_dec5g = dependency('flexran_sdk_ldpc_decoder_5gnr', required: false) if dep_turbo.found() - ext_deps += cc.find_library('stdc++', required: true) - ext_deps += cc.find_library('irc', required: true) - ext_deps += cc.find_library('imf', required: true) - ext_deps += cc.find_library('ipps', required: true) - ext_deps += cc.find_library('svml', required: true) + stdcpp_dep = cc.find_library('stdc++', required: true) + if not cc.links(min_c_code, dependencies: stdcpp_dep) + error('broken dependency, "libstdc++"') + endif + ext_deps += stdcpp_dep + irc_dep = cc.find_library('irc', required: true) + if not cc.links(min_c_code, dependencies: irc_dep) + error('broken dependency, "libirc"') + endif + ext_deps += irc_dep + imf_dep = cc.find_library('imf', required: true) + if not cc.links(min_c_code, dependencies: imf_dep) + error('broken dependency, "libimf"') + endif + ext_deps += imf_dep + ipps_dep = cc.find_library('ipps', required: true) + if not cc.links(min_c_code, dependencies: ipps_dep) + error('broken dependency, "libipps"') + endif + ext_deps += ipps_dep + svml_dep = cc.find_library('svml', required: true) + if not cc.links(min_c_code, dependencies: svml_dep) + error('broken dependency, "libsvml"') + endif + ext_deps += svml_dep ext_deps += dep_turbo ext_deps += dependency('flexran_sdk_crc', required: true) ext_deps += dependency('flexran_sdk_rate_matching', required: true)
drivers/common/mlx5/linux/meson.build +2 -2
@@ -23,7 +23,7 @@ foreach libname:libnames if not lib.found() and not static_ibverbs lib = cc.find_library(libname, required:false) endif - if lib.found() + if lib.found() and cc.links(min_c_code, dependencies: lib) libs += lib if not static_ibverbs and not dlopen_ibverbs ext_deps += lib
@@ -47,7 +47,7 @@ endif libmtcr_ul_found = false lib = cc.find_library('mtcr_ul', required:false) -if lib.found() +if lib.found() and cc.links(min_c_code, dependencies: lib) libmtcr_ul_found = true ext_deps += lib endif
drivers/common/mlx5/windows/meson.build +1 -1
@@ -8,7 +8,7 @@ if not cc.has_header('mlx5devx.h') endif devxlib = cc.find_library('mlx5devx', required: false) -if not devxlib.found() +if not devxlib.found() or not cc.links(min_c_code, dependencies: devxlib) build = false reason = 'missing dependency, "mlx5devx"' subdir_done()
drivers/ml/cnxk/meson.build +5 -1
@@ -72,7 +72,11 @@ ext_deps += dlpack_dep ext_deps += dmlc_dep ext_deps += tvm_dep ext_deps += tvmdp_dep -ext_deps += cc.find_library('stdc++', required: true) +stdcpp_dep = cc.find_library('stdc++', required: true) +if not cc.links(min_c_code, dependencies: stdcpp_dep) + error('broken dependency, "libstdc++"') +endif +ext_deps += stdcpp_dep deps += ['bus_vdev']
drivers/net/af_xdp/meson.build +3 -0
@@ -20,6 +20,9 @@ xdp_dep = dependency('libxdp', version : libxdp_ver, required: false, method: 'p bpf_dep = dependency('libbpf', required: false, method: 'pkg-config') if not bpf_dep.found() bpf_dep = cc.find_library('bpf', required: false) + if bpf_dep.found() and not cc.links(min_c_code, dependencies: bpf_dep) + bpf_dep = disabler() + endif endif cflags += no_wvla_cflag
drivers/net/mana/meson.build +1 -1
@@ -27,7 +27,7 @@ foreach libname:libnames if not lib.found() lib = cc.find_library(libname, required:false) endif - if lib.found() + if lib.found() and cc.links(min_c_code, dependencies: lib) libs += lib ext_deps += lib else
drivers/net/mlx4/meson.build +1 -1
@@ -31,7 +31,7 @@ foreach libname:libnames if not lib.found() and not static_ibverbs lib = cc.find_library(libname, required:false) endif - if lib.found() + if lib.found() and cc.links(min_c_code, dependencies: lib) libs += lib if not static_ibverbs and not dlopen_ibverbs ext_deps += lib
drivers/net/pcap/meson.build +5 -1
@@ -13,7 +13,11 @@ sources = files( ext_deps += pcap_dep if is_windows - ext_deps += cc.find_library('iphlpapi', required: true) + iphlpapi_dep = cc.find_library('iphlpapi', required: true) + if not cc.links(min_c_code, dependencies: iphlpapi_dep) + error('broken dependency, "iphlpapi"') + endif + ext_deps += iphlpapi_dep endif require_iova_in_mbuf = false
drivers/power/amd_uncore/meson.build +1 -1
@@ -9,7 +9,7 @@ endif ESMI_header = '#include<e_smi/e_smi.h>' lib = cc.find_library('e_smi64', required: false) -if not lib.found() +if not lib.found() or not cc.links(min_c_code, dependencies: lib) build = false reason = 'missing dependency, "libe_smi"' else
drivers/raw/ifpga/meson.build +1 -1
@@ -11,7 +11,7 @@ rtdep = dependency('librt', required: false) if not rtdep.found() rtdep = cc.find_library('rt', required: false) endif -if not rtdep.found() +if not rtdep.found() or not cc.links(min_c_code, dependencies: rtdep) build = false reason = 'missing dependency, "librt"' subdir_done()
examples/l2fwd-cat/meson.build +1 -1
@@ -7,7 +7,7 @@ # DPDK instance, use 'make' pqos = cc.find_library('pqos', required: false) -build = pqos.found() +build = (pqos.found() and cc.links(min_c_code, dependencies: pqos)) if not build subdir_done() endif
examples/l2fwd-keepalive/meson.build +1 -1
@@ -8,7 +8,7 @@ allow_experimental_apis = true librt = cc.find_library('rt', required: false) -if not librt.found() +if not librt.found() or not cc.links(min_c_code, dependencies: librt) build = false subdir_done() endif
examples/vm_power_manager/guest_cli/meson.build +1 -1
@@ -17,5 +17,5 @@ sources = files( allow_experimental_apis = true opt_dep = cc.find_library('virt', required : false) -build = opt_dep.found() +build = (opt_dep.found() and cc.links(min_c_code, dependencies: opt_dep)) ext_deps += opt_dep
examples/vm_power_manager/meson.build +1 -1
@@ -38,7 +38,7 @@ else endif opt_dep = cc.find_library('virt', required : false) -build = opt_dep.found() +build = (opt_dep.found() and cc.links(min_c_code, dependencies: opt_dep)) ext_deps += opt_dep opt_dep = dependency('jansson', required : false, method: 'pkg-config')
lib/eal/windows/meson.build +18 -6
@@ -24,12 +24,24 @@ sources += files( dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true) -ext_deps += [ - cc.find_library('dbghelp'), - cc.find_library('setupapi'), - cc.find_library('ws2_32'), -] +dbghelp_dep = cc.find_library('dbghelp') +if not cc.links(min_c_code, dependencies: dbghelp_dep) + error('broken dependency, "dbghelp"') +endif +setupapi_dep = cc.find_library('setupapi') +if not cc.links(min_c_code, dependencies: setupapi_dep) + error('broken dependency, "setupapi"') +endif +ws2_32_dep = cc.find_library('ws2_32') +if not cc.links(min_c_code, dependencies: ws2_32_dep) + error('broken dependency, "ws2_32"') +endif +ext_deps += [dbghelp_dep, setupapi_dep, ws2_32_dep] if is_ms_linker # Contrary to docs, VirtualAlloc2() is exported by mincore.lib. - ext_deps += cc.find_library('mincore') + mincore_dep = cc.find_library('mincore') + if not cc.links(min_c_code, dependencies: mincore_dep) + error('broken dependency, "mincore"') + endif + ext_deps += mincore_dep endif
meson.build +3 -0
@@ -51,6 +51,9 @@ testpmd_drivers_sources = [] testpmd_drivers_deps = [] abi_version_file = files('ABI_VERSION') +# minimal C code for testing library linking compatibility +min_c_code = 'int main(void) { return 0; }' + if host_machine.cpu_family().startswith('x86') arch_subdir = 'x86' elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().startswith('aarch')
Signature · 1 line
2.48.1
Re: [PATCH v2] build: validate libraries returned from meson find function
Hello Bruce,
Quoted 6 lines · Bruce Richardson
The meson
find_library()API call sometimes finds a library that is actually incompatible with the current build, for example, returning a 64-bit library when doing a 32-bit build. To avoid problems with this, check each library returned from afind_library()call and treat the library as unfound if its incompatible.
meson should have all it needs to double check itself that the "found" library links fine...
But well, we need to live with existing behavior.
It's a pity meson refuses to define user helpers... so much copy/paste in this patch.
Quoted 4 lines
This checking is not necessary (or should not be necessary) for dependencies got using pkg-config, since the .pc files for each build type are stored in a different directory on the system.
Would it affect the library lookup if we pass has_headers to find_library()?
Signature · 1 line
David Marchand
Re: [PATCH v2] build: validate libraries returned from meson find function
Quoted 11 lines · David Marchand
Hello Bruce,
Quoted 6 lines · Bruce Richardson
The meson
find_library()API call sometimes finds a library that is actually incompatible with the current build, for example, returning a 64-bit library when doing a 32-bit build. To avoid problems with this, check each library returned from afind_library()call and treat the library as unfound if its incompatible.
Quoted 4 lines
meson should have all it needs to double check itself that the "found" library links fine...
But well, we need to live with existing behavior.
Yes, it's annoying and it should be something I think meson does, but even if it was added today to meson, we'd have to live with current behaviour for a long time. :-(
Quoted 3 lines
It's a pity meson refuses to define user helpers... so much copy/paste in this patch.
Yes, though if we want to reduce it I can remove some that is currently unnecessary. For example, windows support doesn't have any cross-compile options and only supports a single target so the checks there probably aren't necessary. I added them for consistency.
The other thing we could do to help out here, is check to see if any more libraries can be switched to using pkg-config. I noticed some libs have fallbacks after a pkg-config call - we could remove the fallbacks and just mandate use of pkg-config for those.
Quoted 8 lines
Quoted 5 lines
This checking is not necessary (or should not be necessary) for dependencies got using pkg-config, since the .pc files for each build type are stored in a different directory on the system.
Would it affect the library lookup if we pass
has_headerstofind_library()?
I don't think it would affect things, since the headers are common in many cases, only the binary files differ (thinking especially of the 32-bit vs 64-bit case here).
/Bruce
Re: [PATCH v2] build: validate libraries returned from meson find function
Quoted 9 lines · Bruce Richardson
Quoted 3 lines · David Marchand
It's a pity meson refuses to define user helpers... so much copy/paste in this patch.
Yes, though if we want to reduce it I can remove some that is currently unnecessary. For example, windows support doesn't have any cross-compile options and only supports a single target so the checks there probably aren't necessary. I added them for consistency.
For many (all?) DPDK devs, copy/paste is the rule when it comes to meson stuff. Let's keep this consistent.
Quoted 5 lines
The other thing we could do to help out here, is check to see if any more libraries can be switched to using pkg-config. I noticed some libs have fallbacks after a pkg-config call - we could remove the fallbacks and just mandate use of pkg-config for those.
It may be differently implemented across distributions, and their versions.. I suspect we will still need the fallbacks.
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
This checking is not necessary (or should not be necessary) for dependencies got using pkg-config, since the .pc files for each build type are stored in a different directory on the system.
Would it affect the library lookup if we pass
has_headerstofind_library()?I don't think it would affect things, since the headers are common in many cases, only the binary files differ (thinking especially of the 32-bit vs 64-bit case here).
Ok, nevermind, I'm fine with this patch.
Signature · 1 line
David Marchand
Re: [PATCH v2] build: validate libraries returned from meson find function
In reply to Bruce RichardsonQuoted 7 lines · Bruce Richardson
The meson
find_library()API call sometimes finds a library that is actually incompatible with the current build, for example, returning a 64-bit library when doing a 32-bit build. To avoid problems with this, check each library returned from afind_library()call and treat the library as unfound if its incompatible.
Quoted 5 lines
This checking is not necessary (or should not be necessary) for dependencies got using pkg-config, since the .pc files for each build type are stored in a different directory on the system.
Signed-off-by Bruce Richardson <[email protected]>
Signature · 1 line
David Marchand
David Marchand
AppliedRe: [PATCH v2] build: validate libraries returned from meson find function
Quoted 9 lines · David Marchand
Quoted 7 lines · Bruce Richardson
The meson
find_library()API call sometimes finds a library that is actually incompatible with the current build, for example, returning a 64-bit library when doing a 32-bit build. To avoid problems with this, check each library returned from afind_library()call and treat the library as unfound if its incompatible.
Quoted 7 lines
Quoted 5 lines
This checking is not necessary (or should not be necessary) for dependencies got using pkg-config, since the .pc files for each build type are stored in a different directory on the system.
Signed-off-by Bruce Richardson <[email protected]>Acked-by David Marchand <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand
Re: [PATCH v2] build: validate libraries returned from meson find function
Quoted 9 lines · David Marchand
Quoted 8 lines · David Marchand
Quoted 6 lines · Bruce Richardson
The meson
find_library()API call sometimes finds a library that is actually incompatible with the current build, for example, returning a 64-bit library when doing a 32-bit build. To avoid problems with this, check each library returned from afind_library()call and treat the library as unfound if its incompatible.
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
This checking is not necessary (or should not be necessary) for dependencies got using pkg-config, since the .pc files for each build type are stored in a different directory on the system.
Signed-off-by Bruce Richardson <[email protected]>Acked-by David Marchand <[email protected]>Applied, thanks.
Hello,
I have warnings like this for mlx5 drivers on Ubuntu 22.04 with clang:
Message: Disabling mlx5 [drivers/net/mlx5]: missing internal dependency "common_mlx5"
Build command:
CC=clang PKG_CONFIG_PATH=/opt/rdma-core/build/lib/pkgconfig meson --werror --buildtype=debugoptimized build
gcc does not reproduce.
Regards,
Ali
Re: [PATCH v2] build: validate libraries returned from meson find function
Quoted 23 lines · Ali Alnubani
Quoted 9 lines · David Marchand
Quoted 8 lines · David Marchand
Quoted 6 lines · Bruce Richardson
The meson
find_library()API call sometimes finds a library that is actually incompatible with the current build, for example, returning a 64-bit library when doing a 32-bit build. To avoid problems with this, check each library returned from afind_library()call and treat the library as unfound if its incompatible.Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
This checking is not necessary (or should not be necessary) for dependencies got using pkg-config, since the .pc files for each build type are stored in a different directory on the system.
Signed-off-by Bruce Richardson <[email protected]>Acked-by David Marchand <[email protected]>Applied, thanks.
Hello,
I have warnings like this for mlx5 drivers on Ubuntu 22.04 with clang:
Quoted 9 lines
Message: Disabling mlx5 [
drivers/net/mlx5]: missing internal dependency "common_mlx5"Build command:
CC=clang PKG_CONFIG_PATH=/opt/rdma-core/build/lib/pkgconfig meson --werror --buildtype=debugoptimized buildgcc does not reproduce.
[Trimming CC list a bit]
Hi,
There must be an earlier error where the check for a library used by common_mlx5 fails. Can you perhaps send on a more complete build log, or perhaps log a bugzilla and attach the meson configuration output, and the meson build logfile there?
/Bruce
Re: [PATCH v2] build: validate libraries returned from meson find function
Quoted 34 lines · Bruce Richardson
Quoted 22 lines · Ali Alnubani
Quoted 9 lines · David Marchand
Quoted 8 lines · David Marchand
Quoted 6 lines · Bruce Richardson
The meson
find_library()API call sometimes finds a library that is actually incompatible with the current build, for example, returning a 64-bit library when doing a 32-bit build. To avoid problems with this, check each library returned from afind_library()call and treat the library as unfound if its incompatible.Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
This checking is not necessary (or should not be necessary) for dependencies got using pkg-config, since the .pc files for each build type are stored in a different directory on the system.
Signed-off-by Bruce Richardson <[email protected]>Acked-by David Marchand <[email protected]>Applied, thanks.
Hello,
I have warnings like this for mlx5 drivers on Ubuntu 22.04 with clang:
Quoted 9 lines
Message: Disabling mlx5 [
drivers/net/mlx5]: missing internal dependency "common_mlx5"Build command:
CC=clang PKG_CONFIG_PATH=/opt/rdma-core/build/lib/pkgconfig meson --werror --buildtype=debugoptimized buildgcc does not reproduce.
[Trimming CC list a bit]
Quoted 8 lines
Hi,
There must be an earlier error where the check for a library used by
common_mlx5fails. Can you perhaps send on a more complete build log, or perhaps log a bugzilla and attach the meson configuration output, and the meson build logfile there?/Bruce
Created a Bugzilla ticket with meson logs and more info:
https://bugs.dpdk.org/show_bug.cgi?id=1798
Thanks,
Ali