public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ArmPlatformPkg: eliminate Juno gcc build warning
@ 2017-06-20 11:00 Leif Lindholm
  2017-06-20 11:28 ` Ard Biesheuvel
  0 siblings, 1 reply; 9+ messages in thread
From: Leif Lindholm @ 2017-06-20 11:00 UTC (permalink / raw)
  To: edk2-devel; +Cc: ard.biesheuvel, ryan.harkin

When building without LTO, gcc incorrectly resolves the hazards for
'PciRegBase’ when inlining, leading to "may be used uninitialized"
warnings (and hence build failure with -Werror).
Eliminate this warning by explicitly initializing the variable to 0.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---

For those who have heard me mentioning this before but arguing against
upstreaming this patch: I only just tweaked that this warning doesn't
go away with more recent toolchains, but simply when switching to GCC5
build profile, and hence LTO. Build failure still reproducible with
gcc 6.3.1 and GCC49.

 ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
index da93eb5829..18491c7378 100644
--- a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
+++ b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
@@ -343,6 +343,7 @@ ArmJunoSetNicMacAddress ()
     return Status;
   }
 
+  PciRegBase = 0;
   Status = InitPciDev (PciIo, &PciRegBase, &OldPciAttr);
   if (EFI_ERROR (Status)) {
     return Status;
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] ArmPlatformPkg: eliminate Juno gcc build warning
  2017-06-20 11:00 [PATCH] ArmPlatformPkg: eliminate Juno gcc build warning Leif Lindholm
@ 2017-06-20 11:28 ` Ard Biesheuvel
  2017-06-20 11:44   ` Ryan Harkin
  2017-06-20 12:00   ` Leif Lindholm
  0 siblings, 2 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2017-06-20 11:28 UTC (permalink / raw)
  To: Leif Lindholm, Laszlo Ersek; +Cc: edk2-devel@lists.01.org, Ryan Harkin

(+ Laszlo)

On 20 June 2017 at 13:00, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> When building without LTO, gcc incorrectly resolves the hazards for
> 'PciRegBase’ when inlining, leading to "may be used uninitialized"
> warnings (and hence build failure with -Werror).
> Eliminate this warning by explicitly initializing the variable to 0.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>
> For those who have heard me mentioning this before but arguing against
> upstreaming this patch: I only just tweaked that this warning doesn't
> go away with more recent toolchains, but simply when switching to GCC5
> build profile, and hence LTO. Build failure still reproducible with
> gcc 6.3.1 and GCC49.
>

/me annoyed

We keep hitting this with GCC, and I profoundly dislike having to add
redundant initialization sequences. Is there any other solution
possible, e.g., disable this warning for certain builds?

>  ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
> index da93eb5829..18491c7378 100644
> --- a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
> +++ b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
> @@ -343,6 +343,7 @@ ArmJunoSetNicMacAddress ()
>      return Status;
>    }
>
> +  PciRegBase = 0;
>    Status = InitPciDev (PciIo, &PciRegBase, &OldPciAttr);
>    if (EFI_ERROR (Status)) {
>      return Status;
> --
> 2.11.0
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ArmPlatformPkg: eliminate Juno gcc build warning
  2017-06-20 11:28 ` Ard Biesheuvel
@ 2017-06-20 11:44   ` Ryan Harkin
  2017-06-20 12:04     ` Leif Lindholm
  2017-06-20 12:00   ` Leif Lindholm
  1 sibling, 1 reply; 9+ messages in thread
From: Ryan Harkin @ 2017-06-20 11:44 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Leif Lindholm, Laszlo Ersek, edk2-devel@lists.01.org

On 20 June 2017 at 12:28, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> (+ Laszlo)
>
> On 20 June 2017 at 13:00, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>> When building without LTO, gcc incorrectly resolves the hazards for
>> 'PciRegBase’ when inlining, leading to "may be used uninitialized"
>> warnings (and hence build failure with -Werror).
>> Eliminate this warning by explicitly initializing the variable to 0.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
>
> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Ryan Harkin <ryan.harkin@linaro.org>

>
>> ---
>>
>> For those who have heard me mentioning this before but arguing against
>> upstreaming this patch: I only just tweaked that this warning doesn't
>> go away with more recent toolchains, but simply when switching to GCC5
>> build profile, and hence LTO. Build failure still reproducible with
>> gcc 6.3.1 and GCC49.
>>
>
> /me annoyed
>
> We keep hitting this with GCC, and I profoundly dislike having to add
> redundant initialization sequences. Is there any other solution
> possible, e.g., disable this warning for certain builds?
>
>>  ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
>> index da93eb5829..18491c7378 100644
>> --- a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
>> +++ b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
>> @@ -343,6 +343,7 @@ ArmJunoSetNicMacAddress ()
>>      return Status;
>>    }
>>
>> +  PciRegBase = 0;
>>    Status = InitPciDev (PciIo, &PciRegBase, &OldPciAttr);
>>    if (EFI_ERROR (Status)) {
>>      return Status;
>> --
>> 2.11.0
>>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ArmPlatformPkg: eliminate Juno gcc build warning
  2017-06-20 11:28 ` Ard Biesheuvel
  2017-06-20 11:44   ` Ryan Harkin
@ 2017-06-20 12:00   ` Leif Lindholm
  2017-06-20 15:44     ` Laszlo Ersek
  1 sibling, 1 reply; 9+ messages in thread
From: Leif Lindholm @ 2017-06-20 12:00 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Laszlo Ersek, edk2-devel@lists.01.org, Ryan Harkin

On Tue, Jun 20, 2017 at 01:28:38PM +0200, Ard Biesheuvel wrote:
> (+ Laszlo)
> 
> On 20 June 2017 at 13:00, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> > When building without LTO, gcc incorrectly resolves the hazards for
> > 'PciRegBase’ when inlining, leading to "may be used uninitialized"
> > warnings (and hence build failure with -Werror).
> > Eliminate this warning by explicitly initializing the variable to 0.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> 
> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Thanks!

> > ---
> >
> > For those who have heard me mentioning this before but arguing against
> > upstreaming this patch: I only just tweaked that this warning doesn't
> > go away with more recent toolchains, but simply when switching to GCC5
> > build profile, and hence LTO. Build failure still reproducible with
> > gcc 6.3.1 and GCC49.
> 
> /me annoyed

+1

> We keep hitting this with GCC, and I profoundly dislike having to add
> redundant initialization sequences. Is there any other solution
> possible, e.g., disable this warning for certain builds?

I would really like to not disable it.
When it gets it right, that's usually a pretty horrific bug caught.
And if we switch to LTO as the norm, I guess these will become less
noticeable over time.
But it does bug me too.

/
    Leif

> >  ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
> > index da93eb5829..18491c7378 100644
> > --- a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
> > +++ b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
> > @@ -343,6 +343,7 @@ ArmJunoSetNicMacAddress ()
> >      return Status;
> >    }
> >
> > +  PciRegBase = 0;
> >    Status = InitPciDev (PciIo, &PciRegBase, &OldPciAttr);
> >    if (EFI_ERROR (Status)) {
> >      return Status;
> > --
> > 2.11.0
> >


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ArmPlatformPkg: eliminate Juno gcc build warning
  2017-06-20 11:44   ` Ryan Harkin
@ 2017-06-20 12:04     ` Leif Lindholm
  0 siblings, 0 replies; 9+ messages in thread
From: Leif Lindholm @ 2017-06-20 12:04 UTC (permalink / raw)
  To: Ryan Harkin; +Cc: Ard Biesheuvel, Laszlo Ersek, edk2-devel@lists.01.org

On Tue, Jun 20, 2017 at 12:44:09PM +0100, Ryan Harkin wrote:
> On 20 June 2017 at 12:28, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> > (+ Laszlo)
> >
> > On 20 June 2017 at 13:00, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> >> When building without LTO, gcc incorrectly resolves the hazards for
> >> 'PciRegBase’ when inlining, leading to "may be used uninitialized"
> >> warnings (and hence build failure with -Werror).
> >> Eliminate this warning by explicitly initializing the variable to 0.
> >>
> >> Contributed-under: TianoCore Contribution Agreement 1.0
> >> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> >
> > Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> 
> Reviewed-by: Ryan Harkin <ryan.harkin@linaro.org>

Thanks!

Pushed as 2f93c5077f.

> >
> >> ---
> >>
> >> For those who have heard me mentioning this before but arguing against
> >> upstreaming this patch: I only just tweaked that this warning doesn't
> >> go away with more recent toolchains, but simply when switching to GCC5
> >> build profile, and hence LTO. Build failure still reproducible with
> >> gcc 6.3.1 and GCC49.
> >>
> >
> > /me annoyed
> >
> > We keep hitting this with GCC, and I profoundly dislike having to add
> > redundant initialization sequences. Is there any other solution
> > possible, e.g., disable this warning for certain builds?
> >
> >>  ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c | 1 +
> >>  1 file changed, 1 insertion(+)
> >>
> >> diff --git a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
> >> index da93eb5829..18491c7378 100644
> >> --- a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
> >> +++ b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
> >> @@ -343,6 +343,7 @@ ArmJunoSetNicMacAddress ()
> >>      return Status;
> >>    }
> >>
> >> +  PciRegBase = 0;
> >>    Status = InitPciDev (PciIo, &PciRegBase, &OldPciAttr);
> >>    if (EFI_ERROR (Status)) {
> >>      return Status;
> >> --
> >> 2.11.0
> >>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ArmPlatformPkg: eliminate Juno gcc build warning
  2017-06-20 12:00   ` Leif Lindholm
@ 2017-06-20 15:44     ` Laszlo Ersek
  2017-06-20 19:52       ` Ard Biesheuvel
  0 siblings, 1 reply; 9+ messages in thread
From: Laszlo Ersek @ 2017-06-20 15:44 UTC (permalink / raw)
  To: Leif Lindholm, Ard Biesheuvel; +Cc: edk2-devel@lists.01.org, Ryan Harkin

On 06/20/17 14:00, Leif Lindholm wrote:
> On Tue, Jun 20, 2017 at 01:28:38PM +0200, Ard Biesheuvel wrote:
>> (+ Laszlo)
>>
>> On 20 June 2017 at 13:00, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>>> When building without LTO, gcc incorrectly resolves the hazards for
>>> 'PciRegBase’ when inlining, leading to "may be used uninitialized"
>>> warnings (and hence build failure with -Werror).
>>> Eliminate this warning by explicitly initializing the variable to 0.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
>>
>> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> 
> Thanks!
> 
>>> ---
>>>
>>> For those who have heard me mentioning this before but arguing against
>>> upstreaming this patch: I only just tweaked that this warning doesn't
>>> go away with more recent toolchains, but simply when switching to GCC5
>>> build profile, and hence LTO. Build failure still reproducible with
>>> gcc 6.3.1 and GCC49.
>>
>> /me annoyed
> 
> +1
> 
>> We keep hitting this with GCC, and I profoundly dislike having to add
>> redundant initialization sequences. Is there any other solution
>> possible, e.g., disable this warning for certain builds?
> 
> I would really like to not disable it.
> When it gets it right, that's usually a pretty horrific bug caught.
> And if we switch to LTO as the norm, I guess these will become less
> noticeable over time.
> But it does bug me too.

Perhaps we should introduce two macros to "MdePkg/Include/Base.h",

#define UNUSED_POINTER NULL
#define UNUSED_INTEGER 0

These could be used to suppress such warnings, without the risk of
misleading programmers (as to the real necessity of the variable
assignment at hand).

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ArmPlatformPkg: eliminate Juno gcc build warning
  2017-06-20 15:44     ` Laszlo Ersek
@ 2017-06-20 19:52       ` Ard Biesheuvel
  2017-06-20 19:57         ` Laszlo Ersek
  2017-06-20 20:05         ` Leif Lindholm
  0 siblings, 2 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2017-06-20 19:52 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: Leif Lindholm, edk2-devel@lists.01.org, Ryan Harkin

On 20 June 2017 at 17:44, Laszlo Ersek <lersek@redhat.com> wrote:
> On 06/20/17 14:00, Leif Lindholm wrote:
>> On Tue, Jun 20, 2017 at 01:28:38PM +0200, Ard Biesheuvel wrote:
>>> (+ Laszlo)
>>>
>>> On 20 June 2017 at 13:00, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>>>> When building without LTO, gcc incorrectly resolves the hazards for
>>>> 'PciRegBase’ when inlining, leading to "may be used uninitialized"
>>>> warnings (and hence build failure with -Werror).
>>>> Eliminate this warning by explicitly initializing the variable to 0.
>>>>
>>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>>> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
>>>
>>> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>>
>> Thanks!
>>
>>>> ---
>>>>
>>>> For those who have heard me mentioning this before but arguing against
>>>> upstreaming this patch: I only just tweaked that this warning doesn't
>>>> go away with more recent toolchains, but simply when switching to GCC5
>>>> build profile, and hence LTO. Build failure still reproducible with
>>>> gcc 6.3.1 and GCC49.
>>>
>>> /me annoyed
>>
>> +1
>>
>>> We keep hitting this with GCC, and I profoundly dislike having to add
>>> redundant initialization sequences. Is there any other solution
>>> possible, e.g., disable this warning for certain builds?
>>
>> I would really like to not disable it.
>> When it gets it right, that's usually a pretty horrific bug caught.
>> And if we switch to LTO as the norm, I guess these will become less
>> noticeable over time.
>> But it does bug me too.
>
> Perhaps we should introduce two macros to "MdePkg/Include/Base.h",
>
> #define UNUSED_POINTER NULL
> #define UNUSED_INTEGER 0
>
> These could be used to suppress such warnings, without the risk of
> misleading programmers (as to the real necessity of the variable
> assignment at hand).
>

Or perhaps

#ifdef __GNUC__
#define USED(var)  var = (typeof(var))0
#else
#define USED(var)
#endif


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ArmPlatformPkg: eliminate Juno gcc build warning
  2017-06-20 19:52       ` Ard Biesheuvel
@ 2017-06-20 19:57         ` Laszlo Ersek
  2017-06-20 20:05         ` Leif Lindholm
  1 sibling, 0 replies; 9+ messages in thread
From: Laszlo Ersek @ 2017-06-20 19:57 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Leif Lindholm, edk2-devel@lists.01.org, Ryan Harkin

On 06/20/17 21:52, Ard Biesheuvel wrote:
> On 20 June 2017 at 17:44, Laszlo Ersek <lersek@redhat.com> wrote:

>> Perhaps we should introduce two macros to "MdePkg/Include/Base.h",
>>
>> #define UNUSED_POINTER NULL
>> #define UNUSED_INTEGER 0
>>
>> These could be used to suppress such warnings, without the risk of
>> misleading programmers (as to the real necessity of the variable
>> assignment at hand).
>>
> 
> Or perhaps
> 
> #ifdef __GNUC__
> #define USED(var)  var = (typeof(var))0
> #else
> #define USED(var)
> #endif
> 

Sure, why not :)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ArmPlatformPkg: eliminate Juno gcc build warning
  2017-06-20 19:52       ` Ard Biesheuvel
  2017-06-20 19:57         ` Laszlo Ersek
