Commit Graph

809 Commits

Author SHA1 Message Date
Louis Dionne 6b03a4fea0 Revert "[llvm] Remove libcxx, libcxxabi and libunwind from supported LLVM_ENABLE_PROJECTS"
This reverts commit 887b8bd733 while we
work on resolving issues brought up in https://reviews.llvm.org/D132480.
2022-09-21 08:38:00 -04:00
Louis Dionne 887b8bd733 [llvm] Remove libcxx, libcxxabi and libunwind from supported LLVM_ENABLE_PROJECTS
This is a breaking change. If you were passing one of those three runtimes
in LLVM_ENABLE_PROJECTS, you need to start passing them in LLVM_ENABLE_RUNTIMES
instead. The runtimes in LLVM_ENABLE_RUNTIMES will start being built using
the "bootstrapping build" instead, which means that they will be built
using the just-built Clang. This is usually what you wanted anyway.

If you were using LLVM_ENABLE_PROJECTS=all with the explicit goal of
building these three runtimes, you can now use LLVM_ENABLE_RUNTIMES=all
and these runtimes will be built using the bootstrapping build.

Differential Revision: https://reviews.llvm.org/D132480
2022-09-20 11:12:51 -04:00
Louis Dionne f1a601fe88 [libc++] Always query the compiler to find whether a type is always lockfree
In https://llvm.org/D56913, we added an emulation for the __atomic_always_lock_free
compiler builtin when compiling in Freestanding mode. However, the emulation
did (and could not) give exactly the same answer as the compiler builtin,
which led to a potential ABI break for e.g. enum classes.

