Fix bcc and castxml builds with LLVM 23
cover Fix bcc and castxml builds with LLVM 23
From: Sunil Dora <[email protected]>
oe-core is moving clang/llvm from 22.1.8 to 23.1.0. Two recipes in meta-oe do not build against 23, because upstream LLVM and Clang changed APIs they use:
castxml Clang 23 renamed ASTContext::getRawCommentForDeclNoCache to
getRawCommentNoCache.
bcc LLVM 23 changed the MCContext constructor to take MCAsmInfo,
MCRegisterInfo and MCSubtargetInfo by reference rather than by pointer.
Both projects have already fixed this upstream, but neither fix is in a release yet, and meta-oe is already on the newest tag of both. So these are backports rather than version bumps.
Both upstream fixes are guarded on LLVM_VERSION_MAJOR, so the recipes keep building with older Clang.
Both failures also reproduce on the Yocto autobuilder meta-oe world build run against the oe-core clang/llvm 23.1.0 series.
Tested on qemux86-64 with meta-oe and meta-python on top of the oe-core clang/llvm 23.1.0 series: castxml and bcc both build, with the default gcc toolchain and with TOOLCHAIN=clang.
Sunil Dora (2):
castxml: Fix build with LLVM 23
bcc: Fix build with LLVM 23
...ix-MCContext-constructor-for-LLVM-23.patch | 36 +++++++++++++++++++ .../recipes-devtools/bcc/bcc_0.37.0.bb | 1 + .../castxml/0001-Port-to-LLVM-Clang-23.patch | 36 +++++++++++++++++++ .../recipes-devtools/castxml/castxml_0.7.0.bb | 4 ++- 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc/0001-src-cc-Fix-MCContext-constructor-for-LLVM-23.patch create mode 100644 meta-oe/recipes-devtools/castxml/castxml/0001-Port-to-LLVM-Clang-23.patch
Signature · 1 line
2.43.0
PATCH 1/2 castxml: Fix build with LLVM 23
From: Sunil Dora <[email protected]>
Clang 23 renamed ASTContext::getRawCommentForDeclNoCache to getRawCommentNoCache, so castxml no longer builds:
src/Output.cxx:1976:47: error: 'const class clang::ASTContext' has no member named 'getRawCommentForDeclNoCache'; did you mean 'getRawCommentNoCache'?
Backport the upstream fix. It is guarded on LLVM_VERSION_MAJOR so older Clang keeps working. There is no release carrying it yet; v0.7.0 is still the newest tag.
--- .../castxml/0001-Port-to-LLVM-Clang-23.patch | 36 +++++++++++++++++++ .../recipes-devtools/castxml/castxml_0.7.0.bb | 4 ++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-devtools/castxml/castxml/0001-Port-to-LLVM-Clang-23.patch
meta-oe/recipes-devtools/castxml/castxml/0001-Port-to-LLVM-Clang-23.patch new file +36 -0
@@ -0,0 +1,36 @@ +From 315fbacc4e4b9c7ea21d25ad489a90b73a526326 Mon Sep 17 00:00:00 2001 +From: Brad King <[email protected]> +Date: Wed, 10 Jun 2026 10:55:10 -0400 +Subject: [PATCH] Port to LLVM/Clang Git main as of 2026-10-10 (6f47b6de08) + +Upstream-Status: Backport [https://github.com/CastXML/CastXML/commit/315fbacc4e4b] + +Signed-off-by: Sunil Dora <[email protected]> +--- + src/Output.cxx | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/Output.cxx b/src/Output.cxx +index bb986d4b..9f722efd 100644 +--- a/src/Output.cxx ++++ b/src/Output.cxx +@@ -119,6 +119,10 @@ clang::NestedNameSpecifier const& deref(NestedNameSpecifier const& nns) + # define isPureVirtual isPure + #endif + ++#if LLVM_VERSION_MAJOR < 23 ++# define getRawCommentNoCache getRawCommentForDeclNoCache ++#endif ++ + class ASTVisitorBase + { + protected: +@@ -1973,7 +1977,7 @@ void ASTVisitor::PrintCommentAttribute(clang::Decl const* d, + if (!this->Opts.CastXml) { + return; + } +- if (clang::RawComment const* rc = this->CTX.getRawCommentForDeclNoCache(d)) { ++ if (clang::RawComment const* rc = this->CTX.getRawCommentNoCache(d)) { + unsigned int index = ++this->CommentCount; + CommentEntry e = { index, rc, dn }; + this->CommentQueue.push(e);
meta-oe/recipes-devtools/castxml/castxml_0.7.0.bb +3 -1
@@ -3,7 +3,9 @@ LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" SRCREV = "2d52b47cfd88b703d3247f77bb7c3ad7372bc9cb" -SRC_URI = "git://github.com/CastXML/CastXML;protocol=https;branch=master;tag=v${PV}" +SRC_URI = "git://github.com/CastXML/CastXML;protocol=https;branch=master;tag=v${PV} \ + file://0001-Port-to-LLVM-Clang-23.patch \ + " DEPENDS = "clang"
Signature · 1 line
2.43.0
PATCH 2/2 bcc: Fix build with LLVM 23
In reply to [email protected]From: Sunil Dora <[email protected]>
LLVM 23 changed the MCContext constructor to take MCAsmInfo, MCRegisterInfo and MCSubtargetInfo by reference rather than by pointer, so bcc no longer builds:
src/cc/bcc_debug.cc:151:68: error: no matching function for call to 'llvm::MCContext::MCContext(...)'
Backport the upstream fix. It is guarded on LLVM_VERSION_MAJOR so older Clang keeps working. There is no release carrying it yet; v0.37.0 is still the newest tag.
--- ...ix-MCContext-constructor-for-LLVM-23.patch | 36 +++++++++++++++++++ .../recipes-devtools/bcc/bcc_0.37.0.bb | 1 + 2 files changed, 37 insertions(+) create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc/0001-src-cc-Fix-MCContext-constructor-for-LLVM-23.patch
meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc/0001-src-cc-Fix-MCContext-constructor-for-LLVM-23.patch new file +36 -0
@@ -0,0 +1,36 @@ +From dad0db93fd0f443b2a4f43bc2f23c621c9202516 Mon Sep 17 00:00:00 2001 +From: Viktor Malik <[email protected]> +Date: Thu, 13 Aug 2026 08:22:00 +0200 +Subject: [PATCH] src/cc: Fix MCContext constructor for LLVM 23 + +Two LLVM 23 patches [1,2] changed the MCContext constructor to take +MCAsmInfo, MCRegisterInfo, and MCSubtargetInfo by a reference rather +than by a pointer. Reflect the change in call of the constructor. + +[1] https://github.com/llvm/llvm-project/commit/13e98d834101efd1794cdd026377c508293ee21b +[2] https://github.com/llvm/llvm-project/commit/d50631faad3003e73589528c83d3bbbad7ba72f1 + +Upstream-Status: Backport [https://github.com/iovisor/bcc/commit/dad0db93fd0f] + +Signed-off-by: Viktor Malik <[email protected]> +Signed-off-by: Sunil Dora <[email protected]> +--- + src/cc/bcc_debug.cc | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/cc/bcc_debug.cc b/src/cc/bcc_debug.cc +index 2e53c44d4778..0812c4abc788 100644 +--- a/src/cc/bcc_debug.cc ++++ b/src/cc/bcc_debug.cc +@@ -148,7 +148,11 @@ void SourceDebugger::dump() { + T->createMCSubtargetInfo(TripleArg, "", "")); + MCObjectFileInfo MOFI; + #if LLVM_VERSION_MAJOR >= 13 ++#if LLVM_VERSION_MAJOR >= 23 ++ MCContext Ctx(TheTriple, *MAI, *MRI, *STI, nullptr); ++#else + MCContext Ctx(TheTriple, MAI.get(), MRI.get(), STI.get(), nullptr); ++#endif + Ctx.setObjectFileInfo(&MOFI); + MOFI.initMCObjectFileInfo(Ctx, false, false); + #else
meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc_0.37.0.bb +1 -0
@@ -23,6 +23,7 @@ SRC_URI = "gitsm://github.com/iovisor/bcc;branch=master;protocol=https;lfs=0;tag file://0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch \ file://0001-Vendor-just-enough-extra-headers-to-allow-libbpf-to-.patch \ file://0001-tests-cc-Allow-overriding-the-runtime-location-of-te.patch \ + file://0001-src-cc-Fix-MCContext-constructor-for-LLVM-23.patch \ file://run-ptest \ file://ptest_wrapper.sh \ "
Signature · 1 line
2.43.0