@ 2017-06-20 20:05         ` Leif Lindholm
  1 sibling, 0 replies; 9+ messages in thread
From: Leif Lindholm @ 2017-06-20 20:05 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Laszlo Ersek, edk2-devel@lists.01.org, Ryan Harkin

On Tue, Jun 20, 2017 at 09:52:20PM +0200, Ard Biesheuvel wrote:
> >>>> For those who have heard me mentioning this before but arguing against
> >>>> upstreaming this patch: I only just tweaked that this warning doesn't
> >>>> go away with more recent toolchains, but simply when switching to GCC5
> >>>> build profile, and hence LTO. Build failure still reproducible with
> >>>> gcc 6.3.1 and GCC49.
> >>>
> >>> /me annoyed
> >>
> >> +1
> >>
> >>> We keep hitting this with GCC, and I profoundly dislike having to add
> >>> redundant initialization sequences. Is there any other solution
> >>> possible, e.g., disable this warning for certain builds?
> >>
> >> I would really like to not disable it.
> >> When it gets it right, that's usually a pretty horrific bug caught.
> >> And if we switch to LTO as the norm, I guess these will become less
> >> noticeable over time.
> >> But it does bug me too.
> >
> > Perhaps we should introduce two macros to "MdePkg/Include/Base.h",
> >
> > #define UNUSED_POINTER NULL
> > #define UNUSED_INTEGER 0
> >
> > These could be used to suppress such warnings, without the risk of
> > misleading programmers (as to the real necessity of the variable
> > assignment at hand).
> >
> 
> Or perhaps
> 
> #ifdef __GNUC__
> #define USED(var)  var = (typeof(var))0
> #else
> #define USED(var)
> #endif

So ... I prefer this version.

However, semantically, for the situation here (may be used before
initialized), "USED" does not make sense.
Could we have an identical "INITIALIZED" instead?

/
    Leif


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-06-20 20:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-20 11:00 [PATCH] ArmPlatformPkg: eliminate Juno gcc build warning Leif Lindholm
2017-06-20 11:28 ` Ard Biesheuvel
2017-06-20 11:44   ` Ryan Harkin
2017-06-20 12:04     ` Leif Lindholm
2017-06-20 12:00   ` Leif Lindholm
2017-06-20 15:44     ` Laszlo Ersek
2017-06-20 19:52       ` Ard Biesheuvel
2017-06-20 19:57         ` Laszlo Ersek
2017-06-20 20:05         ` Leif Lindholm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox