Commit Graph

8325 Commits

Author SHA1 Message Date
Martin Storsjö 62cff45d76 Revert "Reapply [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind"
This reverts commit 317dc31e53.

After that change, OpenMP doesn't find dependencies in the host
system (it fails do find e.g. /usr/lib/x86_64-linux-gnu/libelf.so
which it found before), which causes some OpenMP target offloading
plugins to not be found. This doesn't break the build, but just
causes the AMDGPU OpenMP target plugin to be omitted. See
https://reviews.llvm.org/D113253#3181934 for the report of this
issue.
2021-12-09 12:56:57 +02:00
Joe Loser ec63930c06
[libc++][NFC] Remove test/support/tracked_value.h
No tests are using `libcxx/test/support/tracked_value.h`. So, remove it.

Differential Revision: https://reviews.llvm.org/D115411
2021-12-08 21:18:58 -05:00
Arthur O'Dwyer f638c4d6e4 [libc++] [test] Refactor range.prim/empty.pass.cpp.
No decrease in test coverage intended. The original goal here
was just to get rid of the global name `sentinel` so that we can
rename the `sentinel_wrapper` in "test_iterators.h" to `sentinel`;
but then I took a closer look at the offending tests and saw
that some of them probably weren't testing what they intended.

Also, add one `/*explicit*/` and one #if'ed out test indicating
bugs in the current ranges::empty (to be fixed by D115312 or
some equivalent patch).

Reviewed as part of D115272.
2021-12-08 16:41:02 -05:00
Arthur O'Dwyer c19d8f955a [libc++] [test] Use sized_sentinel<int*> in range.prim/ssize.pass.cpp.
Reviewed as part of D115272.
2021-12-08 16:41:02 -05:00
Arthur O'Dwyer 67c43d87cd [libc++] [test_iterators] Make all ADL base() functions into hidden friends. NFCI.
This follows up on my addition of base(cpp20_input_iterator) in D115177,
making all the ADL base() functions consistent.
Also align cpp20_input_iterator with the other test iterators' style.

Reviewed as part of D115272.
2021-12-08 16:41:01 -05:00
Nikolas Klauser feb80aa96b [libc++] `= delete` member functions with // = delete;
Use `= delete` for member functions that are marked with `// = delete;`

Reviewed By: ldionne, Quuxplusone, #libc

Spies: jloser, libcxx-commits

Differential Revision: https://reviews.llvm.org/D115291
2021-12-08 19:29:44 +01:00
Mark de Wever ade336dee4 Revert "[libc++][ci] Disable generating debug information."
The bug this patch works around prevents D70631 to land.
Remove the work-around since it's no longer needed.
2021-12-08 17:58:51 +01:00
Louis Dionne a6e5563dfa [libc++][release] Do not force building the runtimes with -fPIC
There's a lot of history behind this, so here's a summary:

1. I stopped forcing -fPIC when building the runtimes in 30f305efe2,
   before the LLVM 9 release back in 2019.

