Commit Graph

36 Commits

Author SHA1 Message Date
Zijun Zhao
0218ea4aaa [libc++] Implement ranges::ends_with
Reviewed By: #libc, var-const

Differential Revision: https://reviews.llvm.org/D150831
2023-09-18 11:56:10 -07:00
Hui
695138ca84 [libc++] implement std::jthread 2023-09-16 19:54:19 +01:00
Alex Brachet
62bec3de12
[libcxx] Fix include directory order (#65859)
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.
2023-09-11 12:36:06 -04:00
Mark de Wever
88359213ee [libc++][chrono] TZDB CI fixes.
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.
2023-09-07 20:31:18 +02:00
Mark de Wever
f78f93bc9f [libc++][chrono] Adds tzdb_list implementation.
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
2023-09-06 20:48:07 +02:00
Mark de Wever
d015e481d7 [libc++][C++20 modules] Tests no experimental library build.
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158936
2023-09-06 19:31:29 +02:00
Louis Dionne
98d28e947c [libc++] Fix issue in std.cppm after introducing views::chunk_by
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.
2023-09-06 09:19:07 -04:00
Jakub Mazurkiewicz
065dc485bd [libc++][ranges] Implement P2443R1: views::chunk_by
This patch implements https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2443r1.html (`views::chunk_by`).

Reviewed By: #libc, var-const

Differential Revision: https://reviews.llvm.org/D144767
2023-09-05 16:19:49 -07:00
Mark de Wever
6f8b17703d [libc++][C++20 modules] Tests no except build.
Depends on D158661

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158862
2023-09-05 18:29:27 +02:00
Mark de Wever
98c6c985f1 [libc++][C++20 modules] Tests no wchar_t build.
Depends on D158358

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158661
2023-09-05 18:22:10 +02:00
Mark de Wever
b9f24033f7 [libc++][C++20 modules] Enabling in C++20.
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
2023-09-05 18:10:46 +02:00
Mark de Wever
10343c910b
[libc++][C++20 modules] Fixes CMake include paths. (#65079)
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.
2023-09-04 20:35:46 +02:00
Mark de Wever
cfab8686bf [libc++][C++20 modules] Tests no unicode build.
Depends on D158347

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158357
2023-08-22 20:17:37 +02:00
Mark de Wever
0e26efe3dc [libc++][C++20 modules] Tests no random device build.
Depends on D158337

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158347
2023-08-22 20:16:53 +02:00
Mark de Wever
c9c71a7e0b [libc++][C++20 modules] Tests no filesystem build.
Depends on D158331

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158337
2023-08-22 20:15:59 +02:00
Mark de Wever
ef3a39160d [libc++][C++20 modules] Tests no threading build.
Depends on D158330

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158331
2023-08-22 20:15:16 +02:00
Mark de Wever
7e8c80fc60 [libc++][C++20 modules] Tests no locale build.
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
2023-08-22 20:14:28 +02:00
Mark de Wever
41161aeb54 [libc++][modules] Generates std.cppm.in.
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
2023-08-22 20:13:39 +02:00
Mark de Wever
f471b4975f [NFC][libc++] Removes no longer existing define.
_LIBCPP_HAS_NO_INCOMPLETE_FORMAT has been removed from libc++ for a
while now.
2023-08-19 14:06:42 +02:00
Mark de Wever
4d4c70c91c [libc++][modules] Removes the module partitions.
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
2023-08-09 19:39:08 +02:00
Mark de Wever
e57f6f709e [libc++][modules] Fixes exporting named declarations.
@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
2023-07-31 18:37:45 +02:00
Christian Trott
fc48765781 [libc++][mdspan] Implement std::mdspan class
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
2023-07-25 06:12:56 -06:00
varconst
c3648f37d0 [libc++][ranges] Implement ranges::to.
Differential Revision: https://reviews.llvm.org/D142335
2023-07-20 22:48:18 -07:00
yrong
a2160dd34d [libc++][ranges] Implement P2474R2(views::repeat).
- Implement https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2474r2.html
- Implement LWG3875(https://cplusplus.github.io/LWG/issue3875).

Depends on D151629

Reviewed By: #libc, Mordante, philnik, var-const

Differential Revision: https://reviews.llvm.org/D141699
2023-07-20 20:03:01 +08:00
Mark de Wever
3f65f71833 [libc++][print] Adds FILE functions.
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
2023-07-18 20:07:11 +02:00
Christian Trott
20c6b9d451 [libc++][mdspan] Implement default_accessor
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
2023-07-14 11:52:40 -06:00
Po-yao Chang
bd03e0ca75 [libc++][NFC] Suppress -Wdeprecated-literal-operator
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
2023-07-14 06:52:39 +08:00
Mark de Wever
20341c3ad6 [libc++][format] Adds a UTF transcoder.
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
2023-07-11 20:28:19 +02:00
Mark de Wever
c62e88eeef [libc++][modules] Avoids duplicated exports.
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
2023-07-08 13:19:43 +02:00
Christian Trott
b4ff893877 [libc++][mdspan] Implement layout_left
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
2023-06-29 14:01:08 -06:00
Christian Trott
cfa096d9c9 [libc++][mdspan] Implement layout_right
This commit implements layout_right in support of C++23 mdspan
(https://wg21.link/p0009). layout_right is a layout mapping policy
whose index mapping corresponds to the memory layout of multidimensional
C-arrays, and is thus also referred to as the C-layout.

Co-authored-by: Damien L-G <dalg24@gmail.com>

Differential Revision: https://reviews.llvm.org/D151267
2023-06-29 10:12:17 -04:00
Mark de Wever
cdcfc5ec9b [libc++][regex] Removes operator!=.
Implements part of:
- P1614R2 The Mothership has Landed

Reviewed By: #libc, H-G-Hristov, philnik

Differential Revision: https://reviews.llvm.org/D153222
2023-06-19 17:01:56 +02:00
Mark de Wever
3f05d044f4 [libc++] Update status after Varna meeting.
This updates:
- The status tables
- Feature test macros
- New headers for modules
The latter avoids forgetting about modules when implementing the feature
in a new header.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153192
2023-06-19 16:55:30 +02:00
Mark de Wever
9b08c8a225 [libc++][modules] Adds the C++23 std module.
The patch is based on D144994.

D151030 added the module definitions for the module std.
This patch wires in the module and enables the basic testing.

Some notable features are missing:
- There is no test that libc++ can be fully imported as a module.
- This lacks the parts for the std.compat module.
- The module is not shipped with libc++.

Implements parts of
- P2465R3 Standard Library Modules std and std.compat

Reviewed By: ldionne, aaronmondal, #libc

Differential Revision: https://reviews.llvm.org/D151814
2023-06-15 18:14:15 +02:00
Mark de Wever
6551e59802 [libc++][modules] Update the .cppm files.
There are some minor fixes in the definiton and it is synced with
upstream changes.

This has been reviewed as part of D151814.
2023-06-15 18:12:06 +02:00
Mark de Wever
c40595f2ce [libc++][modules] Adds std module cppm files.
This adds the cppm files of D144994. These files by themselves will do
nothing. The goal is to reduce the size of D144994 and making it easier
to review the real changes of the patch.

Implements parts of
- P2465R3 Standard Library Modules std and std.compat

Reviewed By: ldionne, ChuanqiXu, aaronmondal, #libc

Differential Revision: https://reviews.llvm.org/D151030
2023-05-23 18:51:27 +02:00