Skip to contentSkip to conversation

build: fix warnings when running external commands

PATCH Applied Bruce Richardson 3 participants 3 messages Jan 20, 2022 – Feb 2, 2022 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): http://patches.dpdk.org/project/dpdk/patch/[email protected]/

#1 lore raw

PATCH v2 1/1 build: fix warnings when running external commands

Meson 0.61.1 is giving warnings that the calls to run_command do not always explicitly specify if the result is to be checked or not, i.e. there is a missing "check" parameter. This is because the default behaviour without the parameter is due to change in the future.

We can fix these warnings by explicitly adding into each call whether the result should be checked by meson or not. This patch therefore adds in "check: false" to each run_command call where the result is being checked by the DPDK meson.build code afterwards, and adds in "check: true" to any calls where the result is currently unchecked.

Bugzilla-id: 921

---
V2: fix build errors in KNI module

---
 app/test/meson.build                    | 2 +-
 buildtools/meson.build                  | 2 +-
 config/arm/meson.build                  | 2 +-
 config/meson.build                      | 5 +++--
 config/x86/meson.build                  | 2 +-
 drivers/common/mlx5/linux/meson.build   | 2 +-
 drivers/common/mlx5/windows/meson.build | 4 ++--
 drivers/net/mlx4/meson.build            | 2 +-
 kernel/linux/kni/meson.build            | 2 +-
 kernel/linux/meson.build                | 9 +++++----
 meson.build                             | 2 +-
 11 files changed, 18 insertions(+), 16 deletions(-)
app/test/meson.build +1 -1
index 344a609a4d..80a23c2dd1 100644
@@ -491,7 +491,7 @@ dpdk_test = executable('dpdk-test',
              driver_install_path),
         install: true)
 
-has_hugepage = run_command('has-hugepage.sh').stdout().strip() != '0'
+has_hugepage = run_command('has-hugepage.sh', check: true).stdout().strip() != '0'
 message('hugepage availability: @0@'.format(has_hugepage))
 
 # some perf tests (eg: memcpy perf autotest)take very long
buildtools/meson.build +1 -1
index 22ea0ba375..400b88f251 100644
@@ -45,7 +45,7 @@ if host_machine.system() != 'windows'
 endif
 foreach module : python3_required_modules
     script = 'import importlib.util; import sys; exit(importlib.util.find_spec("@0@") is None)'
-    if run_command(py3, '-c', script.format(module)).returncode() != 0
+    if run_command(py3, '-c', script.format(module), check: false).returncode() != 0
         error('missing python module: @0@'.format(module))
     endif
 endforeach
config/arm/meson.build +1 -1
index c3a3f2faaf..e102381af5 100644
@@ -463,7 +463,7 @@ else
             # 'Primary Part number', 'Revision']
             detect_vendor = find_program(join_paths(meson.current_source_dir(),
                                                     'armv8_machine.py'))
-            cmd = run_command(detect_vendor.path())
+            cmd = run_command(detect_vendor.path(), check: false)
             if cmd.returncode() == 0
                 cmd_output = cmd.stdout().to_lower().strip().split(' ')
                 implementer_id = cmd_output[0]
config/meson.build +3 -2
index 805d5d51d0..ee12318d4f 100644
@@ -22,7 +22,8 @@ is_ms_linker = is_windows and (cc.get_id() == 'clang')
 # depending on the configuration options
 pver = meson.project_version().split('.')
 major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
-abi_version = run_command(find_program('cat', 'more'), abi_version_file).stdout().strip()
+abi_version = run_command(find_program('cat', 'more'), abi_version_file,
+        check: true).stdout().strip()
 
 # Libraries have the abi_version as the filename extension
 # and have the soname be all but the final part of the abi_version.
@@ -334,7 +335,7 @@ if max_lcores == 'detect'
         error('Discovery of max_lcores is not supported for cross-compilation.')
     endif
     # overwrite the default value with discovered values
-    max_lcores = run_command(get_cpu_count_cmd).stdout().to_int()
+    max_lcores = run_command(get_cpu_count_cmd, check: true).stdout().to_int()
     min_lcores = 2
     # DPDK must be built for at least 2 cores
     if max_lcores < min_lcores
config/x86/meson.build +1 -1
index e25ed316f4..54345c4da3 100644
@@ -4,7 +4,7 @@
 # get binutils version for the workaround of Bug 97
 binutils_ok = true
 if is_linux or cc.get_id() == 'gcc'
-    binutils_ok = run_command(binutils_avx512_check).returncode() == 0
+    binutils_ok = run_command(binutils_avx512_check, check: false).returncode() == 0
     if not binutils_ok and cc.has_argument('-mno-avx512f')
         machine_args += '-mno-avx512f'
         warning('Binutils error with AVX512 assembly, disabling AVX512 support')