2. Someone complained that libc++.a couldn't be used in shared libraries
   built without -fPIC (http://llvm.org/PR43604) since the LLVM 9 release.
   This had been caused by my removal of -fPIC when building libc++.a in (1).

3. I suggested two ways of fixing the issue, the first being to force
   -fPIC back unconditionally (http://llvm.org/D104328), and the second
   being to specify that option explicitly when building the LLVM release
   (http://llvm.org/D104327). We converged on the first solution.

4. I landed D104328, which forced building the runtimes with -fPIC.
   This was included in the LLVM 13.0 release.

5. People complained about that and requested that we be able to
   customize this setting (basically we should have done the second
   solution).

This patch makes it such that the LLVM release script will specifically
ask for building with -fPIC using CMAKE_POSITION_INDEPENDENT_CODE,
however by default the runtimes will not force that option onto users.

This patch has the unintended effect that Clang and the LLVM libraries
(not only the runtime ones like libc++) will also be built with -fPIC
in the release. It would be better if we could specify that -fPIC is to
be used only when building the runtimes, however this is left as a
future improvement. The release should probably be using a bootstrapping
build and passing those options to the stage that builds the runtimes
only, see https://reviews.llvm.org/D112748 for that change.

Differential Revision: https://reviews.llvm.org/D110261
2021-12-08 11:34:35 -05:00
Louis Dionne 9678d25a97 [libc++] Bump Dockerfile 2021-12-08 08:57:24 -05:00
Louis Dionne 81eda008e9 [libc++] Extract __clamp_to_integral to its own header
In addition to being more consistent with our approach for helpers, this
solves an actual issue where <cmath> was using numeric_limits but never
including the <limits> header directly. In a normal setup, this is not
an issue because the <math.h> header included by <cmath> does include
<limits>. However, I did stumble upon some code where that didn't work,
most likely because they were placing their own <math.h> header in front
of ours. I didn't bother investigating further.

Differential Revision: https://reviews.llvm.org/D115282
2021-12-08 08:33:37 -05:00
Mircea Trofin 5dda2efde5 Re-Reland "[benchmarks] Move libcxx's fork of google/benchmark and llvm/utils'"
This reverts commit b2fbd45d23. D114922
fixed the reason of the 2nd revert.

This patch also re-applies 39e9f5d368.

Differential Revision: https://reviews.llvm.org/D112012
2021-12-07 17:10:41 -08:00
Martin Storsjö 317dc31e53 Reapply [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind
This does mostly the same as D112126, but for the runtimes cmake files.
Most of that is straightforward, but the interdependency between
libcxx and libunwind is tricky:

Libunwind is built at the same time as libcxx, but libunwind is not
installed yet. LIBCXXABI_USE_LLVM_UNWINDER makes libcxx link directly
against the just-built libunwind, but the compiler implicit -lunwind
isn't found. This patch avoids that by adding --unwindlib=none if
supported, if we are going to link explicitly against a newly built
unwinder anyway.

Reapplying this after
db32c4f456, which should fix the issues
that were reported last time this was applied.

Differential Revision: https://reviews.llvm.org/D113253
2021-12-08 00:32:40 +02:00
Nikolas Klauser 4955095fe6 [libc++] Remove _LIBCPP_DEFAULT
clang has `= default` as an extension in c++03, so just use it.

Reviewed By: ldionne, Quuxplusone, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D115275
2021-12-07 22:18:38 +01:00
Arthur O'Dwyer b108cd7b45 [libc++] [test] Rationalize the nodiscard tests for range adaptors.
Reviewed as part of D115177.
2021-12-07 13:59:42 -05:00
Arthur O'Dwyer bd0c0e5b8c [libc++] [ranges] SFINAE-friendly "write it three times" in views::counted.
Before this patch, the new test's `CountedInvocable<int*, int*>`
would hard-error instead of SFINAEing and cleanly returning false.

Notice that views::counted specifically does NOT work with pipes;
`counted(42)` is ill-formed. This is because `counted`'s first argument
is supposed to be an iterator, not a range.

Also, mark `views::counted(it, n)` as [[nodiscard]], and test that.
(We have a general policy now that range adaptors are consistently
marked [[nodiscard]], so that people don't accidentally think that
they have side effects. This matters mostly for `reverse` and
`transform`, arguably `drop`, and just generally let's be consistent.)

Differential Revision: https://reviews.llvm.org/D115177
2021-12-07 13:59:41 -05:00
Arthur O'Dwyer 7a06a14f62 [libc++] Remove unneeded `std::` qualifications from <compare>. NFCI.
Reviewed as part of D115177.
2021-12-07 13:59:41 -05:00
Arthur O'Dwyer 04d74aaff9 [libc++] std::move should be _VSTD::move in one place. NFCI.
Reviewed as part of D115177.
2021-12-07 13:59:41 -05:00
Louis Dionne e7f53ec78f [libc++] Bump Dockerfile 2021-12-07 07:30:46 -05:00
Louis Dionne c49a13a45a [libc++] Fix atomic test for _BitInt
In 6c75ab5f66, Clang deprecated _ExtInt in favor of _BitInt, which
made this test fail. This patch disables the test on older compilers
and uses the new _BitInt type instead.

Differential Revision: https://reviews.llvm.org/D115194
2021-12-07 07:30:09 -05:00
Petr Hosek ae53d02f55 Revert "Microsoft's floating-point to_chars powered by Ryu and Ryu Printf"
This reverts commit a8025e06fc since
it triggers PR52584 with debug info enabled.
2021-12-07 00:10:14 -08:00
Louis Dionne 2db67e9771 [libc++] Fix the return value of max_size()
I assume nobody ever uses std::string_view::max_size() outside of
testing. However, we should still return a value that is based on
something with a reasonable rationale. Previously, we would forget
to take into account the size of the character type stored in the
string, and this patch takes that into account.

Thanks to @mclow.lists for pointing out this issue.

Differential Revision: https://reviews.llvm.org/D114395
2021-12-06 13:53:25 -05:00
Louis Dionne 5871969048 [libc++][NFC] Fix release note indentation 2021-12-06 13:44:15 -05:00
Arthur O'Dwyer dcdb07abce [libc++] Work around a Clang bug in transform_view, and regression-test.
Clang trunk rejects the new test case, but this is a Clang bug
(PR47414, 47509, 50864, 44833).

```
In module 'std' imported from /Users/aodwyer/llvm-project/libcxx/test/std/ranges/range.adaptors/range.transform/general.pass.cpp:17:
/Users/aodwyer/llvm-project/build2/include/c++/v1/__ranges/transform_view.h:85:44: error: constraints not satisfied for alias template 'range_reference_t' [with _Rp = const NonConstView]
             regular_invocable<const _Fn&, range_reference_t<const _View>>
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/aodwyer/llvm-project/build2/include/c++/v1/__ranges/transform_view.h:416:25: note: in instantiation of template class 'std::ranges::transform_view<NonConstView, (lambda at /Users/aodwyer/llvm-project/libcxx/test/std/ranges/range.adaptors/range.transform/general.pass.cpp:73:71)>' requested here
      -> decltype(      transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f)))
                        ^
```

We can work around this by adding a layer of indirection: put the
problematic constraint into a named concept and Clang becomes more
amenable to SFINAE'ing instead of hard-erroring.

Drive-by simplify `range.transform/general.pass.cpp` to make it clearer
what it's actually testing in this area.

Differential Revision: https://reviews.llvm.org/D115116
2021-12-06 11:20:08 -05:00
Nikolas Klauser f50be8eb0a [libc++][NFC] Disable clang-tidy checks
Disable clang-tidy checks as discussed in D114915

Reviewed By: ldionne, #libc

Spies: cjdb, aheejin, libcxx-commits

Differential Revision: https://reviews.llvm.org/D114985
2021-12-06 01:51:23 +01:00
Arthur O'Dwyer 2f16b87b4b [libc++] Remove space-alignment of trailing braces in module.modulemap. NFC.
As discussed on the Discord, 2021-12-01 through 2021-12-05.
Our new consistent style for this is "don't align the right-braces"
(but still align the left-braces, as shown).
2021-12-05 18:56:58 -05:00
Arthur O'Dwyer 4c2fef74dd [libc++] Adjust space-alignment in module.modulemap. NFC. 2021-12-05 13:22:19 -05:00
Arthur O'Dwyer 413c3c4f81 [libc++] Add missing `#pragma GCC system_header` in a few headers. NFCI. 2021-12-05 13:22:19 -05:00
Arthur O'Dwyer 0b609efd4f [libc++] Fix an include-guard comment. NFC. 2021-12-05 13:22:19 -05:00
Mark de Wever 8783f53fb2 [libc++][doc] Update format implementation status. 2021-12-05 17:44:24 +01:00
Nilay Vaish 3536e18a6c Remove duplicate comment
The same comment appears in the very next line.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D115018
2021-12-05 14:03:44 +01:00
Mark de Wever a8025e06fc Microsoft's floating-point to_chars powered by Ryu and Ryu Printf
Microsoft would like to contribute its implementation of floating-point to_chars to libc++. This uses the impossibly fast Ryu and Ryu Printf algorithms invented by Ulf Adams at Google. Upstream repos: https://github.com/microsoft/STL and https://github.com/ulfjack/ryu .

Licensing notes: MSVC's STL is available under the Apache License v2.0 with LLVM Exception, intentionally chosen to match libc++. We've used Ryu under the Boost Software License.

This patch contains minor changes from Jorg Brown at Google, to adapt the code to libc++. He verified that it works in Google's Linux-based environment, but then I applied more changes on top of his, so any compiler errors are my fault. (I haven't tried to build and test libc++ yet.) Please tell me if we need to do anything else in order to follow https://llvm.org/docs/DeveloperPolicy.html#attribution-of-changes .

Notes:

* libc++'s integer charconv is unchanged (except for a small refactoring). MSVC's integer charconv hasn't been tuned for performance yet, so you're not missing anything.
* Floating-point from_chars isn't part of this patch because Jorg found that MSVC's implementation (derived from our CRT's strtod) was slower than Abseil's. If you're unable to use Abseil or another implementation due to licensing or technical considerations, Microsoft would be delighted if you used MSVC's from_chars (and you can just take it, or ask us to provide a patch like this). Ulf is also working on a novel algorithm for from_chars.
* This assumes that float is IEEE 32-bit, double is IEEE 64-bit, and long double is also IEEE 64-bit.
* I have added MSVC's charconv tests (the whole thing: integer/floating from_chars/to_chars), but haven't adapted them to libcxx's harness at all. (These tests will be available in the microsoft/STL repo soon.)
* Jorg added int128 codepaths. These were originally present in upstream Ryu, and I removed them from microsoft/STL purely for performance reasons (MSVC doesn't support int128; Clang on Windows does, but I found that x64 intrinsics were slightly faster).
* The implementation is split into 3 headers. In MSVC's STL, charconv contains only Microsoft-written code. xcharconv_ryu.h contains code derived from Ryu (with significant modifications and additions). xcharconv_ryu_tables.h contains Ryu's large lookup tables (they were sufficiently large to make editing inconvenient, hence the separate file). The xmeow.h convention is MSVC's for internal headers; you may wish to rename them.
* You should consider separately compiling the lookup tables (see https://github.com/microsoft/STL/issues/172 ) for compiler throughput and reduced object file size.
* See https://github.com/StephanTLavavej/llvm-project/commits/charconv for fine-grained history. (If necessary, I can perform some rebase surgery to show you what Jorg changed relative to the microsoft/STL repo; currently that's all fused into the first commit.)

Differential Revision: https://reviews.llvm.org/D70631
2021-12-05 13:25:33 +01:00
Mark de Wever 15495be014 [libc++][ci] Disable generating debug information.
In the bootstrap build generating debug information causes an ICE.
This is a work-around for llvm.org/PR52584
2021-12-05 13:22:58 +01:00
Konstantin Varlamov 2d9efcfeec [libc++][ranges] Implement [special.mem.concepts].
Implement the exposition-only concepts specified in
`[special.mem.concepts]`. These are all thin wrappers over other
concepts.

Reviewed By: #libc, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D114761
2021-12-02 17:58:04 -08:00
David Blaikie 1f2492b7da libcxx pretty printers: remove non-lazy_string fallback
This has been supported on gdb for something like ~10 years, so doesn't
seem necessary to carry a fallback.

Differential Revision: https://reviews.llvm.org/D114986
2021-12-02 14:31:08 -08:00
Nikolas Klauser d2b0df35af [libc++][NFC] Update namespace comments in include/
update the namspace comments in include/

Reviewed By: ldionne, #libc

Spies: smeenai, libcxx-commits

Differential Revision: https://reviews.llvm.org/D114947
2021-12-02 21:06:59 +01:00
David Blaikie ff618a963a Simplify the libcxx std::string_view gdb pretty printer
Seems better to rely on the existing formatting, makes the output
smaller/simpler - this is consistent with libstdc++'s std::string_view
pretty printing too.

Differential Revision: https://reviews.llvm.org/D113244
2021-12-02 11:36:38 -08:00
Joe Loser c16b13ebf9
[libc++] Implement P1989R2: range constructor for string_view
Implement P1989R2 which adds a range constructor for `string_view`.

Adjust `operator/=` in `path` to avoid atomic constraints caching issue
getting provoked from this PR.

Add defaulted template argument to `string_view`'s "sufficient
overloads" to avoid mangling issues in `clang-cl` builds. It is a
MSVC mangling bug that this works around.

Differential Revision: https://reviews.llvm.org/D113161
2021-12-01 23:16:36 -05:00
Konstantin Boyarinov 8c6b24899e [libcxx][test][NFC] Various tests for std::vector
Add missing tests for std::vector funcionality to improve code coverage:

  - Rewrote access tests to check modification of the container using
    the reference returned by the non-const overload
  - Added tests for reverse iterators: rbegin, rend, etc.
  - Added exception test for vector::reserve
  - Extended test cases for vector copy assignment
  - Fixed insert_iter_value.pass.cpp to use insert overload with const
    value_type& (not with value_type&& which is tested in
    iter_rvalue.pass.cpp test)

Reviewed By: Quuxplusone, rarutyun, #libc

Differential Revision: https://reviews.llvm.org/D112438
2021-12-02 02:11:45 +03:00
Nikolas Klauser 6146e4cf89 [libc++] Make __wrap_iter constexpr
`__wrap_iter` is currently only constexpr if it's not a debug built, but it isn't used in a constexpr context currently. Making it always constexpr and disabling the debugging utilities at constant evaluation is more usful since it has to be always constexpr to be used in a constexpr context.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D114733
2021-12-01 23:29:22 +01:00
Christopher Di Bella a0efb17500 [libcxx][modularisation] modularises <numeric> header
Differential Revision: https://reviews.llvm.org/D114836
2021-12-01 20:40:21 +00:00
Arthur O'Dwyer 0efd9a03fa [libc++] [test] Refactor string_view comparison tests for comprehensiveness.
Differential Revision: https://reviews.llvm.org/D114658
2021-12-01 15:04:33 -05:00
Arthur O'Dwyer b4a13e4c98 [libc++] [test] C++14/17-friendly `TEST_IS_CONSTANT_EVALUATED` macro.
Reviewed as part of D114658.
Ultimately this will probably have to be flipped around and renamed
`TEST_IS_RUNTIME`, and extended with `TEST_IS_RUNTIME_OR_CXX20` (once
constexpr std::string support is added) and so on for every new C++
version. But we don't need that flexibility yet, so we're not adding it.
2021-12-01 15:02:54 -05:00
Arthur O'Dwyer a0b50c56d1 [libc++] [test] C++03-friendly MAKE_STRING macro.
Reviewed as part of D114658.
2021-12-01 15:02:53 -05:00
Konstantin Varlamov 7da4ee6f23 [libcxx][NFC] Make sequence containers slightly more SFINAE-friendly during CTAD.
Disable the constructors taking `(size_type, const value_type&,
allocator_type)` if `allocator_type` is not a valid allocator.
Otherwise, these constructors are considered when resolving e.g.
`(int*, int*, NotAnAllocator())`, leading to a hard error during
instantiation. A hard error makes the Standard's requirement to not
consider deduction guides of the form `(Iterator, Iterator,
BadAllocator)` during overload resolution essentially non-functional.

The previous approach was to SFINAE away `allocator_traits`. This patch
SFINAEs away the specific constructors instead, for consistency with
`basic_string` -- see [LWG3076](wg21.link/lwg3076) which describes
a very similar problem for strings (note, however, that unlike LWG3076,
no valid constructor call is affected by the bad instantiation).

Differential Revision: https://reviews.llvm.org/D114311
2021-12-01 11:56:51 -08:00
Louis Dionne dc1244dc4e [runtimes] Move WARNING to FATAL_ERROR for folks using FOO_BUILD_32_BITS 2021-12-01 12:57:30 -05:00
Louis Dionne fa1c077b41 [runtimes] Remove support for GCC-style 32 bit multilib builds
This patch removes the ability to build the runtimes in the 32 bit
multilib configuration, i.e. using -m32. Instead of doing this, one
should cross-compile the runtimes for the appropriate target triple,
like we do for all other triples.

As it stands, -m32 has several issues, which all seem to be related to
the fact that it's not well supported by the operating systems that
libc++ support. The simplest path towards fixing this is to remove
support for the configuration, which is also the best course of action
if there is little interest for keeping that configuration. If there
is a desire to keep this configuration around, we'll need to do some
work to figure out the underlying issues and fix them.

Differential Revision: https://reviews.llvm.org/D114473
2021-12-01 12:57:01 -05:00
Mark de Wever 0e9979affe [libc++][format][1/6] Reduce binary size.
This removes the `format_args_t` from `<format>` and adjusts the type of
the `format_args` for the `vformat_to` overloads.

The `format_context` uses a `back_insert_iterator<string>` therefore the
new `output_iterator` function uses a `string` as its temporary storage
buffer. This isn't ideal. The next patches in this series will improve
this. These improvements make it easy to also improve `format_to_n` and
`formatted_size`.

This addresses P2216 `6. Binary size`.
P2216 `5. Compile-time checks` are not part of this change.

Implements parts of:
- P2216 std::format improvements

Depends on D103670

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D110494
2021-12-01 17:50:17 +01:00
Fabian Wolff b254c2e2c4 [libc++] Fix `uniform_int_distribution` for 128-bit result type
Fixes https://llvm.org/PR51520. The problem is that `uniform_int_distribution`
currently uses an unsigned integer with at most 64 bits internally, which
is then casted to the desired result type. If the result type is `int64_t`,
this will produce a negative number if the most significant bit is set,
but if the result type is `__int128_t`, the value remains non-negative
and will be out of bounds for the example in PR#51520. (The reason why
it also seems to work if the upper or lower bound is changed is
because the branch at [1] will then no longer be taken, and proper
rejection sampling takes place.)

The bigger issue here is probably that `uniform_int_distribution` can be
instantiated with `__int128_t` but will silently produce incorrect results
(only the lowest 64 bits can ever be set). libstdc++ also supports `__int128_t`
as a result type, so I have simply extended the maximum width of the
internal intermediate result type.

[1]: https://github.com/llvm/llvm-project/blob/6d28dffb6/libcxx/include/__random/uniform_int_distribution.h#L266-L267

Differential Revision: https://reviews.llvm.org/D114129
2021-12-01 11:03:29 -05:00
Konstantin Boyarinov 8d25da78aa [libcxx][test][NFC] Extend get_allocator() testing for containers
Add dedicated tests for get_allocator() method for sequence, ordered and
unordered associative containers including constness coverage.

Reviewed by: ldionne, Mordante, rarutyun, #libc

Differential revision: https://reviews.llvm.org/D114785
2021-12-01 16:15:19 +03:00
Kent Ross 7d18267cfe [libcxx][doc] Document recent spaceship projects progress
Update a couple authors, differentials, and completed projects for operator<=> implementation

Reviewed By: #libc, Mordante, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D114682
2021-11-30 18:47:19 -08:00