user-mode: Avoid processing unnecessary meson rules
cover user-mode: Avoid processing unnecessary meson rules
Only process linux-user/meson.build on Linux (respectively on BSD).
Philippe Mathieu-Daudé (2):
bsd-user: Only process meson rules on BSD host
linux-user: Only process meson rules on Linux host
bsd-user/meson.build | 4 ++++ linux-user/meson.build | 4 ++++ 2 files changed, 8 insertions(+)
Signature · 1 line
2.31.1
PATCH 1/2 bsd-user: Only process meson rules on BSD host
--- bsd-user/meson.build | 4 ++++ 1 file changed, 4 insertions(+)
bsd-user/meson.build +4 -0
@@ -1,3 +1,7 @@ +if not config_host.has_key('CONFIG_BSD') + subdir_done() +endif + bsd_user_ss.add(files( 'bsdload.c', 'elfload.c',
Signature · 1 line
2.31.1
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Quoted 11 lines · Philippe Mathieu-Daudé
Reported-by Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- bsd-user/meson.build | 4 ++++ 1 file changed, 4 insertions(+)bsd-user/meson.build +0
-0
bsd-user/meson.build line 3
Quoted 3 lines
bsd-user/meson.build +3
-0@@ -1,3 +1,7 @@ +if not config_host.has_key('CONFIG_BSD') + subdir_done() +endif
Why here and not in the parent meson.build?
r~
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Quoted 7 lines · Richard Henderson
Quoted 6 lines · Philippe Mathieu-Daudé
Reported-by Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- bsd-user/meson.build | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 11 lines
bsd-user/meson.build line 3
Quoted 8 lines
bsd-user/meson.build +3
-0@@ -1,3 +1,7 @@ +if not config_host.has_key('CONFIG_BSD') + subdir_done() +endifWhy here and not in the parent meson.build?
I have the same question... I never know where to 'filter' when it comes to meson...
Waner
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
In reply to Richard HendersonQuoted 7 lines · Richard Henderson
Quoted 6 lines · Philippe Mathieu-Daudé
Reported-by Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
bsd-user/meson.build | 4 ++++1 file changed, 4 insertions(+)
Quoted 10 lines
bsd-user/meson.build line 3
Quoted 8 lines
bsd-user/meson.build +3
-0@@ -1,3 +1,7 @@ +if not config_host.has_key('CONFIG_BSD') + subdir_done() +endifWhy here and not in the parent meson.build?
This is what Paolo recommended me to do last time I added a conditional inclusion.
Personally I prefer having it in the call site rather than the callee (no need to read the callee to notice it isn't called). I guess this is for readability, to not clutter meson.build files more...
Paolo, what is your preference?
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 1 line
Why here and not in the parent meson.build?
This is what Paolo recommended me to do last time I added a conditional inclusion.
Personally I prefer having it in the call site rather than the callee (no need to read the callee to notice it isn't called). I guess this is for readability, to not clutter meson.build? files more...
Yes, pretty much. In this case it's quite obvious that bsd-user is BSD-only, but I prefer it if dir/meson.build has the knowledge of what goes on in dir/.
That said, we're not terribly consistent, see have_block and have_tools, so either will be okay.
Paolo
Quoted 2 lines
Paolo, what is your preference?
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
In reply to Philippe Mathieu-DaudéQuoted 5 lines · Philippe Mathieu-Daudé
Reported-by Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- bsd-user/meson.build | 4 ++++ 1 file changed, 4 insertions(+)
I'm newcomer here, but this is just 4 lines of Meson, and two similar usages already exist within QEMU proper so...
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Quoted 7 lines · WANG Xuerui
Quoted 5 lines · Philippe Mathieu-Daudé
Reported-by Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
bsd-user/meson.build | 4 ++++1 file changed, 4 insertions(+)
Quoted 5 lines
I'm newcomer here, but this is just 4 lines of Meson, and two similar usages already exist within QEMU proper so...
Reviewed-by WANG Xuerui <[email protected]>
Hmm, other replies pointed out that one can also make the top-level subdir() call conditional... And we seem to have more than 2 usages following the latter pattern instead. However putting the conditional in sub-directory makes the logic localized, which is arguably more friendly to someone casually browsing the source code.
As both ways work, I think maybe being consistent and moving things to top-level meson.build has more value?
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
In reply to Philippe Mathieu-DaudéQuoted 12 lines · Philippe Mathieu-Daudé
Reported-by Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- bsd-user/meson.build | 4 ++++ 1 file changed, 4 insertions(+)bsd-user/meson.build +0
-0
bsd-user/meson.build line 7
Quoted 7 lines
bsd-user/meson.build +4
-0@@ -1,3 +1,7 @@ +if not config_host.has_key('CONFIG_BSD') + subdir_done() +endif + bsd_user_ss.add(files( 'bsdload.c', 'elfload.c',
So, what's the reason for this change? The commit messages and the cover letter don't really explain it. Is this fixing a bug (if so what?), a precaution to avoid possible future bugs, fixing a performance issue with how long meson takes to run (if so, how much effect does this have), or something else?
thanks
-- PMM
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Philippe Mathieu-Daudé
Reported-by Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- bsd-user/meson.build | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 15 lines
bsd-user/meson.build line 7
Quoted 12 lines
bsd-user/meson.build +4
-0@@ -1,3 +1,7 @@ +if not config_host.has_key('CONFIG_BSD') + subdir_done() +endif + bsd_user_ss.add(files( 'bsdload.c', 'elfload.c',So, what's the reason for this change?
linux-user/meson.build is evaluated on bsd, and bsd-user/meson.build on Linux.
Quoted 5 lines
The commit messages and
the cover letter don't really explain it. Is this fixing a bug (if so what?), a precaution to avoid possible future bugs, fixing a performance issue with how long meson takes to run (if so, how much effect does this have), or something else?
I'll wait for feedback from Paolo, then work on the explanation.
Regards,
Phil.
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Philippe Mathieu-Daudé
Reported-by Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- bsd-user/meson.build | 4 ++++ 1 file changed, 4 insertions(+)Quoted 15 lines
bsd-user/meson.build line 7
Quoted 12 lines
bsd-user/meson.build +4
-0@@ -1,3 +1,7 @@ +if not config_host.has_key('CONFIG_BSD') + subdir_done() +endif + bsd_user_ss.add(files( 'bsdload.c', 'elfload.c',So, what's the reason for this change?
Quoted 3 lines
linux-user/meson.build is evaluated on bsd, and bsd-user/meson.build on Linux.
True, but "meson.build is evaluated but just does nothing or adds files to a sourceset that isn't used" is pretty common (hw/pci/meson.build is evaluated even if we're not building a system with PCI support, for example). If there's a reason why bsd-user and linux-user are special we should explain it, I think.
thanks
-- PMM
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Quoted 4 lines · Peter Maydell
True, but "meson.build is evaluated but just does nothing or adds files to a sourceset that isn't used" is pretty common (hw/pci/meson.build is evaluated even if we're not building a system with PCI support, for example).
Selection of files from hw/pci/meson.build is based on per-target definitions, so there's no way around when:/if_true:. (Technically, hw/pci/meson.build also as an if_false, so there's *really* no way around parsing it).
Instead, when the definition is constant across all targets, it is possible to use either when:/if_true: or an "if" as in
if have_user
util_ss.add(files('selfmap.c'))
endif
or the various "if m[0].found()" found in directories that build shared modules. In this case I personally lean more towards the latter, but when:/if_true: is a little more compact so both are acceptable.
Paolo
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
In reply to Philippe Mathieu-DaudéQuoted 28 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Philippe Mathieu-Daudé
Reported-by Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- bsd-user/meson.build | 4 ++++ 1 file changed, 4 insertions(+)Quoted 15 lines
bsd-user/meson.build line 7
Quoted 12 lines
bsd-user/meson.build +4
-0@@ -1,3 +1,7 @@ +if not config_host.has_key('CONFIG_BSD') + subdir_done() +endif + bsd_user_ss.add(files( 'bsdload.c', 'elfload.c',So, what's the reason for this change?
linux-user/meson.build is evaluated on bsd, and bsd-user/meson.build on Linux.
Quoted 7 lines
Quoted 5 lines
The commit messages and
the cover letter don't really explain it. Is this fixing a bug (if so what?), a precaution to avoid possible future bugs, fixing a performance issue with how long meson takes to run (if so, how much effect does this have), or something else?I'll wait for feedback from Paolo, then work on the explanation.
Ping Paolo?
Signature · 1 line
Alex Bennée
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
In reply to Philippe Mathieu-DaudéQuoted 11 lines · Philippe Mathieu-Daudé
Reported-by Warner Losh <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- bsd-user/meson.build | 4 ++++ 1 file changed, 4 insertions(+)bsd-user/meson.build +0
-0
bsd-user/meson.build line 7
Quoted 7 lines
bsd-user/meson.build +4
-0@@ -1,3 +1,7 @@ +if not config_host.has_key('CONFIG_BSD') + subdir_done() +endif + bsd_user_ss.add(files( 'bsdload.c', 'elfload.c',
If we look at the big picture across the root meson.build, and this meson.build we have
bsd_user_ss = ss.source_set()
...
bsd_user_ss.add(files(
'bsdload.c',
'elfload.c',
'main.c',
'mmap.c',
'signal.c',
'strace.c',
'syscall.c',
'uaccess.c',))
...
bsd_user_ss.add(files('gdbstub.c')) specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
So without this change, we're already correctly dropping bsd_user_ss in its entirity, when not on BSD.
With this change, we're dropping some, but not all, of bsd_user_ss files - gdbstub.c remains.
So this change on its own doesn't make a whole lot of sense.
If we look at linux-user/meson.build though things are more complex. There we have alot of sub-dirs, and meson.biuld in those dirs adds generators for various files. So conceivably skipping linux-user will mean we won't auto-generate files we don't need on non-Linux.
With that in mind, I think it makes conceptual sense to have this bsd-user/meson.build change, for the purpose of design consistency, even if it doesn't have any real world benefit for bsd-user today.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Quoted 4 lines · Daniel P. Berrangé
If we look at linux-user/meson.build though things are more complex. There we have alot of sub-dirs, and meson.biuld in those dirs adds generators for various files. So conceivably skipping linux-user will mean we won't auto-generate files we don't need on non-Linux.
The top level meson.build doesn't call process on the syscall_nr_generators[] list unless we're building linux-user targets, so I don't think we will auto-generate anything we don't need.
-- PMM
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Quoted 7 lines · Peter Maydell
Quoted 4 lines · Daniel P. Berrangé
If we look at linux-user/meson.build though things are more complex. There we have alot of sub-dirs, and meson.biuld in those dirs adds generators for various files. So conceivably skipping linux-user will mean we won't auto-generate files we don't need on non-Linux.
Quoted 5 lines
The top level meson.build doesn't call process on the syscall_nr_generators[] list unless we're building linux-user targets, so I don't think we will auto-generate anything we don't need.
The problem is that I'm trying to add some os-specific files to the bsd-user in a patch set I sent off. bsd-user compiles for different BSDs, and I'd like to start pulling in per-bsd files as I'm upstreaming. To do that, I have this construct in the bsd-user/meson.build file:
# Pull in the OS-specific build glue, if any
if fs.exists(targetos)
subdir(targetos)
endif
primarily because the builds failed on Linux when it tried to find the non-existent bsd-user/linunx directory. The question came up on how to cope with this situation, and Philippe sent off this series as an alternative to that construct. The whole reason why we descend into the linux-user directory on BSD and into the bsd-user directory on linux is unclear to me as well.
So this is preparing the ground for my future work of upstreaming. I'm agnostic as to how it's resolved, but it needs to be resolved.
Warner
Paolo Bonzini
Acked-byRe: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
In reply to Daniel P. BerrangéQuoted 11 lines · Daniel P. Berrangé
bsd_user_ss.add(files('gdbstub.c'))
specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)So without this change, we're already correctly dropping
bsd_user_ssin its entirity, when not on BSD.With this change, we're dropping some, but not all, of
bsd_user_ssfiles -gdbstub.cremains.So this change on its own doesn't make a whole lot of sense.
Agreed; that said, the gdbstub.c files added by
bsd_user_ss.add(files('gdbstub.c')) linux_user_ss.add(files('gdbstub.c', 'thunk.c'))
are unnecessary because there is already
specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)
So, with those two instances of gdbstub.c removed, both patches are
Thanks,
Paolo
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Le 05/10/2021 à 21:26, Paolo Bonzini a écrit :
Quoted 18 lines · Daniel P. Berrangé
Quoted 11 lines
bsd_user_ss.add(files('gdbstub.c'))
specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)So without this change, we're already correctly dropping
bsd_user_ssin its entirity, when not on BSD.With this change, we're dropping some, but not all, of
bsd_user_ssfiles -gdbstub.cremains.So this change on its own doesn't make a whole lot of sense.
Agreed; that said, the
gdbstub.cfiles added bybsd_user_ss.add(files('gdbstub.c'))
linux_user_ss.add(files('gdbstub.c', 'thunk.c'))
Quoted 8 lines
are unnecessary because there is already
specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)So, with those two instances of
gdbstub.cremoved, both patches areAcked-by Paolo Bonzini <[email protected]>
I can take them if a v2 is sent updated accordingly...
Thanks,
Laurent
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Quoted 21 lines · Laurent Vivier
Quoted 20 lines · Paolo Bonzini
Quoted 11 lines · Daniel P. Berrangé
bsd_user_ss.add(files('gdbstub.c'))
specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)So without this change, we're already correctly dropping
bsd_user_ssin its entirity, when not on BSD.With this change, we're dropping some, but not all, of
bsd_user_ssfiles -gdbstub.cremains.So this change on its own doesn't make a whole lot of sense.
Agreed; that said, the
gdbstub.cfiles added bybsd_user_ss.add(files('gdbstub.c'))
linux_user_ss.add(files('gdbstub.c', 'thunk.c'))are unnecessary because there is already
Quoted 9 lines
Quoted 6 lines
specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)So, with those two instances of
gdbstub.cremoved, both patches areAcked-by Paolo Bonzini <[email protected]>I can take them if a v2 is sent updated accordingly...
I'd planned on rolling them into the bsd-user patch set that I'd been working on
that is almost ready to go in (this is I think the only remaining issue with the patch
train, though I need to double check threads). I'd planned on doing that tomorrow,
but would be happy to coordinate with you since one of them does touch linux-user.
Warner
Re: [PATCH 1/2] bsd-user: Only process meson rules on BSD host
Le 05/10/2021 à 22:46, Warner Losh a écrit :
Quoted 35 lines · On Tue, Oct 5, 2021 at 2:41 PM Laurent Vivier <[email protected]…
Le 05/10/2021 à 21:26, Paolo Bonzini a écrit :
> On 27/09/21 11:52, Daniel P. Berrangé wrote:
>> bsd_user_ss.add(files('gdbstub.c'))
>> specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
>>
>>
>> So without this change, we're already correctly dropping bsd_user_ss
>> in its entirity, when not on BSD.
>>
>> With this change, we're dropping some, but not all, of bsd_user_ss
>> files - gdbstub.c remains.
>>
>> So this change on its own doesn't make a whole lot of sense.
>
> Agreed; that said, the gdbstub.c files added by
>
> bsd_user_ss.add(files('gdbstub.c'))
> linux_user_ss.add(files('gdbstub.c', 'thunk.c'))
>
> are unnecessary because there is already
>
> specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)
>
> So, with those two instances of gdbstub.c removed, both patches are
>
> Acked-by: Paolo Bonzini <[email protected] <mailto:[email protected]>>
>
I can take them if a v2 is sent updated accordingly...Quoted 4 lines
I'd planned on rolling them into the bsd-user patch set that I'd been working on that is almost ready to go in (this is I think the only remaining issue with the patch train, though I need to double check threads). I'd planned on doing that tomorrow, but would be happy to coordinate with you since one of them does touch linux-user.
You can take both.
Thanks,
Laurent
PATCH 2/2 linux-user: Only process meson rules on Linux host
In reply to Philippe Mathieu-Daudé--- linux-user/meson.build | 4 ++++ 1 file changed, 4 insertions(+)
linux-user/meson.build +4 -0
@@ -1,3 +1,7 @@ +if not config_host.has_key('CONFIG_LINUX') + subdir_done() +endif + linux_user_ss.add(files( 'elfload.c', 'exit.c',
Signature · 1 line
2.31.1
Re: [PATCH 2/2] linux-user: Only process meson rules on Linux host
Quoted 4 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- linux-user/meson.build | 4 ++++ 1 file changed, 4 insertions(+)