Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Khem Raj <raj.khem@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Khem Raj <raj.khem@gmail.com>
Subject: [PATCH 7/7] fmt: Fix build with clang-21
Date: Thu, 31 Jul 2025 21:22:41 -0700	[thread overview]
Message-ID: <20250801042242.3076232-7-raj.khem@gmail.com> (raw)
In-Reply-To: <20250801042242.3076232-1-raj.khem@gmail.com>

Backport a fix from upstream master branch

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...compilation-on-clang-21-libc-21-4477.patch | 46 +++++++++++++++++++
 meta/recipes-devtools/fmt/fmt_11.2.0.bb       |  4 +-
 2 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/fmt/fmt/0001-Fix-compilation-on-clang-21-libc-21-4477.patch

diff --git a/meta/recipes-devtools/fmt/fmt/0001-Fix-compilation-on-clang-21-libc-21-4477.patch b/meta/recipes-devtools/fmt/fmt/0001-Fix-compilation-on-clang-21-libc-21-4477.patch
new file mode 100644
index 00000000000..911fa90a40c
--- /dev/null
+++ b/meta/recipes-devtools/fmt/fmt/0001-Fix-compilation-on-clang-21-libc-21-4477.patch
@@ -0,0 +1,46 @@
+From f4345467fce7edbc6b36c3fa1cf197a67be617e2 Mon Sep 17 00:00:00 2001
+From: Remy Jette <remy@remyjette.com>
+Date: Sat, 21 Jun 2025 07:28:14 -0700
+Subject: [PATCH] Fix compilation on clang-21 / libc++-21 (#4477)
+
+`<cstdlib>` was not being included, so malloc and free were only declared
+via transitive includes. Some includes changed in the latest libc++-21
+build which broke fmt.
+
+Also changed `malloc`/`free` to `std::malloc` and `std::free`, as
+putting those symbols in the global namespace is optional for the
+implementation when including `<cstdlib>`.
+
+Upstream-Status: Backport [https://github.com/fmtlib/fmt/pull/4477]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ include/fmt/format.h | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+Index: fmt-11.2.0/include/fmt/format.h
+===================================================================
+--- fmt-11.2.0.orig/include/fmt/format.h
++++ fmt-11.2.0/include/fmt/format.h
+@@ -44,6 +44,7 @@
+ #  include <cmath>    // std::signbit
+ #  include <cstddef>  // std::byte
+ #  include <cstdint>  // uint32_t
++#  include <cstdlib>  // std::malloc, std::free
+ #  include <cstring>  // std::memcpy
+ #  include <limits>   // std::numeric_limits
+ #  include <new>      // std::bad_alloc
+@@ -744,12 +745,12 @@ template <typename T> struct allocator {
+ 
+   T* allocate(size_t n) {
+     FMT_ASSERT(n <= max_value<size_t>() / sizeof(T), "");
+-    T* p = static_cast<T*>(malloc(n * sizeof(T)));
++    T* p = static_cast<T*>(std::malloc(n * sizeof(T)));
+     if (!p) FMT_THROW(std::bad_alloc());
+     return p;
+   }
+ 
+-  void deallocate(T* p, size_t) { free(p); }
++  void deallocate(T* p, size_t) { std::free(p); }
+ };
+ 
+ }  // namespace detail
diff --git a/meta/recipes-devtools/fmt/fmt_11.2.0.bb b/meta/recipes-devtools/fmt/fmt_11.2.0.bb
index d0d4cea23e2..fd5dc0c4ab7 100644
--- a/meta/recipes-devtools/fmt/fmt_11.2.0.bb
+++ b/meta/recipes-devtools/fmt/fmt_11.2.0.bb
@@ -5,7 +5,9 @@ LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=b9257785fc4f3803a4b71b76c1412729"
 
 SRC_URI = "git://github.com/fmtlib/fmt;branch=master;protocol=https;tag=${PV}\
-           file://0001-Workaround-an-ABI-issue-in-spdlog.patch"
+           file://0001-Workaround-an-ABI-issue-in-spdlog.patch \
+           file://0001-Fix-compilation-on-clang-21-libc-21-4477.patch \
+           "
 SRCREV = "40626af88bd7df9a5fb80be7b25ac85b122d6c21"
 
 inherit cmake


  parent reply	other threads:[~2025-08-01  4:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-01  4:22 [PATCH 1/7] toolchain/clang-native: Set BUILD_LDFLAGS instead of LDFLAGS Khem Raj
2025-08-01  4:22 ` [PATCH 2/7] cargo-c: Update patches to latest versions Khem Raj
2025-08-01  4:22 ` [PATCH 3/7] libxcrypt: Allow undefined symbols in version scripts with lld linker Khem Raj
2025-08-07  9:57   ` [OE-core] " Alexander Kanavin
2025-08-07 20:18     ` Khem Raj
2025-08-11  8:17       ` Alexander Kanavin
2025-08-11 15:23         ` Khem Raj
2025-08-01  4:22 ` [PATCH 4/7] libtirpc: " Khem Raj
2025-08-01  4:22 ` [PATCH 5/7] gzip: Always use GNU ld for linking Khem Raj
2025-08-11 16:47   ` [OE-core] " Randy MacLeod
2025-08-01  4:22 ` [PATCH 6/7] binutils-cross-canadian: Always use GNU linker Khem Raj
2025-08-01  4:22 ` Khem Raj [this message]
2025-08-01 12:54 ` [OE-core] [PATCH 1/7] toolchain/clang-native: Set BUILD_LDFLAGS instead of LDFLAGS Mathieu Dubois-Briand
2025-08-01 16:13   ` Mathieu Dubois-Briand
2025-08-01 16:24     ` Khem Raj

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=20250801042242.3076232-7-raj.khem@gmail.com \
    --to=raj.khem@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /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