]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: build tests with -Wno-maybe-uninitialized if -O2/-flto are used
authorLuca Boccassi <luca.boccassi@microsoft.com>
Tue, 13 Apr 2021 19:03:39 +0000 (20:03 +0100)
committerLuca Boccassi <luca.boccassi@microsoft.com>
Wed, 14 Apr 2021 10:31:50 +0000 (11:31 +0100)
We intentionally do not inline initializations with definitions for
a bunch of _cleanup_ variables in tests, to ensure valgrind is triggered.
This triggers a lot of maybe-uninitialized false positives when -O2 and
-flto are used. Suppress them.

meson.build

index a8976c203745206e94989443371eeb6d837797df..fa929370bd505849f8fe788d2e71584e5972e3cc 100644 (file)
@@ -3318,6 +3318,11 @@ custom_target(
                    '} >@OUTPUT@'],
         build_by_default : true)
 
+# We intentionally do not do inline initializations with definitions for
+# a bunch of _cleanup_ variables in tests, to ensure valgrind is triggered.
+# This triggers a lot of maybe-uninitialized false positives when the
+# combination of -O2 and -flto is used. Suppress them.
+no_uninit = '-O2' in get_option('c_args') and '-flto=auto' in get_option('c_args') ? cc.first_supported_argument('-Wno-maybe-uninitialized') : []
 foreach tuple : tests
         sources = tuple[0]
         link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
@@ -3326,6 +3331,7 @@ foreach tuple : tests
         condition = tuple.length() > 4 ? tuple[4] : ''
         type = tuple.length() > 5 ? tuple[5] : ''
         defs = tuple.length() > 6 ? tuple[6] : []
+        defs += no_uninit
         parallel = tuple.length() > 7 ? tuple[7] : true
         timeout = 30
 
@@ -3393,7 +3399,7 @@ exe = executable(
         'test-libudev-sym',
         test_libudev_sym_c,
         include_directories : libudev_includes,
-        c_args : '-Wno-deprecated-declarations',
+        c_args : ['-Wno-deprecated-declarations'] + no_uninit,
         link_with : [libudev],
         build_by_default : want_tests != 'false',
         install : install_tests,
@@ -3406,7 +3412,7 @@ exe = executable(
         'test-libudev-static-sym',
         test_libudev_sym_c,
         include_directories : libudev_includes,
-        c_args : '-Wno-deprecated-declarations',
+        c_args : ['-Wno-deprecated-declarations'] + no_uninit,
         link_with : [install_libudev_static],
         build_by_default : want_tests != 'false' and static_libudev_pic,
         install : install_tests and static_libudev_pic,