drivers/common/mlx5/linux/meson.build +1 -1
index 7909f23e21..4c7b53b9bd 100644
@@ -36,7 +36,7 @@ foreach libname:libnames
 endforeach
 if static_ibverbs or dlopen_ibverbs
     # Build without adding shared libs to Requires.private
-    ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
+    ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs', check: true).stdout()
     ext_deps += declare_dependency(compile_args: ibv_cflags.split())
 endif
 if static_ibverbs
drivers/common/mlx5/windows/meson.build +2 -2
index 980f76b11c..edbbaa9ae1 100644
@@ -8,8 +8,8 @@ sources += files(
         'mlx5_common_os.c',
 )
 
-res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])')
-res_inc = run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])')
+res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])', check: false)
+res_inc = run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])', check: false)
 
 if (res_lib.returncode() != 0 or res_inc.returncode() != 0)
     build = false
drivers/net/mlx4/meson.build +1 -1
index 99a30eab8f..a038c1ec1b 100644
@@ -42,7 +42,7 @@ foreach libname:libnames
 endforeach
 if static_ibverbs or dlopen_ibverbs
     # Build without adding shared libs to Requires.private
-    ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
+    ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs', check:true).stdout()
     ext_deps += declare_dependency(compile_args: ibv_cflags.split())
 endif
 if static_ibverbs
kernel/linux/kni/meson.build +1 -1
index c683fc7b36..dae8c37b37 100644
@@ -5,7 +5,7 @@
 # Ref: https://jira.devtools.intel.com/browse/DPDK-29263
 kmod_cflags = ''
 file_path = kernel_source_dir + '/include/linux/netdevice.h'
-run_cmd = run_command('grep', 'ndo_tx_timeout', file_path)
+run_cmd = run_command('grep', 'ndo_tx_timeout', file_path, check: false)
 
 if run_cmd.stdout().contains('txqueue') == true
    kmod_cflags = '-DHAVE_ARG_TX_QUEUE'
kernel/linux/meson.build +5 -4
index 0637452e95..d8fb20c1c3 100644
@@ -11,7 +11,7 @@ cross_args = []
 
 if not meson.is_cross_build()
     # native build
-    kernel_version = run_command('uname', '-r').stdout().strip()
+    kernel_version = run_command('uname', '-r', check: true).stdout().strip()
     kernel_install_dir = '/lib/modules/' + kernel_version + '/extra/dpdk'
     if kernel_build_dir == ''
         # use default path for native builds
@@ -24,14 +24,14 @@ if not meson.is_cross_build()
 
     # test running make in kernel directory, using "make kernelversion"
     make_returncode = run_command('make', '-sC', kernel_build_dir,
-            'kernelversion').returncode()
+            'kernelversion', check: true).returncode()
     if make_returncode != 0
         # backward compatibility:
         # the headers could still be in the 'build' subdir
         if not kernel_build_dir.endswith('build') and not kernel_build_dir.endswith('build/')
             kernel_build_dir = join_paths(kernel_build_dir, 'build')
             make_returncode = run_command('make', '-sC', kernel_build_dir,
-                    'kernelversion').returncode()
+                    'kernelversion', check: true).returncode()
         endif
     endif
 
@@ -54,7 +54,8 @@ if kernel_build_dir == ''
 endif
 cross_compiler = find_program('c').path()
 if cross_compiler.endswith('gcc')
-    cross_prefix = run_command([py3, '-c', 'print("' + cross_compiler + '"[:-3])']).stdout().strip()
+    cross_prefix = run_command([py3, '-c', 'print("' + cross_compiler + '"[:-3])'],
+            check: true).stdout().strip()
 elif cross_compiler.endswith('clang')
     cross_prefix = ''
     found_target = false
meson.build +1 -1
index 12cb6e0e83..1223b79d74 100644
@@ -5,7 +5,7 @@ project('DPDK', 'C',
         # Get version number from file.
         # Fallback to "more" for Windows compatibility.
         version: run_command(find_program('cat', 'more'),
-            files('VERSION')).stdout().strip(),
+            files('VERSION'), check: true).stdout().strip(),
         license: 'BSD',
         default_options: ['buildtype=release', 'default_library=static'],
         meson_version: '>= 0.49.2'
Signature · 1 line
2.32.0
Tested-by on v2 1/1
#2 lore raw
Quoted 12 lines · Bruce Richardson

Meson 0.61.1 is giving warnings that the calls to run_command do not always explicitly specify if the result is to be checked or not, i.e. there is a missing "check" parameter. This is because the default behaviour without the parameter is due to change in the future.

