From 26978ac7c3fa9ca39dd01688c18fbe52e7c0a2d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 9 Mar 2023 10:35:05 +0100 Subject: [PATCH 1/5] meson: stop using nested lists for sources meson itself flattens the list when it is used in "sources:" field, but it makes our own processing more complicated. I find it also a bit confusing. --- src/test/meson.build | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/src/test/meson.build b/src/test/meson.build index fe1a0fec21..b57ba23539 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -200,16 +200,12 @@ tests += [ 'condition' : 'HAVE_ACL', }, { - 'sources' : [ - files('test-af-list.c'), - generated_gperf_headers, - ], + 'sources' : files('test-af-list.c') + + generated_gperf_headers, }, { - 'sources' : [ - files('test-arphrd-util.c'), - generated_gperf_headers, - ], + 'sources' : files('test-arphrd-util.c') + + generated_gperf_headers, }, { 'sources' : files('test-ask-password-api.c'), @@ -228,10 +224,8 @@ tests += [ 'type' : 'manual', }, { - 'sources' : [ - files('test-cap-list.c'), - generated_gperf_headers, - ], + 'sources' : files('test-cap-list.c') + + generated_gperf_headers, 'dependencies' : libcap, }, { @@ -268,28 +262,25 @@ tests += [ 'dependencies' : libp11kit_cflags }, { - 'sources' : [ - files('test-errno-list.c'), - generated_gperf_headers, - ], + 'sources' : files('test-errno-list.c') + + generated_gperf_headers, }, { 'sources' : files('test-fd-util.c'), 'dependencies' : libseccomp, }, { - 'sources' : [files( - 'test-hashmap.c', - 'test-hashmap-plain.c'), - test_hashmap_ordered_c, - ], + 'sources' : files( + 'test-hashmap.c', + 'test-hashmap-plain.c', + ) + [ + test_hashmap_ordered_c, + ], 'timeout' : 180, }, { - 'sources' : [ - files('test-ip-protocol-list.c'), - shared_generated_gperf_headers, - ], + 'sources' : files('test-ip-protocol-list.c') + + shared_generated_gperf_headers, }, { 'sources' : files('test-ipcrm.c'), From 78103450b4dd7d704b9acd517a28c669a0120b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 12 Jun 2023 10:45:48 +0200 Subject: [PATCH 2/5] meson: define _GNU_SOURCE as '1' This changes the generated config.h file thusly: -#define _GNU_SOURCE +#define _GNU_SOURCE 1 Canonically, _GNU_SOURCE is just defined, without any value, but g++ defines _GNU_SOURCE implicitly [1]. This causes a warning about a redefinition during complilation of C++ programs after '-include config.h'. Our config attempts to inject this (and a bunch of other arguments) into all compliations. But before meson 0.54, flags for dependencies were not propagated correctly (*), and the C++ compilation was done without various flags (**). Once that was fixed, we started getting a warning. [1] http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.predefined (*) Actually, the changelog doesn't say anything. But it mentions various work related to dependency propagation, and apparently this changes as a side effect. (**) -fno-strict-aliasing -fstrict-flex-arrays=1 -fvisibility=hidden -fno-omit-frame-pointer -include config.h This could be solved in various ways, but it'd require either making the compilation command line longer, which we want to avoid for readability of the build logs, or splitting the logic to define the args for C++ progs separately, which would make our meson.build files more complicated. Changing the definition to '1' also solves the issue (because apparently now we match the implicit definition), and shouldn't have other effects. I checked compilation with gcc and clang. Maybe on other systems this could cause problems. We can revisit if people report issues. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 51a5fc82e3..fe3ec079cf 100644 --- a/meson.build +++ b/meson.build @@ -527,7 +527,7 @@ has_wstringop_truncation = cc.has_argument('-Wstringop-truncation') ##################################################################### # compilation result tests -conf.set('_GNU_SOURCE', true) +conf.set('_GNU_SOURCE', 1) conf.set('__SANE_USERSPACE_TYPES__', true) conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation) From daf4e78e4841a527ba62da48fd00e2e6b8805193 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 16 May 2022 03:21:16 +0900 Subject: [PATCH 3/5] meson: bump required version to 0.54.0 --- meson.build | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index fe3ec079cf..3a714238d4 100644 --- a/meson.build +++ b/meson.build @@ -10,7 +10,7 @@ project('systemd', 'c', 'localstatedir=/var', 'warning_level=2', ], - meson_version : '>= 0.53.2', + meson_version : '>= 0.54.0', ) libsystemd_version = '0.36.0' @@ -330,7 +330,7 @@ slow_tests = want_tests != 'false' and get_option('slow-tests') fuzz_tests = want_tests != 'false' and get_option('fuzz-tests') install_tests = get_option('install-tests') -if add_languages('cpp', required : fuzzer_build) +if add_languages('cpp', native : false, required : fuzzer_build) # Used only for tests cxx = meson.get_compiler('cpp') cxx_cmd = ' '.join(cxx.cmd_array()) @@ -4449,8 +4449,8 @@ foreach test : tests versiondep, ] - # FIXME: Use fs.stem() with meson >= 0.54.0 - name = '@0@'.format(sources[0]).split('/')[-1] + # FIXME: Drop .format with meson >= 0.59.0 + name = fs.stem('@0@'.format(sources[0])) if not name.endswith('.cc') deps += [userspace] endif @@ -4589,8 +4589,8 @@ foreach fuzzer : fuzzers endif sources += fuzz_generated_directives - # FIXME: Use fs.stem() with meson >= 0.54.0 - name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0] + # FIXME: Drop .format with meson >= 0.59.0 + name = fs.stem('@0@'.format(sources[0])) exe = executable( name, From 573c0dc13406be6575cb9177d8fe818a45426ba8 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 16 May 2022 03:22:33 +0900 Subject: [PATCH 4/5] meson: bump required version to 0.55.0 --- meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 3a714238d4..c6942a89ab 100644 --- a/meson.build +++ b/meson.build @@ -10,7 +10,7 @@ project('systemd', 'c', 'localstatedir=/var', 'warning_level=2', ], - meson_version : '>= 0.54.0', + meson_version : '>= 0.55.0', ) libsystemd_version = '0.36.0' @@ -735,7 +735,7 @@ foreach prog : progs '/usr/sbin/' + prog[0], '/sbin/' + prog[0], required: false) - path = exe.found() ? exe.path() : prog[1] + path = exe.found() ? exe.full_path() : prog[1] endif name = prog.length() > 2 ? prog[2] : prog[0].to_upper() conf.set_quoted(name, path) @@ -1123,7 +1123,7 @@ else r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0') clang_found = r.found() if clang_found - clang = r.path() + clang = r.full_path() endif else clang_found = true From 80dc9ad98c29c708a8cffbcade44ebf7f3f355e5 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 16 May 2022 03:36:34 +0900 Subject: [PATCH 5/5] meson: bump required version to 0.56.0 --- meson.build | 2 +- shell-completion/bash/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index c6942a89ab..cadb735000 100644 --- a/meson.build +++ b/meson.build @@ -10,7 +10,7 @@ project('systemd', 'c', 'localstatedir=/var', 'warning_level=2', ], - meson_version : '>= 0.55.0', + meson_version : '>= 0.56.0', ) libsystemd_version = '0.36.0' diff --git a/shell-completion/bash/meson.build b/shell-completion/bash/meson.build index 5fe7611b71..24cb785e6b 100644 --- a/shell-completion/bash/meson.build +++ b/shell-completion/bash/meson.build @@ -4,7 +4,7 @@ bashcompletiondir = get_option('bashcompletiondir') if bashcompletiondir == '' bash_completion = dependency('bash-completion', required : false) if bash_completion.found() - bashcompletiondir = bash_completion.get_pkgconfig_variable('completionsdir') + bashcompletiondir = bash_completion.get_variable(pkgconfig : 'completionsdir') else bashcompletiondir = datadir / 'bash-completion/completions' endif