Installs the source files of the experimental libc++ modules. These
source files (.cppm) are used by the Clang to build the std and
std.compat modules.
The design of this patch is based on a discussing in SG-15 on
12.12.2023. (SG-15 is the ISO C++ Tooling study group):
- The modules are installed at a location, that is not known to build
systems and compilers.
- Next to the library there will be a module manifest json file.
This json file contains the information to build the module from the
libraries sources. This information includes the location where the
sources are installed. @ruoso supplied the specification of this json
file.
- If possible, the compiler has an option to give the location of the
module manifest file
(https://github.com/llvm/llvm-project/pull/76451).
Currently there is no build system support, but it expected to be added
in the future.
Fixes: https://github.com/llvm/llvm-project/issues/73089
Revert "Revert #76246 and #76083"
This reverts commit 5c150e7eeb.
Adds a small fix that should properly disable the tests on Windows.
Unfortunately the original poster has not provided feedback and the
original patch did not fail in the LLVM CI infrastructure.
Modules are known to fail on Windows due to non compliance of the
C library. Currently not having this patch prevents testing on other
platforms.
This removes the entire modules testing infrastructure.
The current infrastructure uses CMake to generate the std and std.compat
module. This requires quite a bit of plumbing and uses CMake. Since
CMake introduced module support in CMake 3.26, modules have a higher
CMake requirement than the rest of the LLVM project. (The LLVM project
requires 3.20.) The main motivation for this approach was how libc++
generated its modules. Every header had its own module partition. This
was changed to improve performance and now only two modules remain. The
code to build these can be manually crafted.
A followup patch will reenable testing modules, using a different
approach.
Recent CI changes have disabled testing modules in different
configurations. This broke building the std and std.compat module in
C++20. This was found by the CI in #76246.
Notable things in this commit:
* refactors `__indirect_binary_left_foldable`, making it slightly
different (but equivalent) to _`indirect-binary-left-foldable`_, which
improves readability (a [patch to the Working Paper][patch] was made)
* omits `__cpo` namespace, since it is not required for implementing
niebloids (a cleanup should happen in 2024)
* puts tests ensuring invocable robustness and dangling correctness
inside the correctness testing to ensure that the algorithms' results
are still correct
[patch]: https://github.com/cplusplus/draft/pull/6734
Finishes implementation of
- P2093R14 Formatted output
- P2539R4 Should the output of std::print to a terminal be synchronized
with the underlying stream?
Differential Revision: https://reviews.llvm.org/D156609
The fix changes the way the validation script determines the qualified
name of a declaration. Inline namespaces without a reserved name are now
always part of the name. The Clang code only does this when the names
are ambigious. This method is often used for the operator""foo for UDLs.
Adjusted the newly flagged issue and removed a work-around in the test
code that is no longer required.
Fixes https://github.com/llvm/llvm-project/issues/72427
This adds the std.compat module. The patch contains a bit of refactoring
to avoid code duplication between the std and std.compat module.
Implements parts of
- P2465R3 Standard Library Modules std and std.compat
This patch implements `std::basic_syncbuf` and `std::basic_osyncstream` as specified in paper p0053r7. ~~For ease of reviewing I am submitting this patch before submitting a patch for `std::basic_osyncstream`. ~~
~~Please note, this patch is not 100% complete. I plan on adding more tests (see comments), specifically I plan on adding tests for multithreading and synchronization.~~
Edit: I decided that it would be far easier for me to keep track of this and make changes that affect both `std::basic_syncbuf` and `std::basic_osyncstream` if both were in one patch.
The patch was originally written by @zoecarver
Implements
- P0053R7 - C++ Synchronized Buffered Ostream
- LWG-3127 basic_osyncstream::rdbuf needs a const_cast
- LWG-3334 basic_osyncstream move assignment and destruction calls basic_syncbuf::emit() twice
- LWG-3570 basic_osyncstream::emit should be an unformatted output function
- LWG-3867 Should std::basic_osyncstream's move assignment operator be noexcept?
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D67086
This implements layout_stride for C++23 and with that completes the
implementation of the C++23 mdspan header. The feature test macro is
added, and the status pages updated.
Co-authored-by: Damien L-G <dalg24@gmail.com>
Differential Revision: https://reviews.llvm.org/D157171
It's important that the arch directory be included first so that
its header files which interpose on the default include dir
be included instead of the default ones. The clang driver [1] does
this when not building with -nostdinc, the libcxx build should
do the same.
We found this after https://reviews.llvm.org/D154282 when cross
compiling from non Linux to Linux. If the host machine was not
Linux, _LIBCPP_HAS_NO_TIME_ZONE_DATABASE would be defined in
the default include dir __config_site, while it was undefined
in the arch specific one causing build failures.
Fixes a conflict with adding the no experimental module build.
Disables some tests that need further investigation, this should fix the
CI runners.
These issues were reported on Discord and in D154282.
This is the first step to implement time zone support in libc++. This
adds the complete tzdb_list class and a minimal tzdb class. The tzdb
class only contains the version, which is used by reload_tzdb.
Next to these classes it contains documentation and build system support
needed for time zone support. The code depends on the IANA Time Zone
Database, which should be available on the platform used or provided by
the libc++ vendors.
The code is labeled as experimental since there will be ABI breaks
during development; the tzdb class needs to have the standard headers.
Implements parts of:
- P0355 Extending <chrono> to Calendars and Time Zones
Addresses:
- LWG3319 Properly reference specification of IANA time zone database
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D154282
This should fix CI issues introduced by 065dc485bd where the std.cppm
module won't build in C++20 mode because views::chunk_by was added in
C++23 but wasn't marked as such in ranges.inc.
The vendors of the MSVC STL, libstdc++ and libc++ have agreed [1] to
make the C++23 modules std and std.compat available in C++20. This
provides the std module; libc++ has not implemented the std.compat
module yet.
[1] https://github.com/microsoft/STL/issues/3945
Depends on D158357
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D158358
When the modules are used in a bootstrap build the paths
${LIBCXX_GENERATED_INCLUDE_DIR} and
${LIBCXX_GENERATED_INCLUDE_TARGET_DIR} have a different value and both
are needed to build modules.
This issue has been reported on Slack.
This fixes some missing #ifndef and implements the header restrictions
in the modules script.
Depends on D158192
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D158330
This takes the header restrictions into account instead of manually
duplicating this build information. This is a preparation to properly
support the libc++ disabled parts in the std module.
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D158192
This patch is based on the suggestion by @ChuanqiXu on discourse
(https://discourse.llvm.org/t/alternatives-to-the-implementation-of-std-modules/71958)
Instead of making a module partition per header every header gets an inc
file which contains the exports per header. The std module then includes
all public headers and these inc files. The one file per header is
useful for testing purposes. The CI tests whether the exports of a
header's module partition matches the "public" named declarations in the
header. With one file per header this can still be done.
The patch improves compilation time of files using "import std;" and the
size of the std module.
A comparision of the compilation speed using a libc++ test
build/bin/llvm-lit -a -Dstd=c++23 -Denable_modules=std libcxx/test/std/modules/std.pass.cpp
Which boils down to
import std;
int main(int, char**) {
std::println("Hello modular world");
return 0;
}
and has -ftime-report enabled
Before
===-------------------------------------------------------------------------===
Clang front-end time report
===-------------------------------------------------------------------------===
Total Execution Time: 8.6585 seconds (8.6619 wall clock)
---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name ---
4.5041 ( 57.2%) 0.4264 ( 54.4%) 4.9305 ( 56.9%) 4.9331 ( 57.0%) Clang front-end timer
3.2037 ( 40.7%) 0.2408 ( 30.7%) 3.4445 ( 39.8%) 3.4452 ( 39.8%) Reading modules
0.1665 ( 2.1%) 0.1170 ( 14.9%) 0.2835 ( 3.3%) 0.2837 ( 3.3%) Loading .../build/test/__config_module__/CMakeFiles/std.dir/std.pcm
7.8744 (100.0%) 0.7842 (100.0%) 8.6585 (100.0%) 8.6619 (100.0%) Total
After
===-------------------------------------------------------------------------===
Clang front-end time report
===-------------------------------------------------------------------------===
Total Execution Time: 1.2420 seconds (1.2423 wall clock)
---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name ---
0.8892 ( 84.6%) 0.1698 ( 88.8%) 1.0590 ( 85.3%) 1.0590 ( 85.2%) Clang front-end timer
0.1533 ( 14.6%) 0.0168 ( 8.8%) 0.1701 ( 13.7%) 0.1704 ( 13.7%) Reading modules
0.0082 ( 0.8%) 0.0047 ( 2.5%) 0.0129 ( 1.0%) 0.0129 ( 1.0%) Loading .../build/test/__config_module__/CMakeFiles/std.dir/std.pcm
1.0507 (100.0%) 0.1913 (100.0%) 1.2420 (100.0%) 1.2423 (100.0%) Total
Using "include <print>" instead of "import module;"
===-------------------------------------------------------------------------===
Clang front-end time report
===-------------------------------------------------------------------------===
Total Execution Time: 2.1507 seconds (2.1517 wall clock)
---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name ---
1.9714 (100.0%) 0.1793 (100.0%) 2.1507 (100.0%) 2.1517 (100.0%) Clang front-end timer
1.9714 (100.0%) 0.1793 (100.0%) 2.1507 (100.0%) 2.1517 (100.0%) Total
It's possible to use the std module in external projects
(https://libcxx.llvm.org/Modules.html#using-in-external-projects)
Tested this with a private project to validate the size of the generated files:
Before
$ du -sch std-*
448M std-build
508K std-src
120K std-subbuild
449M total
After
$ du -sch std-*
29M std-build
1004K std-src
132K std-subbuild
30M total
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D156907
@ChuanqiXu noticed std::atomic was not properly exported in the std module.
Investigation showed other named declarations were not exported either. This
fixes the issue.
Depends on D156550
Reviewed By: #libc, philnik
Differential Revision: https://reviews.llvm.org/D156592
This implements P0009 std::mdspan ((https://wg21.link/p0009)),
a multidimensional span with customization points for
layouts and data access.
Co-authored-by: Damien L-G <dalg24@gmail.com>
Differential Revision: https://reviews.llvm.org/154367
Drive-by fix to make sure the __retarget_buffer works correctly whan
using a hint of 1. This was discovered in one of the new tests.
Drive-by fixes __retarget_buffer when initialized with size 1.
Implements parts of
- P2093R14 Formatted output
- P2539R4 Should the output of std::print to a terminal be
synchronized with the underlying stream?
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D150044
This commit implements default_accessor in support of C++23 mdspan
(https://wg21.link/p0009). default_accessor is the trivial accessor
using plain pointers and reference to element types.
Co-authored-by: Damien L-G <dalg24@gmail.com>
Differential Revision: https://reviews.llvm.org/D153935
Remove spaces between operator"" and identifier to suppress
-Wdeprecated-literal-operator, and between operator and ""
like how they are written in [string.view.literals] and [basic.string.literals].
Differential Revision: https://reviews.llvm.org/D155200
This is a preparation for
P2093R14 Formatted output
When the output of print is to the terminal it needs to use the native
API. This means transcoding UTF-8 to UTF-16 on Windows. The encoder's
interface is modeled after
P2728 Unicode in the Library, Part 1: UTF Transcoding
But only the required part for P2093R14 is implemented.
On Windows wchar_t is 16 bits, in order to test on platforms where
wchar_t is 32 bits the transcoder has support for char16_t. It also adds
and UTF-8 to UTF-32 encoder which is useful for other tests.
Note it is possible to use <codecvt> for transcoding, but that header is
deprecated. So rather write new code that is not deprecated; the hard
part, decoding, has already been done. The <codecvt> header also
requires locale support while the new code works without including
<locale>.
Note the current transcoder implementation can be optimized since it
basically does UTF-8 -> UTF-32 -> UTF-16. The first goal is to have a
working implementation. Since it's not part of the ABI it's possible to
do the optimization later.
Depends on D149672
Reviewed By: ldionne, tahonermann, #libc
Differential Revision: https://reviews.llvm.org/D150031
The first issue was found by @ldionne, upon further investigation there
were more duplicates. This removes the duplicates and updates the
clang-tidy test to detect duplicates.
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D154723
This commit implements layout_left in support of C++23 mdspan
(https://wg21.link/p0009). layout_left is a layout mapping policy
whose index mapping corresponds to the memory layout of Fortran arrays.
Thus the left most index has stride-1 access, and the right most index
is associated with the largest stride.
Co-authored-by: Damien L-G <dalg24@gmail.com>
Differential Revision: https://reviews.llvm.org/D153783