1170 Commits

Author SHA1 Message Date
ZhangYin
cf0f6a1460
[libc++] <experimental/simd> Add assignment operator of simd reference (#70020) 2023-10-26 23:09:55 +02:00
Jakub Mazurkiewicz
e1e0598e20
[libc++] Update status of P2770R0, P2441R2 and P2711R1 (#70045)
This patch adds a mention that the following papers are in progress:

* P2770R0: #66033
* P2441R2 and P2711R1: #65536
2023-10-24 12:03:12 -07:00
Konstantin Varlamov
45d5a49c51
[libc++][NFC] Remove the list of nodiscard extensions from the docs. (#69546)
This list is a burden to maintain and provides very limited value. A
user wishing to know whether a particular function is declared with a
`nodiscard` extension would be better off grepping the headers.
2023-10-24 14:03:57 +02:00
Nikolas Klauser
5d7f346bd3 [libc++][PSTL] Implement std::rotate_copy
Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155025
2023-10-24 14:02:37 +02:00
Ryan Prichard
dc9ed440b5
[libc++][Android] Enable Android testing in BuildKite CI (#69275)
Enable testing for two NDK configurations:
 - android-ndk-21-def-x86
 - android-ndk-33-goog-x86_64

Fixes: https://github.com/llvm/llvm-project/issues/69270
2023-10-23 14:24:33 -07:00
ZhangYin
dc53410693
[libc++] <experimental/simd> Add operator value_type() of simd reference (#68960) 2023-10-23 11:51:34 +02:00
Nikolas Klauser
d2a46e6480 [libc++][PSTL] Implement std::move
Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155330
2023-10-22 10:25:49 +02:00
Christian Trott
639a0986f3
[libc++] mdspan - implement layout_stride (#69650)
This implements layout_stride for C++23 and with that completes the
implementation of the C++23 mdspan header. The feature test macro is
added, and the status pages updated.

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

Differential Revision: https://reviews.llvm.org/D157171
2023-10-20 08:13:52 -06:00
Ryan Prichard
a7c4ff9a56
[libc++][Android] Don't list Android as supported yet (#69660)
We don't have a pre-commit CI bot running Android tests yet, so this is still WIP.
2023-10-19 18:09:39 -07:00
Ryan Prichard
d173ce4a67
[libc++][Android] Support libc++ testing on Android (#69274)
I could probably break this commit into more pieces.

---

This patch adds libc++ support for Android L (Android 5.0+) and up,
tested using the Android team's current compiler, a recent version of
the AOSP sysroot, and the x86[-64] Android Emulator.

CMake and Lit Configuration:

Add runtimes/cmake/android/Arch-${ARCH}.cmake files that configure CMake
to cross-compile to Android without using CMake's built-in NDK support
(which only works with an actual packaged NDK).

Add libcxx/cmake/caches/AndroidNDK.cmake that builds and tests libc++
(and libc++abi) for Android. This file configures libc++ to match what
the NDK distributes, e.g.:
- libc++_shared.so (includes libc++abi objects, there is no
libc++abi.so). libunwind is linked statically but not exported.
 - libc++_static.a (does not include libc++abi) and libc++abi.a
 - `std::__ndk1` namespace
- All the libraries are built with `__ANDROID_API__=21`, even when they
are linked to something targeting a higher API level.

(However, when the Android LLVM team builds these components, they do
not use these CMake cache files. Instead they use Python scripts to
configure the builds. See
https://android.googlesource.com/toolchain/llvm_android/.)

Add llvm-libc++[abi].android-ndk.cfg.in files that test the Android
NDK's libc++_shared.so. These files can target old or new Android
devices. The Android LLVM team uses these test files to test libc++ for
both arm/arm64 and x86/x86_64 architectures.

The Android testing mode works by setting %{executor} to adb_run.py,
which uses `adb push` and `adb shell` to run tests remotely. adb_run.py
always runs tests as the "shell" user even on an old emulator where "adb
unroot" doesn't work. The script has workarounds for old Android
devices. The script uses a Unix domain socket on the host
(--job-limit-socket) to restrict concurrent adb invocations. Compiling
the tests is a major part of libc++ testing run-time, so it's desirable
to exploit all the host cores without overburdening the test devices,
which can have far fewer cores.

BuildKite CI:

Add a builder to run-buildbot, `android-ndk-*`, that uses Android Clang
and an Android sysroot to build libc++, then starts an Android emulator
container to run tests.

Run the emulator and an adb server in a separate Docker container
(libcxx-ci-android-emulator), and create a separate Docker image for
each emulator OS system image. Set ADB_SERVER_SOCKET to connect to the
container's adb server. Running the only adb server inside the container
makes cleanup more reliable between test runs, e.g. the adb client
doesn't create a `~/.android` directory and the adb server can be
restarted along with the emulator using docker stop/run. (N.B. The
emulator insists on connecting to an adb server and will start one
itself if it can't connect to one.)

The suffix to the android-ndk-* job is a label that concisely specifies
an Android SDK emulator image. e.g.:
 - "system-images;android-21;default;x86" ==> 21-def-x86
 - "system-images;android-33;google_apis;x86_64" ==> 33-goog-x86_64

Fixes: https://github.com/llvm/llvm-project/issues/69270
Differential Revision: https://reviews.llvm.org/D139147
2023-10-19 16:58:30 -04:00
Louis Dionne
a574242f19
[libc++][docs] Update contributing docs to reflect the move to GitHub (#69386)
Fixes #69367
2023-10-18 20:00:50 -07:00
Eric
20f39bf482
Lower std::string's alignment requirement from 16 to 8. (#68807)
This allows smaller allocations to occur, closer to the actual
std::string's required size. This is particularly effective in
decreasing the allocation size upon initial construction (where
__recommend is called to determine the size).

Although the memory savings per-string are never more than 8 bytes per
string initially, this quickly adds up. And has lead to not insigficant
memory savings at Google.

Unfortunately, this change is ABI breaking because it changes the value
returned by max_size. So it has to be guarded.
2023-10-13 11:56:24 -04:00
ZhangYin
593521b079
[libcxx] <experimental/simd> Add generate constructor of class simd (#66737)
Differential Revision: https://reviews.llvm.org/D159442
2023-10-12 07:39:31 -05:00
Martin Storsjö
ebf1feaeda
[libcxx] [docs] Update the MinGW build example (#68790)
The previous example wasn't a configuration that we actually test, but
was a simplistic configuration with libstdc++ as ABI library.

The previous example configuration has bitrotted and broken in a couple
different ways since it was added:

- In b0fd9497af6d2efd305e9eecfa0c1e265f1b2192, libcxx added uses of weak
  symbols that can be overridden by the user. GNU ld fails to export such
  weak symbols on MinGW, resulting in errors like:
    C:/msys64/mingw64/bin/ld: cannot export _ZNSt3__126__libcpp_assertion_handlerEPKciS1_S1_: symbol wrong type (2 vs 3) 
  By switching to using LLD, -DLLVM_ENABLE_LLD=ON, alternatively
  -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld, linking still succeeds.

- In a80e65e00ada7a9c16acf17a5fd40b4f12ced3a8, building with
  -DLIBCXX_CXX_ABI=libstdc++ in this configuration started failing. Switch
  to showing how to build with libcxxabi instead, which is the tested
  configuration and also is the typical configuration in how it most
  usually would be used on Windows.

These updates allow removing the mentions of the old caveats with the
build configuration.
2023-10-11 06:35:08 -07:00
Martin Storsjö
06322d43d5
[libcxx] [docs] Remove mention of a MSVC/Debug mode caveat (#68791)
Since e346fd8a60d4969b29bdd1740a89b1ea43635331 and
cd1b8be8de91bc1c43bac3eea7ebf3b5643b031c, the tests should run fine in
Debug mode, with failed asserts not popping up blocking dialog boxes.
2023-10-11 06:32:45 -07:00
James Y Knight
b964419ec2
[libcxx] Allow string to use SSO in constant evaluation. (#66576)
Previously, libcxx forced all strings created during constant evaluation
to point to allocated memory. That was done due to implementation
difficultites, but it turns out not to be necessary. This patch permits
the use of SSO strings during constant evaluation, and also simplifies
the implementation.

This does have a downside in terms of enabling users to accidentally
write non-portable code, however, which I've documented in
UsingLibcxx.rst.

In particular, whether `constinit std::string x = "...";` will
successfully compile now depends on whether the string is smaller than
the SSO capacity -- in libc++, up to 22 bytes on 64-bit platforms, and
up to 10 bytes on 32-bit platforms. By comparison, libstdc++ and MSVC
have an SSO capacity of 15 bytes, except that in libstdc++,
constant-initialized strings cannot be used as function-locals because
the object contains a pointer to itself.

Closes #68434
2023-10-10 11:31:47 -07:00
Konstantin Varlamov
c6151f5350
[libc++][hardening] Undeprecate safe mode (#68391)
To allow for a smoother transition, keep the safe mode working as is in
the LLVM 18 release (the first release that aims to make hardening
available), then deprecate it in LLVM 19.
2023-10-10 11:10:18 -07:00
Hui
bcf172ec57
[libc++] LWG 3821 uses_allocator_construction_args should have overload for pair-like (#66939)
This change addresses LWG 3821 and LWG 3677.

- make `std::pair`'s constructor no longer takes `subrange`
- `uses_allocator_construction_args` constraint changes w.r.t to
`pair-like` types
- `uses_allocator_construction_args` constraints checks
`is-pair-like<remove_cv_t<T>>`
2023-10-09 13:50:27 +01:00
Nikolas Klauser
a9138cdb36 [libc++] Optimize ranges::count for __bit_iterators
```
---------------------------------------------------------------
Benchmark                                    old            new
---------------------------------------------------------------
bm_vector_bool_count/1                   1.92 ns        1.92 ns
bm_vector_bool_count/2                   1.92 ns        1.92 ns
bm_vector_bool_count/3                   1.92 ns        1.92 ns
bm_vector_bool_count/4                   1.92 ns        1.92 ns
bm_vector_bool_count/5                   1.92 ns        1.92 ns
bm_vector_bool_count/6                   1.92 ns        1.92 ns
bm_vector_bool_count/7                   1.92 ns        1.92 ns
bm_vector_bool_count/8                   1.92 ns        1.92 ns
bm_vector_bool_count/16                  1.92 ns        1.92 ns
bm_vector_bool_count/64                  2.24 ns        2.25 ns
bm_vector_bool_count/512                 3.19 ns        3.20 ns
bm_vector_bool_count/4096                14.1 ns        12.3 ns
bm_vector_bool_count/32768               84.0 ns        83.6 ns
bm_vector_bool_count/262144               664 ns         661 ns
bm_vector_bool_count/1048576             2623 ns        2628 ns
bm_vector_bool_ranges_count/1            1.07 ns        1.92 ns
bm_vector_bool_ranges_count/2            1.65 ns        1.92 ns
bm_vector_bool_ranges_count/3            2.27 ns        1.92 ns
bm_vector_bool_ranges_count/4            2.68 ns        1.92 ns
bm_vector_bool_ranges_count/5            3.33 ns        1.92 ns
bm_vector_bool_ranges_count/6            3.99 ns        1.92 ns
bm_vector_bool_ranges_count/7            4.67 ns        1.92 ns
bm_vector_bool_ranges_count/8            5.19 ns        1.92 ns
bm_vector_bool_ranges_count/16           11.1 ns        1.92 ns
bm_vector_bool_ranges_count/64           52.2 ns        2.24 ns
bm_vector_bool_ranges_count/512           452 ns        3.20 ns
bm_vector_bool_ranges_count/4096         3577 ns        12.1 ns
bm_vector_bool_ranges_count/32768       28725 ns        83.7 ns
bm_vector_bool_ranges_count/262144     229676 ns         662 ns
bm_vector_bool_ranges_count/1048576    905574 ns        2625 ns
```

Reviewed By: #libc, ldionne

Spies: arichardson, ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D156956
2023-10-06 22:58:41 +02:00
Nikolas Klauser
0d7947b08c [libc++] Implement P2614R2 (Deprecate numeric_limits::has_denorm)
Reviewed By: #libc, ldionne

Spies: ldionne, Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155411
2023-10-06 11:30:55 +02: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
Will Hawkins
08e4ccbff8
[libc++][ranges][NFC] Mark ranges::slide_view in progress (#68056)
Mark `ranges::slide_view` implementation as in progress.
2023-10-03 14:05:25 -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
Alexander Richardson
78d649a417
[libc++][lit] Allow overriding the executor for tests (#66545)
This is useful when trying to run multiple tests with different
arguments to the executor script. This is needed in my case since I
do not know the correct ssh connection arguments when building libc++.
The testing script I have spawns multiple QEMU instances that listen on
a given port on localhost and runs lit with the --num-shards/--run-shard
argument. In order to connect each shard to the right QEMU instances I
need to customize the arguments passed to ssh.py (--extra-ssh-args and
--extra-scp-args) but can't do this at configure time since the target
port is only known when running the tests but not when calling CMake.
This change allows me to pass `executor=ssh.py <args>` to lit once I
know
the right hostname/port for running the tests.

This also deprecates the `LIB{CXX,CXXABI,UNWIND}_EXECUTOR` CMake
variable
as the same can be achieved by adding `executor=...` to the
`LIB{CXX,CXXABI,UNWIND}_TEST_PARAMS` variable.
2023-09-26 15:19:31 +01: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
ba94646c76 [libc++][NFC] Qualify mention of va_list with std:: in documentation 2023-09-25 13:40:24 -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
Igor Zhukov
910b76a002 [libc++] Implement LWG-3655: The INVOKE operation and union types
https://cplusplus.github.io/LWG/issue3655

Differential Revision: https://reviews.llvm.org/D144645
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-09-21 05:23:41 -04:00
Daniel Cheng
078651b6de
[libc++] Implement LWG3545: std::pointer_traits should be SFINAE-friendly. (#65177)
See https://wg21.link/LWG3545 for background and details.

Differential Revision: https://reviews.llvm.org/D158922
2023-09-18 08:46:59 -04:00
Hui
695138ca84 [libc++] implement std::jthread 2023-09-16 19:54:19 +01:00
Louis Dionne
4d08eccd63
[libc++] Implement P2538R1 "ADL-proof std::projected" (#65411)
Notice that because Holder<Incomplete> is _possible_ to complete, but
_unsafe_ to complete, that means that Holder<Incomplete>* is basically
not an iterator and it's not even safe to ask if
input_iterator<Holder<Incomplete>*> because that _will_ necessarily
complete the type. So it's totally expected that we still cannot safely
ask e.g.


static_assert(std::indirect_unary_predicate<bool(&)(Holder<Incomplete>&),
Holder<Incomplete>*>);

or even

static_assert(!std::indirect_unary_predicate<int, Holder<Incomplete>*>);

This was originally uploaded as https://reviews.llvm.org/D119029 and I
picked it up here as part of the Github PR transition.

Co-authored-by: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
2023-09-15 10:09:38 -04:00
eric
571e4f233b Mark LWG 2426 as complete.
Atomic is implemented by Clang, and Clang already implements the
behavior in the DR. This was initially noticed by Zoe Carver.
2023-09-14 16:42:57 -04:00
Louis Dionne
cce062d226
[libc++] Reintroduce the removed std::char_traits specialization (#66153)
This partially reverts commit e30a148b098, which removed the base
template for std::char_traits. That base template had been marked as
deprecated since LLVM 16 and we were planning to remove it in LLVM 18.
However, as explained in the post-commit comments in
https://reviews.llvm.org/D157058, the deprecation mechanism didn't work
as expected. Basically, the deprecation warnings were never shown to
users since libc++ headers are system headers and Clang doesn't show
warnings in system headers.

As a result, this removal came with basically no lead time as far as
users are concerned, which is a poor experience. For this reason, I am
re-introducing the deprecated char_traits specialization until we have a
proper way of phasing it out in a way that is not a surprise for users.
2023-09-13 12:30:05 -04:00
Konstantin Varlamov
b85e1862c1 [libc++][hardening] Add back the safe mode.
The safe mode is in-between the hardened and the debug modes, extending
the checks contained in the hardened mode with certain checks that are
relatively cheap and prevent common sources of errors but aren't
security-critical. Thus, the safe mode trades off some performance for
a wider set of checks, but unlike the debug mode, it can still be used
in production.

Differential Revision: https://reviews.llvm.org/D158823
2023-09-12 12:01:51 -07:00
Louis Dionne
3e266905f9 [libc++] Add missing std::ranges::join_view to the list of experimental features 2023-09-12 11:39:17 -04:00
Louis Dionne
06bb6c8b5c
[libc++] Document experimental features in the library (#65994)
Fixes #65125
2023-09-12 11:02:17 -04:00
Zhangyin
ed29f275bf [libcxx] <experimental/simd> Add broadcast constructor of class simd/simd_mask
Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D156225
2023-09-12 11:41:49 +08:00
Zhangyin
a284d0cc9c [libcxx] <experimental/simd> Added aliagned flag types, traits is_simd_flag_type[_v], memory_alignment[_v] and related tests
Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153319
2023-09-12 11:41:44 +08:00
Zhangyin
ce5652c78a [libcxx] <experimental/simd> Added simd width functions, simd_size traits and related tests
Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D144363
2023-09-12 11:41:42 +08:00
Zhangyin
0e30dd44ad [libcxx] <experimental/simd> Add ABI tags, class template simd/simd_mask implementations. Add related simd traits and tests.
[libcxx] <experimental/simd> Add ABI tags, class template simd/simd_mask implementations.
[libcxx] <experimental/simd> Add traits is_abi_tag[_v], is_simd[_v] and is_simd_mask[_v].
[libcxx] <experimental/simd> Add related tests.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D144362
2023-09-12 11:41:40 +08:00
Hristo Hristov
623bb5c2c2 [libc++][ranges][NFC] Status page: Adds enumerate_view patch 2023-09-11 14:43:19 +03:00
Konstantin Varlamov
5795e7ba3e [libc++][hardening][NFC] Fix the 17 release notes to remove mentions of hardening
This is to bring `main` in sync with `release/17.x` after https://reviews.llvm.org/D159171.

Differential Revision: https://reviews.llvm.org/D159454
2023-09-08 11:41:13 -07:00
Will Hawkins
f00e0f2bdc
[libc++][doc] Add warning about limitation of --fresh in boostrapping build (#65265)
Add a warning to the `Building Libcxx` documentation about the
limitations of the utility of `--fresh` at the top level.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2023-09-07 13:22:07 -04:00
h-vetinari
afc96481c4
[libc++] Clean up some minor inconsistencies in the status pages (#65259) 2023-09-07 11:05:19 -04: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
yronglin
9f67143be0 [libc++] Implement LWG3938 (Cannot use std::expected monadic ops with move-only error_type)
Implement LWG3938 (Cannot use std::expected monadic ops with move-only error_type)
https://wg21.link/LWG3938

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D154116
2023-09-06 22:38:29 +08: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
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