11096 Commits

Author SHA1 Message Date
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 166b3a86173, which was reverted in
fde1ecdec878b 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
Nikolas Klauser
640274ff1f [libc++][NFC] Refactor __enable_ifs in <cstddef> to be defaulted
template arguments

This makes the library more consistent and reduces the size of mangled
names a bit as a bonus.
2023-10-29 11:49:50 +01:00
Vitaly Buka
22c3d9d9a4 [libc++] Disable test which timeouts on ARM with sanitizers
Introduced with cf0f6a146038ca95e9ab9df40c153fd22015a042 (#70020).

https://lab.llvm.org/buildbot/#/builders/237/builds/5145
https://lab.llvm.org/buildbot/#/builders/236/builds/7004
https://lab.llvm.org/buildbot/#/builders/239/builds/4269

Sometimes it passes with Asan but it's extemly slow

```
Slowest Tests:
1388.61s: llvm-libc++-shared.cfg.in :: std/experimental/simd/simd.reference/reference_assignment.pass.cpp
309.42s:  llvm-libc++-shared.cfg.in :: std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp
```
2023-10-27 14:28:28 -07:00
Louis Dionne
574c5cc9d8 [libc++] Fix incorrect length check in std::basic_filebuf
This patch fixes an ASAN-found issue in std::basic_filebuf where we'd
check the wrong size before proceeding to set our internal buffer to
the externally-provided buffer, leading to the library trying to read
from the incorrect buffer in underflow().

Thanks to Andrey Semin for the patch.

Differential Revision: https://reviews.llvm.org/D154514
2023-10-27 10:21:50 -04:00
Louis Dionne
cb950c9dc9
[libc++] Make sure we implement and test LWG2280 properly (#67670)
We did not mark std::begin/std::end as noexcept for C-style arrays, we
did not have conditional noexcept on cbegin/cend, and we did not mark
array cbegin/cend as constexpr in all Standard modes. Since this is a
LWG issue, we should implement it as a DR in all Standard modes as
usual.

This patch fixes these issues and adds test coverage. Fixes #67471.
2023-10-27 10:19:20 -04:00
Konstantin Varlamov
b3b611fe1a
[libc++] Fix flakiness in atomic_notify_all.pass.cpp (#70436)
Avoid relying on sleep for synchronization.
2023-10-27 09:49:54 -04:00
Rajveer Singh Bharadwaj
dd4891318c
[libc++] Fix _CopySegment helper in ranges::copy(join_view, out) when called in a static assertion context (#69593)
Resolves Issue #69083

The `_CopySegment` helper for `ranges::copy(join_view, out)` is not
`constexpr` causing rejection in `libc++` in a static assertion context
as in the issue snippet.
2023-10-27 11:07:12 +02:00
Vitaly Buka
fde1ecdec8 Revert "[libc++][tests] Fix a few remaining instances of outdated static assertion regexes in our test suite"
Fails like https://lab.llvm.org/buildbot/#/builders/238/builds/6278/steps/11/logs/stdio on many bots.

This reverts commit 166b3a86173666ccf823d09e30f40f4a0d386e18.
2023-10-27 00:02:31 -07:00
Vitaly Buka
8d30e80166 Fix typo in c07903aac7b9bc60d48f0381073285d79642cc3f 2023-10-26 23:44:58 -07:00
Vitaly Buka
c07903aac7 [libc++abi] Disable test with a leaks
Leak could be real, as the code terminates before freeing the memory.
2023-10-26 21:48:56 -07:00
ZhangYin
cf0f6a1460
[libc++] <experimental/simd> Add assignment operator of simd reference (#70020) 2023-10-26 23:09:55 +02:00
Louis Dionne
59750027b9
[libc++][NFC] Remove unused typedefs in filesystem::path helpers (#70331)
I came across those typedefs while working on another change, and I
noticed they were just never used.
2023-10-26 13:10:44 -04:00
Ilya Tocar
178a1fea57
[libc++] Optimize string operator[] for known large inputs (#69500)
If we know that index is larger than SSO size, we know that we can't be
in SSO case, and should access the pointer. This removes extra check
from operator[] for inputs known at compile time to be larger than SSO.
2023-10-26 13:09:20 -04:00
Louis Dionne
166b3a8617 [libc++][tests] Fix a few remaining instances of outdated static assertion regexes in our test suite 2023-10-26 11:31:36 -04:00
Igor Zhukov
c555a12377 [libc++] Make sure std::declval() produces an error when ODR-used
Fixes https://github.com/llvm/llvm-project/issues/61202

Differential Revision: https://reviews.llvm.org/D145376
2023-10-26 11:27:12 -04:00
Nikolas Klauser
a349092061 [libc++] Add __small_buffer
This is an implementation detail for `move_only_function` (and potentially other type-erasing classes).

Reviewed By: #libc, ldionne

Spies: Mordante, ldionne, EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D140259
2023-10-26 17:25:53 +02:00
Louis Dionne
bc792a2843
[libc++] Encode additional ODR-affecting properties in the ABI tag (#69669)
As explained in `__config`, we have an ABI tag that we use to ensure
that we don't run into ODR issues when mixing different versions of
libc++ in multiple TUs. However, the reasoning behind that extends not
only to different versions of libc++, but also to different
configurations of the same version of libc++. In fact, we've been aware
of this for a while but never really bothered to make the change because
ODR issues are often thought to be benign.

Well, it turns out that I just spent over an hour banging my head
against an issue that boils down to our lack of encoding of some ODR
properties in the ABI tag, so here's the patch we should have done a
long time ago.

For now, the ODR properties we encode in the ABI tag are:
- library version
- exceptions vs no-exceptions
- hardening mode

Those are all things that we support different values for on a per-TU
basis and they definitely affect ODR in a meaningful way. We can add
more properties later as we see fit.
2023-10-26 09:05:16 -04:00
Eric
78dcd015b6
Improve CI output. (#70236)
There is currently a major problem with the CI output:

The information you need to see never appears in the visible log.

This is because our logs are very verbose, and list (A) every test as
they run it, and (B) every unsupported tests. This can be thousands of
lines.

(A) was introduced by me when I disabled the PTY progress bar, which
doesn't play nice with log files. That change was an improvement, but I
have now disabled the PTY on the builders, so we can go back to passing
`-s`. When `-s` is passed but no PTY is available, it prints a long
friendly progress indicator.

(B) is solved here by disabling the printing of unsupported tests at the
end of the test suite. While it can be useful on occasion to audit the
list of unsupported tests, it's far from a common operation. Instead
people want to see the log of their failure. We should upload the xml
results, so if auditing is needed, it can be done using that.

Hopefully this change will make it so that the test failures appear in
the actual log output
2023-10-25 18:10:29 -04: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
Louis Dionne
15f179e5d1
[libc++] Remove the Buildkite job that builds documentation (#69992)
Since #69828, we have a Github Action that builds the documentation for
libc++, so we don't need to do it as part of our Buildkite pipeline
anymore.
2023-10-24 14:06:21 +02: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
Hans Wennborg
e2fc68c3db Typos: 'maxium', 'minium' 2023-10-23 10:42:28 +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
Ryan Prichard
07ba499817
[libc++][Android] Disable Android ABI list checking (#69666)
Issue: https://github.com/llvm/llvm-project/issues/69270
2023-10-20 13:26:28 -04:00
Joel E. Denny
080fb3e5b7
[lit] Clean up internal shell parse errors with ScriptFatal (#68496)
Without this patch, the functions `executeScriptInternal` and thus
`runOnce` in `llvm/utils/lit/lit/TestRunner.py` return either a tuple like
`(out, err, exitCode, timeoutInfo)` or a `lit.Test.Result` object. They
return the latter only when there's a lit internal shell parse error in
a RUN line. In my opinion, a more straight-forward way to handle
exceptional cases like that is to use python exceptions.

For that purpose, this patch introduces `ScriptFatal`. Thus, this patch
changes `executeScriptInternal` to always either return the tuple or
raise the `ScriptFatal` exception. It updates `runOnce` and
`libcxx/utils/libcxx/test/format.py` to catch the exception rather than
check for the special return type.

This patch also changes `runOnce` to convert the exception to a
`Test.UNRESOLVED` result instead of `TEST.FAIL`. The former is the
proper result for such a malformed test, for which a rerun (given an
`ALLOW_RETRIES:`) serves no purpose. There are at least two benefits
from this change. First, `_runShTest` no longer has to specially and
cryptically handle this case to avoid unnecessary reruns. Second, an
`XFAIL:` directive no longer hides such a failure [as we saw
previously](https://reviews.llvm.org/D154987#4501125).

To facilitate the `_runShTest` change, this patch inserts the internal
shell parse error diagnostic into the format of the test's normal debug
output rather than suppressing the latter entirely. That change is also
important for [D154987](https://reviews.llvm.org/D154987), which
proposes to reuse `ScriptFatal` for python compile errors in PYTHON
lines or in `config.prologue`. In that case, the diagnostic might follow
debugging output from the test's previous RUN or PYTHON lines, so
suppressing the normal debug output would lose information.
2023-10-20 11:53:18 -04: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
Louis Dionne
7961fa36ba
[libc++] Fix uninitialized algorithms when using unconstrained comparison operators (#69373)
If an iterator passed to std::uninitialized_copy & friends provided an
unconstrained comparison operator, we would trigger an ambiguous
overload resolution because we used to compare against
__unreachable_sentinel in our implementation.

This patch fixes that by only comparing the output iterator when it is
actually required, i.e. in the <ranges> versions of the algorithms.

Fixes #69334
2023-10-19 23:22:11 -07: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
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
Ryan Prichard
a30095a1e4
[libc++][Android] Add libcxx-builder-android Docker image (#69273)
Add a Dockerfile for a new Docker image, libcxx-builder-android, that
extends libcxx-builder with support for testing Android.

The image includes these things:

 * An Android Clang compiler and sysroot.

* The Android platform-tools (e.g. adb), so that an Android buildbot can
run programs on an Android device. At container startup, copy these
platform tools to an "android-platform-tools" Docker volume to share
them with an emulator container. This copying ensures that the emulator
and libcxx-builder containers avoid mismatched adb versions.

* Docker, so that an Android buildbot can manage a sibling Docker
container that runs the Android emulator.

Add an Android-specific run-buildbot-container script for local
development. Currently using this script requires building
libcxx-build-android and an emulator image locally.

Fixes: https://github.com/llvm/llvm-project/issues/69270
Differential Revision: https://reviews.llvm.org/D155271
2023-10-19 17:15:20 -04: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