Commit Graph

11229 Commits

Author SHA1 Message Date
Dimitrij Mijoski
390840fbdf
[libc++] Fix UTF-8 decoding in codecvts (#68442)
This patch fixes one case where the decoding member function `in()` was
returning `partial` instead of `error`. Additionally, it adds large
testsuite that tests all `codecvt` facets that were added in C++11 and
in C++20. The testsuite covers this bug.

Fixes #60177.
2023-11-27 18:31:03 +01:00
Louis Dionne
12bb2910c3
[libc++] Remove experimental pmr headers now shipped in mainline (#73172)
Several experimental headers around std::pmr have been slated for
removal for a while now. This patch actually performs the removal and
cleanups from the code base.
2023-11-27 10:54:35 -05:00
Louis Dionne
936180a5e8 [libc++][NFC] Fix typo in comment 2023-11-27 10:35:07 -05:00
Stephan T. Lavavej
bf95a0cd20
[libc++][test] Avoid C++23 Core features that MSVC lacks (#73438)
Found while running libc++'s test suite with MSVC's STL, where we use
both Clang and MSVC's compiler.

libc++'s test suite has started using some C++23 Core Language features
that MSVC hasn't implemented yet. When avoiding these features costs
just a tiny bit of syntax, I would like to ask libc++ to consider making
that change in the interest of practical portability, at least until
MSVC catches up. If there's no desire to do so, then I could skip the
affected tests, but that would make me a slightly sad kitty.
2023-11-27 10:24:22 -05:00
h-vetinari
80403e9fee
[libc++] fix some inconsistencies on libcxx status pages (#73471)
Minor things I've noticed from looking at the pages. For the missing
space I actually searched for "``\\\s\w" to see where they were hiding.
2023-11-27 10:14:18 -05:00
Dmitry Vyukov
f8afc53d64
[libc++] Speed up classic locale (#72112)
Locale objects use atomic reference counting, which may be very
expensive in parallel applications. The classic locale is used by
default by all streams and can be very contended. But it's never
destroyed, so the reference counting is also completely pointless on the
classic locale. Currently ~70% of time in the parallel stringstream
benchmarks is spent in locale ctor/dtor. And the execution radically
slows down with more threads.

Avoid reference counting on the classic locale. With this change
parallel benchmarks start to scale with threads.

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>

```
                              │   baseline   │    optimized                            │
                              │    sec/op    │    sec/op      vs base                  │
Istream_numbers/0/threads:1      4.672µ ± 0%   4.419µ ± 0%     -5.42% (p=0.000 n=30+39)
Istream_numbers/0/threads:72   539.817µ ± 0%   9.842µ ± 1%    -98.18% (p=0.000 n=30+40)
Istream_numbers/1/threads:1      4.890µ ± 0%   4.750µ ± 0%     -2.85% (p=0.000 n=30+40)
Istream_numbers/1/threads:72     66.44µ ± 1%   10.14µ ± 1%    -84.74% (p=0.000 n=30+40)
Istream_numbers/2/threads:1      4.888µ ± 0%   4.746µ ± 0%     -2.92% (p=0.000 n=30+40)
Istream_numbers/2/threads:72     494.8µ ± 0%   410.2µ ± 1%    -17.11% (p=0.000 n=30+40)
Istream_numbers/3/threads:1      4.697µ ± 0%   4.695µ ± 5%          ~ (p=0.391 n=30+37)
Istream_numbers/3/threads:72     421.5µ ± 7%   421.9µ ± 9%          ~ (p=0.665 n=30)
Ostream_number/0/threads:1       183.0n ± 0%   141.0n ± 2%    -22.95% (p=0.000 n=30)
Ostream_number/0/threads:72    24196.5n ± 1%   343.5n ± 3%    -98.58% (p=0.000 n=30)
Ostream_number/1/threads:1       250.0n ± 0%   196.0n ± 2%    -21.60% (p=0.000 n=30)
Ostream_number/1/threads:72    16260.5n ± 0%   407.0n ± 2%    -97.50% (p=0.000 n=30)
Ostream_number/2/threads:1       254.0n ± 0%   196.0n ± 1%    -22.83% (p=0.000 n=30)
Ostream_number/2/threads:72      28.49µ ± 1%   18.89µ ± 5%    -33.72% (p=0.000 n=30)
Ostream_number/3/threads:1       185.0n ± 0%   185.0n ± 0%      0.00% (p=0.017 n=30)
Ostream_number/3/threads:72      19.38µ ± 4%   19.33µ ± 5%          ~ (p=0.425 n=30)
```
2023-11-27 07:00:21 +01:00
Stephan T. Lavavej
b84cb9c2e6
[libc++][test] Use LIBCPP_STATIC_ASSERT for std::__mdspan_detail (#73436)
Found while running libc++'s test suite against MSVC's STL.

`libcxx/test/std` should be portable, so these lines checking
`std::__mdspan_detail` machinery should be using `LIBCPP_STATIC_ASSERT`.

I checked for other occurrences and these appear to be the only ones
which have appeared since our last libc++ test suite update.
2023-11-26 17:22:06 -08: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
philnik777
1314e8774f
[libc++] Add missing headers to the modulemap (#71127)
I don't know when, but at some point we lost test coverage to ensue that
all the headers are in the modulemap. This adds a test to make sure all
the headers (excluding a few which shouldn't be part of the modulemap)
are at least mentioned. This also fixes a few headers which bit-rotted
while we were missing the coverage.
2023-11-27 00:14:59 +01:00
philnik777
cd9829c231
[libc++][NFC] Use __construct_at and __destroy_at instead of using preprocessor conditionals (#70866) 2023-11-26 20:47:03 +01:00
philnik777
2c545131b0
[libc++] Fix a few tests that are missing proper suffixes (#73444)
The tests were missing the `.pass.cpp` suffix to be recognized as tests.
As a result, they were never run and some are completely broken.
2023-11-26 20:44:23 +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
Mark de Wever
7c44167daa [libc++] Updates mdspan synopsis,
The class layout_stride has been implemented in
639a0986f3
2023-11-25 14:45:21 +01:00
Mark de Wever
3703e7cb42 [libc++][doc] Fixes grammar issues. 2023-11-25 14:40:55 +01:00
Mark de Wever
494c9e5f59
[libc++] Removes basic_string::reserve(). (#73354)
Implements:
- P2870R3 Remove basic_string::reserve()

---------

Co-authored-by: philnik777 <nikolasklauser@berlin.de>
2023-11-25 13:56:40 +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
Mark de Wever
233e7c5de2
[libc++] Removes codecvt. (#72496)
Implements:
- P2871R3 Remove Deprecated Unicode Conversion Facets from C++26
2023-11-24 17:34:30 +01:00
Mark de Wever
92d9f232dd
[libc++] Implements Runtime format strings II. (#72543)
Implements
- P2918R2 Runtime format strings II
2023-11-24 17:30:33 +01:00
ZhangYin
ba89749cd2
[libc++] <experimental/simd> Add implicit type conversion constructor for class simd/simd_mask (#71132) 2023-11-24 00:29:41 +01:00
philnik777
e90845fb9e
[libc++][NFC] Move QoI attributes into a single place inside <__config> (#70870)
We have quite a few macros scattered around in `<__config>` which are
there for QoI purposes. To make things a bit simpler this patch moves
all these attributes into a single place.
2023-11-23 22:15:06 +01:00
Anton Rydahl
aea7929b0a
[libc++] Unify __is_trivial_equality_predicate and __is_trivial_plus_operation into __desugars_to (#68642)
When working on an OpenMP offloading backend for standard parallel
algorithms (https://github.com/llvm/llvm-project/pull/66968) we noticed
the need of a generalization of `__is_trivial_plus_operation`. This patch
merges `__is_trivial_equality_predicate` and `__is_trivial_plus_operation`
into `__desugars_to`, and in the future we might extend the latter to support
other binary operations as well.

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-11-23 13:55:55 -05:00
Louis Dionne
1fb91beb17 [libc++][NFC] Adjust synopsis for std::launder 2023-11-23 11:11:51 -05:00
Louis Dionne
026776fb60
[libc++] Refactor the creation of the global and classic locales (#72581)
The creation of the global and the classic locales was pretty twisty.
This patch refactors how this is done to reduce the amount of
indirections and prepare the terrain for a future where GCC implements
the no_destroy attribute.
2023-11-23 10:28:57 -05:00
Louis Dionne
97952aa319 [libc++][NFC] Run clang-format on uses_alloc_types.h 2023-11-23 10:24:35 -05:00
Vitaly Buka
dc40415a8b
[libc++][test][msan] Refine XFAIL after #67799 (#73213)
Undo a part of #73152.

These test do not hang, but unexpectedlty pass on aarch64
https://lab.llvm.org/buildbot/#/builders/74/builds/23708

Tests work on aarch64 and probably any platform without fp80.
2023-11-23 10:19:02 -05:00
Louis Dionne
4b1fe097f9
[libc++] Simplify the conditions for generating a linker script (#73151)
We really shouldn't be depending on far away configuration options like
LLVM_HAVE_LINK_VERSION_SCRIPT here. This patch simplifies the enablement
of the linker scripts and as a result gets rid of an undesirable
dependency on HandleLLVMOptions.cmake.

As a drive-by, the patch also stops taking into account whether Python3
is available. This should have no bearing on whether we generate a
linker script or not, which is required for correctness. If someone
tries to build libc++ and generate a linker script but Python3 is not
available, they should get an error instead of silently getting an
incorrect installation of the library.
2023-11-23 10:15:03 -05:00
Louis Dionne
48f5855e4c
[libc++] Remove the deprecated _LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED macro (#73164)
We release-noted that we were going to remove it in the LLVM 18 timeline
and we've been issuing a warning since then.
2023-11-22 17:49:05 -05:00
Louis Dionne
07fdc084fe [libc++] Add missing check for C++17 in test
This was never caught on our bots because this specific test is marked
as `XFAIL: !is-lockfree-runtime-function`, which is the case on our bots.
2023-11-22 16:44:01 -05:00
Louis Dionne
6772c4f248
[libc++] Remove the ignore_format.txt file (#73135)
The ignore_format.txt file and the associated checks have been causing a
lot of confusion since we introduced them. Formatting becomes one of the
main hurdle for contributors (especially new contributors), and that is
not great.

The original goal of ignore_format.txt was to enforce clang-format only
in a subset of the files of the project. In practice, we have now
shifted to a model where we have a Github action that checks whether new
code surrounding edits is formatted. In that context, it probably
doesn't make sense to keep having a ignore list for formatting files.

After this patch, the clang-format job will enforce that all new code is
formatted properly, and that all edits to existing files are formatted
properly, regardless of which files the edits are in. This seems
reasonable and I believe will lead to much less confusion than our
current setup.

In the future, we could consider clang-formatting the whole code base
once and for all but this requires a bit of upfront technical work to
put in place a merge driver to help resolve merge conflicts across
formatting changes.
2023-11-22 15:21:01 -05:00
Louis Dionne
a9c149df76 [libc++] Document upcoming removal of _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT in LLVM 19 2023-11-22 15:06:00 -05:00
Louis Dionne
6f0c52e56f
[libc++] Refactor atomic_{unsigned,signed}_lock_free (#73041)
Their definition was a bit roundabout and it was actually wrong since
atomic_unsigned_lock_free would be a signed type whenever
__cxx_contention_t is lock free, which is most of the time.

Fixes #72968
2023-11-22 14:54:40 -05:00
bgra8
5d73c7d1af
[libc++] Re-introduce special support for narrowing conversions to bool in variant (#73121)
This patch re-introduces special support for narrowing conversions to
bool
in std::variant, which was removed in 170810fca6 in order to make
libc++
Standards-conforming.

The special support is gated by the
`_LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT`
macro and will be supported for LLVM 18 only as a courtesy to help large
code bases migrate over to the Standard behavior.

---------

Co-authored-by: Bogdan Graur <bgraur@google.com>
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-11-22 20:41:12 +01:00
Vitaly Buka
9be9f622bf
[libc++][test][msan] Fix bots after #67799 (#73152)
This adds a few UNSUPPORTED annotations for tests that hang on some
msan bots:

https://lab.llvm.org/buildbot/#/builders/sanitizer-x86_64-linux-bootstrap-msan
https://lab.llvm.org/buildbot/#/builders/sanitizer-aarch64-linux-bootstrap-msan

We still haven't figured out the root cause of them hanging on these 
bots but not on the main libc++ CI infra.
2023-11-22 14:13:05 -05:00
Hui
de7fbfeef5
[libc++] Floating Point Atomic (#67799)
- implement P0020R6 Floating Point Atomic

Differential Revision: https://reviews.llvm.org/D153981
2023-11-22 11:48:49 +00:00
Louis Dionne
ca9b1d1ac7
[libc++] Make common_iterator's data member private (#72564)
Fixes #71498
2023-11-21 16:22:59 -05:00
Konstantin Varlamov
bed1a5b342
[libc++][hardening] Categorize all ryu assertions as internal (#71853)
These assertions can only be triggered by bugs in the algorithm's
implementation; all user inputs should be handled gracefully.
2023-11-21 12:09:35 -08:00
Eric
46a8479448
[libc++] Promote android to supported. (#72949)
The bots have been running smoothly for a while. Check out
https://libcxx.efcs.ca/cistats.html for more info.
2023-11-21 14:47:25 -05:00
Louis Dionne
9824040ad5
[libc++] Don't open-close namespace std in __config (#72695)
This doesn't seem necessary and it is just kind of weird to do that in
__config, so remove it.
2023-11-20 13:32:49 -05:00
Louis Dionne
5cd24759c4
[libc++] Reduce the compilation time required by SIMD tests (#72602)
Testing all the SIMD widths exhaustively is nice in theory, however in
practice it leads to extremely slow tests. Given that
1. our testing resources are finite and actually pretty costly
2. we have thousands of other tests we also need to run
3. the value of executing these SIMD tests for absolutely all supported
SIMD widths is fairly small compared to cherry-picking a few relevant
widths

I think it makes a lot of sense to reduce the exhaustiveness of these
tests. I'm getting a ~4x speedup for the worst offender
(reference_assignment.pass.cpp) after this patch.

I'd also like to make this a reminder to anyone seeing this PR that
tests impact everyone's productivity. Slow unit tests contribute to
making the CI slower as a whole, and that has a direct impact on
everyone's ability to iterate quickly during PRs. Even though we have a
pretty robust CI setup in place, we should remember that it doesn't come
for free and should strive to keep our tests at a good bang for the buck
ratio.
2023-11-20 13:27:59 -05:00
Louis Dionne
c38ae74b48
[libc++] Stop checking for trailing whitespace in check-generated-output (#72711)
Trailing whitespace is removed by clang-format, so if someone tries to
check-in new code with trailing whitespaces, it'll be caught by the
clang-format job. Removing this duplication helps reduce the confusion
around our numerous ways of enforcing formatting rules.
2023-11-20 11:23:24 -05:00
philnik777
5a305cea52
[libc++] Use __is_pointer_in_range for char_traits checks (#72643)
This allows us to also check the constraints during constant evaluation.
2023-11-19 16:49:40 +01:00
PragmaTwice
a3f17ba3fe [libc++] Implement P2467R1: Support exclusive mode for fstreams
This patch brings std::ios_base::noreplace from P2467R1 to libc++.
This requires compiling the shared library in C++23 mode since otherwise
fstream::open(...) doesn't know about the new flag.

Differential Revision: https://reviews.llvm.org/D137640
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-11-17 17:27:30 -05:00
Louis Dionne
0133e25d99 [runtimes][NFC] Remove trailing whitespace 2023-11-17 16:50:49 -05:00
Louis Dionne
a1ae7e97de
[libc++] Fix char_traits deprecation message (LLVM 18 -> 19) (#72690)
We intend to remove the base specialization in LLVM 19, not LLVM 18. We
simply forgot to update the deprecation message accordingly.
2023-11-17 14:32:11 -05:00
Eric
9ed4a57e31
Add libc++ github actions workflow to replace buildkite (#71836)
This change ports almost all of the linux buildkite builders to github
actions.

I would like to have this transition occur as soon as possible.
2023-11-17 08:57:01 -05:00
Louis Dionne
b034da7dad [libc++][NFC] Fix include guard for simd helper header 2023-11-16 22:00:37 -05:00
Tacet
00da5eb86e
[NFC] Remove outdated comment (#72591)
Special-casing has been already removed.
2023-11-16 21:23:07 -05:00
Mark de Wever
003a3b04b0
[libc++] Fixes lit portability issues. (#72435)
@StephanTLavavej mentioned the libc++ tests no longer works for MSVC
STL. The regex changes have been provided by Stephan.
2023-11-16 17:56:34 -05:00
Louis Dionne
f97a579b74 [runtimes] Add TODO about CXX_STANDARD_REQUIRED being off after review comment 2023-11-16 14:58:52 -05:00
Eric
f4e3fb5972
Refactor dockerfile to support Buildkite AND Github Actions (#71954)
This change adds the image used by the self-hosted Github Actions
builders.

In an attempt to make the transition simple, all of the different images
share as much of the same state as possible, including packages, users,
etc... This results in bigger images, but that shouldn't be a problem.
That said, the refactorings caused the buildkite image to shrink by 100
MB.

This change also renames all of the packages for consistency. Bots will
have to be changed to use the new package names eventually.

Again, docker-compose was used as the source of truth for defining
argument.

I have already pushed example images to ghcr.io/libcxx/<name>:testing
2023-11-16 12:52:46 -05:00
Mark de Wever
d04c019d28 [NFC][libc++] Fixes double space in comment. 2023-11-16 14:09:18 +01:00
Will Hawkins
b57abb721e
[libc++] Fix minor formatting error in test/support/counting_projection.h (#72480)
Causing CI/CD to fail.
2023-11-16 12:08:19 +01:00
Mark de Wever
56daf026ba [libc++][doc] Updates format status page. 2023-11-16 10:23:21 +01:00
Mark de Wever
1bcb56ecb5
[libc++] Adds tests for deprecation macros. (#72425) 2023-11-16 10:21:22 +01:00
Mark de Wever
f49ccca86a
[libc++] Update status after the Kona meeting. (#72421)
This updates:
- The status tables
- Feature test macros (including previously missing ones)
- New headers for modules
2023-11-16 10:17:19 +01:00
David Benjamin
170810fca6
P1957R2: remove special-case for booleans in std::variant (#71502)
This picks up the std::variant half of P1957R2. Fixes #62332.
2023-11-15 23:50:58 +01:00
philnik777
b25d36c3ab
[libc++] Extend is_trivially_equality_comparable to integral types with the same signedness and size (#70344)
This enables all optimizations that rely on
`is_trivially_equality_comparable` to work with these integral types,
for example `std::equal` and `std::find`.
2023-11-15 23:40:05 +01:00
Nikolas Klauser
c81bfc61da [libc++] Optimize for_each for segmented iterators
```
---------------------------------------------------
Benchmark                       old             new
---------------------------------------------------
bm_for_each/1               3.00 ns         2.98 ns
bm_for_each/2               4.53 ns         4.57 ns
bm_for_each/3               5.82 ns         5.82 ns
bm_for_each/4               6.94 ns         6.91 ns
bm_for_each/5               7.55 ns         7.75 ns
bm_for_each/6               7.06 ns         7.45 ns
bm_for_each/7               6.69 ns         7.14 ns
bm_for_each/8               6.86 ns         4.06 ns
bm_for_each/16              11.5 ns         5.73 ns
bm_for_each/64              43.7 ns         4.06 ns
bm_for_each/512              356 ns         7.98 ns
bm_for_each/4096            2787 ns         53.6 ns
bm_for_each/32768          20836 ns          438 ns
bm_for_each/262144        195362 ns         4945 ns
bm_for_each/1048576       685482 ns        19822 ns
```

Reviewed By: ldionne, Mordante, #libc

Spies: bgraur, sberg, arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D151274
2023-11-14 23:55:24 +01:00
S. B. Tam
4ee747f8d3
[libc++][test] Don't use __libcpp_is_constant_evaluated in tests (#72226) 2023-11-14 19:04:57 +08:00
Eric
c66d5f57ce
Attempt entire rewrite of buildkite pipeline using anchors. (#71624)
This uses YAML anchors to deduplicate a lot of the pipeline LOC.

This makes it a lot easier to navigate through the file and to make modifications.
2023-11-13 17:06:25 -05:00
Nikolas Klauser
8b73be5f57 [libc++] Readd _LIBCPP_CONSTINIT
This isn't used by libc++, but it's still used in libc++abi.
2023-11-13 13:07:32 +01:00
Nikolas Klauser
9e618e5ed4 [libc++][NFC] Remove a few unused macros from <__config> 2023-11-13 12:57:59 +01:00
Louis Dionne
e734bc53de
[libc++] Remove _LIBCPP_HAS_NO_FGETPOS_FSETPOS (#72073)
Instead of using individual macros to turn off missing C library
features, we use the using_if_exists attribute now. This patch removes
the _LIBCPP_HAS_NO_FGETPOS_FSETPOS macro used to workaround missing
fgetpos and fsetpos on older versions of Android -- using_if_exists
should take care of those in the headers and we should add appropriate
XFAILs to the tests instead of using TEST_HAS_NO_FGETPOS_FSETPOS.
2023-11-13 09:43:25 +01:00
Duo Wang
d05bada592
[libcxx][test] std::array::iterator are not pointers by C++ standard (#70729)
This is to modify a list of libcxx tests written under the assumption
that iterators for std::array, std::string_view, and std::string are
pointers. The motivation for this PR is to make the tests more universal
and potentially being used to test other C++ standard library
implementations, for example
[microsoft/STL](https://github.com/microsoft/STL).

I can confirm that this patch makes a number of tests compatible with
microsoft STL:
`Failed :  204 (2.12%)`  ->  `Failed :  136 (1.42%)`
, and does not break any tests on `libcxx`.

This is not a complete list of such incompatibilities, but I am hoping
this will start a discussion about whether we are open to accepting such
changes.
2023-11-12 17:30:15 +01:00
Louis Dionne
acb9156266 [libc++][NFC] Fix license comment typo
Fixes #72024
2023-11-11 08:24:19 -10:00
Eric
601e8fdd28
Rehome libcxx-builder docker image & attempt gentler termination. (#71604)
There are three changes present in this PR.

1. Use github packages for libcxx-builder rather than dockerhub.

The ldionne/libcxx-builder image will now be hosted at
ghcr.io/libcxx/libcxx-builder. This has the benefit of allowing members
of the github org to push new versions.

In the future I hope to add github actions to rebuild the image as
needed.

2. Add docker-compose file

The compose file allows to to specify the package repository, so that
users can simply write 'docker compose build' and 'docker compose push'.

It also gives us a centralized place to manage version arguments which
change frequently.

3. Use non-shell CMD form.

This may help the google libcxx builders disconnect more gracefully as
the shell form of CMD may eat the shutdown signal. I'm hoping this
corrects inaccurate agent counts from the buildkite API, since when the
VM's terminate, they do so without signaling it to buildkite, which
hangs around waiting for them to reconnect. It's likely more changes
will be needed though.

---------

Co-authored-by: Mark de Wever <zar-rpg@xs4all.nl>
2023-11-10 08:24:39 -05:00
Louis Dionne
ea89965b3c
[libc++] Update Clang version check in __config (#71849)
We only support Clang >= 16, but we seem to have forgotten to update the
version check in __config to reflect that.
2023-11-10 01:55:20 +01:00
Alexander Richardson
d002ce55f2
[runtimes] Add a qemu-system executor script (#68643)
This is useful when trying to test libc++/libc++abi/libunwind against a
baremetal enviroment (e.g. picolibc).

See also https://reviews.llvm.org/D155521
2023-11-09 21:09:06 +00:00
Louis Dionne
553ae2f866
[libc++] Remove outdated _LIBCPP_CLANG_VER check (#71759)
We always use Clang >= 16 now, so the check for Clang >= 14 is
tautological. As a drive-by, clang-format the header.
2023-11-09 09:09:39 -10:00
Jake Egan
67d29fbd49
[libc++][AIX] Adjust support of timespec_get test (#71827)
The function `timespec_get` is not available without an update to the
time.h header in AIX 7.3 TL2 (7.3.2.*).
2023-11-09 09:05:32 -10:00
Tacet
8a454e1e3c
[libc++][ASan] Removing clang version checks (#71673)
This commit removes checks like `_LIBCPP_CLANG_VER >= 1600` related to
ASan annotations. As only 2 previous versions are supported, it's a TODO
for LLVM 18.
2023-11-08 16:28:08 -10:00
Konstantin Varlamov
64d413efdd
[libc++][hardening] Rework macros for enabling the hardening mode. (#70575)
1. Instead of using individual "boolean" macros, have an "enum" macro
`_LIBCPP_HARDENING_MODE`. This avoids issues with macros being
mutually exclusive and makes overriding the hardening mode within a TU
more straightforward.

2. Rename the safe mode to debug-lite.

This brings the code in line with the RFC:
https://discourse.llvm.org/t/rfc-hardening-in-libc/73925

Fixes #65101
2023-11-08 09:10:00 -10:00
Mark de Wever
3d131f960e
[libc++][CI] Adds a new CMake version in Docker. (#71582)
This allows testing the upcoming CMake 3.28 release in the CI. CMake
3.28 will have non-experimental support for C++20 modules. So this would
be a better CMake version for the modular builds.

The goal is to remove CMake 3.27 from the CI when the builder work
properly with 3.28.
2023-11-08 17:51:27 +01:00
Mark de Wever
7cc72a0a2e Implement syncstream (p0053)
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
2023-11-08 17:45:06 +01:00
Konstantin Varlamov
b85fdc4ffd
[libc++][hardening] Add _LIBCPP_ASSERT_NON_NULL to check for null pointers (#71428) 2023-11-07 16:12:15 -10:00
Louis Dionne
02540b2f6d
[libc++] Make sure ranges algorithms and views handle boolean-testable correctly (#69378)
Before this patch, we would fail to implicitly convert the result of
predicates to bool, which means we'd potentially perform a copy or move
construction of the boolean-testable, which isn't allowed. The same
holds true for comparing iterators against sentinels, which is allowed
to return a boolean-testable type.

We already had tests aiming to ensure correct handling of these types,
but they failed to provide appropriate coverage in several cases due to
guaranteed RVO. This patch fixes the tests, adds tests for missing
algorithms and views, and fixes the actual problems in the code.

Fixes #69074
2023-11-06 21:19:49 -10:00
Louis Dionne
b3857b2ecf
[libc++][NFC] Make data members of counted_iterator private (#70491)
There's no reason for them to be public AFAICT. I came across this while
auditing the code bases for places where we'd be using
[[no_unique_address]] incorrectly. Since one of these members is marked
as [[no_unique_address]], this is an extra reason to keep this private
to ensure the member isn't escaped anywhere.
2023-11-06 09:23:21 -10:00
Zoe Carver
7a62bee611 [libc++] Implement std::experimental::observer_ptr
This patch adds std::experimental::observer_ptr (n4282) and also
fixes LWG2516.

Co-Authored-By: Louis Dionne <ldionne.2@gmail.com>
Differential Revision: https://reviews.llvm.org/D63230
2023-11-05 17:59:04 -07:00
Louis Dionne
cf7d4f543c
[libc++] Handle threads-related .cpp files like we do all other source files (#71100)
Source files in libc++ are added to the CMake targets only if they are
required by the configuration. We do this pretty consistently for all
configurations like no-filesystem, no-random-device, etc. but we didn't
do it for no-threads. This patch makes this consistent for no-threads,
which is helpful in reducing the amount of work required to port libc++
to some platforms without threads.

Indeed, with the previous approach, several threads-related source files
would end up including headers that might fail to compile properly on
some platforms. This issue is sidestepped entirely by making the
approach for no-threads consistent with the other configurations.
2023-11-05 17:08:24 -07:00
Louis Dionne
25a2d51842
[libc++] Guard the whole print.cpp file with _LIBCPP_WIN32API (#71122)
The print.cpp source file is only used when building on Windows. Avoid
including anything else but <__config> in the file in the case where
there's nothing to compile here at all. As a drive-by change, use
_LIBCPP_WIN32API consistently instead of _WIN32.
2023-11-05 16:24:34 -07:00
Louis Dionne
2b4b26ea84
[libc++] Improve tests for std::find_if and std::find_if_not (#71192)
These tests are salvaged from https://reviews.llvm.org/D112152 which I
decided not to pursue anymore.
2023-11-05 16:23:27 -07:00
Louis Dionne
8a7846fe86
[libc++] Bump the C++ Standard used to compile the dylib to C++23 (#66824)
This is necessary in order to implement some papers like P2467R1, which
require using C++23 declarations in the dylib. It is a good habit to
keep building the dylib with a recent standard version regardless.

With this patch, we also stop strictly enforcing that the targets are
built with C++23. Concretely, C++23 will soon be required in order to
build the dylib, but not enforcing it strictly works around some issues
like the documentation bots using an old and unsupported compiler. Since
these bots do not actually build the library, not strictly enforcing the
C++ Standard makes our CMake build more resilient to these kinds of
situation. This is just a workaround though, the better way of going
about would be to update the compiler on the documentation bot but we
don't seem to have control over that.
2023-11-05 08:40:51 -05:00
Konstantin Varlamov
aa9f14a52d
[libc++][format] Fix a missing include in <format> tests. (#71252) 2023-11-05 08:32:51 -05:00
Ryan Prichard
76b1a7c916
[libc++][Android] Explicitly declare low-level lib existence (#70534)
Android's librt and libpthread functionality is part of libc.{a,so}
instead. The atomic APIs are part of the compiler-rt builtins archive.
Android does have libdl.

Android's libc.so has `__cxa_thread_atexit_impl` starting in API 23, and
the oldest supported API is 21, so continue using feature detection for
that API.

These settings need to be declared explicitly for the sake of the fuzzer
library's custom libc++ build `add_custom_libcxx`. That macro builds
libc++ using `-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY`, which
breaks the feature detection.
2023-11-03 12:54:55 -07:00
Louis Dionne
1061c0150b
[libc++] Remove legacy feature suse-linux-enterprise-server-11 (#71103)
This Lit feature is not defined anywhere anymore and that platform is
not on our radar for support, so this is basically dead code.
2023-11-03 09:48:38 -04:00
Konstantin Varlamov
fe300f35ca
[libc++][hardening] Add tests for the hardened mode with ABI breaks. (#71020)
Add a new test mode that enables the hardened mode in combination with
ABI-breaking changes (only bounded iterators currently) and reenable the
bounded iterator tests for `span` and `string_view`.
2023-11-03 09:46:19 -04:00
Konstantin Varlamov
766772342c
[libc++][hardening] Clean up some legacy debug mode tests: (#71016)
- reenable a few tests that still pass under the new debug mode;
- delete a placeholder test;
- delete a test that is no longer relevant.
2023-11-02 15:02:57 -07:00
Konstantin Varlamov
e98195f318
[libc++] Fix another potentially flaky atomic test. (#71011)
This is a follow-up to https://github.com/llvm/llvm-project/pull/70436.
2023-11-01 23:57:05 -07: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
Louis Dionne
dba04bbcf4
[libc++] Add a %{verify} substitution (#70878)
This makes it easier to write .sh.cpp tests that perform multiple clang-verify checks in the same test.
2023-11-01 14:35:18 -07:00
ZhangYin
e3c2eacfd8
[libc++] <experimental/simd> Add default constructor for class simd/simd_mask (#70424) 2023-11-01 10:51:23 -04:00
Louis Dionne
979c19ab12
[libc++] Fix complexity guarantee in ranges::clamp (#68413)
This patch prevents us from calling the projection more than 3 times in
std::clamp, as required by the Standard.

Fixes #64717
2023-11-01 10:43:05 -04:00
Will Hawkins
8c0e2963eb
[libc++][NFC] Update ignore_format for expected tests (#70869)
After changes to <expected>, more test files are now properly formatted.
2023-10-31 23:56:46 +01:00
Jake Egan
4fc7019791 [libc++][AIX] Add OS version to target triple
This will allow for configuring tests according to AIX version.

Reviewed By: daltenty, #libc, Mordante

Differential Revision: https://reviews.llvm.org/D149660
2023-10-31 16:23:05 -04:00
Jade Lovelace
a3ee0d4fac
[libc++] Remove unnecessary <cstdint> include from <string> (#70613)
<string> doesn't use any declarations from <cstdint> and this doesn't change
the transitive includes, so this is effectively a NFC cleanup.
2023-10-31 13:30:24 -04:00
philnik777
e7de95595c
[libc++] Remove alignment_of uses (#70591)
There is no reason to use `alignment_of<T>` instead of `alignof(T)` or
`_LIBCPP_ALIGNOF(T)`. It only makes the code more verbose and results in
slightly worse compile times.
2023-10-31 10:24:44 -04:00
Petr Hosek
a5403a3a69
[libcxx] Amend XFAIL for failing tests on Windows (#70422)
Some tests starting passing/failing after #69431 because Clang no longer
enables -fdelayed-template-parsing by default on Windows with C++20.
2023-10-30 23:45:03 -04:00
Jan Kokemüller
134c915955
[libc++] Fix UB in <expected> related to "has value" flag (#68552) (#68733)
The calls to std::construct_at might overwrite the previously set
__has_value_ flag in the case where the flag is overlapping with
the actual value or error being stored (since we use [[no_unique_address]]).
To fix this issue, this patch ensures that we initialize the
__has_value_ flag after we call std::construct_at.

Fixes #68552
2023-10-30 14:56:03 -04:00
Louis Dionne
3c5885535a
[libc++][tests] Fix a few remaining instances of outdated static assertion regexes in our test suite (#70454)
This is a re-application of 166b3a8617, which was reverted in
fde1ecdec8 because it broke some tests.
2023-10-30 17:28:51 +01:00
philnik777
a65070a76a
[libc++] Remove a few transitive includes (#70553) 2023-10-29 18:31:37 +01:00