[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMj1kXHXR5UOxS2C1T267hFg+x15Gnf+OS8RYSUs8fPpR=6a1Q@mail.gmail.com>
Date: Wed, 30 Aug 2023 15:32:49 +0200
From: Ard Biesheuvel <ardb@...nel.org>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Justin Stitt <justinstitt@...gle.com>,
Darren Hart <dvhart@...radead.org>,
Andy Shevchenko <andy@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Tom Rix <trix@...hat.com>, linux-efi@...r.kernel.org,
platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev
Subject: Re: [PATCH] efi: fix -Wmissing-variable-declarations warning
On Wed, 30 Aug 2023 at 15:25, Andy Shevchenko <andy.shevchenko@...il.com> wrote:
>
> On Wed, Aug 30, 2023 at 2:04 AM Ard Biesheuvel <ardb@...nel.org> wrote:
> > On Wed, 30 Aug 2023 at 00:54, Justin Stitt <justinstitt@...gle.com> wrote:
>
> ...
>
> > > When building x86/defconfig with Clang-18 I encounter the following warnings:
> > > | arch/x86/platform/efi/efi.c:934:23: warning: no previous extern declaration for non-static variable 'efi_attr_fw_vendor' [-Wmissing-variable-declarations]
> > > | 934 | struct kobj_attribute efi_attr_fw_vendor = __ATTR_RO(fw_vendor);
> > > | arch/x86/platform/efi/efi.c:935:23: warning: no previous extern declaration for non-static variable 'efi_attr_runtime' [-Wmissing-variable-declarations]
> > > | 935 | struct kobj_attribute efi_attr_runtime = __ATTR_RO(runtime);
> > > | arch/x86/platform/efi/efi.c:936:23: warning: no previous extern declaration for non-static variable 'efi_attr_config_table' [-Wmissing-variable-declarations]
> > > | 936 | struct kobj_attribute efi_attr_config_table = __ATTR_RO(config_table);
> > >
> > > These variables are not externally declared anywhere (AFAIK)
> >
> > They are:
> >
> > drivers/firmware/efi/efi.c:extern __weak struct kobj_attribute
> > efi_attr_fw_vendor;
> > drivers/firmware/efi/efi.c:extern __weak struct kobj_attribute efi_attr_runtime;
> > drivers/firmware/efi/efi.c:extern __weak struct kobj_attribute
> > efi_attr_config_table;
> >
> > > so let's add the static keyword and ensure we follow the ODR.
>
> > This won't work.
> >
> > Those variables are referenced via weak references in generic code.
> > The idea is that the weak references resolve to NULL pointers on
> > architectures other than x86, terminating the array early and hiding
> > the non-existent variables.
> >
> > Making them static in arch/x86/platform/efi/efi.c means that these
> > references will remain unsatisfied, and so the variables will no
> > longer be exposed on x86 either.
>
> So it means that we have no definitions in the header for these, right?
>
Indeed.
If there are better ways of fixing this that don't involve weak
references, I am also fine with that, but just moving the existing
extern declarations into linux/efi.h is probably the easiest approach
here.
Powered by blists - more mailing lists