From 9cc8092b287b8df957c5ae6503f4ef35edba5871 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 31 Jul 2025 21:22:41 -0700 Subject: [PATCH] fmt: Fix build with clang-21 Backport a fix from upstream master branch Signed-off-by: Khem Raj Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- ...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 0000000000..911fa90a40 --- /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 +Date: Sat, 21 Jun 2025 07:28:14 -0700 +Subject: [PATCH] Fix compilation on clang-21 / libc++-21 (#4477) + +`` 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 ``. + +Upstream-Status: Backport [https://github.com/fmtlib/fmt/pull/4477] +Signed-off-by: Khem Raj +--- + 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 // std::signbit + # include // std::byte + # include // uint32_t ++# include // std::malloc, std::free + # include // std::memcpy + # include // std::numeric_limits + # include // std::bad_alloc +@@ -744,12 +745,12 @@ template struct allocator { + + T* allocate(size_t n) { + FMT_ASSERT(n <= max_value() / sizeof(T), ""); +- T* p = static_cast(malloc(n * sizeof(T))); ++ T* p = static_cast(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 d0d4cea23e..fd5dc0c4ab 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 -- 2.47.2