Re: [libcxx22] devel/fmt build fix

Stuart Henderson <[email protected]>
Newsgroups gmane.os.openbsd.ports
Message-ID <[email protected]>
On 2026/08/19 09:14, Theo Buehler wrote:
> fmt relies on libc++ headers pulling in stdlib.h somehow. This on longer
> happens in llvm22's libc++, and the build fails.  The diff fixes this by
> following the approach taken in
> 
> https://github.com/fmtlib/fmt/commit/b77a7516251d21aef1c6130dad116edff1a13173
> 
> It is not hard to update fmt itself to 12.2.0 which does build and pass
> tests, but I seem to remember that this has a tendency of breaking things
> that have embedded copies, so this seems the safer approach for now.

This seems a good approach for now. At this point embedded copies are
probably slightly less of an issue than API changes, which are very
common with fmt (there are some in 12.0.0 and 12.2.0, though I don't
know if they affect ports).

> /usr/ports/pobj/fmt-11.2.0/fmt-11.2.0/include/fmt/format.h:747:28: error: use of undeclared identifier 'malloc'
>   747 |     T* p = static_cast<T*>(malloc(n * sizeof(T)));
>       |                            ^~~~~~
> /usr/ports/pobj/fmt-11.2.0/fmt-11.2.0/include/fmt/format.h:752:35: error: use of undeclared identifier 'free'
>   752 |   void deallocate(T* p, size_t) { free(p); }
>       |                                   ^~~~
> 
> Index: Makefile
> ===================================================================

ok.

> RCS file: /cvs/ports/devel/fmt/Makefile,v
> diff -u -p -r1.7 Makefile
> --- Makefile	19 Nov 2025 11:50:17 -0000	1.7
> +++ Makefile	19 Aug 2026 07:07:52 -0000
> @@ -3,6 +3,7 @@ COMMENT=		alternative formatting library
>  GH_ACCOUNT=		fmtlib
>  GH_PROJECT=		fmt
>  GH_TAGNAME=		11.2.0
> +REVISION=		0
>  
>  SHARED_LIBS=		fmt	2.1
>  
> Index: patches/patch-include_fmt_format_h
> ===================================================================
> RCS file: patches/patch-include_fmt_format_h
> diff -N patches/patch-include_fmt_format_h
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ patches/patch-include_fmt_format_h	19 Aug 2026 07:07:42 -0000
> @@ -0,0 +1,12 @@
> +Index: include/fmt/format.h
> +--- include/fmt/format.h.orig
> ++++ include/fmt/format.h
> +@@ -41,6 +41,8 @@
> + #include "base.h"
> + 
> + #ifndef FMT_MODULE
> ++#  include <stdlib.h> // malloc, free
> ++
> + #  include <cmath>    // std::signbit
> + #  include <cstddef>  // std::byte
> + #  include <cstdint>  // uint32_t
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.