]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
meson: write all warning flags to 'c-warnings.txt'
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 16 Jan 2026 14:56:18 +0000 (14:56 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 16 Jan 2026 18:11:03 +0000 (18:11 +0000)
Passing warning flags to the C compiler results in incredibly long
command lines, which in turns results in incredibly large CI log
files. Our logs are so large that they often exceed the GitLab
file limits.

We've cut out the irrelevant cruft from the logs and they're still
too large. The only option left is to stop passing so many args
to the compiler.

Fortunately it is easy to achieve this with GCC/CLang as when seeing
an argument "@somepath" they will treat each line in "somepath" as
being an additional compiler argument.

Putting the warning flags in a 'c-warnings.txt' file is fairly
easy and a massive win. We don't lose anything from the CI logs
as we print the full set of warning flags at the end of running
'meson'. Meanwhile for interactive builds the flags are visible
in the c-warnings.txt file in the build directory root.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
meson.build
scripts/meson-warnings.py [new file with mode: 0644]

index d72c8e7a23196c47901905c577bb0c2bb30da18b..964d1fa4e17df81756686ed5bf88ac4ff04d70a5 100644 (file)
@@ -232,6 +232,59 @@ libvirt_revision = arr_version[2].to_int()
 libvirt_lib_version = '@0@.@1@.@2@'.format(libvirt_so_version, libvirt_age, libvirt_revision)
 
 
+# Where we look for daemons and admin binaries during configure
+
+libvirt_sbin_path = []
+
+if host_machine.system() != 'windows'
+  libvirt_sbin_path += [
+    '/sbin',
+    '/usr/sbin',
+    '/usr/local/sbin',
+  ]
+endif
+
+
+# required programs check
+
+required_programs = [
+  'perl',
+  'python3',
+  'xmllint',
+  'xsltproc',
+]
+
+foreach name : required_programs
+  prog = find_program(name, dirs: libvirt_sbin_path)
+  varname = name.underscorify()
+  set_variable('@0@_prog'.format(varname), prog)
+endforeach
+
+# optional programs
+
+optional_programs = [
+  'augparse',
+  'black',
+  'flake8',
+  'pdwtags',
+  'pytest',
+]
+
+missing_optional_programs = []
+foreach name : optional_programs
+  prog = find_program(name, required: false, dirs: libvirt_sbin_path)
+  varname = name.underscorify()
+  if prog.found()
+    prog_path = prog.full_path()
+  else
+    prog_path = name
+    missing_optional_programs += [ name ]
+  endif
+
+  set_variable('@0@_prog'.format(varname), prog)
+endforeach
+
+
 # check compile flags
 
 cc = meson.get_compiler('c')
@@ -534,7 +587,13 @@ if get_option('warning_level') == '2'
   endif
 
 endif
-add_project_arguments(supported_cc_flags, language: 'c')
+
+run_command([python3_prog,
+             'scripts' / 'meson-warnings.py',
+             meson.current_build_dir() / 'c-warnings.txt'] + supported_cc_flags,
+            check: true)
+
+add_project_arguments('@' + meson.current_build_dir() / 'c-warnings.txt', language: 'c')
 
 if cc.has_argument('-Wsuggest-attribute=format')
   conf.set('WITH_SUGGEST_ATTRIBUTE_FORMAT', 1)
@@ -809,59 +868,6 @@ endforeach
 conf.set('SIZEOF_LONG', cc.sizeof('long'))
 
 
-# Where we look for daemons and admin binaries during configure
-
-libvirt_sbin_path = []
-
-if host_machine.system() != 'windows'
-  libvirt_sbin_path += [
-    '/sbin',
-    '/usr/sbin',
-    '/usr/local/sbin',
-  ]
-endif
-
-
-# required programs check
-
-required_programs = [
-  'perl',
-  'python3',
-  'xmllint',
-  'xsltproc',
-]
-
-foreach name : required_programs
-  prog = find_program(name, dirs: libvirt_sbin_path)
-  varname = name.underscorify()
-  set_variable('@0@_prog'.format(varname), prog)
-endforeach
-
-# optional programs
-
-optional_programs = [
-  'augparse',
-  'black',
-  'flake8',
-  'pdwtags',
-  'pytest',
-]
-
-missing_optional_programs = []
-foreach name : optional_programs
-  prog = find_program(name, required: false, dirs: libvirt_sbin_path)
-  varname = name.underscorify()
-  if prog.found()
-    prog_path = prog.full_path()
-  else
-    prog_path = name
-    missing_optional_programs += [ name ]
-  endif
-
-  set_variable('@0@_prog'.format(varname), prog)
-endforeach
-
-
 # early checks where lot of other packages depend on the result
 
 if not get_option('driver_remote').disabled()
diff --git a/scripts/meson-warnings.py b/scripts/meson-warnings.py
new file mode 100644 (file)
index 0000000..d6e9539
--- /dev/null
@@ -0,0 +1,8 @@
+#!/usr/bin/env python3
+
+import shutil
+import sys
+
+with open(sys.argv[1], "w") as out:
+    for w in sys.argv[2:]:
+        print(w, file=out)