]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Optionally define std::print functions non-inline [PR124410]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 10 Mar 2026 21:19:09 +0000 (21:19 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 17 Apr 2026 12:43:49 +0000 (13:43 +0100)
commitfa4754797c2935e4e2be95f128e668d6499ec267
tree08a21088e846208832f40472e41c872460b8ce91
parent20af0e529a79186f7600c87554aeee3231f80bee
libstdc++: Optionally define std::print functions non-inline [PR124410]

We don't want to export std::vprint_unicode etc. from libstdc++.so yet,
but we can give users the option of improving compile times by getting
the definitions of the std::print internals from libstdc++exp.a instead.

This commit adds a macro, _GLIBCXX_NO_INLINE_PRINT, which disables the
inline definitions of std::vprint_unicode etc. so that extern
definitions in libstdc++exp.a can be used instead.

With this change compiling a helloworld using std::print goes from 8s to
under 2s with trunk. For release branches with --enable-checking=release
we should see even faster times. The object file size is also
dramatically smaller, because there's just a single call to an extern
function instead of instantiating the entire std::print and std::format
implementation inline.

libstdc++-v3/ChangeLog:

PR libstdc++/124410
* doc/html/*: Regenerate.
* doc/xml/manual/using.xml (_GLIBCXX_NO_INLINE_PRINT): Document
macro.
* include/Makefile.am: Add bits/print.h and bits/ostream_print.h
headers.
* include/Makefile.in: Regenerate.
* include/std/ostream (vprint_nonunicode, vprint_unicode): Move
definitions to new bits/ostream_print.h header.
* include/std/print (__format::_File_sink, vprint_nonunicode)
(vprint_nonunicode_buffered, vprint_unicode)
(vprint_unicode_buffered): Move definitions to new bits/print.h
header.
* src/c++23/print.cc: Include new headers to define symbols for
inline print functions.
* include/bits/ostream_print.h: New file.
* include/bits/print.h: New file.
libstdc++-v3/doc/html/index.html
libstdc++-v3/doc/html/manual/using.html
libstdc++-v3/doc/html/manual/using_macros.html
libstdc++-v3/doc/xml/manual/using.xml
libstdc++-v3/include/Makefile.am
libstdc++-v3/include/Makefile.in
libstdc++-v3/include/bits/ostream_print.h [new file with mode: 0644]
libstdc++-v3/include/bits/print.h [new file with mode: 0644]
libstdc++-v3/include/std/ostream
libstdc++-v3/include/std/print
libstdc++-v3/src/c++23/print.cc