329 Commits

Author SHA1 Message Date
Mark de Wever
b271b44158
[libc++] Guard call_once against operator hijacking. (#128054) 2025-03-18 18:06:24 +01:00
Kadir Cetinkaya
f059e58702
Revert "[libc++] Don't try to wait on a thread that hasn't started in std::async (#125433)"
This reverts commit 11766a40972f5cc853e296231e5d90ca3c886cc1.
2025-03-10 15:13:41 +01:00
A. Jiang
fa5db05ca3
[libc++][test] XFAIL for FreeBSD in thread_create_failure.pass.cpp (#129413)
Per https://man.freebsd.org/cgi/man.cgi?query=setrlimit, FreeBSD's
`setrlimit` seems to limit the number of processes, not threads via
`RLIMIT_NPROC`. So this test should be XFAIL for FreeBSD.
2025-03-02 11:35:22 +01:00
Thurston Dang
5e4938a991
Exclude hwasan from thread_create_failure.pass.cpp (#128768)
Fixes hwasan buildbot failure

(https://lab.llvm.org/buildbot/#/builders/55/builds/7536/steps/10/logs/stdio)
introduced in https://github.com/llvm/llvm-project/pull/125433 by
excluding this test for hwasan, similar to the existing exclusion of
asan.
2025-02-25 12:18:07 -08:00
Nikolas Klauser
11766a4097
[libc++] Don't try to wait on a thread that hasn't started in std::async (#125433)
If the creation of a thread fails, this causes an idle loop that will
never end because the thread wasn't started in the first place.

Fixes #125428
2025-02-25 13:33:17 +01:00
Nikolas Klauser
9ebc6f5d6d
[libc++] Include headers in <thread> conditionally (#116539) 2024-11-20 23:07:20 +01:00
Nikolas Klauser
85ef9666c8
[libc++] Avoid including all of <thread> in <future> (#116541) 2024-11-18 20:04:05 +01:00
Nikolas Klauser
2e43a304f1
[libc++] Granularize <vector> (#99705)
|                    | old time | new time |
| ------------------ | -------- | -------- |
| functional - c++23 | 416ms    | 225ms    |
| random - c++23     | 513ms    | 392ms    |
| vector - c++17     | 206ms    | 100ms    |
2024-10-25 11:28:46 +02:00
Louis Dionne
121ed5c198
[libc++] Remove test suite annotations for experimental stop_token (#110890)
<stop_token> is not experimental anymore, so its tests shouldn't be
guarded by libcpp-has-no-experimental-stop_token.
2024-10-03 09:05:16 -04:00
Louis Dionne
09e3a36058
[libc++][modules] Fix missing and incorrect includes (#108850)
This patch adds a large number of missing includes in the libc++ headers
and the test suite. Those were found as part of the effort to move
towards a mostly monolithic top-level std module.
2024-09-16 15:06:20 -04:00
Louis Dionne
33325524f5
[libc++][modules] Refactor poisoned_hash_helper (#108296)
The poisoned_hash_helper header was relying on an implicit forward
declaration of std::hash located in <type_traits>. When we improve the
modularization of the library, that causes issues, in addition to being
a fundamentally non-portable assumption in the test suite.

It turns out that the reason for relying on a forward declaration is to
be able to test that std::hash is *not* provided if we don't include any
header that provides it. But testing that is actually both non-portable
and not really useful.

Indeed, what harm does it make if additional headers provide std::hash
specializations? That would certainly be conforming -- the Standard
never requires an implementation to avoid providing a declaration when a
given header is included, instead it mandates what *must* be provided
for sure. In that spirit, it would be conforming for e.g. `<cstddef>` to
define the hash specializations if that was our desire. I also don't
read https://wg21.link/P0513R0 as going against that statement. Hence,
this patch just removes that test which doesn't carry its weight.

Fixes #56938
2024-09-12 15:07:49 -04:00
Louis Dionne
99174842ae
[libc++] Make std::jthread supported in non-experimental mode (#107900)
We waited before supporting std::jthread fully because we wanted to
investigate other implementation strategies (in particular one involving
std::mutex). Since then, we did some benchmarking and decided that we
wouldn't be moving forward with std::mutex. Hence, there is no real
reason to punt on making std::jthread & friends non-experimental.
2024-09-12 09:48:59 -04:00
A. Jiang
3a0ef2a2d3
[libc++] Reland LWG2921 and LWG2976 (#107960)
They were originally implemented in d42db7e083ee0 but reverted later in
a2f3c63282330be0.

This PR implement both LWG issues again, guarding the removed functions
with `_LIBCPP_STD_VER <= 14`, because they should be treated as patches 
for P0302R1 which was adopted for C++17.

Fixes #103598
Fixes #103755
2024-09-11 17:46:59 -04:00
Nikolas Klauser
9ff0468436
[libc++] Refactor the std::unique_lock tests (#102151)
This makes some of the tests not flaky anymore, updates some tests to
also work in C++03 and modernizes them in general.
2024-08-22 11:47:56 +02:00
Louis Dionne
1e5f275f36
[libc++] Refactor the tests for mutex, recursive mutex and their timed counterparts (#104852)
This refactoring is done to remove flakyness as described in
https://github.com/llvm/llvm-project/pull/89083.
2024-08-21 08:47:22 -04:00
Louis Dionne
bf1666fb0b
[libc++] Drop support for the C++20 Synchronization Library before C++20 (#82008)
When we initially implemented the C++20 synchronization library, we
reluctantly accepted for the implementation to be backported to C++03
upon request from the person who provided the patch. This was when we
were only starting to have experience with the issues this can create,
so we flinched. Nowadays, we have a much stricter stance about not
backporting features to previous standards.

We have recently started fixing several bugs (and near bugs) in our
implementation of the synchronization library. A recurring theme during
these reviews has been how difficult to understand the current code is,
and upon inspection it becomes clear that being able to use a few recent
C++ features (in particular lambdas) would help a great deal. The code
would still be pretty intricate, but it would be a lot easier to reason
about the flow of callbacks through things like
__thread_poll_with_backoff.

As a result, this patch drops support for the synchronization library
before C++20. This makes us more strictly conforming and opens the door
to major simplifications, in particular around atomic_wait which was
supported all the way to C++03.

This change will probably have some impact on downstream users, however
since the C++20 synchronization library was added only in LLVM 10 (~3
years ago) and it's quite a niche feature, the set of people trying to
use this part of the library before C++20 should be reasonably small.
2024-07-31 17:53:09 -04:00
Louis Dionne
6a54dfbfe5 [libc++][NFC] Add missing license headers
Also standardize the license comment in several files where it was
different from what we normally do.
2024-07-31 12:58:09 -04:00
Paul Kirth
e9d5842ac7
[libc++] Make std::unique_lock available with _LIBCPP_HAS_NO_THREADS (#99562)
This is a follow up to https://github.com/llvm/llvm-project/pull/98717,
which made lock_guard available under _LIBCPP_HAS_NO_THREADS. We can
make unique_lock available under similar circumstances. This patch
follows the example in #98717, by:

  - Removing the preprocessor guards for _LIBCPP_HAS_NO_THREADS in the
    unique_lock header.
  - providing a set of custom mutex implementations in a local header.
  - using custom locks in tests that can be made to work under
    `no-threads`.
2024-07-31 08:15:55 -07:00
Louis Dionne
29ef92b905
[libc++] Refactor tests for shared_mutex and shared_timed_mutex (#100783)
This makes the tests less flaky and also makes a few other refactorings
like using traits instead of .compile.fail.cpp tests.
2024-07-31 09:27:01 -04:00
Petr Hosek
6192f458f4
[libc++] Make std::lock_guard available with _LIBCPP_HAS_NO_THREADS (#98717)
This change makes `std::lock_guard` available when
`_LIBCPP_HAS_NO_THREADS` is set. This class is generic and doesn't
require threading support, and is regularly used even in environments
where threading isn't available like embedded.

fixes #89891

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2024-07-16 21:58:13 -07:00
Hui
840e857a19
[libc++] Fix sporadic test failure in condition_variable notify_all test (#97622)
fixes #95944
2024-07-12 15:56:30 +01:00
Louis Dionne
3497500946
[libc++] Clean up and update deployment target features (#96312)
This patch removes many annotations that are not relevant anymore since
we don't support or test back-deploying to macOS < 10.13. It also cleans
up raw usage of target triples to identify versions of dylibs shipped on
prior versions of macOS, and uses the target-agnostic Lit features
instead. Finally, it reorders both the Lit backdeployment features and
the corresponding availability macros in the library in a way that makes
more sense, and reformulates the Lit backdeployment features in terms of
when a version of LLVM was introduced instead of encoding the system
versions on which it hasn't been introduced yet. Although one can be
derived from the other, encoding the negative form is extremely
error-prone.

Fixes #80901
2024-06-28 10:40:35 -05:00
Louis Dionne
db8c7e004a
[libc++] Fix deployment target Lit features (#94791)
We were not making any distinction between e.g. the "Apple-flavored"
libc++ built from trunk and the system-provided standard library on
Apple platforms. For example, any test that would be XFAILed on a
back-deployment target would unexpectedly pass when run on that
deployment target against the tip of trunk Apple-flavored libc++. In
reality, that test would be expected to pass because we're running
against the latest libc++, even if it is Apple-flavored.

To solve this issue, we introduce a new feature that describes whether
the Standard Library in use is the one provided by the system by
default, and that notion is different from the underlying standard
library flavor. We also refactor the existing Lit features to make a
distinction between availability markup and the library we're running
against at runtime, which otherwise limit the flexibility of what we can
express in the test suite. Finally, we refactor some of the
back-deployment versions that were incorrect (such as thinking that LLVM
10 was introduced in macOS 11, when in reality macOS 11 was synced with
LLVM 11).

Fixes #82107
2024-06-21 10:31:22 -04:00
Stephan T. Lavavej
88ff2463ea
[libc++][test] Avoid -Wunused-variable warnings in mutex tests (#94907)
After enhancing MSVC's STL to statically initialize our condition_variable,
Clang began noticing that some mutexes in the test suite were unused.
2024-06-10 09:54:56 -04:00
Stephan T. Lavavej
45964eb9b8
[libc++] [test] Fix __has_include usage, expand condvarany and spaceship coverage (#94120)
Three unrelated, small improvements:

* `test_macros.h` was incorrectly saying `__has_include("<version>")`
instead of `__has_include(<version>)`.
+ This caused `<ciso646>` to always be included (noticed because MSVC's
STL emitted a deprecation warning).
  + I searched all of LLVM and found no other occurrences.
* `thread.condition.condvarany/wait_for_pred.pass.cpp` forgot to test
anything.
  + I followed what `wait_for.pass.cpp` is testing.
* Uncomment spaceship test coverage.
2024-06-02 12:37:31 +02:00
Louis Dionne
ac88ad3c80
[libc++] Refactor tests for std::condition_variable (#91530)
These tests have always been flaky, which led us to using ALLOW_RETRIES
on them. However, while investigating #89083 (using Github provided
macOS builders), these tests surfaced as being basically unworkably
flaky in that environment.

This patch solves that problem by refactoring the tests to make them
succeed deterministically.
2024-05-23 10:33:25 -04:00
Mark de Wever
f98a3dd7a2
[NFC][libc++][test] Removes C++98 support. (#92930)
Libc++ has no separate C++98 support, it uses C++03 instead. This
removes some obsolete c++98 markers in the test.

Thanks to @StephanTLavavej for spotting this.
2024-05-22 11:05:01 +02:00
Louis Dionne
0012b1ea84
[libc++] Refactor flaky tests for std::shared_lock (#91779)
This makes the tests non-flaky.
2024-05-21 15:08:47 -07:00
Nikolas Klauser
17f006207c
[libc++] Granularize <ostream> (#85537)
This also includes `<__ostream/basic_ostream.h>` in `<sstream>` now,
reducing the include time of `<complex>` from 819ms to 603ms.
2024-05-02 22:38:44 +02:00
Louis Dionne
9ddedf07ed
[libc++] Deprecate the C++20 synchronization library before C++20 (#86410)
When we initially implemented the C++20 synchronization library, we
reluctantly accepted for the implementation to be backported to C++03
upon request from the person who provided the patch. This was when we
were only starting to have experience with the issues this can create,
so we flinched. Nowadays, we have a much stricter stance about not
backporting features to previous standards.

We have recently started fixing several bugs (and near bugs) in our
implementation of the synchronization library. A recurring theme during
these reviews has been how difficult to understand the current code is,
and upon inspection it becomes clear that being able to use a few recent
C++ features (in particular lambdas) would help a great deal. The code
would still be pretty intricate, but it would be a lot easier to reason
about the flow of callbacks through things like
__thread_poll_with_backoff.

As a result, this patch deprecates support for the synchronization
library before C++20. In the next release, we can remove that support
entirely.
2024-04-16 10:57:48 -04:00
Hui
81e2693c12
[libc++][test] Fix race condition in condition_variable_any tests (#84788)
Some tests in `condition_variable_any` use two `shared_lock` to guard,
which does not work.
The fix is to make the writer to use `unique_lock`
2024-03-24 20:52:47 +00:00
A. Jiang
63ae5099b7
[libc++][test] Don't include test_format_context.h in parse.pass.cpp (#83734)
The `parse.pass.cpp` tests doen't need to call
`test_format_context_create` to create a `basic_format_context`, so they
shouldn't include `test_format_context.h`.

The `to_address` mechanism works around the iterator debugging
mechanisms of MSVC STL. Related to
[LWG3989](https://cplusplus.github.io/LWG/issue3989).

Discovered when implementing `formatter<tuple>` in MSVC STL. With the
inclusion removed, `std/utilities/format/format.tuple/parse.pass.cpp`
when using enhanced MSVC STL (and `/utf-8` option for MSVC).
2024-03-11 10:55:16 -04:00
Po-yao Chang
08fe7df600
[libc++][format] Don't treat a closing '}' as part of format-spec (#81305)
This allows:
```
std::println("{}>42", std:🧵:id{});
std::println("{}>42", std::span<int>{});
std::println("{}>42", std::pair{42, "Hello"sv});
std::println("{:}>42", std:🧵:id{});
std::println("{:}>42", std::span<int>{});
std::println("{:}>42", std::pair{42, "Hello"sv});
```
to compile and run.
2024-02-16 02:41:07 +08:00
Hui
825658856d
[libc++] fix counting_semaphore lost wakeups (#79265)
Fixes #77659
Fixes #46357

Picked up from https://reviews.llvm.org/D114119
2024-02-05 13:59:48 +00:00
Hui
85a8e5c3e0
[libc++] fix condition_variable_any hangs on stop_request (#77127)
When I implemented `condition_variable_any::wait`, I missed the most
important paragraph in the spec:

> The following wait functions will be notified when there is a stop
request on the passed stop_token.
> In that case the functions return immediately, returning false if the
predicate evaluates to false.

From
https://eel.is/c++draft/thread.condition#thread.condvarany.intwait-1.

Fixes #76807
2024-01-20 21:18:44 +00:00
Stephan T. Lavavej
64addd6521
[libc++][test] Enhance ADDITIONAL_COMPILE_FLAGS, use TEST_MEOW_DIAGNOSTIC_IGNORED sparingly (#75317)
This is the last PR that's needed (for now) to get libc++'s tests
working with MSVC's STL.

The ADDITIONAL_COMPILE_FLAGS machinery is very useful, but also very
problematic for MSVC, as it doesn't understand most of Clang's compiler
options. We've been dealing with this by simply marking anything that
uses ADDITIONAL_COMPILE_FLAGS as FAIL or SKIPPED, but that creates
significant gaps in test coverage.

Fortunately, ADDITIONAL_COMPILE_FLAGS also supports "features", which
can be slightly enhanced to send Clang-compatible and MSVC-compatible
options to the right compilers.

This patch adds the gcc-style-warnings and cl-style-warnings Lit features,
and uses that to pass the appropriate warning flags to tests. It also uses
TEST_MEOW_DIAGNOSTIC_IGNORED for a few local suppressions of MSVC
warnings.
2023-12-14 17:38:27 -05:00
Stephan T. Lavavej
b2cc4b994e
[libc++][test] Fix more MSVC and Clang warnings (#74965)
Found while running libc++'s tests with MSVC's STL.

*
`libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/ranges_sort_heap.pass.cpp`
+ Fix Clang `-Wunused-variable`, because `LIBCPP_ASSERT` expands to
nothing for MSVC's STL.
+ This is the same "always void-cast" change that #73437 applied to the
neighboring `complexity.pass.cpp`. I missed that
`ranges_sort_heap.pass.cpp` was also affected because we had disabled
this test.
*
`libcxx/test/std/input.output/file.streams/fstreams/ifstream.members/buffered_reads.pass.cpp`
*
`libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/buffered_writes.pass.cpp`
+ Fix MSVC "warning C4244: '`=`': conversion from '`__int64`' to
'`_Ty`', possible loss of data".
+ This is a valid warning, possibly the best one that MSVC found in this
entire saga. We're accumulating a `std::vector<std::streamsize>` and
storing the result in `std::streamsize total_size` but we actually have
to start with `std::streamsize{0}` or we'll truncate.
*
`libcxx/test/std/input.output/filesystems/fs.enum/enum.path.format.pass.cpp`
+ Fix Clang `-Wunused-local-typedef` because the following usage is
libc++-only.
+ I'm just expanding it at the point of use, and using the dedicated
`LIBCPP_STATIC_ASSERT` to keep the line length down.
*
`libcxx/test/std/input.output/syncstream/syncbuf/syncstream.syncbuf.assign/swap.pass.cpp`
+ Fix MSVC "warning C4242: 'argument': conversion from '`int`' to
'`const _Elem`', possible loss of data".
+ This is a valid warning (possibly the second-best) as `sputc()`
returns `int_type`. If `sputc()` returns something unexpected, we want
to know, so we should separately say `expected.push_back(CharT('B'))`.
*
`libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.pass.cpp`
*
`libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_nothrow.pass.cpp`
  + Fix MSVC "warning C6001: Using uninitialized memory '`x`'."
  + [N4964](https://wg21.link/N4964) \[new.delete.single\]/12:
> *Effects:* The deallocation functions
(\[basic.stc.dynamic.deallocation\]) called by a *delete-expression*
(\[expr.delete\]) to render the value of `ptr` invalid.
  + \[basic.stc.general\]/4:
> When the end of the duration of a region of storage is reached, the
values of all pointers representing the address of any part of that
region of storage become invalid pointer values (\[basic.compound\]).
Indirection through an invalid pointer value and passing an invalid
pointer value to a deallocation function have undefined behavior. Any
other use of an invalid pointer value has implementation-defined
behavior.
+ In certain configurations, after `delete x;` MSVC will consider `x` to
be radioactive (and in other configurations, it'll physically null out
`x` as a safety measure). We can copy it into `old_x` before deletion,
which the implementation finds acceptable.
*
`libcxx/test/std/ranges/range.adaptors/range.elements/general.pass.cpp`
*
`libcxx/test/std/ranges/range.adaptors/range.elements/iterator/deref.pass.cpp`
+ Fix MSVC "warning C4242: 'initializing': conversion from '`_Ty`' to
'`_Ty`', possible loss of data".
+ This was being emitted in `pair` and `tuple`'s perfect forwarding
constructors. Passing `short{1}` allows MSVC to see that no truncation
is happening.
*
`libcxx/test/std/ranges/range.adaptors/range.elements/iterator/member_types.compile.pass.cpp`
+ Fix MSVC "warning C4242: 'initializing': conversion from '`_Ty`' to
'`_Ty2`', possible loss of data".
+ Similarly, this was being emitted in `pair`'s perfect forwarding
constructor. After passing `short{1}`, I reduced repetition by relying
on CTAD. (I can undo that cleanup if it's stylistically undesirable.)
*
`libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp`
+ Fix MSVC "warning C4930: '`std::reference_wrapper<int> purr(void)`':
prototyped function not called (was a variable definition intended?)".
+ There's no reason for `purr()` to be locally declared (aside from
isolating it to a narrow scope, which has minimal benefits); it can be
declared like `meow()` above. 😸
*
`libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared_for_overwrite.pass.cpp`
*
`libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique_for_overwrite.default_init.pass.cpp`
  + Fix MSVC static analysis warnings when replacing `operator new`:
    ```
warning C28196: The requirement that '(_Param_(1)>0)?(return!=0):(1)' is
not satisfied. (The expression does not evaluate to true.)
warning C6387: 'return' could be '0': this does not adhere to the
specification for the function 'new'.
warning C6011: Dereferencing NULL pointer 'reinterpret_cast<char
*>ptr+i'.
    ```
+ All we need is a null check, which appears in other `operator new`
replacements:
b85f1f9b18/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size.replace.pass.cpp (L27-L28)
2023-12-10 13:46:40 -08:00
Stephan T. Lavavej
164c204a19
[libc++][test] Fix simple warnings (#74186)
Found while running libc++'s tests with MSVC's STL. This fixes 3 kinds of warnings:

- Add void-casts to fix `-Wunused-variable` warnings.
- Avoid sign/truncation warnings in `ConvertibleToIntegral.h`.
- Add `TEST_STD_AT_LEAST_23_OR_RUNTIME_EVALUATED` to avoid mixing preprocessor 
  and runtime tests.
- Cleanup: Add `TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED` for
  consistency.
2023-12-05 09:46:41 -05:00
Nikolas Klauser
1ee41b4153 [libc++][NFC] Update the remaining old license headers 2023-12-01 11:29:43 +01:00
Stephan T. Lavavej
f5832bab6f
[libc++][test] Cleanup typos and unnecessary semicolons (#73435)
I've structured this into a series of commits for even easier reviewing,
if that helps. I could easily split this up into separate PRs if
desired, but as this is low-risk with simple edits, I thought one PR
would be easiest.

* Drop unnecessary semicolons after function definitions.
* Cleanup comment typos.
* Cleanup `static_assert` typos.
* Cleanup test code typos.
+ There should be no functional changes, assuming I've changed all
occurrences.
* ~~Fix massive test code typos.~~
+ This was a real problem, but needed more surgery. I reverted those
changes here, and @philnik777 is fixing this properly with #73444.
* clang-formatting as requested by the CI.
2023-11-27 02:11:24 +01:00
Stephan T. Lavavej
346a29908e
[libc++][test] Fix unused and nodiscard warnings (#73437)
Found while running libc++'s test suite with MSVC's STL.

This is structured into a series of commits for easier reviewing; I
could also split this into smaller PRs if desired.

* Add void-casts for `invoke_r` calls to fix MSVC STL `[[nodiscard]]`
warnings.
+ Our rationale is that if someone is calling `invoke_r<NonVoidType>`,
it sure looks like they care about the return value.
* Add `[[maybe_unused]]` to silence `-Wunused-parameter` warnings.
+ This happens because the parameters are used within `LIBCPP_ASSERT`,
which vanishes for MSVC's STL. This also motivates the following
changes.
* Add `[[maybe_unused]]` to fix `-Wunused-variable` warnings.
* Always void-cast `debug_comparisons` to fix `-Wunused-variable`
warnings.
+ As this was already unused with a void-cast in one
`_LIBCPP_HARDENING_MODE` branch, I'm simply lifting it next to the
variable definition.
* Add `[[maybe_unused]]` to fix `-Wunused-local-typedef` warnings.
2023-11-26 18:00:18 +01:00
philnik777
12563ea640
[libc++][NFC] Refactor _LIBCPP_AVAILABILITY_HAS_* macros to always be defined (#71002)
This makes the conditionals quite a bit simpler to understand, since it
avoids double negatives and makes sure we have <__availability>
included. For vendors which use availability macros, it also enforces
that they check when specific features are introduced and define the
macro for their platform appropriately.
2023-11-24 23:45:17 +01:00
philnik777
ec350ad418
[libc++] Remove availability annotations which can never be triggered (#69226)
According to https://developer.apple.com/support/xcode/, quite a few of
our availability macros don't do anything anymore, so we might as well
remove them to clean up the code a bit.
2023-11-01 23:56:43 +01:00
Ryan Prichard
bce3b50593
[libc++][Android] Mark tests XFAIL/UNSUPPORTED (#69271)
Mark tests as necessary to accommodate Android L (5.0 / API 21) and up.

Add three Android lit features:
 - android
 - android-device-api=(21,22,23,...)
 - LIBCXX-ANDROID-FIXME (for failures that need follow-up work)

Enable an AIX workaround in filesystem_test_helper.h for the broken
chmod on older Android devices.

Mark failing test with XFAIL or UNSUPPORTED:
 - Mark modules tests as UNSUPPORTED, matching other configurations.
 - Mark a gdb test as UNSUPPORTED.
 - XFAIL tests for old devices that lack an API (fmemopen).
- XFAIL various FS tests (because SELinux blocks FIFO and hard linking,
because fchmodat is broken on old devices).
- XFAIL various locale tests (because Bionic has limited locale
support). (Also XFAIL an re.traits test.)
- XFAIL some print.fun tests because the error exception has no system
error string.
- Mark std::{cin,wcin} tests UNSUPPORTED because they hang with
adb_run.py on old devices.
 - Mark a few tests UNSUPPORTED because they allocate too much memory.
 - notify_one.pass.cpp is flaky on Android.
- XFAIL libc++abi demangler test because of Android's special long
double on x86[-64].

N.B. The `__ANDROID_API__` macro specifies a minimum required API level
at build-time, whereas the android-device-api lit feature is the
detected API level of the device at run-time. The android-device-api
value will be >= `__ANDROID_API__`.

This commit was split out from https://reviews.llvm.org/D139147.

Fixes: https://github.com/llvm/llvm-project/issues/69270
2023-10-19 17:27:01 -07:00
Louis Dionne
475e154331
[libc++] Introduce make_test_jthread for jthread tests (#68837)
This patch introduces the support::make_test_jthread utility which is
basically the same as support::make_test_thread but for std::jthread. It
allows vendors to maintain a downstream way to create threads for use
within the test suite, which is especially useful for embedded
platforms.
2023-10-13 10:54:54 -07:00
Marek Kurdej
d2cb198f25 [libc++] Make future_error constructor standard-compliant
This patch removes the non compliant constructor of std::future_error
and adds the standards compliant constructor in C++17 instead.

Note that we can't support the constructor as an extension in all
standard modes because it uses delegating constructors, which require
C++11. We could in theory support the constructor as an extension in
C++11 and C++14 only, however I believe it is acceptable not to do that
since I expect the breakage from this patch will be minimal.

If it turns out that more code than we expect is broken by this, we can
reconsider that decision.

This was found during D99515.

Differential Revision: https://reviews.llvm.org/D99567
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-10-05 09:11:49 -04:00
Hui
4fa812bb52 [libc++] Implement std::condition_variable_any::wait[_for/until] overloads that take stop_token
- This is section 32.6.4 of P0660R10
- https://eel.is/c++draft/thread.condvarany.intwait

Differential Revision: https://reviews.llvm.org/D153441
2023-09-29 13:50:16 +01:00
Louis Dionne
9bb9ec380a
[libc++][NFC] Simplify checks for static assertions in .verify.cpp tests (#67559)
We don't neeed to handle both spellings anymore since we don't support
Clang 15 anymore.
2023-09-28 09:07:08 -04:00
Louis Dionne
580d26ae46
[libc++] Remove the CI job testing Clang 15 (#66406)
Since LLVM 17 has been branched and is on the verge of being released,
we can drop the CI job that tests against Clang 15. I think the number
of cherry-picks to `release/17.x` will be a lot smaller now, so keeping
a Clang 15 job around for that purpose seems unnecessary.

As a fly-by, this patch also removes some Clang 15 workarounds and test
suite annotations as we usually do. It also removes some slightly older
gcc test suite annotations that were missed.
2023-09-25 17:55:59 -04:00
Louis Dionne
5f2da9c80d
[runtimes] Bump the supported AppleClang version to AppleClang 15 (#67065)
AppleClang 15 was released on September 18th and is now stable. Per our
policy, we're bumping the supported AppleClang compiler to the latest
release. This allows cleaning up the test suite, but most importantly
unblocking various other patches that are blocked on bumping the
compiler requirements.
2023-09-25 09:46:01 -04:00