1638 Commits

Author SHA1 Message Date
Mark de Wever
b6bb9dc5ab
[libc++][CI] Update action runner base image. (#130433)
Updates to the latest release. The side effect of this change is
updating all compilers to the latest upstream version.
2025-03-09 17:36:10 +01:00
Martin Storsjö
f909b2229a
[libcxx] Provide locale conversions to tests through lit substitution (#105651)
There are 2 problems today that this PR resolves:

libcxx tests assume the thousands separator for fr_FR locale is x00A0 on
Windows. This currently fails when run on newer versions of Windows (it
seems to have been updated to the new correct value of 0x202F around
windows 11. The exact windows version where it changed doesn't seem to
be documented anywhere). Depending the OS version, you need different
values.

There are several ifdefs to determine the environment/platform-specific
locale conversion values and it leads to maintenance as things change
over time.

This PR includes the following changes:

- Provide the environment's locale conversion values through a
  substitution. The test can opt in by placing the substitution value in a
  define flag.
- Remove the platform ifdefs (the swapping of values between Windows,
  Linux, Apple, AIX).

This is accomplished through a lit feature action that fetches the
environment's locale conversions (lconv) for members like
'thousands_sep' that we need to provide. This should ensure that we
don't lose the effectiveness of the test itself.

In addition, as a result of the above, this PR:

- Fixes a handful of locale tests which unexpectedly fail on newer
  Windows versions.
- Resolves 3 XFAIL FIX-MEs.

Originally submitted in https://github.com/llvm/llvm-project/pull/86649.

Co-authored-by: Rodrigo Salazar <4rodrigosalazar@gmail.com>
2025-02-28 23:43:46 +02:00
Nikolas Klauser
f896bd3670
[libc++] Diagnose when nullptrs are passed to string APIs (#122790)
This allows catching misuses of APIs that take a pointer to a
null-terminated string.
2025-02-27 22:57:19 +01:00
Nikolas Klauser
28851edf16
[libc++] Silence CMake's install messages in the CI (#128872)
Currently, there are a ton of `-- Installing:` and `-- Up-to-date:`
messages in the CI log, which just clutter the output. This disables
these messages to significantly shorten the CI logs, making them much
faster to load and easier to read.
2025-02-27 22:56:28 +01:00
Louis Dionne
de473fcdea
[libc++] Synchronize Docker container SHA in run-buildbot-container (#128225)
We should really find a way to have a canonical location for that SHA,
but last time I looked into it I failed to find a way to share it.
2025-02-24 09:03:06 -05:00
Louis Dionne
aa6d3ff80d
[libc++] Re-enable the FreeBSD CI job (#127687)
Technical issues have apparently been resolved and the node should be
back online.

Closes #117780
2025-02-21 11:38:23 -05:00
Simon Tatham
30ae485835
[libcxx] Work around picolibc argv handling in tests. (#127662)
This fixes some test failures when the libcxx tests are run against an
up-to-date picolibc on embedded Arm, because those tests depend on an
unsupported locale but the `hasAnyLocale` preliminary check wrongly
concluded that the locale _was_ supported.

`hasAnyLocale` passes a set of locale strings to a test program via the
command line, and checks if the libc under test reports that any of the
locales can be successfully set via setlocale(). In some invocations one
of the locale names contains a space, e.g. the Windows-style locale name
"English_United States.1252".

Unfortunately picolibc's crt0, when running under Arm semihosting,
fetches the single command string from the host and then splits it up at
spaces without implementing any kind of quoting. So it simply isn't
possible to get a space into an argv word. As a result, we end up
testing for the locale (in this example) "English_United". In up-to-date
versions of picolibc, this is actually accepted, since it contains no
objectionable character set specification (or indeed any at all). So the
lit check wrongly concludes that libc supports that locale, and enables
some locale tests, which fail.

This patch works around the issue entirely within `hasAnyLocale()`, by
abandoning the use of argv completely, and instead encoding the list of
locales to check as an array of strings inside the test program.
2025-02-21 09:08:53 +00:00
A. Jiang
2207e3e325
[libc++] Set feature-test macro __cpp_lib_atomic_float (#127559)
The corresponding feature was implemented in LLVM 18 (by #67799), but
this FTM wasn't added before.
2025-02-19 09:06:51 +08:00
Mark de Wever
fbd92d0985
[libc++][format] Disables the FTM on older MacOS versions. (#126547)
On older MacOS versions where `std::to_chars` for floating-point types
is not available the format library can't be used. Due to some issue
with the availability macro used to disable format on MacOS the issue
triggers regardless of the type being formatted.

The print library has the same issue.

Fixes: #125353
2025-02-14 18:27:54 +01:00
Louis Dionne
5953e5a3c6
[libc++] Simplify the apple-system-hardened CI configuration (#126911)
It was basically a copy-paste of the non-hardened version of the same
job, and it's easy to remove the duplication.
2025-02-12 23:58:14 +01:00
Mark de Wever
c4fe4561c7 [libc++] Fixes building with Python 3.8.
This addresses the post-commit issues reported in #101880.
2025-02-11 20:08:12 +01:00
Mark de Wever
b319dfef21
[libc++][CI] Updates Clang HEAD version in Docker. (#126419)
This is a preparation to test Clang 21 in the CI,

Drive-by: Updated some outdated documentation.
2025-02-10 18:08:24 +01:00
Mark de Wever
5b9e6c7993
[libc++] Improves type-safety in generator script. (#101880)
This changes the code to use dataclasses instead of dict entries. It
also adds type aliases to use in the typing information and updates the
typing information.
2025-02-10 18:03:44 +01:00
Mark de Wever
5b98be4e0b
[lib++][Format] Updates Unicode database. (#125712)
Updates the databease to the Unicode release 16.0.0. The algorithms of
the Grapheme clustering rules have not changed.
2025-02-05 18:55:02 +01:00
Peng Liu
cf9806eb4d
[libc++] Fix UB in bitwise logic of {std, ranges}::{fill, fill_n} algorithms (#122410)
This PR addresses an undefined behavior that arises when using the
`std::fill` and `std::fill_n` algorithms, as well as their ranges
counterparts `ranges::fill` and `ranges::fill_n`, with `vector<bool, Alloc>`
that utilizes a custom-sized allocator with small integral types.
2025-02-05 11:39:49 -05:00
Hui
def50f701f
[libc++] implement std::flat_multimap (#113835)
fixes https://github.com/llvm/llvm-project/issues/105190

---------

Co-authored-by: Hui Xie <huixie@Mac.broadband>
Co-authored-by: Hui Xie <huixie@Huis-MacBook-Pro.local>
2025-01-25 18:30:00 +00:00
Mark de Wever
de5ff8ad07
[libc++][test] Improves C++ Standard filtering. (#89499)
Adds a new lit directive to improve C++ Standard filtering. This is
based on the

[Discourse](https://discourse.llvm.org/t/rfc-improving-c-standard-filtering-in-the-lit-tests/78474)
discussion.
2025-01-25 13:08:00 +01:00
Nikolas Klauser
24e70e3930
[libc++] Switch experimental library macros to 0/1 macros (#124030)
This is a continuation of what's been started in #89178.

As a drive-by, this also changes the PSTL macro to say `EXPERIMENTAL`
instead of `INCOMPLETE`.
2025-01-24 09:34:42 +01:00
Louis Dionne
8688a31729 [libc++] Allow passing arguments to GoogleBenchmark's compare.py tool 2025-01-17 09:28:47 -05:00
Jakub Mazurkiewicz
c91d805e66
[libc++] Implement std::not_fn<NTTP> (#86133)
Implement `std::not_fn<NTTP>` from "P2714R1 Bind front and back to NTTP callables".
2025-01-10 14:14:14 -05:00
Sv. Lockal
473510abf5
[libc++] Fix mi-mode in GDB pretty printers (#120951)
GDB/MI requires unique names for each child, otherwise fails with
"Duplicate variable object name". Also wrapped containers printers
were flattened for cleaner visualization in IDEs and CLI.

Fixes #62340
2025-01-09 11:40:36 -05:00
Louis Dionne
292c1350d1
[libc++] Add new utilities to compare benchmark results between builds (#120743)
Also, add documentation for it.
2025-01-07 12:37:11 -05:00
Nikolas Klauser
b9a2658a3e
[libc++][C++03] Use __cxx03/ headers in C++03 mode (#109002)
This patch implements the forwarding to frozen C++03 headers as
discussed in
https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc. In the
RFC, we initially proposed selecting the right headers from the Clang
driver, however consensus seemed to steer towards handling this in the
library itself. This patch implements that direction.

At a high level, the changes basically amount to making each public
header look like this:

```
// inside <vector>
#ifdef _LIBCPP_CXX03_LANG
#  include <__cxx03/vector>
#else
  // normal <vector> content
#endif
```

In most cases, public headers are simple umbrella headers so there isn't
much code in the #else branch. In other cases, the #else branch contains
the actual implementation of the header.
2024-12-21 13:01:48 +01:00
Louis Dionne
d8a0709b10
[libc++] Bump the version of CMake built in the CI Docker image (#120240)
This will allow using the $<LINK_LIBRARY> generator expression in some
of our configurations. We should separately pursue officially bumping
the minimum CMake version across all LLVM so we can use this feature
more widely.
2024-12-17 10:29:18 -05:00
Louis Dionne
2135babe28
[libc++] Save benchmark results in a json file (#119761)
When running a benchmark, also save the benchmark results in a JSON
file. That is cheap to do and useful to compare benchmark results
between different runs.
2024-12-13 14:19:35 -05:00
Louis Dionne
7b2d592a19 [libc++] Fix test FTM header guard
That template is actually not used to generate the version header yet,
but we can at least fix the include guards which are clearly incorrect.
2024-12-11 12:39:43 -05:00
Louis Dionne
bd8eb7894f [libc++] Temporarily disable FreeBSD runners
They have been out for over 10 days, which only causes confusion
when looking at CI results.
2024-12-10 10:11:27 -05:00
Louis Dionne
c9009543ab
[libc++] Run the LLDB data formatter tests after libc++'s own tests (#119028)
It makes more sense to start testing libc++ with the latest compiler and
only then to run the LLDB data formatter tests, since that provides more
signal than starting with the data formatter tests.
2024-12-09 11:17:40 -05:00
Louis Dionne
6cb339f9c1
[libc++] Refactor tests for aligned allocation and sized deallocation (#117915)
This patch refactors the tests around aligned allocation and sized
deallocation to avoid relying on passing the -fsized-deallocation or
-faligned-allocation flags by default. Since both of these features are
enabled by default in >= C++14 mode, it now makes sense to make that
assumption in the test suite.

A notable exception is MinGW and some older compilers, where sized
deallocation is still not enabled by default. We treat that as a "bug"
in the test suite and we work around it by explicitly adding
-fsized-deallocation, but only under those configurations.
2024-12-06 16:12:30 -05:00
Louis Dionne
1b03747ed8
[libc++] Augment Github - CSV synchronization script to auto-create new Github issues (#118139)
This makes it easier to create the Github issues and add them to the
libc++ conformance project after a WG21 meeting.
2024-12-02 13:47:47 -05:00
Louis Dionne
ef50d790c2 [libc++] Update run-buildbot-container with up-to-date image information 2024-11-29 12:10:45 -05:00
Nikolas Klauser
aaa0dd2f05 [libc++][NFC] Remove a bunch of unused environment variables from the CI configs 2024-11-23 12:32:47 +01:00
Ryan Prichard
1c8ac4c620
[libc++][Android] BuildKite CI: update Clang and sysroot versions (#116151)
Android clang-r536225 identifies as Clang 19 but it predates LLVM
19.0.0. It is based off of fc57f88f007497a4ead0ec8607ac66e1847b02d6.
2024-11-20 14:07:55 -08:00
Louis Dionne
649e4bf5d8 [libc++] Update the docker-compose file for actions CI 2024-11-15 10:51:37 +01:00
Louis Dionne
073159004f [libc++] Remove obsolete 'macos-ci-setup' script
We don't use it anymore since we moved to Github hosted runners
for mac instead of the Foundation-provided runners.
2024-11-15 09:07:33 +01:00
Louis Dionne
e58949632e
[libc++] Define all CMake configuration features in the same location (#115361)
This moves the configuration of the CMake features to turn off RTTI,
exceptions and friends to the beginning of the CMake file, where we
configure other optional parts of the library.

This fixes an important bug where we would disable the benchmarks
because these options were not defined yet, leading to the build
thinking they were defined to OFF.
2024-11-14 13:06:43 +01:00
Alexander Richardson
30feb35c1e
[libc++] Update CMake dependency for generate_iwyu_mapping.py (#115387)
This script does not depend on the generated headers since those are
already special-cased in header_information.py. Change the dependency
list to depend on header_information.py instead. While looking at this
code also simplify the assignment to libcxx_root inside this script.
2024-11-11 09:59:58 -05:00
Louis Dionne
427a5cf105
[libc++] Add support for bounded iterators in std::array (#110729)
This patch introduces a new kind of bounded iterator that knows the size
of its valid range at compile-time, as in std::array. This allows computing
the end of the range from the start of the range and the size, which requires
storing only the start of the range in the iterator instead of both the start
and the size (or start and end). The iterator wrapper is otherwise identical
in design to the existing __bounded_iter.

Since this requires changing the type of the iterators returned by
std::array, this new bounded iterator is controlled by an ABI flag.

As a drive-by, centralize the tests for std::array::operator[] and add
missing tests for OOB operator[] on non-empty arrays.

Fixes #70864
2024-11-07 09:23:21 -05:00
Louis Dionne
e236a52a88
[libc++] Unify the benchmarks with the test suite (#101399)
Instead of building the benchmarks separately via CMake and running them
separately from the test suite, this patch merges the benchmarks into
the test suite and handles both uniformly.

As a result:
- It is now possible to run individual benchmarks like we run tests
  (e.g. using libcxx-lit), which is a huge quality-of-life improvement.

- The benchmarks will be run under exactly the same configuration as
  the rest of the tests, which is a nice simplification. This does
  mean that one has to be careful to enable the desired optimization
  flags when running benchmarks, but that is easy with e.g.
  `libcxx-lit <...> --param optimization=speed`.

- Benchmarks can use the same annotations as the rest of the test
  suite, such as `// UNSUPPORTED` & friends.

When running the tests via `check-cxx`, we only compile the benchmarks
because running them would be too time consuming. This introduces a bit
of complexity in the testing setup, and instead it would be better to
allow passing a --dry-run flag to GoogleBenchmark executables, which is
the topic of https://github.com/google/benchmark/issues/1827.

I am not really satisfied with the layering violation of adding the
%{benchmark_flags} substitution to cmake-bridge, however I believe
this can be improved in the future.
2024-11-07 09:07:50 -05:00
Nikolas Klauser
c6f3b7bcd0
[libc++] Refactor the configuration macros to being always defined (#112094)
This is a follow-up to #89178. This updates the `<__config_site>`
macros.
2024-11-06 10:39:19 +01:00
A. Jiang
76b71c0bc4
[libc++] Set __cpp_lib_smart_ptr_for_overwrite (#114700)
The features were implemented in LLVM 16, but mistakenly considered
unimplemented in FTM tools.
2024-11-05 13:27:40 +08:00
Joseph Huber
95a2eb70cf
[libcxx] Add testing configuration for GPU targets (#104515)
Summary:
The GPU runs these tests using the files built from the `libc` project.
These will be placed in `include/<triple>` and `lib/<triple>`. We use
the `amdhsa-loader` and `nvptx-loader` tools, which are also provided by
`libc`. These launch a kernel called `_start` which calls `main` so we
can pretend like GPU programs are normal terminal applications.

We force serial exeuction here, because `llvm-lit` runs way too many
processes in parallel, which has a bad habit of making the GPU drivers
hang or run out of resources. This allows the compilation to be run in
parallel while the jobs themselves are serialized via a file lock.

In the future this can likely be refined to accept user specified
architectures, or better handle including the root directory by exposing
that instead of just `include/<triple>/c++/v1/`.

This currently fails ~1% of the tests on AMDGPU and ~3% of the tests on
NVPTX. This will hopefully be reduced further, and later patches can
XFAIL a lot of them once it's down to a reasonable number.

Future support will likely want to allow passing in a custom
architecture instead of simply relying on `-mcpu=native`.
2024-11-04 12:58:23 -06:00
Nikolas Klauser
e99c4906e4
[libc++] Granularize <cstddef> includes (#108696) 2024-10-31 02:20:10 +01:00
A. Jiang
63eb40eeb1
[libc++] Deprecate and remove meaningless <cxxx> headers (#111615)
This PR deprecates `<ccomplex>`, `<cstdbool>`, `<ctgmath>`, and
`<ciso646>` in C++17 and "removes" them in C++20 by special deprecation
warnings.

`<cstdalign>` is previously missing. This PR also tries to add them, and
then deprecates and "removes" `<cstdalign>`.

Papers:
- https://wg21.link/P0063R3
- https://wg21.link/P0619R4

Closes #99985.

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2024-10-30 09:49:26 +08:00
Hui
0be1883c36
[libc++] Implement P0429R9 std::flat_map (#98643)
Around half of the tests are based on the tests Arthur O'Dwyer's
original implementation of std::flat_map, with modifications and
removals.

partially implement #105190
2024-10-26 18:58:53 +01:00
A. Jiang
cae351f345
[libc++] Bump __cpp_lib_optional and __cpp_lib_variant (#113650)
In C++20 mode, `__cpp_lib_optional` and `__cpp_lib_variant` should be
`202106L` due to DR P2231R1.

In C++26 mode, `__cpp_lib_variant` should be bumped to `202306L` due to
P2637R3.
- Clang 16/17 shouldn't get this bumping (as member `visit` requires
explicit object parameters), but it's very tricky to make the bumping
conditionally enabled. I _hope_ unconditionally bumping in C++26 will be
OK for LLVM 20 when the support for Clang 17 is dropped.

Related PRs:
- https://reviews.llvm.org/D102119
- #83335
- #76447
2024-10-26 07:38:52 +08:00
Louis Dionne
460406affe
[libc++] Exclude C++03 frozen headers from the modulemap (#113572)
This is a temporary patch, eventually these headers should be included
in the modulemap as well.
2024-10-24 11:57:42 -04:00
Nikolas Klauser
e78f53d1e8
Reapply "[libc++][C++03] Copy the LLVM 19 headers (#108999)" (#112127)
This reverts commit 68c04b0ae62d8431d72d8b47fc13008002ee4387.

This disables the IWYU mapping that caused the failure, since
the headers aren't reachable for now.

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-24 00:17:37 +02:00
Louis Dionne
d6e714b10e
[libc++] Rewrite the transitive header checking machinery (#110554)
Since we don't generate a full dependency graph of headers, we can
greatly simplify the script that parses the result of --trace-includes.

At the same time, we also unify the mechanism for detecting whether a
header is a public/C compat/internal/etc header with the existing
mechanism in header_information.py.

As a drive-by this fixes the headers_in_modulemap.sh.py test which had
been disabled by mistake because it used its own way of determining
the list of libc++ headers. By consistently using header_information.py
to get that information, problems like this shouldn't happen anymore.

This should also unblock #110303, which was blocked because of
a brittle implementation of the transitive includes check which broke
when the repository was cloned at a path like /path/__something/more.
2024-10-22 09:18:58 -04:00
Michael Jones
6c4267fb17
[libcxx][libc] Hand in Hand PoC with from_chars (#91651)
Implements std::from_chars for float and double.

The implementation uses LLVM-libc to do the real parsing. Since this is
the first time libc++
uses LLVM-libc there is a bit of additional infrastructure code. The
patch is based on the
[RFC] Project Hand In Hand (LLVM-libc/libc++ code sharing)

https://discourse.llvm.org/t/rfc-project-hand-in-hand-llvm-libc-libc-code-sharing/77701
2024-10-21 15:04:06 -07:00