[PATCH 3/3] trace: do not include TCG helper tracepoints in no-TCG builds

Paolo Bonzini posted 3 patches 4 years, 11 months ago
[PATCH 3/3] trace: do not include TCG helper tracepoints in no-TCG builds
Posted by Paolo Bonzini 4 years, 11 months ago
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 trace/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/trace/meson.build b/trace/meson.build
index 3fa760f568..012d0dbceb 100644
--- a/trace/meson.build
+++ b/trace/meson.build
@@ -71,7 +71,7 @@ foreach d : [
                 input: meson.project_source_root() / 'trace-events',
                 command: [ tracetool, '--group=root', '--format=@0@'.format(d[1]), '@INPUT@' ],
                 capture: true)
-  specific_ss.add(gen)
+  specific_ss.add(when: 'CONFIG_TCG', if_true: gen)
 endforeach
 
 if 'CONFIG_TRACE_UST' in config_host
-- 
2.28.0


Re: [PATCH 3/3] trace: do not include TCG helper tracepoints in no-TCG builds
Posted by Richard Henderson 4 years, 11 months ago
On 12/16/20 7:55 AM, Paolo Bonzini wrote:
> diff --git a/trace/meson.build b/trace/meson.build
> index 3fa760f568..012d0dbceb 100644
> --- a/trace/meson.build
> +++ b/trace/meson.build
> @@ -71,7 +71,7 @@ foreach d : [
>                  input: meson.project_source_root() / 'trace-events',
>                  command: [ tracetool, '--group=root', '--format=@0@'.format(d[1]), '@INPUT@' ],
>                  capture: true)
> -  specific_ss.add(gen)
> +  specific_ss.add(when: 'CONFIG_TCG', if_true: gen)
>  endforeach

Sure, unless it makes more sense to conditionalize the entire loop, so that
those targets aren't even created?

Acked-by: Richard Henderson <richard.henderson@linaro.org>


r~

Re: [PATCH 3/3] trace: do not include TCG helper tracepoints in no-TCG builds
Posted by Paolo Bonzini 4 years, 11 months ago
On 16/12/20 16:13, Richard Henderson wrote:
>> @@ -71,7 +71,7 @@ foreach d : [
>>                   input: meson.project_source_root() / 'trace-events',
>>                   command: [ tracetool, '--group=root', '--format=@0@'.format(d[1]), '@INPUT@' ],
>>                   capture: true)
>> -  specific_ss.add(gen)
>> +  specific_ss.add(when: 'CONFIG_TCG', if_true: gen)
>>   endforeach
>
> Sure, unless it makes more sense to conditionalize the entire loop, so that
> those targets aren't even created?

The targets exist but the files won't be created (the rules will be in 
build.ninja but they'll be orphan).

Paolo


Re: [PATCH 3/3] trace: do not include TCG helper tracepoints in no-TCG builds
Posted by Richard Henderson 4 years, 11 months ago
On 12/16/20 9:22 AM, Paolo Bonzini wrote:
> On 16/12/20 16:13, Richard Henderson wrote:
>>> @@ -71,7 +71,7 @@ foreach d : [
>>>                   input: meson.project_source_root() / 'trace-events',
>>>                   command: [ tracetool, '--group=root',
>>> '--format=@0@'.format(d[1]), '@INPUT@' ],
>>>                   capture: true)
>>> -  specific_ss.add(gen)
>>> +  specific_ss.add(when: 'CONFIG_TCG', if_true: gen)
>>>   endforeach
>>
>> Sure, unless it makes more sense to conditionalize the entire loop, so that
>> those targets aren't even created?
> 
> The targets exist but the files won't be created (the rules will be in
> build.ninja but they'll be orphan).

Yes, I get that.  So... is there a reason for them to be there, when it seems
just as easy for them not to be?


r~

Re: [PATCH 3/3] trace: do not include TCG helper tracepoints in no-TCG builds
Posted by Paolo Bonzini 4 years, 11 months ago
On 16/12/20 16:25, Richard Henderson wrote:
> On 12/16/20 9:22 AM, Paolo Bonzini wrote:
>> On 16/12/20 16:13, Richard Henderson wrote:
>>>> @@ -71,7 +71,7 @@ foreach d : [
>>>>                    input: meson.project_source_root() / 'trace-events',
>>>>                    command: [ tracetool, '--group=root',
>>>> '--format=@0@'.format(d[1]), '@INPUT@' ],
>>>>                    capture: true)
>>>> -  specific_ss.add(gen)
>>>> +  specific_ss.add(when: 'CONFIG_TCG', if_true: gen)
>>>>    endforeach
>>>
>>> Sure, unless it makes more sense to conditionalize the entire loop, so that
>>> those targets aren't even created?
>>
>> The targets exist but the files won't be created (the rules will be in
>> build.ninja but they'll be orphan).
> 
> Yes, I get that.  So... is there a reason for them to be there, when it seems
> just as easy for them not to be?

Just a dislike for "if"s when conditional add() will do.

Speaking in general, I like the various sections of the meson.build 
files to use either foreach (taking the job of Makefile target pattern 
rules, where "if"s add complication) or if (taking the job of configure 
code, where loops are rare).  It can't always be done, but it helps 
limiting the amount of spaghetti...

Paolo