On Mon, 16 Mar 2026 at 08:21, Tomasz Kaminski <[email protected]> wrote:
>
>
>
> On Thu, Mar 12, 2026 at 11:06 AM Jonathan Wakely <[email protected]> wrote:
>>
>> This ensures that the module init functions are present in libstdc++.so
>> and libstdc++.a, so that users of the std and std.compat modules don't
>> need to manually link to std.o and/or std.compat.o in addition to
>> compiling the CMIs.
>>
>> This also adds a clean-local target to remove the generated interface
>> units and manifest, and the gcm.cache directory for the CMIs.
>>
>> libstdc++-v3/ChangeLog:
>>
>> PR libstdc++/124268
>> * config/abi/pre/gnu.ver: Export symbols.
>> * src/Makefile.am: Add libc++23modulesconvenience.la to
>> libstdc++ link.
>
> The name of the file seems strange to me, I would either go for
> 23convience.la (modules are C++23)
We already have libc++23convenience.la so that name is taken. Those
are the files that are linked into libstdc++exp.a and not linked into
libstdc++.so, so we need a different name for the module objects.
> or modulesconvience.la (as you can use std module with C++20).
I can change it to that.
>>
>> * src/Makefile.in: Regenerate.
>> * src/c++23/Makefile.am: Create libc++23modulesconvenience.la
>> and populate it with std.o and std.compat.o interface units.
>> Add clean-local target.
>> * src/c++23/Makefile.in: Regenerate.
>> ---
>>
>> Tested x86_64-linux.
>>
>> I'm not sure why I needed the -Wno-unknown-pragmas flag to suppress
>> warnings from PSTL headers when compiling std.o here, but don't need
>> that when using --compile-std-module on the command line for a program
>> that imports std.
>>
>> The std.compat.o target has std.o as a prerequisite because it needs to
>> use the CMI for the std module, which is created as a side effect of the
>> std.o target.
>>
>> libstdc++-v3/config/abi/pre/gnu.ver | 4 +++
>> libstdc++-v3/src/Makefile.am | 6 ++--
>> libstdc++-v3/src/Makefile.in | 6 ++--
>> libstdc++-v3/src/c++23/Makefile.am | 25 +++++++++++--
>> libstdc++-v3/src/c++23/Makefile.in | 56 +++++++++++++++++++++--------
>> 5 files changed, 77 insertions(+), 20 deletions(-)
>>
>> diff --git a/libstdc++-v3/config/abi/pre/gnu.ver
>> b/libstdc++-v3/config/abi/pre/gnu.ver
>> index fb968e122d8a..323fff28c255 100644
>> --- a/libstdc++-v3/config/abi/pre/gnu.ver
>> +++ b/libstdc++-v3/config/abi/pre/gnu.ver
>> @@ -2592,6 +2592,10 @@ GLIBCXX_3.4.35 {
>> _ZSt15__get_once_callv;
>> #endif
>>
>> + # Module inititialization symbols for std and std.compat modules.
>> + _ZGIW3std;
>> + _ZGIW3stdW6compat;
>> +
>> } GLIBCXX_3.4.34;
>>
>> # Symbols in the support library (libsupc++) have their own tag.
>> diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
>> index 55a8c88a0e12..3f91e09ac6ec 100644
>> --- a/libstdc++-v3/src/Makefile.am
>> +++ b/libstdc++-v3/src/Makefile.am
>> @@ -145,7 +145,8 @@ libstdc___la_LIBADD = \
>> $(top_builddir)/src/c++98/libc++98convenience.la \
>> $(top_builddir)/src/c++11/libc++11convenience.la \
>> $(top_builddir)/src/c++17/libc++17convenience.la \
>> - $(top_builddir)/src/c++20/libc++20convenience.la
>> + $(top_builddir)/src/c++20/libc++20convenience.la \
>> + $(top_builddir)/src/c++23/libc++23modulesconvenience.la
>>
>> libstdc___la_DEPENDENCIES = \
>> ${version_dep} \
>> @@ -153,7 +154,8 @@ libstdc___la_DEPENDENCIES = \
>> $(top_builddir)/src/c++98/libc++98convenience.la \
>> $(top_builddir)/src/c++11/libc++11convenience.la \
>> $(top_builddir)/src/c++17/libc++17convenience.la \
>> - $(top_builddir)/src/c++20/libc++20convenience.la
>> + $(top_builddir)/src/c++20/libc++20convenience.la \
>> + $(top_builddir)/src/c++23/libc++23modulesconvenience.la
>>
>> if ENABLE_DARWIN_AT_RPATH
>> libstdc___darwin_rpath = -Wc,-nodefaultrpaths
>> diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
>> index f0ad019a71fd..0ae19c778028 100644
>> --- a/libstdc++-v3/src/Makefile.in
>> +++ b/libstdc++-v3/src/Makefile.in
>> @@ -555,7 +555,8 @@ libstdc___la_LIBADD = \
>> $(top_builddir)/src/c++98/libc++98convenience.la \
>> $(top_builddir)/src/c++11/libc++11convenience.la \
>> $(top_builddir)/src/c++17/libc++17convenience.la \
>> - $(top_builddir)/src/c++20/libc++20convenience.la
>> + $(top_builddir)/src/c++20/libc++20convenience.la \
>> + $(top_builddir)/src/c++23/libc++23modulesconvenience.la
>>
>> libstdc___la_DEPENDENCIES = \
>> ${version_dep} \
>> @@ -563,7 +564,8 @@ libstdc___la_DEPENDENCIES = \
>> $(top_builddir)/src/c++98/libc++98convenience.la \
>> $(top_builddir)/src/c++11/libc++11convenience.la \
>> $(top_builddir)/src/c++17/libc++17convenience.la \
>> - $(top_builddir)/src/c++20/libc++20convenience.la
>> + $(top_builddir)/src/c++20/libc++20convenience.la \
>> + $(top_builddir)/src/c++23/libc++23modulesconvenience.la
>>
>> @ENABLE_DARWIN_AT_RPATH_TRUE@libstdc___darwin_rpath = \
>> @ENABLE_DARWIN_AT_RPATH_TRUE@ -Wc,-nodefaultrpaths \
>> diff --git a/libstdc++-v3/src/c++23/Makefile.am
>> b/libstdc++-v3/src/c++23/Makefile.am
>> index b031ec69576c..85413a435cd8 100644
>> --- a/libstdc++-v3/src/c++23/Makefile.am
>> +++ b/libstdc++-v3/src/c++23/Makefile.am
>> @@ -23,10 +23,13 @@
>> include $(top_srcdir)/fragment.am
>>
>> # Convenience library for C++23 runtime.
>> -noinst_LTLIBRARIES = libc++23convenience.la
>> +# This libc++23convenience.la one isn't linked into libstdc++.la yet,
>> +# so build an additional libc++23modulesconvenience.la which is linked in.
>> +noinst_LTLIBRARIES = libc++23convenience.la libc++23modulesconvenience.la
>>
>> -# Module std support. Not compiled for now, only installed.
>> +# Module std support.
>> # Let's install the interface units in the bits subdirectory.
>> +# We also compile them and include them in libc++23modulesconvenience.la
>> toolexeclib_DATA = libstdc++.modules.json
>> includebitsdir = $(gxx_include_dir)/bits
>> includebits_DATA = std.cc std.compat.cc
>> @@ -59,6 +62,9 @@ stamp-modules-bits: $(includebits_DATA)
>>
>> all-local: stamp-module-manifest stamp-modules-bits
>>
>> +clean-local:
>> + rm -rf stamp* libstdc++.modules.json std.cc std.compat.cc gcm.cache
>> +
>> headers =
>>
>> if ENABLE_EXTERN_TEMPLATE
>> @@ -80,12 +86,27 @@ else
>> libc__23convenience_la_SOURCES =
>> endif
>>
>> +libc__23modulesconvenience_la_SOURCES = std.cc std.compat.cc
>> +
>> # Use C++26 so that std::filebuf::native_handle() is available.
>> print.lo: print.cc
>> $(LTCXXCOMPILE) -std=gnu++26 -c $<
>> print.o: print.cc
>> $(CXXCOMPILE) -std=gnu++26 -c $<
>>
>> +MODULES_FLAGS = -isystem ${glibcxx_srcdir}/include/backward -fmodules \
>> + -Wno-unknown-pragmas
>> +
>> +# These go into libc++23modulesconvenience.la and are linked into libstdc++
>> +std.lo: std.cc
>> + $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $<
>> +std.o: std.cc
>> + $(CXXCOMPILE) $(MODULES_FLAGS) -c $<
>> +std.compat.lo: std.compat.cc std.lo
>> + $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $<
>> +std.compat.o: std.compat.cc std.o
>> + $(CXXCOMPILE) $(MODULES_FLAGS) -c $<
>> +
>> # AM_CXXFLAGS needs to be in each subdirectory so that it can be
>> # modified in a per-library or per-sub-library way. Need to manually
>> # set this option because CONFIG_CXXFLAGS has to be after
>> diff --git a/libstdc++-v3/src/c++23/Makefile.in
>> b/libstdc++-v3/src/c++23/Makefile.in
>> index fd9110ab8ad2..348ce97fc73f 100644
>> --- a/libstdc++-v3/src/c++23/Makefile.in
>> +++ b/libstdc++-v3/src/c++23/Makefile.in
>> @@ -133,6 +133,10 @@ AM_V_lt = $(am__v_lt_@AM_V@)
>> am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
>> am__v_lt_0 = --silent
>> am__v_lt_1 =
>> +libc__23modulesconvenience_la_LIBADD =
>> +am_libc__23modulesconvenience_la_OBJECTS = std.lo std.compat.lo
>> +libc__23modulesconvenience_la_OBJECTS = \
>> + $(am_libc__23modulesconvenience_la_OBJECTS)
>> AM_V_P = $(am__v_P_@AM_V@)
>> am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
>> am__v_P_0 = false
>> @@ -159,7 +163,8 @@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
>> am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
>> am__v_CXXLD_0 = @echo " CXXLD " $@;
>> am__v_CXXLD_1 =
>> -SOURCES = $(libc__23convenience_la_SOURCES)
>> +SOURCES = $(libc__23convenience_la_SOURCES) \
>> + $(libc__23modulesconvenience_la_SOURCES)
>> am__can_run_installinfo = \
>> case $$AM_UPDATE_INFO_DIR in \
>> n|no|NO) false;; \
>> @@ -457,10 +462,13 @@ WARN_CXXFLAGS = \
>> AM_CPPFLAGS = $(GLIBCXX_INCLUDES) $(CPPFLAGS)
>>
>> # Convenience library for C++23 runtime.
>> -noinst_LTLIBRARIES = libc++23convenience.la
>> +# This libc++23convenience.la one isn't linked into libstdc++.la yet,
>> +# so build an additional libc++23modulesconvenience.la which is linked in.
>> +noinst_LTLIBRARIES = libc++23convenience.la libc++23modulesconvenience.la
>>
>> -# Module std support. Not compiled for now, only installed.
>> +# Module std support.
>> # Let's install the interface units in the bits subdirectory.
>> +# We also compile them and include them in libc++23modulesconvenience.la
>> toolexeclib_DATA = libstdc++.modules.json
>> includebitsdir = $(gxx_include_dir)/bits
>> includebits_DATA = std.cc std.compat.cc
>> @@ -473,6 +481,10 @@ headers =
>> sources = stacktrace.cc print.cc
>> @GLIBCXX_HOSTED_FALSE@libc__23convenience_la_SOURCES =
>> @GLIBCXX_HOSTED_TRUE@libc__23convenience_la_SOURCES = $(sources)
>> $(inst_sources)
>> +libc__23modulesconvenience_la_SOURCES = std.cc std.compat.cc
>> +MODULES_FLAGS = -isystem ${glibcxx_srcdir}/include/backward -fmodules \
>> + -Wno-unknown-pragmas
>> +
>>
>> # AM_CXXFLAGS needs to be in each subdirectory so that it can be
>> # modified in a per-library or per-sub-library way. Need to manually
>> @@ -586,6 +598,9 @@ clean-noinstLTLIBRARIES:
>> libc++23convenience.la: $(libc__23convenience_la_OBJECTS)
>> $(libc__23convenience_la_DEPENDENCIES)
>> $(EXTRA_libc__23convenience_la_DEPENDENCIES)
>> $(AM_V_CXXLD)$(CXXLINK) $(libc__23convenience_la_OBJECTS)
>> $(libc__23convenience_la_LIBADD) $(LIBS)
>>
>> +libc++23modulesconvenience.la: $(libc__23modulesconvenience_la_OBJECTS)
>> $(libc__23modulesconvenience_la_DEPENDENCIES)
>> $(EXTRA_libc__23modulesconvenience_la_DEPENDENCIES)
>> + $(AM_V_CXXLD)$(CXXLINK) $(libc__23modulesconvenience_la_OBJECTS)
>> $(libc__23modulesconvenience_la_LIBADD) $(LIBS)
>> +
>> mostlyclean-compile:
>> -rm -f *.$(OBJEXT)
>>
>> @@ -739,8 +754,8 @@ maintainer-clean-generic:
>> @echo "it deletes files that may require special tools to rebuild."
>> clean: clean-am
>>
>> -clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
>> - mostlyclean-am
>> +clean-am: clean-generic clean-libtool clean-local \
>> + clean-noinstLTLIBRARIES mostlyclean-am
>>
>> distclean: distclean-am
>> -rm -f Makefile
>> @@ -809,15 +824,15 @@ uninstall-am: uninstall-includebitsDATA
>> uninstall-toolexeclibDATA
>> .MAKE: install-am install-strip
>>
>> .PHONY: CTAGS GTAGS TAGS all all-am all-local check check-am clean \
>> - clean-generic clean-libtool clean-noinstLTLIBRARIES \
>> - cscopelist-am ctags ctags-am distclean distclean-compile \
>> - distclean-generic distclean-libtool distclean-tags dvi dvi-am \
>> - html html-am info info-am install install-am install-data \
>> - install-data-am install-dvi install-dvi-am install-exec \
>> - install-exec-am install-html install-html-am \
>> - install-includebitsDATA install-info install-info-am \
>> - install-man install-pdf install-pdf-am install-ps \
>> - install-ps-am install-strip install-toolexeclibDATA \
>> + clean-generic clean-libtool clean-local \
>> + clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am distclean \
>> + distclean-compile distclean-generic distclean-libtool \
>> + distclean-tags dvi dvi-am html html-am info info-am install \
>> + install-am install-data install-data-am install-dvi \
>> + install-dvi-am install-exec install-exec-am install-html \
>> + install-html-am install-includebitsDATA install-info \
>> + install-info-am install-man install-pdf install-pdf-am \
>> + install-ps install-ps-am install-strip install-toolexeclibDATA \
>> installcheck installcheck-am installdirs maintainer-clean \
>> maintainer-clean-generic mostlyclean mostlyclean-compile \
>> mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
>> @@ -855,6 +870,9 @@ stamp-modules-bits: $(includebits_DATA)
>>
>> all-local: stamp-module-manifest stamp-modules-bits
>>
>> +clean-local:
>> + rm -rf stamp* libstdc++.modules.json std.cc std.compat.cc gcm.cache
>> +
>> vpath % $(top_srcdir)/src/c++23
>>
>> # Use C++26 so that std::filebuf::native_handle() is available.
>> @@ -863,6 +881,16 @@ print.lo: print.cc
>> print.o: print.cc
>> $(CXXCOMPILE) -std=gnu++26 -c $<
>>
>> +# These go into libc++23modulesconvenience.la and are linked into libstdc++
>> +std.lo: std.cc
>> + $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $<
>> +std.o: std.cc
>> + $(CXXCOMPILE) $(MODULES_FLAGS) -c $<
>> +std.compat.lo: std.compat.cc std.lo
>> + $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $<
>> +std.compat.o: std.compat.cc std.o
>> + $(CXXCOMPILE) $(MODULES_FLAGS) -c $<
>> +
>> # Tell versions [3.59,3.63) of GNU make to not export all variables.
>> # Otherwise a system limit (for SysV at least) may be exceeded.
>> .NOEXPORT:
>> --
>> 2.53.0
>>