Commit Graph

9094 Commits

Author SHA1 Message Date
Louis Dionne
6de59ca417 [libc++] Introduce LIBCXX_LIBRARY_VERSION
This allows controlling the current_version linker property on Apple
platforms.

Differential Revision: https://reviews.llvm.org/D125686
2022-05-17 08:36:19 -04:00
Louis Dionne
193f458c30 [libc++] Remove overly conservative error in <stdatomic.h>
As mentionned in D97044, it is fine if users include <atomic> and then
include <stdatomic.h> -- we don't need to error out for that case.

Differential Revision: https://reviews.llvm.org/D125579
2022-05-16 15:30:01 -04:00
Louis Dionne
efcee4b06d [libc++] Remove the legacy LIBCXX_LIBCPPABI_VERSION option
I think this notion of libc++abi's version was relevant a long time ago
on Apple platforms when we were using a Xcode project to build the library.
As part of moving Apple's build to CMake, D59489 made it possible to
specify the "ABI version" of libc++abi in use. However, it's not possible
to build libc++abi with that old ABI anymore and we don't need the ability
to link against that version from libc++ anymore.

Hence, we can clean this up and stop falsely pretending that libc++abi
has more than one ABI version.

Differential Revision: https://reviews.llvm.org/D125687
2022-05-16 15:23:43 -04:00
Louis Dionne
aa656f6c2d [runtimes] Introduce object libraries
This is a variant of D116689 rebased on top of the new (proposed) ABI
refactoring in D120727. It should conserve the basic properties of the
original patch by @phosek, except it also allows cleaning up the merging
of libc++abi into libc++ from the libc++ side.

Differential Revision: https://reviews.llvm.org/D125393
2022-05-16 08:41:16 -04:00
Joe Loser
496e135b03
[libc++][test] Verify std::views::drop and std::views::join are CPOs
`std::views::drops` and `std::views::join` have been implemented, but the tests
verifying the CPOs for them are still commented out. Uncomment the tests.