After speaking to the original author of D56913, we agree that the correct
behavior is to instead always use the compiler builtin, since that provides
a more accurate answer, and __atomic_always_lock_free is a purely front-end
builtin which doesn't require any runtime support. Furthermore, it is
available regardless of the Standard mode (see https://godbolt.org/z/cazf3ssYY).

However, this patch does constitute an ABI break. As shown by https://godbolt.org/z/1eoex6zdK:
- In LLVM <= 11.0.1, an atomic<enum class with 1 byte> would not contain a lock byte.
- In LLVM >= 12.0.0, an atomic<enum class with 1 byte> would contain a lock byte.

This patch breaks the ABI again to bring it back to 1 byte, which seems
like the correct thing to do.

Fixes #57440

Differential Revision: https://reviews.llvm.org/D133377
2022-09-19 11:10:02 -04:00
Mark de Wever 24e1736d84 [libc++][random] Removes transitive includes.
It seems these includes are still provided by the sub headers, so it only
removes the duplicates.

There is no change in the list of includes, but the change affects the
modular build. By not having the includes in the top-level header the
module map has changed. This uncovers missing includes in the tests
and missing exports in the module map. This causes the huge amount of
changes in the patch.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D133252
2022-09-11 17:39:27 +02:00
Mark de Wever 52a374e938 [libc++][doc] Updates format status page. 2022-09-11 12:12:22 +02:00
Tom Honermann 7e7013c5d4 [libc++][cuchar] Declare std::c8rtomb and std::mbrtoc8 in <cuchar> if available.
This change implements the C library dependent portions of P0482R6
(char8_t: A type for UTF-8 characters and strings (Revision 6)) by
declaring std::c8rtomb() and std::mbrtoc8() in the <cuchar> header
when implementations are provided by the C library as specified by
WG14 N2653 (char8_t: A type for UTF-8 characters and strings
(Revision 1)) as adopted for C23.

A _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8 macro is defined by the libc++ __config
header unless it is known that the C library provides these functions
in the current compilation mode. This macro is used for testing purposes
and may be of use to libc++ users. At present, the only C library known
to implement these functions is GNU libc as of its 2.36 release.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D130946
2022-09-10 21:10:33 -04:00
Mark de Wever 3695cf2065 [libc++] Removes Clang 13 support.
Reviewed By: #libc, ldionne, jloser

Differential Revision: https://reviews.llvm.org/D133435
2022-09-08 17:51:52 +02:00
Mark de Wever ab7b776cf9 [libc++][locale] Removes an transitive include.
Removes <cstdarg> transitive include from <locale> in C++23.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D133254
2022-09-07 18:54:26 +02:00
Mark de Wever e5d2d3eafb [libc++][chrono] Implements formatter day.
This implements the enabled specializaton
template<class charT> struct formatter<chrono::day, charT>;

and
template<class charT, class traits>
    basic_ostream<charT, traits>&
      operator<<(basic_ostream<charT, traits>& os, const day& d);

Implements:
- LWG 3241 chrono-spec grammar ambiguity in §[time.format]

Partially implements:
- P1361 Integration of chrono with text formatting

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D128577
2022-09-07 18:44:04 +02:00
Mark de Wever b490c8a662 [libc++][format] Updates feature-test macros.
During the discussion on the SG-10 mailinglist regarding the format
feature-test macros voted in during the last plenary it turns out libc++
can't mark the format feature-test macro as implemented.

According to
  https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_lib_format
the not yet implemented paper
  P1361R2 Integration of chrono with text formatting
affects the feature test macro.

Note that P1361R2 doesn't mention the feature-test macro nor is there an
LWG-issue to address the issue. The reporter of the issue didn't recall
where this requirement exactly has been decided.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D133271
2022-09-07 18:39:39 +02:00
Igor Zhukov 30dadaa2eb [libc++] Implement P2273R3 (`constexpr` `unique_ptr`)
Reviewed By: mordante, #libc

Differential Revision: https://reviews.llvm.org/D131315
2022-09-03 18:49:50 +07:00
Igor Zhukov 3a49cffe3a [libc++] Implement P2445R1 (`std::forward_like`)
Co-authored-by: A. Jiang <de34@live.cn>

Reviewed By: philnik, huixie90, #libc

Differential Revision: https://reviews.llvm.org/D132327
2022-09-03 09:17:53 +07:00
Nikolas Klauser 3c355e2881 [libc++] Enable [[nodiscard]] extensions by default
Adding `[[nodiscard]]` to functions is a conforming extension and done extensively in the MSVC STL.

Reviewed By: ldionne, EricWF, #libc

Spies: #libc_vendors, cjdb, mgrang, jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D128267
2022-09-02 21:34:20 +02:00
Mark de Wever 8ff2d6af69 [libc++] Reduces the number of transitive includes.
This defines a new policy for removal of transitive includes.
The goal of the policy it to make it relatively easy to remove
headers when needed, but avoid breaking developers using and
vendors shipping libc++.

The method used is to guard transitive includes based on the
C++ language version. For the upcoming C++23 we can remove
headers when we want, but for other language versions we try
to keep it to a minimum.

In this code the transitive include of `<chrono>` is removed
since D128577 introduces a header cycle between `<format>`
and `<chrono>`. This cycle is indirectly required by the
Standard. Our cycle dependency tool basically is a grep based
tool, so it needs some hints to ignore cycles. With the input
of our transitive include tests we can create a better tool.
However that's out of the scope of this patch.

Note the flag `_LIBCPP_REMOVE_TRANSITIVE_INCLUDES` remains
unchanged. So users can still opt-out of transitives includes
entirely.

Reviewed By: #libc, ldionne, philnik

Differential Revision: https://reviews.llvm.org/D132284
2022-08-31 19:50:03 +02:00
Mark de Wever 36e0e2c485 [libc++][format] Allows width arg-id with value 0.
Implements:
- LWG3721 Allow an arg-id with a value of zero for width in std-format-spec

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D130649
2022-08-31 19:19:13 +02:00
Nikolas Klauser 98f6a56f5e [libc++] Enable hash only for the correct types
Also implement LWG3705.
Fixes https://github.com/llvm/llvm-project/issues/55823

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D132338
2022-08-26 17:40:23 +02:00
Nikolas Klauser b978dfbf74 [libc++] Consolidate the different [[nodiscard]] configuration options into a single one
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D129054
2022-08-25 22:01:34 +02:00
Mark de Wever d49a82fafe [NFC][libc++][doc] Improves rst formatting. 2022-08-21 17:16:14 +02:00
Mark de Wever 2ede992c01 [libc++][doc] Updates status of P2291R3.
Work on the paper has started but it's blocked by PR52954.
Updating the status to avoid duplicated effort implementing this paper.
2022-08-20 14:45:17 +02:00
Adrian Vogelsgesang ae071a59bc [libc++][NFC][spaceship] Update status doc 2022-08-19 17:32:05 -07:00
John Ericson e941b031d3 Revert "[cmake] Use `CMAKE_INSTALL_LIBDIR` too"
This reverts commit f7a33090a9.

Unfortunately this causes a number of failures that didn't show up in my
local build.
2022-08-18 22:46:32 -04:00
Adrian Vogelsgesang f1974f039f [libc++] Implement `operator<=>` for `filesystem::directory_entry`
Implements part of P1614R2 "The Mothership has Landed"

Differential Revision: https://reviews.llvm.org/D130860
2022-08-18 14:46:13 -07:00
Adrian Vogelsgesang b3ab3bece0 [libc++] Implement `operator<=>` for `filesystem::path`
Implements part of P1614R2 "The Mothership has Landed"

Differential Revision: https://reviews.llvm.org/D130859
2022-08-18 14:13:48 -07:00
John Ericson f7a33090a9 [cmake] Use `CMAKE_INSTALL_LIBDIR` too
We held off on this before as `LLVM_LIBDIR_SUFFIX` conflicted with it.
Now we return this.

`LLVM_LIBDIR_SUFFIX` is kept as a deprecated way to set
`CMAKE_INSTALL_LIBDIR`. The other `*_LIBDIR_SUFFIX` are just removed
entirely.

I imagine this is too potentially-breaking to make LLVM 15. That's fine.
I have a more minimal version of this in the disto (NixOS) patches for
LLVM 15 (like previous versions). This more expansive version I will
test harder after the release is cut.

Reviewed By: sebastian-ne, ldionne, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D130586
2022-08-18 15:33:35 -04:00
Kent Ross 081dad9e9e [libcxx][spaceship][doc] Repair links and clean up spaceship progress doc
Previously the specification was in a table in paragraph 14 of [container.requirements.general] but it has since been given its own sub section header, 24.2.2.4 [container.opt.reqmts].

This happened in 93ff092d1c

This update also includes misc. other cleanups of the spaceship projects sheet.

Reviewed By: Mordante, avogelsgesang, #libc

Differential Revision: https://reviews.llvm.org/D131928
2022-08-17 12:14:32 -07:00
Adrian Vogelsgesang 877620bd96 [libc++] Implement `operator<=>` for `error_{code,condition}`
Implements part of P1614R2 "The Mothership has Landed"

Differential Revision: https://reviews.llvm.org/D131371
2022-08-15 16:05:53 -07:00
Adrian Vogelsgesang 0e876eda26 [libc++] Implement `operator<=>` for `error_category`
Implements part of P1614R2 "The Mothership has Landed"

Differential Revision: https://reviews.llvm.org/D131363
2022-08-15 16:05:08 -07:00
Kent Ross c4566cac49 [libc++][spaceship] Implement std::variant::operator<=>
Implements [variant.relops] and [variant.monostate.relops] for P1614R2

Reviewed By: Mordante, #libc, avogelsgesang

Differential Revision: https://reviews.llvm.org/D131372
2022-08-14 16:16:52 -07:00
Mark de Wever 22b5adff71 [libc++] Uses operator<=> in string.
Implements part of:
- P1614R2 The Mothership has Landed

Reviewed By: avogelsgesang, #libc, philnik

Differential Revision: https://reviews.llvm.org/D131421
2022-08-14 14:05:05 +02:00
Nikolas Klauser f02120fba2 [libc++] Implement P2417R2 (A more constexpr bitset)
Reviewed By: ldionne, #libc

Spies: jloser, arichardson, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D131218
2022-08-14 10:34:01 +02:00
Adrian Vogelsgesang 41e7665c4b [libc++] Implement `operator<=>` for `thread::id`
The new operator<=> is mapped onto the existing functions
__libcpp_thread_id_equal and __libcpp_thread_id_less. Introducing a
new __libcpp_thread_id_compare_three_way might lead to more efficient
code. Given that we can still introduce __libcpp_thread_id_compare_three_way
later, for this commit I opted to not break ABI. If requested, I will
add __libcpp_thread_id_compare_three_way in a follow-up commit.

Implements part of P1614R2 "The Mothership has Landed"

Differential Revision: https://reviews.llvm.org/D131362
2022-08-13 17:30:55 -07:00
Nikolas Klauser 80c7e93a2a [libc++] Add a bunch of missing _LIBCPP_HIDE_FROM_ABI
Reviewed By: ldionne, Mordante, var-const, huixie90, #libc

Spies: jloser, libcxx-commits, arichardson, miyuki

Differential Revision: https://reviews.llvm.org/D129968
2022-08-13 22:41:22 +02:00
Louis Dionne 497705ff27 [libc++] Reorganize the documentation of extensions for integral types 2022-08-10 17:35:08 -04:00
Adrian Vogelsgesang 2d34cb74b5 [libc++] Implement `thread::id` comparators as free functions
So far, the `thread::id` comparators were implemented as hidden friends.
This was non-conforming and lead to incorrectly rejected C++ code, as
can be seen in the linked Github issue.

Fixes https://github.com/llvm/llvm-project/issues/56187

Differential Revision: https://reviews.llvm.org/D131430
2022-08-10 11:39:50 -07:00
Adrian Vogelsgesang 9df5892804 [libc++] Implement `operator<=>` for `type_index`
Implements part of P1614R2 "The Mothership has Landed"

Differential Revision: https://reviews.llvm.org/D131357
2022-08-09 16:35:17 -07:00
Mark de Wever 195287d90a [libc++][ranges] Sets ranges feature-test macro.
D131234 marked the ranges papers as complete, but it didn't set the
feature-test macro.

Reviewed By: ldionne, var-const, #libc

Differential Revision: https://reviews.llvm.org/D131326
2022-08-09 17:20:36 +02:00
Adrian Vogelsgesang 706b3951b3 [libc++] Implement `operator==` for `filesystem::space_info`
Implements part of P1614R2 "The Mothership has Landed"

Differential Revision: https://reviews.llvm.org/D130861
2022-08-08 10:05:47 -07:00
Adrian Vogelsgesang 3354644aad [libc++][doc] Update `SpaceshipProjects` status to reflect in-flight reviews 2022-08-08 06:39:12 -07:00
Louis Dionne e36f9e13bc [libc++] Allow enabling assertions when back-deploying
When back-deploying to older platforms, we can still provide assertions,
but we might not be able to provide a great implementation for the verbose
handler. Instead, we can just call ::abort().

Differential Revision: https://reviews.llvm.org/D131199
2022-08-08 08:43:34 -04:00
Adrian Vogelsgesang 619e8f46f3 [libc++] Remove `operator!=` from `type_info` in C++20
Implements part of:

* P1614R2 The Mothership has Landed

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D130853
2022-08-06 15:10:38 +02:00
Adrian Vogelsgesang 735240b38f [libc++] Implement `operator<=>` for `unique_ptr`
Implements part of:

  - P1614R2 The Mothership has Landed

Fixes LWG3426

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D130838
2022-08-06 15:09:16 +02:00
Konstantin Varlamov 3fa291fa92 [libc++][ranges][NFC] Mark the completed Ranges papers and issues as done.
The newly-completed papers:
- P0896R4 ("The One Ranges Proposal");
- P1243R4 ("Rangify New Algorithms");
- P1252R2 ("Ranges Design Cleanup");
- P1716R3 ("Range Comparison Algorithms Are Over-Constrained");
- P1871R1 ("Concept traits should be named after concepts");
- P2106R0 ("Alternative wording for GB315 and GB316").

Differential Revision: https://reviews.llvm.org/D131234
2022-08-05 14:03:02 -07:00
Nikolas Klauser 4038c859e5 [libc++][ranges] Implement `ranges::is_permutation`
Co-authored-by: Konstantin Varlamov <varconst@apple.com>

Differential Revision: https://reviews.llvm.org/D127194
2022-08-04 10:54:37 -07:00
Mark de Wever 3818b4df1e [libc++] Uses operator<=> in string_view
Implements:
- LWG3432 Missing requirement for comparison_category

Implements part of:
- P1614R2 The Mothership has Landed

Reviewed By: #libc, ldionne, jloser, philnik

Differential Revision: https://reviews.llvm.org/D130295
2022-08-04 19:13:47 +02:00
Mark de Wever d1d799b696 [libc++][doc] Updates format status page.
Adds the details for P2286 and its status.
2022-08-04 17:40:38 +02:00
Nikolas Klauser a203acb9dd [libc++][ranges] Implement `ranges::clamp`
Differential Revision: https://reviews.llvm.org/D126193
2022-08-04 02:45:32 -07:00
Konstantin Varlamov 36c746ca2d [libc++][ranges] Implement `ranges::rotate`.
Also fix `ranges::stable_sort` and `ranges::inplace_merge` to support
proxy iterators now that their internal implementations can correctly
dispatch `rotate`.

Differential Revision: https://reviews.llvm.org/D130758
2022-08-03 16:04:24 -07:00
Adrian Vogelsgesang 3b217f2f12 [libc++] Implement `operator<=>` for `shared_ptr`
Implements part of:

* P1614R2 The Mothership has Landed

Fixes LWG3427

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D130852
2022-08-03 18:32:45 +02:00
Louis Dionne 3d5d44269c [libc++] More documentation improvements about running tests 2022-08-03 09:25:01 -04:00
Nikolas Klauser 68264b6494 [libc++][ranges] Implement `ranges::{prev, next}_permutation`.
Co-authored-by: Konstantin Varlamov <varconst@apple.com>

Differential Revision: https://reviews.llvm.org/D129859
2022-08-02 22:46:15 -07:00