We can fix these warnings by explicitly adding into each call whether the result should be checked by meson or not. This patch therefore adds in "check: false" to each run_command call where the result is being checked by the DPDK meson.build code afterwards, and adds in "check: true" to any calls where the result is currently unchecked.

Quoted 4 lines

Bugzilla-id: 921

Quoted 202 lines

---
V2: fix build errors in KNI module

---
 app/test/meson.build                    | 2 +-
 buildtools/meson.build                  | 2 +-
 config/arm/meson.build                  | 2 +-
 config/meson.build                      | 5 +++--
 config/x86/meson.build                  | 2 +-
 drivers/common/mlx5/linux/meson.build   | 2 +-
 drivers/common/mlx5/windows/meson.build | 4 ++--
 drivers/net/mlx4/meson.build            | 2 +-
 kernel/linux/kni/meson.build            | 2 +-
 kernel/linux/meson.build                | 9 +++++----
 meson.build                             | 2 +-
 11 files changed, 18 insertions(+), 16 deletions(-)
app/test/meson.build +1 -1
index 344a609a4d..80a23c2dd1 100644
@@ -491,7 +491,7 @@ dpdk_test = executable('dpdk-test',
              driver_install_path),
         install: true)
 
-has_hugepage = run_command('has-hugepage.sh').stdout().strip() != '0'
+has_hugepage = run_command('has-hugepage.sh', check: true).stdout().strip() != '0'
 message('hugepage availability: @0@'.format(has_hugepage))
 
 # some perf tests (eg: memcpy perf autotest)take very long
buildtools/meson.build +1 -1
index 22ea0ba375..400b88f251 100644
@@ -45,7 +45,7 @@ if host_machine.system() != 'windows'
 endif
 foreach module : python3_required_modules
     script = 'import importlib.util; import sys; exit(importlib.util.find_spec("@0@") is None)'
-    if run_command(py3, '-c', script.format(module)).returncode() != 0
+    if run_command(py3, '-c', script.format(module), check: false).returncode() != 0
         error('missing python module: @0@'.format(module))
     endif
 endforeach
config/arm/meson.build +1 -1
index c3a3f2faaf..e102381af5 100644
@@ -463,7 +463,7 @@ else
             # 'Primary Part number', 'Revision']
             detect_vendor = find_program(join_paths(meson.current_source_dir(),
                                                     'armv8_machine.py'))
-            cmd = run_command(detect_vendor.path())
+            cmd = run_command(detect_vendor.path(), check: false)
             if cmd.returncode() == 0
                 cmd_output = cmd.stdout().to_lower().strip().split(' ')
                 implementer_id = cmd_output[0]
config/meson.build +3 -2
index 805d5d51d0..ee12318d4f 100644
@@ -22,7 +22,8 @@ is_ms_linker = is_windows and (cc.get_id() == 'clang')
 # depending on the configuration options
 pver = meson.project_version().split('.')
 major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
-abi_version = run_command(find_program('cat', 'more'), abi_version_file).stdout().strip()
+abi_version = run_command(find_program('cat', 'more'), abi_version_file,
+        check: true).stdout().strip()
 
 # Libraries have the abi_version as the filename extension
 # and have the soname be all but the final part of the abi_version.
@@ -334,7 +335,7 @@ if max_lcores == 'detect'
         error('Discovery of max_lcores is not supported for cross-compilation.')
     endif
     # overwrite the default value with discovered values
-    max_lcores = run_command(get_cpu_count_cmd).stdout().to_int()
+    max_lcores = run_command(get_cpu_count_cmd, check: true).stdout().to_int()
     min_lcores = 2
     # DPDK must be built for at least 2 cores
     if max_lcores < min_lcores
config/x86/meson.build +1 -1
index e25ed316f4..54345c4da3 100644
@@ -4,7 +4,7 @@
 # get binutils version for the workaround of Bug 97
 binutils_ok = true
 if is_linux or cc.get_id() == 'gcc'
-    binutils_ok = run_command(binutils_avx512_check).returncode() == 0
+    binutils_ok = run_command(binutils_avx512_check, check: false).returncode() == 0
     if not binutils_ok and cc.has_argument('-mno-avx512f')
         machine_args += '-mno-avx512f'
         warning('Binutils error with AVX512 assembly, disabling AVX512 support')
drivers/common/mlx5/linux/meson.build +1 -1
index 7909f23e21..4c7b53b9bd 100644
@@ -36,7 +36,7 @@ foreach libname:libnames
 endforeach
 if static_ibverbs or dlopen_ibverbs
     # Build without adding shared libs to Requires.private
