gcc/contrib
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
..
gcc-changelog contrib: Add another ignored commit 2024-11-14 10:14:53 -07:00
header-tools
legacy
mdcompact
reghunt
regression
testsuite-management
unicode
vim-gcc-dev
analyze_brprob_spec.py
analyze_brprob.py
bench-stringop
ChangeLog Daily bump. 2024-11-14 17:20:15 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
check_GNU_style_lib.py
check_GNU_style.py
check_GNU_style.sh
check_makefile_deps.sh
check_warning_flags.sh
check-internal-format-escaping.py
check-MAINTAINERS.py
check-params-in-docs.py
clang-format
compare_tests
compare_two_ftime_report_sets
compare-all-tests
compare-debug
compare-lto
compareSumTests3
config-list.mk
dg-cmp-results.sh
dg-extract-results.py
dg-extract-results.sh
dg-out-generator.pl
dglib.pm
download_prerequisites
filter_gcc_for_doxygen
filter_knr2ansi.pl
filter_params.py
filter-clang-warnings.py
gcc_build
gcc_update
gcc-git-customization.sh
gcc.doxy
gen_autofdo_event.py Update gcc-auto-profile / gen_autofdo_event.py 2024-11-08 20:42:43 -08:00
gennews
git-add-user-branch.sh
git-add-vendor-branch.sh
git-backport.py
git-commit-mklog.py
git-descr.sh
git-fetch-vendor.sh
git-fix-changelog.py
git-undescr.sh
gthr_supp_vxw_5x.c
index-prop
jit-coverage-report.py
make_sunver.pl
make-obstacks-texi.pl
mark_spam.py
mklog.py
paranoia.cc
patch_tester.sh
prepare_patch.sh
prepare-commit-msg
prerequisites.md5
prerequisites.sha512
relpath.sh libstdc++: add module std [PR106852] 2024-11-17 16:23:21 +01:00
repro_fail
test_installed
test_mklog.py
test_recheck
test_summary
texi2pod.pl
uninclude
unused_functions.py
update-copyright.py
vimrc
warn_summary