Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	linux-hardening@vger.kernel.org, llvm@lists.linux.dev,
	patches@lists.linux.dev
Subject: Re: [PATCH] hardening: Require clang 20.1.0 for __counted_by
Date: Mon, 11 Aug 2025 14:09:06 -0700	[thread overview]
Message-ID: <20250811210906.GA924329@ax162> (raw)
In-Reply-To: <a9c64598-41e9-4ec8-8ec1-add5a5f903b4@intel.com>

On Mon, Aug 11, 2025 at 04:21:32PM +0200, Alexander Lobakin wrote:
> From: Nathan Chancellor <nathan@kernel.org>
> Date: Thu, 07 Aug 2025 14:36:28 -0700
> 
> > After an innocuous change in -next that modified a structure that
> > contains __counted_by, clang-19 start crashing when building certain
> > files in drivers/gpu/drm/xe. When assertions are enabled, the more
> > descriptive failure is:
> > 
> >   clang: clang/lib/AST/RecordLayoutBuilder.cpp:3335: const ASTRecordLayout &clang::ASTContext::getASTRecordLayout(const RecordDecl *) const: Assertion `D && "Cannot get layout of forward declarations!"' failed.
> > 
> > According to a reverse bisect, a tangential change to the LLVM IR
> > generation phase of clang during the LLVM 20 development cycle [1]
> > resolves this problem. Bump the version of clang that enables
> > CONFIG_CC_HAS_COUNTED_BY to 20.1.0 to ensure that this issue cannot be
> > hit.
> 
> Any chance for this to go to the next 19.x (if it's planned at all)?
> I always use the latest HEAD from llvm-project, but 19 is still widely
> used across distros etc =\

Unfortunately not, LLVM does not maintain more than one branch at a
time, so LLVM 19 has been unsupported since LLVM 20.1.0-rc1 was
released back in February :/

Some distros may be willing to patch that in but there is not really a
good way for us to check for that here, so I am not sure it helps much.

Kees and Bill may have thoughts around working around this in the one
spot we know it happens but in my opinion, I would rather do the big
hammer. The deployment of __counted_by in the kernel is only growing so
it is totally possible for us to fix this one instance then run into
another case in a few months, which is more painful for clang than GCC
since it has been supported for a bigger number of releases.

Cheers,
Nathan

  reply	other threads:[~2025-08-11 21:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-07 21:36 [PATCH] hardening: Require clang 20.1.0 for __counted_by Nathan Chancellor
2025-08-07 22:12 ` Justin Stitt
2025-08-11 14:21 ` Alexander Lobakin
2025-08-11 21:09   ` Nathan Chancellor [this message]
2025-08-12 16:28     ` Alexander Lobakin
2025-08-12 21:23       ` Nathan Chancellor
2025-08-25 13:25 ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250811210906.GA924329@ax162 \
    --to=nathan@kernel.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=gustavoars@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=patches@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox