[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 01/11] Compiler Attributes: Add __require_explicit_initialization macro
- To: Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx>
- From: Kees Cook <kees@xxxxxxxxxx>
- Date: Wed, 14 Oct 2026 09:37:44 -0700
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=k20260515 header.d=kernel.org header.i="@kernel.org" header.h="Date:From:To:Cc:Subject:References:In-Reply-To"
- Cc: Ian Rogers <irogers@xxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, "Rafael J . Wysocki" <rafael@xxxxxxxxxx>, Danilo Krummrich <dakr@xxxxxxxxxx>, Miguel Ojeda <ojeda@xxxxxxxxxx>, Nathan Chancellor <nathan@xxxxxxxxxx>, Nick Desaulniers <ndesaulniers@xxxxxxxxxx>, Bill Wendling <morbo@xxxxxxxxxx>, Justin Stitt <justinstitt@xxxxxxxxxx>, Jonathan Corbet <corbet@xxxxxxx>, Madhavan Srinivasan <maddy@xxxxxxxxxxxxx>, Michael Ellerman <mpe@xxxxxxxxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Christophe Leroy <chleroy@xxxxxxxxxx>, Nayna Jain <nayna@xxxxxxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, Rich Felker <dalias@xxxxxxxx>, John Paul Adrian Glaubitz <glaubitz@xxxxxxxxxxxxxxxxxxx>, Viresh Kumar <viresh.kumar@xxxxxxxxxx>, David Teigland <teigland@xxxxxxxxxx>, Alexander Aring <aahringo@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Heiko Carstens <hca@xxxxxxxxxxxxx>, Vasily Gorbik <gor@xxxxxxxxxxxxx>, Alexander Gordeev <agordeev@xxxxxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>, Sven Schnelle <svens@xxxxxxxxxxxxx>, Richard Weinberger <richard@xxxxxx>, Zhihao Cheng <chengzhihao1@xxxxxxxxxx>, Felix Kuehling <Felix.Kuehling@xxxxxxx>, Alex Deucher <alexander.deucher@xxxxxxx>, Christian König <christian.koenig@xxxxxxx>, driver-core@xxxxxxxxxxxxxxx, llvm@xxxxxxxxxxxxxxx, linux-hardening@xxxxxxxxxxxxxxx, linux-doc@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, linux-sh@xxxxxxxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxx, linux-acpi@xxxxxxxxxxxxxxx, gfs2@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, linux-mtd@xxxxxxxxxxxxxxxxxxx, amd-gfx@xxxxxxxxxxxxxxxxxxxxx, dri-devel@xxxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
- Delivery-date: Wed, 14 Oct 2026 16:37:47 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Wed, Oct 14, 2026 at 01:28:55PM +0200, Miguel Ojeda wrote:
> On Wed, Oct 14, 2026 at 12:40 AM Ian Rogers <irogers@xxxxxxxxxx> wrote:
> >
> > +/*
> > + * Optional: not supported by gcc
> > + *
> > + * clang:
> > https://clang.llvm.org/docs/AttributeReference.html#require-explicit-initialization
> > + */
> > +#if __has_attribute(__require_explicit_initialization__)
> > +# define __require_explicit_initialization
> > __attribute__((__require_explicit_initialization__))
> > +#else
> > +# define __require_explicit_initialization
> > +#endif
>
> The LPC slides mention Clang 14+, but from a quick test in Compiler
> Explorer and a `git log --grep` on the LLVM repository to confirm, it
> seems the attribute was introduced in Clang 20+, no?
>
> If that is correct, then it is not available in all LLVM versions we
> support (LLVM 17+), so we should add:
>
> * Optional: only supported since clang >= 20.0
>
> With that:
>
> Acked-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
Yup, I can confirm, I only see it with 20+ too.
--
Kees Cook
|