gcc/libstdc++-v3
Jason Merrill 7db55c0ba1 libstdc++: add module std [PR106852]
This patch introduces an installed source form of module std and std.compat.
To help a build system find them, we install a libstdc++.modules.json file
alongside libstdc++.so, which tells the build system where the files are and
any special flags it should use when compiling them (none, in this case).
The format is from a proposal in SG15.  The build system can find this file
with 'gcc -print-file-name=libstdc++.modules.json'.

It seems preferable to use a relative path from this file to the sources so
that moving the installation doesn't break the reference, but I didn't see
any obvious way to compute that without relying on coreutils, perl, or
python, so I wrote a POSIX shell script for it.  The .. canonicalization
bits aren't necessary since I discovered $(abspath), but I guess I might as
well leave them in.

Currently this installs the sources under $(gxx_include_dir)/bits/,
i.e. /usr/include/c++/15/bits.  So with my -fsearch-include-path change,
std.cc can be compiled with g++ -fsearch-include-path bits/std.cc.  Note
that if someone actually tries to #include <bits/std.cc> it will fail with
"error: module control-line cannot be in included file".

Any ideas about a more user-friendly way to express "compile module std" are
welcome.

The sources currently have the extension .cc, like other source files.

std.cc started with m.cencora's implementation in PR114600.  I've made some
adjustments, but more is probably desirable, e.g. of the <algorithm>
handling of namespace ranges, and to remove exports of templates that are
only specialized in a particular header.  I've filled in a bunch of missing
exports, and added some FIXMEs where I noticed bits that are not implemented
yet.

Since bits/stdc++.h also intends to include the whole standard library, I
include it rather than duplicate it.  But stdc++.h comments out <execution>,
due to TBB issues; I include it separately and suppress TBB usage, so module
std won't currently provide parallel execution.

It seemed most convenient for the two files to be monolithic so we don't
need to worry about include paths.  So the C library names that module
std.compat exports in both namespace std and :: are a block of code that is
appended to both files, adjusted based on whether the macro STD_COMPAT is
defined before the block.

In this implementation std.compat imports std; it would also be valid for it
to duplicate everything in std.  I see the libc++ std.compat also imports
std.

As discussed in the PR, module std is supported in C++20 mode even though it
was added in C++23.

Changes to test module std will follow in a separate patch.  In my testing
I've noticed a few compiler bugs that break various testcases, so I don't
expect to enable module std testing by default at first.

	PR libstdc++/106852

libstdc++-v3/ChangeLog:

	* include/bits/version.def: Add __cpp_lib_modules.
	* include/bits/version.h: Regenerate.
	* src/c++23/Makefile.am: Add modules std and std.compat.
	* src/c++23/Makefile.in: Regenerate.
	* src/c++23/std-clib.cc.in: New file.
	* src/c++23/std.cc.in: New file.
	* src/c++23/std.compat.cc.in: New file.
	* src/c++23/libstdc++.modules.json.in: New file.

contrib/ChangeLog:

	* relpath.sh: New file.
2024-11-17 16:23:21 +01:00
..
config aarch64: libstdc++: Use shufflevector instead of shuffle in opt_random.h 2024-10-24 15:01:23 +01:00
doc libstdc++: Move a gcc.gnu.org link to https 2024-11-17 12:36:29 +01:00
include libstdc++: add module std [PR106852] 2024-11-17 16:23:21 +01:00
libsupc++ ibstdc++: Add some further attributes to ::operator new in <new> 2024-11-08 22:07:33 +01:00
po
python libstdc++: Fix Python deprecation warning in printers.py 2024-10-16 10:09:16 +01:00
scripts libstdc++: Write timestamp to libstdc++-performance.sum file 2024-11-13 20:21:29 +00:00
src libstdc++: add module std [PR106852] 2024-11-17 16:23:21 +01:00
testsuite libstdc++: Make equal and is_permutation short-circuit (LWG 3560) 2024-11-14 20:01:25 +00:00
.editorconfig
acinclude.m4
aclocal.m4
ChangeLog Daily bump. 2024-11-17 00:21:19 +00:00
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog-2017
ChangeLog-2018
ChangeLog-2019
ChangeLog-2020
ChangeLog-2021
ChangeLog-2022
ChangeLog-2023
config.h.in
configure
configure.ac
configure.host
crossconfig.m4
fragment.am
linkage.m4
Makefile.am libstdc++: Use -C option to run recursive make in sub-directories 2024-11-16 01:05:06 +00:00
Makefile.in libstdc++: Use -C option to run recursive make in sub-directories 2024-11-16 01:05:06 +00:00
README

file: libstdc++-v3/README

New users may wish to point their web browsers to the file
index.html in the 'doc/html' subdirectory.  It contains brief
building instructions and notes on how to configure the library in
interesting ways.