Differential Revision: https://reviews.llvm.org/D125618
2022-05-14 22:11:36 -06:00
varconst
44ae09d75f [libc++][ranges][NFC] Mark completed issues related to the One Ranges Proposal.
Quite a few C++20 LWG issues/papers related to the One Ranges Proposal
were already effectively implemented (or contain semantic-only wording
changes that don't affect the implementation), mark them as such.

Differential Revision: https://reviews.llvm.org/D125065
2022-05-14 13:08:51 -07:00
Nikolas Klauser
5d55ffe94d [libc++] Simplify the string structures a bit more
This simplifies the string structs a bit more and the normal layout should not contain any undefined behaviour anymore. I don't think there is a way to achieve this in the alternate string mode without breaking the ABI.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D125496
2022-05-14 22:07:50 +02:00
Mark de Wever
6c11aebd30 [libc++] Improve std::to_chars for base != 10.
This improves the speed of `to_chars` for bases 2, 8, and 16.
These bases are common and used in `<format>`. This change
uses a lookup table, like done in base 10 and causes an increase
in code size. The change has a small overhead for the other bases.

```
Benchmark                             Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------
BM_to_chars_good/2                 -0.9476         -0.9476           252            13           252            13
BM_to_chars_good/3                 +0.0018         +0.0018           145           145           145           145
BM_to_chars_good/4                 +0.0108         +0.0108           104           105           104           105
BM_to_chars_good/5                 +0.0159         +0.0160            89            91            89            91
BM_to_chars_good/6                 +0.0162         +0.0162            80            81            80            81
BM_to_chars_good/7                 +0.0117         +0.0117            72            73            72            73
BM_to_chars_good/8                 -0.8643         -0.8643            64             9            64             9
BM_to_chars_good/9                 +0.0095         +0.0095            60            60            60            60
BM_to_chars_good/10                +0.0540         +0.0540             6             6             6             6
BM_to_chars_good/11                +0.0299         +0.0299            55            57            55            57
BM_to_chars_good/12                +0.0060         +0.0060            48            49            49            49
BM_to_chars_good/13                +0.0102         +0.0102            48            48            48            48
BM_to_chars_good/14                +0.0184         +0.0185            47            48            47            48
BM_to_chars_good/15                +0.0269         +0.0269            44            45            44            45
BM_to_chars_good/16                -0.8207         -0.8207            37             7            37             7
BM_to_chars_good/17                +0.0241         +0.0241            37            38            37            38
BM_to_chars_good/18                +0.0221         +0.0221            37            38            37            38
BM_to_chars_good/19                +0.0222         +0.0223            37            38            37            38
BM_to_chars_good/20                +0.0317         +0.0317            38            39            38            39
BM_to_chars_good/21                +0.0342         +0.0341            38            39            38            39
BM_to_chars_good/22                +0.0336         +0.0336            36            38            36            38
BM_to_chars_good/23                +0.0222         +0.0222            34            35            34            35
BM_to_chars_good/24                +0.0185         +0.0185            31            32            31            32
BM_to_chars_good/25                +0.0157         +0.0157            32            32            32            32
BM_to_chars_good/26                +0.0181         +0.0181            32            32            32            32
BM_to_chars_good/27                +0.0153         +0.0153            32            32            32            32
BM_to_chars_good/28                +0.0179         +0.0179            32            32            32            32
BM_to_chars_good/29                +0.0189         +0.0189            32            33            32            33
BM_to_chars_good/30                +0.0212         +0.0212            32            33            32            33
BM_to_chars_good/31                +0.0221         +0.0221            32            33            32            33
BM_to_chars_good/32                +0.0292         +0.0292            32            33            32            33
BM_to_chars_good/33                +0.0319         +0.0319            32            33            32            33
BM_to_chars_good/34                +0.0411         +0.0410            33            34            33            34
BM_to_chars_good/35                +0.0515         +0.0515            33            34            33            34
BM_to_chars_good/36                +0.0502         +0.0502            32            34            32            34
BM_to_chars_bad/2                  -0.8752         -0.8752            40             5            40             5
BM_to_chars_bad/3                  +0.1952         +0.1952            21            26            21            26
BM_to_chars_bad/4                  +0.3626         +0.3626            16            22            16            22
BM_to_chars_bad/5                  +0.2267         +0.2268            17            21            17            21
BM_to_chars_bad/6                  +0.3560         +0.3559            14            19            14            19
BM_to_chars_bad/7                  +0.4599         +0.4600            12            18            12            18
BM_to_chars_bad/8                  -0.5074         -0.5074            11             5            11             5
BM_to_chars_bad/9                  +0.4814         +0.4814            10            15            10            15
BM_to_chars_bad/10                 +0.7761         +0.7761             2             4             2             4
BM_to_chars_bad/11                 +0.3948         +0.3948            12            16            12            16
BM_to_chars_bad/12                 +0.3203         +0.3203            10            13            10            13
BM_to_chars_bad/13                 +0.3067         +0.3067            11            14            11            14
BM_to_chars_bad/14                 +0.2235         +0.2235            12            14            12            14
BM_to_chars_bad/15                 +0.2675         +0.2675            11            14            11            14
BM_to_chars_bad/16                 -0.1801         -0.1801             7             5             7             5
BM_to_chars_bad/17                 +0.5651         +0.5651             7            11             7            11
BM_to_chars_bad/18                 +0.5407         +0.5406             7            11             7            11
BM_to_chars_bad/19                 +0.5593         +0.5593             8            12             8            12
BM_to_chars_bad/20                 +0.5823         +0.5823             8            13             8            13
BM_to_chars_bad/21                 +0.6032         +0.6032             9            15             9            15
BM_to_chars_bad/22                 +0.6407         +0.6408             9            14             9            14
BM_to_chars_bad/23                 +0.6292         +0.6292             7            12             7            12
BM_to_chars_bad/24                 +0.5784         +0.5784             6            10             6            10
BM_to_chars_bad/25                 +0.5784         +0.5784             6            10             6            10
BM_to_chars_bad/26                 +0.5713         +0.5713             7            10             7            10
BM_to_chars_bad/27                 +0.5969         +0.5969             7            11             7            11
BM_to_chars_bad/28                 +0.6131         +0.6131             7            11             7            11
BM_to_chars_bad/29                 +0.6937         +0.6937             7            11             7            11
BM_to_chars_bad/30                 +0.7655         +0.7656             7            12             7            12
BM_to_chars_bad/31                 +0.8939         +0.8939             6            12             6            12
BM_to_chars_bad/32                 +1.0157         +1.0157             6            13             6            13
BM_to_chars_bad/33                 +1.0279         +1.0279             7            14             7            14
BM_to_chars_bad/34                 +1.0388         +1.0388             7            14             7            14
BM_to_chars_bad/35                 +1.0990         +1.0990             7            15             7            15
BM_to_chars_bad/36                 +1.1503         +1.1503             7            15             7            15
```

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D97705
2022-05-14 13:01:35 +02:00
Mark de Wever
c74753f959 [lib++][doc] Fixes a link in the status paper. 2022-05-14 11:25:15 +02:00
Louis Dionne
374d789997 [runtimes] Fix how we trigger CI
For example, we used to trigger CI even for commits that touched a file
whose path contained 'cmake', even if it's not the root cmake directory.
Fix that.
2022-05-13 14:45:35 -04:00
Louis Dionne
0a22dfcb11 [runtimes][NFC] Remove dead code for Standalone builds
Standalone builds have been deprecated and then removed for a while now.
Trying to use standalone builds leads to a fatal CMake error, so this
code is all dead. Remove it to clean things up.

Differential Revision: https://reviews.llvm.org/D125561
2022-05-13 14:37:24 -04:00
Louis Dionne
a80e65e00a [libc++] Overhaul how we select the ABI library
This patch overhauls how we pick up the ABI library. Instead of setting
ad-hoc flags, it creates interface targets that can be linked against by
the rest of the build, which is easier to follow and extend to support
new ABI libraries.

This is intended to be a NFC change, however there are some additional
simplifications and improvements we can make in the future that would
require a slight behavior change.

Differential Revision: https://reviews.llvm.org/D120727
2022-05-13 08:32:09 -04:00
Martin Storsjö
f8da28f522 [runtimes] [cmake] Fix -Werror detection in common build configs
We add `--unwindlib=none` to `CMAKE_REQUIRED_FLAGS`
to make sure that builds with a yet-incomplete toolchain succeed,
to avoid linker failures about missing unwindlib.

When this option is added to `CMAKE_REQUIRED_FLAGS`, it gets added to
both compile and link commands in CMake compile tests. If
`--unwindlib=none` is included in compilation commands, it causes
warnings about unused arguments, as the flag only is relevant for
linking.

Due to the warnings in CMake tests, the later CMake test for the
`-Werror` option failed (as the tested `-Werror` option caused the
preexisting warning due to unused `--unwindlib=none` to become a
hard error). Therefore, most CI configurations that build with
`LIBCXX_ENABLE_WERROR` didn't actually end up enabling `-Werror`
after all.

When looking at the CI build log of recent CI builds, they do
end up printing:

    -- Performing Test LIBCXX_SUPPORTS_WERROR_FLAG
    -- Performing Test LIBCXX_SUPPORTS_WERROR_FLAG - Failed
    -- Performing Test LIBCXX_SUPPORTS_WX_FLAG
    -- Performing Test LIBCXX_SUPPORTS_WX_FLAG - Failed

Thus while the configurations are meant to error out on warnings,
they actually haven't done that, due to the interaction of these
options.

To fix this, remove the individual cases of adding `--unwindlib=none`
into `CMAKE_REQUIRED_FLAGS` in libcxx and libunwind.
`runtimes/CMakeLists.txt` still adds `--unwindlib=none` if needed, but
not otherwise. (The same issue with enabling `-Werror` does remain
if `--unwindlib=none` strictly is needed though - that can be fixed
separately afterwards.)

These individual cases in libunwind and libcxx were added while
standalone builds of the runtimes still were supported - but no longer
are necessary now.

Differential Revision: https://reviews.llvm.org/D124375
2022-05-12 22:22:15 +03:00
Louis Dionne
4128a4a6c2 [libc++] Mark <stdatomic.h> as requiring C++23
Otherwise, we might get errors with modules in pre-C++23 when mixing
<atomic> and <stdatomic.h>. This should fix breakage on Green Dragon.
2022-05-12 14:45:49 -04:00
Martin Storsjö
39328a6581 [libcxx] Switch __cxx_contention_t to int32_t on 32 bit AIX
I guess this is an ABI break for the 32 bit AIX configuration, but I'm
not sure if that one is meant to be ABI stable yet or not.

Previously, this used int32_t for this type on linux, but int64_t
on all other platforms. This was added in D68480 /
54fa9ecd30, but I don't really see
any discussion around this detail there.

Switching this to 32 bit on 32 bit AIX silences these libcxx build
warnings:

```
In file included from /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/libcxx/src/atomic.cpp:12:
/scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/include/c++/v1/atomic:1005:12: warning: large atomic operation may incur significant performance penalty; the access size (8 bytes) exceeds the max lock-free size (4  bytes) [-Watomic-alignment]
    return __c11_atomic_fetch_add(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
           ^
/scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/include/c++/v1/atomic:948:12: warning: large atomic operation may incur significant performance penalty; the access size (8 bytes) exceeds the max lock-free size (4  bytes) [-Watomic-alignment]
    return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));
           ^
/scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/include/c++/v1/atomic:1000:12: warning: large atomic operation may incur significant performance penalty; the access size (8 bytes) exceeds the max lock-free size (4  bytes) [-Watomic-alignment]
    return __c11_atomic_fetch_add(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
           ^
/scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/include/c++/v1/atomic:1022:12: warning: large atomic operation may incur significant performance penalty; the access size (8 bytes) exceeds the max lock-free size (4  bytes) [-Watomic-alignment]
    return __c11_atomic_fetch_sub(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
           ^
4 warnings generated.
```

Differential Revision: https://reviews.llvm.org/D124519
2022-05-12 19:00:42 +03:00
Nikolas Klauser
c095440caf [libc++] Remove __invalidate_all_iterators and replace the uses with std::__debug_db_invalidate_all
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D125188
2022-05-11 21:36:06 +02:00
Nikolas Klauser
08f68dfef6 [libc++] Add a few more debug wrapper functions
Reviewed By: ldionne, #libc, jloser

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D125176
2022-05-11 21:32:37 +02:00
Konstantin Varlamov
8200e1253f [libc++][ranges] Implement views::drop.
The view itself has been implemented previously -- this patch only adds
the ability to pipe it.

Also finishes the implementation of [P1739](https://wg21.link/p1739) and
[LWG3407](https://wg21.link/lwg3407).

Differential Revision: https://reviews.llvm.org/D125156
2022-05-10 09:31:05 -07:00
Martin Storsjö
61f9ec5e61 [libcxx] [test] Fix the nasty_macros test on Windows on ARM/ARM64
This isn't a configuration that we unfortunately can add to
the CI practically at the moment, but I do run the tests
sporadically offline in this configuration.

Differential Revision: https://reviews.llvm.org/D124993
2022-05-09 12:46:41 +03:00
Petr Hosek
83e07916ff Revert "[CMake][libcxx] Use target_include_directories for libc++ headers"
This reverts commit 203455c85a since
it breaks the OpenMP builders for AMDGPU.
2022-05-06 22:20:06 -07:00
Brad Smith
67b0b02ec9 [libcxx] Remove static inline and make use of _LIBCPP_HIDE_FROM_ABI in __support headers
After feedback from D122861, do the same thing with some of the other headers. Try to move the
headers so they have a similar style and way of doing things.

Reviewed By: ldionne, daltenty

Differential Revision: https://reviews.llvm.org/D124227
2022-05-07 01:14:33 -04:00
Brad Smith
ed85de6db4 [libcxx] random_device, use arc4random() on Solaris
Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D125068
2022-05-07 00:59:12 -04:00
Konstantin Varlamov
0102527352 [libc++][ranges] Implement views::single.
This only adds the customization point object (which isn't pipeable),
the view itself has already been implemented previously.

Differential Revision: https://reviews.llvm.org/D124978
2022-05-06 14:27:08 -07:00
Konstantin Varlamov
9924d8d66a [libc++][ranges] Implement views::take.
The view itself has been implemented previously -- this patch only adds
the ability to pipe it.

Also implements [P1739](https://wg21.link/p1739) (partially) and [LWG3407](https://wg21.link/lwg3407).

Differential Revision: https://reviews.llvm.org/D123600
2022-05-06 14:16:13 -07:00
Petr Hosek
203455c85a [CMake][libcxx] Use target_include_directories for libc++ headers
This is the idiomatic way to handle include directories in CMake.

Differential Revision: https://reviews.llvm.org/D122614
2022-05-06 14:06:25 -07:00
Louis Dionne
9fffca0444 [libc++][NFC] Fix formatting that was incorrectly changed by D124695 2022-05-06 12:58:51 -04:00
Louis Dionne
ec3d22cd3a [libc++][NFC] Add release note for constexpr std::string 2022-05-06 11:18:07 -04:00
Louis Dionne
687ccba198 [libc++][NFC] Move swap_noexcept test to .compile.pass.cpp 2022-05-06 11:04:29 -04:00
Louis Dionne
3442ff17a5 [libc++][NFC] Slight refactoring of some std::vector tests 2022-05-06 10:56:34 -04:00
Louis Dionne
586efd52b9 [libc++][P0943] Add stdatomic.h header.
* https://wg21.link/P0943
* https://eel.is/c++draft/stdatomic.h.syn

This is a re-application of 5d1c1a24, which was reverted in 987c7f407
because it broke the LLDB build.

Co-authored-by: Marek Kurdej <marek.kurdej@gmail.com>

Differential Revision: https://reviews.llvm.org/D97044
2022-05-06 09:52:48 -04:00
Nikolas Klauser
37ba1b9d1a [libc++] Implement ranges::is_partitioned
Reviewed By: var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D124440
2022-05-06 13:02:38 +02:00
David Spickett
ab07d06e7b [libcxx] Reject month 0 in get_date/__get_month
[libcxx] Reject month 0 in get_date/__get_month

This fixes #47663.

Months in dates should be >= 1 and <= 12.
We parse up to two digits then minus one, because
we want to store this as "months since January"
(0-11).

However we didn't check that the result of that
was not -1. For example if you had (MM/DD/YYYY)
00/21/2022.

Added tests for:
* Failing if month is 0
* Failing if month is 13
* Allowing a leading zero in month e.g. "01"

Note that libc++ and libstdc++ return different
values on parsing failure, and MSVC STL returns
end of stream instead.

Handle the first two by checking for defines, MSVC STL
expects these tests to fail for other reasons already:
https://github.com/microsoft/STL/blob/main/tests/libcxx/expected_results.txt#L372
so not handling that case here.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D124175
2022-05-06 10:07:53 +00:00
John Brawn
f3a970a825 [libc++] Mark tests that use check_assertion.h as requiring unix headers
On targets without unistd.h or sys/wait.h (such as bare metal targets)
any test that uses check_assertion.h will fail, so add
REQUIRES: has-unix-headers to them and autodetect whether we have
these headers or not.

These tests currently have unsupported on windows, but that's exactly
because windows doesn't have these headers so we can remove the
specific check for windows.

Differential Revision: https://reviews.llvm.org/D124623
2022-05-06 10:59:42 +01:00
Martin Storsjö
30194d45f0 [libcxx] [ci] Add a i386 Windows configuration to CI
Adding a mingw based config is easy in the current CI environment
(where we can just choose the different target by calling
`i686-w64-mingw32-clang`), while adding a clang-cl based config would
require setting up different environment variables pointing to the
i386 library directory.

Just adding one config (DLL) instead of exhaustively testing both
(DLL and static) as very few tests would differ in practice, to keep
the CI load reasonable.

Differential Revision: https://reviews.llvm.org/D124991
2022-05-06 10:12:04 +03:00
Martin Storsjö
07c96a3113 [libcxx] [test] Narrow down an XFAIL for clang-cl configurations
This test only fails on x86_64 clang-cl, not for i386.

(The root cause is still not explored, thus the FIXME is still
relevant.)

Differential Revision: https://reviews.llvm.org/D124994
2022-05-05 23:21:19 +03:00
Martin Storsjö
9dfbccf052 [libcxx] [test] Extend the UNSUPPORTED lines in strong_order_long_double.verify.cpp for non-x86_64 Windows
Differential Revision: https://reviews.llvm.org/D124992
2022-05-05 23:21:19 +03:00
Martin Storsjö
448eabd754 [libcxx] [test] Fix max_size.pass.cpp for other Windows architectures
All current Windows architectures (i386, x86_64, arm, arm64) get
the full_size() behaviour here. x86_64 (the only one tested in CI
currently) is handled by the first ifdef at the top, but handle
Windows in general on all other architectures later.

Differential Revision: https://reviews.llvm.org/D124989
2022-05-05 23:21:18 +03:00
Peter Kasting
5a4f177c94 [libc++] Avoid a Microsoft SAL macro.
Bug: https://github.com/llvm/llvm-project/issues/55195

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D124695
2022-05-05 20:08:33 +02:00
Brian Tracy
87a55137e2 Fix "the the" typo in documentation and user facing strings
There are many more instances of this pattern, but I chose to limit this change to .rst files (docs), anything in libcxx/include, and string literals. These have the highest chance of being seen by end users.

Reviewed By: #libc, Mordante, martong, ldionne

Differential Revision: https://reviews.llvm.org/D124708
2022-05-05 17:52:08 +02:00
Louis Dionne
990ea3925b [libc++] Add a few _LIBCPP_ASSERTs in __tree
Several helper functions specify preconditions as comments, but we never
check them. I ran across a bug report (without a reproducer) in this code,
and I thought that having these assertions in place would make it easier
to troubleshoot.

Differential Revision: https://reviews.llvm.org/D124477
2022-05-05 11:29:48 -04:00
Nikolas Klauser
80045e9afa [libc++] Implement ranges::for_each{, _n}
Reviewed By: var-const, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D124332
2022-05-04 20:28:01 +02:00
Louis Dionne
0e2fb8ac84 [libc++] Refactor max_size.pass.cpp
Reorganize the test and simplify the #ifdefs. Fix a typo in __powerpc64__
as a fly-by, and also add a test for the unstable ABI.

Differential Revision: https://reviews.llvm.org/D124403
2022-05-04 11:05:29 -07:00
Nikolas Klauser
639b9618f4 [libc++][NFC] Replace _LIBCPP_INLINE_VISIBILTIY and _VSTD in <string>
Replace all the instances of `_LIBCPP_INLINE_VISIBILITY` with `_LIBCPP_HIDE_FROM_ABI` and `_VSTD` with `std`.

Reviewed By: Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D124662
2022-05-01 12:59:52 +02:00
Mark de Wever
d563df88e9 Revert "[msan][libcxx] Enable -fsanitize-memory-param-retval"
This reverts commit beff64ee44.

The original commit was reviewed as D123979.

This commit caused the libc++ pre-commit CI to fail
https://buildkite.com/llvm-project/libcxx-ci/builds/10483

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D124713
2022-04-30 15:19:16 +02:00
Vitaly Buka
beff64ee44 [msan][libcxx] Enable -fsanitize-memory-param-retval
We are considering to make -fsanitize-memory-param-retval enabled by default so probably this patch is unnneded.

Reviewed By: #libc, EricWF

Differential Revision: https://reviews.llvm.org/D123979
2022-04-28 19:12:41 -07:00
Mark de Wever
d03bc249d8 [NFC][libc++][format] Enable unit tests.
The GCC failures were partly fixed in D124103.

The format functions tests are fixed on GCC but they require a huge
amount of RAM (>10 GB). This fails with parallel testing in the CI. It
can be solved by splitting the test, but GCC-12 will be released shortly
and might fix the memory usage in these tests. Therefore these tests
remain disabled.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D124335
2022-04-28 17:11:47 +02:00
Nikolas Klauser
425620ccdd [libc++] Implement P0980R1 (constexpr std::string)
Reviewed By: #libc, ldionne

Spies: daltenty, sdasgup3, ldionne, arichardson, MTC, ChuanqiXu, mehdi_amini, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes, tatianashp, rdzhabarov, teijeong, cota, dcaballe, Chia-hungDuan, wrengr, wenzhicui, arphaman, Mordante, miscco, Quuxplusone, smeenai, libcxx-commits

Differential Revision: https://reviews.llvm.org/D110598
2022-04-27 12:25:34 +02:00
Mark de Wever
0289c90d70 [NFC][libc++] Fixes some tests on Linux.
The tests are adapted to the output produced on Linux.

Reviewed By: #libc, philnik, ldionne

Differential Revision: https://reviews.llvm.org/D124331
2022-04-26 17:50:17 +02:00
Nikolas Klauser
a83f4b9cda [libc++] Remove <functional> includes
Reviewed By: var-const, #libc, ldionne

Spies: #libc_vendors, ldionne, libcxx-commits, miyuki

Differential Revision: https://reviews.llvm.org/D124123
2022-04-26 08:54:37 +02:00
Vitaly Buka
0c99575df4 [libc++] Avoid lifetime UB in __thread_local_data()
Detected on many lld tests with -fsanitize-memory-use-after-dtor.
Also https://lab.llvm.org/buildbot/#/builders/sanitizer-x86_64-linux-fast after D122869 will report a lot of them.

Threads may outlive static variables. Even if ~__thread_specific_ptr() does nothing, lifetime of members ends with ~ and accessing the value is UB https://eel.is/c++draft/basic.life#1

```
==9214==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x557e1cec4539 in __libcpp_tls_set ../include/c++/v1/__threading_support:428:12
    #1 0x557e1cec4539 in set_pointer ../include/c++/v1/thread:196:5
    #2 0x557e1cec4539 in void* std::__msan::__thread_proxy<
      std::__msan::tuple<...>, llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()::operator()() const::'lambda'()> >(void*) ../include/c++/v1/thread:285:27

  Memory was marked as uninitialized
    #0 0x557e10a0759d in __sanitizer_dtor_callback compiler-rt/lib/msan/msan_interceptors.cpp:940:5
    #1 0x557e1d8c478d in std::__msan::__thread_specific_ptr<std::__msan::__thread_struct>::~__thread_specific_ptr() libcxx/include/thread:188:1
    #2 0x557e10a07dc0 in MSanCxaAtExitWrapper(void*) compiler-rt/lib/msan/msan_interceptors.cpp:1151:3
```

The test needs D123979 or  -fsanitize-memory-param-retval enabled by default.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122864
2022-04-25 14:56:44 -07:00