-    ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
+    ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs', check: true).stdout()
     ext_deps += declare_dependency(compile_args: ibv_cflags.split())
 endif
 if static_ibverbs
drivers/common/mlx5/windows/meson.build +2 -2
index 980f76b11c..edbbaa9ae1 100644
@@ -8,8 +8,8 @@ sources += files(
         'mlx5_common_os.c',
 )
 
-res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])')
-res_inc = run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])')
+res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])', check: false)
+res_inc = run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])', check: false)
 
 if (res_lib.returncode() != 0 or res_inc.returncode() != 0)
     build = false
drivers/net/mlx4/meson.build +1 -1
index 99a30eab8f..a038c1ec1b 100644
@@ -42,7 +42,7 @@ foreach libname:libnames
 endforeach
 if static_ibverbs or dlopen_ibverbs
     # Build without adding shared libs to Requires.private
-    ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
+    ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs', check:true).stdout()
     ext_deps += declare_dependency(compile_args: ibv_cflags.split())
 endif
 if static_ibverbs
kernel/linux/kni/meson.build +1 -1
index c683fc7b36..dae8c37b37 100644
@@ -5,7 +5,7 @@
 # Ref: https://jira.devtools.intel.com/browse/DPDK-29263
 kmod_cflags = ''
 file_path = kernel_source_dir + '/include/linux/netdevice.h'
-run_cmd = run_command('grep', 'ndo_tx_timeout', file_path)
+run_cmd = run_command('grep', 'ndo_tx_timeout', file_path, check: false)
 
 if run_cmd.stdout().contains('txqueue') == true
    kmod_cflags = '-DHAVE_ARG_TX_QUEUE'
kernel/linux/meson.build +5 -4
index 0637452e95..d8fb20c1c3 100644
@@ -11,7 +11,7 @@ cross_args = []
 
 if not meson.is_cross_build()
     # native build
-    kernel_version = run_command('uname', '-r').stdout().strip()
+    kernel_version = run_command('uname', '-r', check: true).stdout().strip()
     kernel_install_dir = '/lib/modules/' + kernel_version + '/extra/dpdk'
     if kernel_build_dir == ''
         # use default path for native builds
@@ -24,14 +24,14 @@ if not meson.is_cross_build()
 
     # test running make in kernel directory, using "make kernelversion"
     make_returncode = run_command('make', '-sC', kernel_build_dir,
-            'kernelversion').returncode()
+            'kernelversion', check: true).returncode()
     if make_returncode != 0
         # backward compatibility:
         # the headers could still be in the 'build' subdir
         if not kernel_build_dir.endswith('build') and not kernel_build_dir.endswith('build/')
             kernel_build_dir = join_paths(kernel_build_dir, 'build')
             make_returncode = run_command('make', '-sC', kernel_build_dir,
-                    'kernelversion').returncode()
+                    'kernelversion', check: true).returncode()
         endif
     endif
 
@@ -54,7 +54,8 @@ if kernel_build_dir == ''
 endif
 cross_compiler = find_program('c').path()
 if cross_compiler.endswith('gcc')
-    cross_prefix = run_command([py3, '-c', 'print("' + cross_compiler + '"[:-3])']).stdout().strip()
+    cross_prefix = run_command([py3, '-c', 'print("' + cross_compiler + '"[:-3])'],
+            check: true).stdout().strip()
 elif cross_compiler.endswith('clang')
     cross_prefix = ''
     found_target = false
meson.build +1 -2
index 12cb6e0e83..1223b79d74 100644
@@ -5,7 +5,7 @@ project('DPDK', 'C',
         # Get version number from file.
         # Fallback to "more" for Windows compatibility.
         version: run_command(find_program('cat', 'more'),
-            files('VERSION')).stdout().strip(),
+            files('VERSION'), check: true).stdout().strip(),
         license: 'BSD',
         default_options: ['buildtype=release', 'default_library=static'],
         meson_version: '>= 0.49.2'
--

2.32.0

#3 lore raw

24/01/2022 15:08, Jerin Jacob:

Quoted 14 lines
Quoted 12 lines · Bruce Richardson

Meson 0.61.1 is giving warnings that the calls to run_command do not always explicitly specify if the result is to be checked or not, i.e. there is a missing "check" parameter. This is because the default behaviour without the parameter is due to change in the future.

We can fix these warnings by explicitly adding into each call whether the result should be checked by meson or not. This patch therefore adds in "check: false" to each run_command call where the result is being checked by the DPDK meson.build code afterwards, and adds in "check: true" to any calls where the result is currently unchecked.

Quoted 6 lines
Quoted 4 lines

Bugzilla-id: 921

Applied, thanks.