12315 Commits

Author SHA1 Message Date
Louis Dionne
917ada35cd
[runtimes] Always define cxx_shared, cxx_static & other targets (#80007)
This patch always defines the cxx_shared, cxx_static & other top-level
targets. However, they are marked as EXCLUDE_FROM_ALL when we don't want
to build them. Simply declaring the targets should be of no harm, and it
allows other projects to mention these targets regardless of whether
they end up being built or not.

This patch basically moves the definition of e.g. cxx_shared out of the
`if (LIBCXX_ENABLE_SHARED)` and instead marks it as EXCLUDE_FROM_ALL
conditionally on whether LIBCXX_ENABLE_SHARED is passed. It then does
the same for libunwind and libc++abi targets. I purposefully avoided to
reformat the files (which now has inconsistent indentation) because I
wanted to keep the diff minimal, and I know this is an area of the code
where folks may have downstream diffs. I will re-indent the code
separately once this patch lands.

This is a reapplication of 79ee0342dbf0, which was reverted in
a3539090884c because it broke the TSAN and the Fuchsia builds.

Resolves #77654

Differential Revision: https://reviews.llvm.org/D134221
2024-10-10 08:00:01 -04:00
Louis Dionne
ea2b8976e6
[libc++] Remove nonexistent directory from check-generated-output (#111746)
The libcxx/benchmarks directory was moved to libcxx/test/benchmarks,
which is already checked by that grep command.
2024-10-10 07:57:45 -04:00
Martin Storsjö
9fb2378ad5
[libcxx] [test] Merge the MinGW static/shared test config files (#111759)
These were split in 0e8208eca1c316b7302de7803ab0d85a1dd77076, with the
only functional difference between them at the time being `--prepend_env
PATH=%{lib-dir}` in the static config and `--prepend_env
PATH=%{install-prefix}/bin` in the shared library config.

However this difference is unnecessary - the static library config
doesn't need any `--prepend_env` argument at all. Before
0e8208eca1c316b7302de7803ab0d85a1dd77076, both configurations used the
same config file, where the `--prepend_env` argument was unnecessary but
benign in the static case.

Reduce the unnecessary config duplication in this case, and return these
configs to using one single config file for both setups.
2024-10-10 09:13:47 +03:00
Louis Dionne
749e218600 [libc++][NFC] Remove obsolete --osx-roots parameter to run-buildbot
That isn't used anymore since we now run backdeployment testing
on the target system directly instead of using pre-packaged roots.
2024-10-09 15:04:56 -04:00
Louis Dionne
9200adee26
[libc++] Narrow the exports for common_type (#111681)
Based on a comment in #99473, it seems like `export *` may be overkill.
2024-10-09 14:58:13 -04:00
simpal01
d25f1a19c8
Add 64bit atomic check in the is_always_lock_free_pass test. (#111540)
Currently this test is completely xfailed as part of the patch
https://github.com/llvm/llvm-project/pull/106077. But this test works on
A and R profile, not in v7M profile. Because the test contain cases in
which m-profile will fail for atomic types greater than 4 bytes in size.
2024-10-09 09:19:11 -04:00
Louis Dionne
21da4e7f51
[libc++] Fix broken configuration system-libcxxabi on Apple (#110920)
On Apple platforms, using system-libcxxabi as an ABI library wouldn't
work because we'd try to re-export symbols from libc++abi that the
system libc++abi.dylib might not have. Instead, only re-export those
symbols when we're using the in-tree libc++abi.

This does mean that libc++.dylib won't re-export any libc++abi symbols
when building against the system libc++abi, which could be fixed in
various ways. However, the best solution really depends on the intended
use case, so this patch doesn't try to solve that problem.

As a drive-by, also improve the diagnostic message when the user forgets
to set the LIBCXX_CXX_ABI_INCLUDE_PATHS variable, which would previously
lead to a confusing error.

Closes #104672
2024-10-09 08:46:59 -04:00
Hans Wennborg
ada6372e52 Revert "[clang] Finish implementation of P0522 (#96023)"
This caused Clang to reject valid code, see discussion on the PR
https://github.com/llvm/llvm-project/pull/96023#issuecomment-2393228464
and https://github.com/llvm/llvm-project/issues/111363

This reverts commit 6afe56732a172d3f2cbd0330b1fcb34bbfd002a9 and
follow-up commit 9abb97f9663a27fe5b8e346ed557b3435aa9ec2f.
2024-10-09 08:41:42 +02:00
Hristo Hristov
a06591b4d4
[libc++][type_traits] P2674R1: A trait for implicit lifetime types (#106870)
Implements P2674R1: https://wg21.link/P2674R1

- https://eel.is/c++draft/type.traits
  - https://eel.is/c++draft/meta.type.synop
  - https://eel.is/c++draft/meta.unary.prop
- https://eel.is/c++draft/support.limits
  - https://eel.is/c++draft/version.syn

Implementation details:
- Uses compiler intrinsic `__builtin_is_implicit_lifetime`:
  - https://github.com/llvm/llvm-project/pull/101807
- Tests based on:
-
d213981c80/clang/test/SemaCXX/type-traits.cpp (L1989)

References:
- Implicit-lifetime
- Implicit-lifetime types [basic.types.general]/9:
https://eel.is/c++draft/basic.types.general
- Implicit-lifetime class [class.prop]/9:
https://eel.is/c++draft/class.prop
- P0593R6 Implicit creation of objects for low-level object
manipulation: https://wg21.link/P0593R6
- P1010R1 Container support for implicit lifetime types:
https://wg21.link/P1010R1
- P0593R6 Implicit creation of objects for low-level object
manipulation: https://wg21.link/P0593R6

Closes: #105259

---------

Co-authored-by: Hristo Hristov <zingam@outlook.com>
2024-10-09 08:19:14 +02:00
Enna1
ff6facaa61
[clang] remove extra space in warn_atomic_op_oversized (NFC) (#110955) 2024-10-09 09:16:55 +08:00
Michael Buch
20b8d3f52b
[libc++][CI] Replace LLDB test targets with libc++ test category (#110856)
We've been increasing the coverage of libc++ LLDB tests in the pre-merge
CI (see https://github.com/llvm/llvm-project/pull/110570). Unfortunately
the tests are spread across different targets. It would be great if we
had a single target that libc++ maintainers could run.

We do this by passing the `libc++` test-category as a parameter to
LLDB's [`dotest` testing
framework](https://lldb.llvm.org/resources/test.html). This will only
run LLDB tests that have been marked as belonging to the `libc++`
category.
2024-10-08 10:21:51 +02:00
Louis Dionne
5c88aa9d34
[libc++] Document the de-facto status of compiler extension support (#110877)
This was brought up in a maintainer's meeting a few months ago. This
simply documents the current status quo.
2024-10-07 17:27:29 -04:00
Mark de Wever
7f65377880
[libc++][format][2/3] Optimizes c-string arguments. (#101805)
The formatter specializations for _CharT* and const _CharT* typically
write all elements in a loop. This format's internal functions are
optimized for larger writes.

Instead of writing one element at a time, convert the range to a
basic_string_view and write that instead.

For C string of 6 characters this is a bit slower, but for 60 characters
it's faster. The improvements for back_inserter<std::list<_CharT>> are
not as great as the others; it just gets as slow as
basic_string_view<_CharT>.

omparing libcxx/test/benchmarks/write_string_comparison.bench.out-before to libcxx/test/benchmarks/write_string_comparison.bench.out-after
Benchmark                                                                            Time             CPU      Time Old      Time New       CPU Old       CPU New
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
BM_sprintf/C_string_len_6                                                         -0.0015         +0.0013             5             5             5             5
BM_format/C_string_len_6                                                          +0.0390         +0.0416            53            55            53            55
BM_format_to_back_inserter<std::string>/C_string_len_6                            +0.0381         +0.0408            53            55            53            55
BM_format_to_back_inserter<std::vector<char>>/C_string_len_6                      +0.0287         +0.0315            69            71            69            71
BM_format_to_back_inserter<std::deque<char>>/C_string_len_6                       +0.0503         +0.0530           123           129           123           129
BM_format_to_back_inserter<std::list<char>>/C_string_len_6                        -0.0241         -0.0213           133           130           133           130
BM_format_to_iterator/<std::array> C_string_len_6                                 -0.0075         -0.0049            45            45            45            45
BM_format_to_iterator/<std::string> C_string_len_6                                +0.0311         +0.0340            44            46            44            46
BM_format_to_iterator/<std::vector> C_string_len_6                                +0.0380         +0.0409            43            45            43            45
BM_format_to_iterator/<std::deque> C_string_len_6                                 +0.0366         +0.0392            48            50            48            50
BM_format/string_len_6                                                            -0.0010         -0.0007            56            55            55            55
BM_format_to_back_inserter<std::string>/string_len_6                              +0.0044         +0.0041            55            56            55            55
BM_format_to_back_inserter<std::vector<char>>/string_len_6                        +0.0128         +0.0128            70            71            70            71
BM_format_to_back_inserter<std::deque<char>>/string_len_6                         +0.0151         +0.0151           126           128           126           128
BM_format_to_back_inserter<std::list<char>>/string_len_6                          -0.0719         -0.0718           140           130           139           129
BM_format_to_iterator/<std::array> string_len_6                                   -0.0323         -0.0324            47            46            47            46
BM_format_to_iterator/<std::string> string_len_6                                  -0.0011         -0.0010            45            44            44            44
BM_format_to_iterator/<std::vector> string_len_6                                  -0.0002         -0.0001            45            45            44            44
BM_format_to_iterator/<std::deque> string_len_6                                   +0.0046         +0.0047            51            51            51            51
BM_format/string_view_len_6                                                       +0.0031         +0.0031            54            54            54            54
BM_format_to_back_inserter<std::string>/string_view_len_6                         +0.0041         +0.0040            54            54            54            54
BM_format_to_back_inserter<std::vector<char>>/string_view_len_6                   +0.0022         +0.0022            70            70            70            70
BM_format_to_back_inserter<std::deque<char>>/string_view_len_6                    +0.0392         +0.0391           124           129           124           129
BM_format_to_back_inserter<std::list<char>>/string_view_len_6                     -0.0680         -0.0680           139           129           138           129
BM_format_to_iterator/<std::array> string_view_len_6                              -0.0321         -0.0320            47            46            47            46
BM_format_to_iterator/<std::string> string_view_len_6                             -0.0013         -0.0011            45            44            44            44
BM_format_to_iterator/<std::vector> string_view_len_6                             -0.0024         -0.0023            45            44            44            44
BM_format_to_iterator/<std::deque> string_view_len_6                              +0.0057         +0.0057            51            51            51            51
BM_sprintf/C_string_len_60                                                        -0.0035         -0.0035             4             4             4             4
BM_format/C_string_len_60                                                         -0.5627         -0.5627           169            74           169            74
BM_format_to_back_inserter<std::string>/C_string_len_60                           -0.5642         -0.5641           170            74           169            74
BM_format_to_back_inserter<std::vector<char>>/C_string_len_60                     -0.5300         -0.5299           178            84           178            84
BM_format_to_back_inserter<std::deque<char>>/C_string_len_60                      -0.2548         -0.2548           356           265           355           264
BM_format_to_back_inserter<std::list<char>>/C_string_len_60                       -0.1013         -0.1013          1325          1191          1322          1188
BM_format_to_iterator/<std::array> C_string_len_60                                -0.6790         -0.6791           141            45           141            45
BM_format_to_iterator/<std::string> C_string_len_60                               -0.6738         -0.6740           143            47           142            46
BM_format_to_iterator/<std::vector> C_string_len_60                               -0.6807         -0.6808           142            45           142            45
BM_format_to_iterator/<std::deque> C_string_len_60                                -0.6488         -0.6486           144            51           144            51
BM_format/string_len_60                                                           +0.0118         +0.0117            73            74            73            73
BM_format_to_back_inserter<std::string>/string_len_60                             +0.0089         +0.0088            73            73            73            73
BM_format_to_back_inserter<std::vector<char>>/string_len_60                       +0.0080         +0.0081            83            84            83            83
BM_format_to_back_inserter<std::deque<char>>/string_len_60                        +0.0005         +0.0002           262           263           262           262
BM_format_to_back_inserter<std::list<char>>/string_len_60                         -0.0384         -0.0380          1236          1188          1232          1186
BM_format_to_iterator/<std::array> string_len_60                                  -0.0288         -0.0288            47            46            47            46
BM_format_to_iterator/<std::string> string_len_60                                 +0.0213         +0.0210            44            45            44            45
BM_format_to_iterator/<std::vector> string_len_60                                 +0.0202         +0.0205            45            45            44            45
BM_format_to_iterator/<std::deque> string_len_60                                  +0.0124         +0.0124            50            51            50            51
BM_format/string_view_len_60                                                      +0.0093         +0.0093            73            73            73            73
BM_format_to_back_inserter<std::string>/string_view_len_60                        +0.0055         +0.0055            73            73            73            73
BM_format_to_back_inserter<std::vector<char>>/string_view_len_60                  +0.0165         +0.0166            81            83            81            83
BM_format_to_back_inserter<std::deque<char>>/string_view_len_60                   +0.0138         +0.0140           260           263           259           263
BM_format_to_back_inserter<std::list<char>>/string_view_len_60                    -0.0334         -0.0335          1228          1187          1225          1184
BM_format_to_iterator/<std::array> string_view_len_60                             -0.0257         -0.0259            48            46            47            46
BM_format_to_iterator/<std::string> string_view_len_60                            +0.0324         +0.0323            45            46            44            46
BM_format_to_iterator/<std::vector> string_view_len_60                            +0.0174         +0.0177            45            45            44            45
BM_format_to_iterator/<std::deque> string_view_len_60                             +0.0076         +0.0076            50            51            50            51
BM_sprintf/C_string_len_6000                                                      +0.4922         +0.4921            77           115            77           114
BM_format/C_string_len_6000                                                       -0.9239         -0.9239         11780           897         11750           894
BM_format_to_back_inserter<std::string>/C_string_len_6000                         -0.9239         -0.9239         11792           898         11763           895
BM_format_to_back_inserter<std::vector<char>>/C_string_len_6000                   -0.9257         -0.9257         11709           870         11679           868
BM_format_to_back_inserter<std::deque<char>>/C_string_len_6000                    -0.4057         -0.4057         25616         15225         25553         15187
BM_format_to_back_inserter<std::list<char>>/C_string_len_6000                     -0.0832         -0.0833        127144        116569        126823        116265
BM_format_to_iterator/<std::array> C_string_len_6000                              -0.9853         -0.9853         10869           160         10843           160
BM_format_to_iterator/<std::string> C_string_len_6000                             -0.9864         -0.9864         10870           148         10841           148
BM_format_to_iterator/<std::vector> C_string_len_6000                             -0.9863         -0.9863         10874           149         10846           148
BM_format_to_iterator/<std::deque> C_string_len_6000                              -0.9629         -0.9629         11239           417         11212           416
BM_format/string_len_6000                                                         -0.0012         -0.0013           846           845           844           842
BM_format_to_back_inserter<std::string>/string_len_6000                           -0.0029         -0.0034           845           843           843           840
BM_format_to_back_inserter<std::vector<char>>/string_len_6000                     -0.0129         -0.0125           832           821           830           819
BM_format_to_back_inserter<std::deque<char>>/string_len_6000                      +0.0048         +0.0048         15042         15114         15004         15076
BM_format_to_back_inserter<std::list<char>>/string_len_6000                       -0.0017         -0.0017        116266        116072        115967        115768
BM_format_to_iterator/<std::array> string_len_6000                                -0.0257         -0.0256           120           117           120           117
BM_format_to_iterator/<std::string> string_len_6000                               -0.0025         -0.0029           117           117           117           117
BM_format_to_iterator/<std::vector> string_len_6000                               -0.0089         -0.0087           118           116           117           116
BM_format_to_iterator/<std::deque> string_len_6000                                -0.0478         -0.0477           379           361           378           360
BM_format/string_view_len_6000                                                    -0.0092         -0.0091           842           835           840           833
BM_format_to_back_inserter<std::string>/string_view_len_6000                      -0.0081         -0.0083           841           835           839           832
BM_format_to_back_inserter<std::vector<char>>/string_view_len_6000                +0.0089         +0.0088           808           815           806           813
BM_format_to_back_inserter<std::deque<char>>/string_view_len_6000                 +0.0068         +0.0068         15030         15131         14992         15093
BM_format_to_back_inserter<std::list<char>>/string_view_len_6000                  +0.0012         +0.0010        116099        116243        115813        115934
BM_format_to_iterator/<std::array> string_view_len_6000                           -0.0122         -0.0121           118           117           118           116
BM_format_to_iterator/<std::string> string_view_len_6000                          +0.0010         +0.0010           106           107           106           106
BM_format_to_iterator/<std::vector> string_view_len_6000                          -0.0008         -0.0006           106           106           106           106
BM_format_to_iterator/<std::deque> string_view_len_6000                           -0.0549         -0.0548           370           349           369           349
OVERALL_GEOMEAN
2024-10-06 21:20:22 +02:00
Mark de Wever
d54b1cfa38
[libc++][format][1/3] Adds more benchmarks. (#101803)
This patch is the start of a series to improve the speed of std::format,
std::format_to, std::format_to_n, and std::formatted_size.

This is mostly achieved by changing the __output_buffer class. This new
__output_buffer class also makes it easier to implement buffering for
P3107R5 "Permit an efficient implementation of std::print"
2024-10-06 18:18:57 +02:00
Yang Kun
37ce3c2208
[libc++] Fix a typo (#111239)
Just a small typo I found when I refer to libc++'s code.
2024-10-06 07:58:25 +02:00
Matheus Izvekov
9abb97f966
[clang] Handle template argument conversions for non-pack param to pack argument (#110963)
This fixes a regression introduced in #96023, reported in
https://github.com/llvm/llvm-project/issues/110231#issuecomment-2389131854
2024-10-03 15:18:37 -03:00
Louis Dionne
848b20de76
[libc++] Correctly handle custom deleters in hardened unique_ptr<T[]> (#110685)
It turns out that we can never do bounds-checking for unique_ptrs with
custom deleters, except when converting from a unique_ptr with a default
deleter to one with a custom deleter.

If we had an API like `std::make_unique` that allowed passing a custom
deleter, we could at least get bounds checking when the unique_ptr is
created through those APIs, but for now that is not possible.

Fixes #110683
2024-10-03 11:45:58 -04:00
Louis Dionne
34d0c99d82
[libc++] Stop trying to avoid exporting some typeinfo names (#110925)
When the library was initially written, it was not built with hidden
visibility. In an attempt to reduce the number of symbols exported from
libc++, an explicit list of symbols to avoid exporting was passed to the
linker. This was only done on Apple platforms.

Since then, the library has moved on in several ways. First, we now
build with hidden visibility by default, so arbitrary symbols don't get
exported from the library for no reason. Second, we have proper
visibility control via source annotations, so we export exactly what we
want to, and we do that from the sources.

This patch removes the explicit list of symbols to avoid exporting from
the library, which at this point doesn't cover much anyways. The only
symbols we will now be exporting that we were not before are some
typeinfo names for implementation-detail types. While we technically
wouldn't have to export those (I don't think any user can get their
hands on those typeinfo names), that makes the library more consistent
on all platforms.
2024-10-03 09:58:11 -04:00
Louis Dionne
8e049fa327
[libc++] Rename __range_adaptor_closure_t (#110886)
The name __range_adaptor_closure_t can easily be confused with
__range_adaptor_closure, so something more distinct is preferable.

Fixes #67611
2024-10-03 09:35:52 -04:00
Brian Cain
ea62db0c03
[cmake] Add hexagon-linux cmake cache files (#98712)
These can be used to create a fully-bootstrapped toolchain to target
hexagon {baremetal,linux} with scripts like the ones in
https://github.com/quic/toolchain_for_hexagon
2024-10-03 08:11:34 -05:00
Louis Dionne
bfb3a442b8
[libc++] Index from 0 in GDB pretty printers (#110881)
Fixes #62168
2024-10-03 09:07:08 -04:00
Louis Dionne
121ed5c198
[libc++] Remove test suite annotations for experimental stop_token (#110890)
<stop_token> is not experimental anymore, so its tests shouldn't be
guarded by libcpp-has-no-experimental-stop_token.
2024-10-03 09:05:16 -04:00
A. Jiang
19c6958d24
[libc++] Re-apply LWG3870: Remove voidify (#110944)
This reverts commit f3d58f4161b86a479f68acb453e9622911c688a0.

Relands #110355.
2024-10-03 08:28:26 -04:00
A. Jiang
557f7e1398
[libc++] P2167R3: Improved Proposed Wording for LWG 2114 (#109102)
Only the [cmp.alg] part (for `comparison_meow_fallback` CPOs) in the
paper required changes. Other parts merely fixed preconditions of some
standard library functions.

I strongly feel that P2167R3 should be a DR despite that it is not a DR
officially: CPOs -> C++20; remain parts -> C++98/11 (except that
_`boolean-testable`_ should be transformed into the original
_BooleanTestable_ requirements in the old resolution of LWG2114).

Note that P2167R3 damaged the resolution of LWG3465: the type of `F < E`
was left underconstrained. I've tried to submit an LWG issue for this,
which is now LWG4157.

Drive-by change:
- enable some test coverages in `compare_strong_order_fallback.pass.cpp`
when `TEST_LONG_DOUBLE_IS_DOUBLE`, following up #106742

Closes #105241.
2024-10-03 01:09:53 +08:00
Nikolas Klauser
d278fa5e1a
[libc++] Fix constant initialization of unique_ptr in C++17 and prior (#108956)
This is already tested in
`std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp`
except that `TEST_CONSTINIT` doesn't do anything before C++20 without
this patch.
2024-10-02 17:09:06 +02:00
Nikolas Klauser
5f909c0ab2
[libc++][NFC] Remove some boilerplate from <string> after #76756 (#108952)
A few functions are now unnecessary, since we can access the members
directly instread now.
2024-10-02 15:12:30 +02:00
Louis Dionne
8805ff72a0
[libc++] Mark LWG3317 as complete in LLVM 16 (#110757)
This was fixed in 719c3dc6f2f7 and landed in LLVM 16.

Closes #100429
2024-10-02 09:00:41 -04:00
Louis Dionne
b45661953e
[libc++] Fix name of is_always_lock_free test which was never being run (#106077) 2024-10-02 08:54:25 -04:00
Sylvestre Ledru
68c04b0ae6 Revert "[libc++][C++03] Copy the LLVM 19 headers (#108999)"
it causes: https://github.com/llvm/llvm-project/issues/110808

This reverts commit 67432f20491a0fa6b05f8a3a91f88e26175453d6.
2024-10-02 11:53:16 +02:00
Nikolas Klauser
67432f2049
[libc++][C++03] Copy the LLVM 19 headers (#108999)
This is the first part of the "Freezing C++03 headers" proposal
explained in
https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc/77319/58.

This patch mechanically copies the headers as of the LLVM 19.1 release
into a subdirectory of libc++ so that we can start using these headers
when building in C++03 mode. We are going to be backporting important
changes to that copy of the headers until the LLVM 21 release. After the
LLVM 21 release, only critical bugfixes will be fixed in the C++03 copy
of the headers.

This patch only performs a copy of the headers -- these headers are
still unused by the rest of the codebase.
2024-10-01 22:57:30 +02:00
Louis Dionne
5366bf5b66 [libc++][NFC] Improve the synopsis of <algorithm> 2024-10-01 13:00:29 -04:00
serge-sans-paille
0eb26021d2
[libc++] Remove potential 0-sized array in __compressed_pair_padding (#109028) 2024-10-01 11:58:25 -04:00
Zibi Sarbinowski
60b604a198
[libc++][z/OS] Fix shared_ptr control block test when aligned allocation is not available (#109693)
This PR fixes the shared_ptr control block layout test that was recently updated in #76756.
When aligned allocation/deallocation is not available, part of the test doesn't work.
2024-10-01 09:57:46 -04:00
Louis Dionne
d6d3d2f5d9
[libc++] Run additional LLDB data formatters tests as part of libc++'s CI (#110570) 2024-10-01 09:49:22 -04:00
Louis Dionne
677e8cd6ff
[libc++] Avoid re-exporting a few specific symbols from libc++abi (#109054)
In 6a884a9aef39, I synchronized the export list of libc++abi to the
export list of libc++. From the linker's perspective, this caused these
symbols to be taken from libc++.dylib instead of libc++abi.dylib.

However, that can be problematic when back-deploying. Indeed, this means
that the linker will encode an undefined reference to be fullfilled by
libc++.dylib, but when backdeploying against an older system, that
symbol might only be available in libc++abi.dylib.

Most of the symbols that started being re-exported after 6a884a9aef39
turn out to be implementation details of libc++abi, so nobody really
depends on them and this back-deployment issue is inconsequential.

However, we ran into issues with a few of these symbols while testing
LLVM 19, which led to this patch. This slipped between the cracks and
that is why the patch is coming so long after the original patch landed.

In the future, a follow-up cleanup would be to stop exporting most of
the _cxxabiv1_foo_type_infoE symbols from both libc++abi and libc++
since they are implementation details that nobody should be relying on.

rdar://131984512
2024-10-01 09:39:44 -04:00
Michael Buch
f3d58f4161
Revert "[libc++] LWG3870: Remove voidify (#110355)" (#110587)
This reverts commit 78f9a8b82d772ff04a12ef95f2c9d31ee8f3e409.

This caused the LLDB test `TestDataFormatterGenericOptional.py` to fail, and we need
a bit more time to look into it.
2024-10-01 08:57:03 -04:00
Vitaly Buka
eea5e7e095
[libc++][string] Add regression test for sized new/delete bug (#110210)
This is regression test for #90292.

Allocator used in test is very similar to test_allocator.
However, reproducer requires size_type of the string
to be 64bit, but test_allocator uses 32bit.

32bit size_type makes `sizeof(string::__long)` to be 16,
but the alignment issue fixed with #90292 is only triggered
with default `sizeof(string::__long)` which is 24.

Fixes #92128.

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2024-09-30 22:29:11 -07:00
David Tenty
f3a4def436
[libcxx][ios] initialize __fill_val_ in _FillHelper (#110279)
This is a small fix to https://github.com/llvm/llvm-project/pull/89305.
In the `__init` function of `_FillHelper`, `__fill_val_` was left
uninitialized. This worked for the implementation in the PR because we
always checked `__set_` before trying to read it, and would initialize
if it was unset.

However it turns out in earlier versions of the header (at least on AIX
which followed this path), we do a read of `__fill_val_` even if
`__set_` was false before initializing, to check if it matched the
sentinel value, so this causes undesired behaviour and UB.
2024-09-30 19:24:32 -04:00
Louis Dionne
0547e573c5
[runtimes] Run backdeployment CI on Github hosted runners (#109984)
This removes the need for macOS nodes in Buildkite. It also moves to the
proper way of testing backdeployment, which is to actually run on the
target OS itself, instead of using packaged dylibs from previous OS
versions and trying to emulate backdeployment with DYLD_LIBRARY_PATH.

As a drive-by change, also fix a few back-deployment annotations that
were incorrect and add support for minor versions in the Lit feature
determining availability from the target triple.
2024-09-30 17:08:44 -04:00
Louis Dionne
41145feb77
[libc++][modules] Rewrite the modulemap to have fewer top-level modules (#110501)
This is a re-application of bc6bd3bc1e9 which was reverted in
f11abac6524 because it broke the Clang pre-commit CI.

Original commit message:

This patch rewrites the modulemap to have fewer top-level modules.
Previously, our modulemap had one top level module for each header in
the library, including private headers. This had the well-known problem
of making compilation times terrible, in addition to being somewhat
against the design principles of Clang modules.

This patch provides almost an order of magnitude compilation time
improvement when building modularized code (certainly subject to
variations). For example, including <ccomplex> without a module cache
went from 22.4 seconds to 1.6 seconds, a 14x improvement.

To achieve this, one might be tempted to simply put all the headers in a
single top-level module. Unfortunately, this doesn't work because libc++
provides C compatibility headers (e.g. stdlib.h) which create cycles
when the C Standard Library headers are modularized too. This is
especially tricky since base systems are usually not modularized: as far
as I know, only Xcode 16 beta contains a modularized SDK that makes this
issue visible. To understand it, imagine we have the following setup:

   // in libc++'s include/c++/v1/module.modulemap
   module std {
      header stddef.h
      header stdlib.h
   }

   // in the C library's include/module.modulemap
   module clib {
      header stddef.h
      header stdlib.h
   }

Now, imagine that the C library's <stdlib.h> includes <stddef.h>,
perhaps as an implementation detail. When building the `std` module,
libc++'s <stdlib.h> header does `#include_next <stdlib.h>` to get the C
library's <stdlib.h>, so libc++ depends on the `clib` module.

However, remember that the C library's <stdlib.h> header includes
<stddef.h> as an implementation detail. Since the header search paths
for libc++ are (and must be) before the search paths for the C library,
the C library ends up including libc++'s <stddef.h>, which means it
depends on the `std` module. That's a cycle.

To solve this issue, this patch creates one top-level module for each C
compatibility header. The rest of the libc++ headers are located in a
single top-level `std` module, with two main exceptions. First, the
module containing configuration headers (e.g. <__config>) has its own
top-level module too, because those headers are included by the C
compatibility headers.

Second, we create a top-level std_core module that contains several
dependency-free utilities used (directly or indirectly) from the __math
subdirectory. This is needed because __math pulls in a bunch of stuff,
and __math is used from the C compatibility header <math.h>.

As a direct benefit of this change, we don't need to generate an
artificial __std_clang_module header anymore to provide a monolithic
`std` module, since our modulemap does it naturally by construction.

A next step after this change would be to look into whether math.h
really needs to include the contents of __math, and if so, whether
libc++'s math.h truly needs to include the C library's math.h header.
Removing either dependency would break this annoying cycle.

Thanks to Eric Fiselier for pointing out this approach during a recent
meeting. This wasn't viable before some recent refactoring, but wrapping
everything (except the C headers) in a large module is by far the
simplest and the most effective way of doing this.

Fixes #86193
2024-09-30 14:17:05 -04:00
A. Jiang
432ba353d8
[libc++][test] Cover move construction of allocators again (#110375)
Previous PR #107344 fixed move constructor of `test_allocator` but
dropped test coverage for move construction in some cases. This PR
attempts to restore the test coverage.

Thanks @Quuxplusone for reminding.
2024-10-01 01:24:23 +08:00
A. Jiang
78f9a8b82d
[libc++] LWG3870: Remove voidify (#110355)
Instead of changing the cast sequence to implicit conversion in
_`voidify`_, I think it is better to totally remove `__voidify` and use
`static_cast` to `void*`, which has equivalent effects.

Test coverage for const iterators are removed.

Now most affected algorithms are underconstrained, for which I submitted
[LWG3888](https://cplusplus.github.io/LWG/issue3888). I'm not sure
whether we should speculatively implement it at this moment, and thus
haven't added any `*.verify.cpp`.

In some control block types and `optional`, the stored objects are
changed to have cv-unqualified type.

Fixes #105119.
2024-10-01 01:24:00 +08:00
Louis Dionne
2121b961fd
[libc++abi][libunwind] Run c++abi and unwind tests against a fake install root (#110171)
This is what we started doing in libc++ and it straightens up a lot of
things that only happened to work before, notably the presence of
relative rpaths in dylibs when running from the build tree.

This unlocks the ability to link against a just-built dylib but run
against another version of the dylib (for example the system-provided
one), which is necessary for proper backdeployment testing.

This patch adds a lot of code duplication between the libc++ and
libc++abi testing setups. However, there is already a large amount of
duplication and the only real way to get rid of it is to merge libc++abi
into libc++. In a way, this patch is a step in that direction because it
closes the gap between the two libraries' testing setup.
2024-09-30 11:57:35 -04:00
Louis Dionne
18df9d23ea [libc++] Add an ABI setting to harden unique_ptr<T[]>::operator[] (#91798)
This allows catching OOB accesses inside `unique_ptr<T[]>` when the size
of the allocation is known. The size of the allocation can be known when
the unique_ptr has been created with make_unique & friends or when the
type necessitates an array cookie before the allocation.

This is a re-aplpication of 45a09d181 which had been reverted in
f11abac6 due to unrelated CI failures.
2024-09-30 08:32:35 -04:00
Louis Dionne
8e6bba230e [libc++][NFC] Rename fold.h to ranges_fold.h (#109696)
This follows the pattern we use consistently for ranges algorithms.

This is a re-application of 24bc3244d4e which had been reverted in
f11abac65 due to unrelated failures.
2024-09-30 08:30:16 -04:00
Chris B
f11abac652
Revert "[libc++][modules] Rewrite the modulemap to have fewer top-level modules (#107638)" (#110384)
This reverts 3 commits:
45a09d1811d5d6597385ef02ecf2d4b7320c37c5
24bc3244d4e221f4e6740f45e2bf15a1441a3076
bc6bd3bc1e99c7ec9e22dff23b4f4373fa02cae3

The GitHub pre-merge CI has been broken since this PR went in. This
change reverts it to see if I can get the pre-merge CI working again.
2024-09-28 21:47:09 -05:00
Marc Auberer
e9c0c6604e
[libc++] Add [[nodiscard]] to std::prev and std::next (#109550)
Add `[[nodiscard]]` attribute to `std::prev` and `std::next`. Those are
potential pitfalls for users who might think they mutate the iterator.

Fixes #109452
2024-09-28 22:56:11 +02:00
Un1q32
6389974873
[libc++] Don't use aligned_alloc on iOS versions before 13 (#110315)
There's a check here to not use aligned_alloc on macOS versions before
10.15, this patch adds an equivalent check that tests for iOS 13.
2024-09-27 16:11:47 -04:00
Louis Dionne
48dc4d39c7
[libc++][Apple] Add missing availabilty mappings for Apple platforms (#110289) 2024-09-27 16:05:01 -04:00
Xiaoyang Liu
51259deb72
[libc++] LWG4025: Move assignment operator of std::expected<cv void, E> should not be conditionally deleted (#109363)
This patch implements LWG4025: Move assignment operator of
`std::expected<cv void, E>` should not be conditionally deleted.

Closes #105324
2024-09-27 12:54:22 -04:00