Commit Graph

6030 Commits

Author SHA1 Message Date
marshall 8424789eec Update last-mod date for libcxx status page 2020-02-16 18:55:50 +01:00
marshall 1a07084f6d Updated with list of papers and issues adopted in Prague 2020-02-16 18:54:28 +01:00
Eric Fiselier 82b47b2978 [libc++] Move abs and div into stdlib.h to fix header cycle.
libc++ is careful to not fracture overload sets. When one overload
is visible to a user, all of them should be. Anything less causes
subtle bugs and ODR violations.

Previously, in order to support ::abs and ::div being supplied by
both <cmath> and <cstdlib> we had to do awful things that make
<math.h> and <stdlib.h> have header cycles and be non-modular.
This really breaks with modules.

Specifically the problem was that in C++ ::abs introduces overloads
for floating point numbers, these overloads forward to ::fabs,
which are defined in math.h. Therefore ::abs needed to be in math.h
too. But this required stdlib.h to include math.h and math.h to
include stdlib.h.

To avoid these problems the definitions have been moved to stddef.h
(which math includes), and the floating point overloads of ::abs
have been changed to call __builtin_fabs, which both Clang and GCC
support.
2020-02-15 18:55:07 -05:00
Eric Fiselier 99382e450f [libc++] Add utility to generate and display libc++'s header dependency
graph.
2020-02-15 18:47:17 -05:00
Eric Fiselier e8358455a2 [libc++] Add missing include for is_same in test 2020-02-14 18:55:27 +01:00
Eric Fiselier cccf1ef0c8 [libc++] Remove cycle between <type_traits> and <cstddef>
This was caused by byte depending on traits. This patch moves
the minimal amount of meta-programming into <cstddef> to break the cycle.
2020-02-14 17:36:27 +01:00
Eric Fiselier e337fb0790 add type_traits include as required for std::integral_constant 2020-02-14 16:38:28 +01:00
Louis Dionne f54e7b4e3a [libc++] Remove unnecessary typenames from std/numerics/c.math/abs.pass.cpp
There are some unnecessary typenames in std/numerics/c.math/abs.pass.cpp;
e.g. they're not in a dependent context.

Patch by Bryce Adelstein Lelbach

Differential Revision: https://reviews.llvm.org/D72106
2020-02-14 16:04:40 +01:00
Louis Dionne 0a0e0afaa0 [libc++] span: Fix incorrect static asserts
The static asserts in span<T, N>::front() and span<T, N>::back() are
incorrect as they may be triggered from valid code due to evaluation
of a never taken branch:

    span<int, 0> foo;
    if (!foo.empty()) {
        auto x = foo.front();
    }

The problem is that the branch is always evaluated by the compiler,
creating invalid compile errors for span<T, 0>.

Thanks to Michael Schellenberger Costa for the patch.

Differential Revision: https://reviews.llvm.org/D71995
2020-02-14 14:32:41 +01:00
Louis Dionne 8bec892713 [libc++][Apple] Use CLOCK_MONOTONIC_RAW instead of CLOCK_UPTIME_RAW for steady_clock
Summary:
In D27429, we switched the Apple implementation of steady_clock::now()
from clock_gettime(CLOCK_MONOTONIC) to clock_gettime(CLOCK_UPTIME_RAW).
The purpose was to get nanosecond precision, and also to improve the
performance of the implementation.

However, it appears that CLOCK_UPTIME_RAW does not satisfy the requirements
of the Standard, since it is not strictly speaking monotonic. Indeed, the
clock does not increment while the system is asleep, which had been
mentioned in D27429 but somehow not addressed.

This patch switches to CLOCK_MONOTONIC_RAW, which is monotonic, increased
during sleep, and also has nanosecond precision.

https://llvm.org/PR44773

Reviewers: bruno, howard.hinnant, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits, mclow.lists, EricWF

Tags: #libc

Differential Revision: https://reviews.llvm.org/D74341
2020-02-12 16:43:36 +01:00
Louis Dionne b5abd50f06 [libc++] span: Guard against overflow in span::subspan
The calculation _Offset + _Count <= size() may overflow, so use
_Count <= size() - _Offset instead. Note that this is safe due to
the previous constraint that _Offset <= size().

Patch by Michael Schellenberger Costa.

Differential Revision: https://reviews.llvm.org/D71998
2020-02-12 16:21:46 +01:00
Sergej Jaskiewicz 377a1c80e9 [libcxx] Don't assume cwd name in std::filesystem tests
Summary:
In `std::filesystem::proximate` tests we assume that the current working directory's name
is `fs.op.proximate`. This is fine when we're running the tests locally.

However, if we're running those tests on a remote machine via SSH, the directory layout may be
different. For example, currently we copy each test executable individually into
a temporary directory on the target board using SCP, so the assumption about the working directory name
doesn't necessarily hold.

This patch is the only thing that is necessary for all libc++ tests to pass when run remotely.

Reviewers: ldionne, EricWF, mclow.lists

Reviewed By: ldionne, EricWF

Subscribers: christof, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D74348
2020-02-12 16:08:17 +03:00
David Zarzycki 11fb68abab [libc++] Unbreak test suite (CWG1423)
clang 9ce6dc9872 drops support for
implicit conversion of nullptr_t to bool. From that commit:

    The C++ rules briefly allowed this, but the rule changed nearly 10
    years ago and we never updated our implementation to match. However,
    we've warned on this by default for a long time, and no other compiler
    accepts (even as an extension).
2020-02-11 15:00:33 -05:00
Louis Dionne 37f46650c3 [libc++] Make sure that vector copy-construction is disabled for non-copyable types
The Standard requires the value_type of the vector to be Cpp17CopyInsertable
in order for copy-construction to be enabled:

	http://eel.is/c++draft/container.requirements#tab:container.req

rdar://problem/56674564

Differential Revision: https://reviews.llvm.org/D74251
2020-02-11 17:12:16 +01:00
Louis Dionne 592f35481a [libc++] Disable a filesystem test that uses debug mode with the macOS system libc++
The system libc++.dylib doesn't support the debug mode, so this test
can't be supported. As a fly-by fix, we also specify more stringently
that only the macOS system library is unsupported in other tests using
the debug mode.
2020-02-11 14:57:14 +01:00
Louis Dionne 2234cf5114 [libc++][macOS CI] Ensure that the SDK version is not older than the deployment target 2020-02-11 13:52:41 +01:00
Louis Dionne 92a1f65f17 [libc++] span: Fix incorrect return type of span::subspan
The extent of the returned span was always std::dynamic_extent, which
is incorrect.

Thanks to Michael Schellenberger Costa for the patch.

Differential Revision: https://reviews.llvm.org/D71997
2020-02-11 11:58:45 +01:00
Louis Dionne b4a3e6b664 [libcxx] span: Remove unneeded comparison
size_t is always greater than 0, so remove the artifact from the old
index_type.

Patch by Michael Schellenberger Costa.

Differential Revision: https://reviews.llvm.org/D71996
2020-02-11 11:39:12 +01:00
Louis Dionne edbaa7fc04 [libc++] span: Cleanup includes
Thanks to Michael Schellenberger Costa for the patch.

Differential Revision: https://reviews.llvm.org/D72036
2020-02-11 11:17:30 +01:00
Louis Dionne 9fda213d62 [libcxx] Qualify make_move_iterator in vector::insert for input iterators
Unqualified calls to make_move_iterator in the vector::insert overload
for input iterators lead to ADL issues: https://gcc.godbolt.org/z/bmcNbh

Patch by Logan Smith.

Differential Revision: https://reviews.llvm.org/D74290
2020-02-11 11:00:45 +01:00
Louis Dionne f2af4f8a45 [libc++][span] Add failing tests for span::first and span::last
Both methods have compile time constraints that we should test against.

Patch by Michael Schellenberger Costa

Differential Revision: https://reviews.llvm.org/D71999
2020-02-10 13:52:20 +01:00
Louis Dionne 1ac44d9fd1 [libc++] Protect <span> against min/max macro
Patch by Corentin Jabot
Differential Revision: https://reviews.llvm.org/D73855
2020-02-10 13:41:34 +01:00
Sergej Jaskiewicz 1a7e688b0b Revert "[libcxx] Force-cache LIBCXX_CXX_ABI_LIBRARY_PATH"
This reverts commit 41f4dfd63e.

It broke standalone libc++ builds, which now try to use libc++abi from the wrong directory, instead of system instance.

(cherry picked from commit 3573526c0286c9461f0459be1a4592b2214594e7)
2020-02-03 11:03:58 +01:00
Stephan T. Lavavej 5b14abf0c1 [libcxx] [test] Update msvc_stdlib_force_include.h.
Restore features that are removed in C++20.
2020-01-31 16:38:01 -08:00
Marek Kurdej e93e58c6c4 Reland [libc++] [P0325] Implement to_array from LFTS with updates.
Fixed expected errors and notes.

Summary:
This patch implements https://wg21.link/P0325.

Reviewers: EricWF, mclow.lists, ldionne, lichray

Reviewed By: ldionne, lichray

Subscribers: lichray, dexonsmith, zoecarver, christof, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D69882
2020-01-31 11:47:18 +01:00
Marek Kurdej 5e7017273f Revert "[libc++] [P0325] Implement to_array from LFTS with updates."
This reverts commit 86aae78268.

A test is failing on "Release" build without assertions enabled (Fedora 31 on x86_64).
2020-01-31 09:45:50 +01:00
Martijn Vels 282b803b62 White space only change: reflow a comment in basic_string
Summary: This change reflows a comment line. This change serves as a no-op test commit

Reviewers: mclow.lists, ldionne, EricWF

Subscribers: dexonsmith, christof, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D73552
2020-01-30 19:55:48 -05:00
Marek Kurdej 86aae78268 [libc++] [P0325] Implement to_array from LFTS with updates.
Summary:
This patch implements https://wg21.link/P0325.
Please mind that at it is my first contribution to libc++, so I may have forgotten to abide to some conventions.

Reviewers: EricWF, mclow.lists, ldionne, lichray

Reviewed By: ldionne, lichray

Subscribers: lichray, dexonsmith, zoecarver, christof, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D69882
2020-01-30 13:38:37 +01:00
Dimitry Andric 5e416ba943 Define _LIBCPP_HAS_TIMESPEC_GET for FreeBSD when appropriate
Summary:
FreeBSD got `timespec_get` support somewhere in the 12.x timeframe, but
the C++ version check in its system headers was written incorrectly.
This has now been fixed for both FreeBSD 13 and 12.

Add checks for the corresponding `__FreeBSD_version` values, to define
`_LIBCPP_HAS_TIMESPEC_GET` when the function is supported.

Reviewers: emaste, EricWF, ldionne, mclow.lists

Reviewed By: ldionne

Subscribers: arichardson, krytarowski, christof, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D71522
2020-01-30 08:00:56 +01:00
Petr Hosek 7f49dc4966 [CMake][libcxx] Don't wrap __config_site path in quotes on Windows
This is failing to compile on Windows because clang-cl is trying to
use the path with quotes, dropping them resolves the issue.

Differential Revision: https://reviews.llvm.org/D73525
2020-01-29 19:37:35 -08:00
Louis Dionne 93cdd310e1 [libc++] Explicitly specify LIBCXX_ENABLE_SHARED to try and fix CI
Configuring libc++abi with LIBCXX_ENABLE_STATIC=OFF is broken since
https://reviews.llvm.org/D71894, so this patch fixes the issue for
Apple platforms to unblock our CI.
2020-01-29 17:29:43 -08:00
Martin Storsjö 7db4f2c694 [libcxx] [Windows] Store the lconv struct returned from localeconv in locale_t
This fixes using non-default locales, which currently can crash when
e.g. formatting numbers.

Within the localeconv_l function, the per-thread locale is temporarily
changed with __libcpp_locale_guard, then localeconv() is called,
returning an lconv * struct pointer.

When localeconv_l returns, the __libcpp_locale_guard dtor restores
the per-thread locale back to the original. This invalidates the
contents of the earlier returned lconv struct, and all C strings
that are pointed to within it are also invalidated.

Thus, to have an actually working localeconv_l function, the
function needs to allocate some sort of storage for the returned
contents, that stays valid for as long as the caller needs to use
the returned struct.

Extend the libcxx/win32 specific locale_t class with storage for
a deep copy of a lconv struct, and change localeconv_l to take
a reference to the locale_t, to allow it to store the returned
lconv struct there.

This works fine for libcxx itself, but wouldn't necessarily be right
for a caller that uses libcxx's localeconv_l function.

This fixes around 11 of libcxx's currently failing tests on windows.

Differential Revision: https://reviews.llvm.org/D69505
2020-01-29 22:37:11 +02:00
Eric Fiselier b4c911eccc [libcxx] Add a std::string_view pretty printer for libcxx.
This adds a std::string_view pretty printer for libcxx and updates the gdb
pretty printer test.

Patch by Ali Tamur (tamur@google.com)
Reviewed as https://reviews.llvm.org/D73514
2020-01-29 13:04:29 -05:00
Shoaib Meenai 076da521f3 [libcxx] Link against android_support when needed
libc++ on Android needs to be linked against libandroid_support on API
levels less than 21 to provide needed functions that aren't in the libc
on those platforms (e.g. posix_memalign for libcxxabi). libc++ from the
NDK is a linker script that pulls in libandroid_support, but for
building libc++ itself, we need to explicitly add libandroid_support as
a dependency. Moreover, libc++ headers reference the functions provided
by libandroid_support, so it needs to be added as a public dependency.

Differential Revision: https://reviews.llvm.org/D73516
2020-01-28 14:36:24 -08:00
David Zarzycki 5dda92fcb0
Add test for spaceship operator to __config
Summary:
The libcxx test suite auto-detects spaceship operator, but __config does not. This means that the libcxx test suite has been broken for over a month when using top-of-tree clang. This also really ought to be fixed before 10.0.

See: bc633a42dd

Reviewers: chandlerc, mclow.lists, EricWF, ldionne, CaseyCarter

Reviewed By: EricWF

Subscribers: broadwaylamb, hans, dexonsmith, tstellar, llvm-commits, libcxx-commits

Tags: #libc, #llvm

Differential Revision: https://reviews.llvm.org/D72980
2020-01-24 13:27:22 -05:00
Billy Robert O'Neal III 45f630d729 [libcxx] [test] Don't assert that moved-from containers with non-POCMA allocators are empty. 2020-01-22 21:15:16 -08:00
Joerg Sonnenberger d42baff45d Replace old-style cast of null pointer with nullptr 2020-01-23 02:20:09 +01:00
Louis Dionne 8ae404a2f6 [libc++] Make sure std::is_scalar returns true for block types
Summary:
The compiler already treats them as scalar types, so the library should
too. Furthermore, this allows blocks to be used in more places, for
example in std::optional, which requires an object type.

rdar://problem/57892832

Reviewers: dexonsmith, EricWF, mclow.lists
Differential Revision: https://reviews.llvm.org/D72708
2020-01-21 17:15:15 -08:00
Sergej Jaskiewicz 7b8dc8c576 [libcxx] Support Python 3.8 in the test suite
Summary: `platform.linux_distribution()` has been deprecated in Python 3.5 and removed in Python 3.8.

Reviewers: bcain, bcraig, jroelofs, EricWF, mclow.lists, ldionne

Reviewed By: jroelofs

Subscribers: dexonsmith, christof, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D72501
2020-01-21 20:27:31 +03:00
Eric Fiselier fa40b41168 Revert "[libc++] Optimize / partially inline basic_string copy constructor"
This reverts commit a8a9c8e0a1.

There are multiple reported failures caused by this change.
Each failure is really weird, but it makes sense to revert
while investigating.
2020-01-20 21:41:58 -05:00
Eric Fiselier d15fad2653 [libc++][libc++abi] Fix or suppress failing tests in single-threaded
builds.

Fix a libc++abi test that was incorrectly checking for threading
primitives even when threading was disabled.

Additionally, temporarily XFAIL some module tests that fail because
the <atomic> header is unsupported but still built as a part of the
std module.

To properly address this libc++ would either need to produce a different
module.modulemap for single-threaded configurations, or it would need
to make the <atomic> header not hard-error and instead be empty
for single-threaded configurations
2020-01-19 21:49:14 -05:00
Sergej Jaskiewicz 049c437c40 [libcxx] Introduce LinuxRemoteTI for remote testing
Summary:
This patch adds a new target info object called LinuxRemoteTI.
Unlike LinuxLocalTI, which asks the host system about various things
like available locales, distribution name etc. which don't make sense
if we're testing on a remote board, LinuxRemoteTI uses SSHExecutor
to get information from the target system.

Reviewers: jroelofs, ldionne, bcraig, EricWF, danalbert, mclow.lists

Reviewed By: jroelofs

Subscribers: christof, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D72847
2020-01-18 01:27:30 +03:00
Eric Fiselier a8a9c8e0a1 [libc++] Optimize / partially inline basic_string copy constructor
Splits copy constructor up inlining short initialization, outlining long
initialization into __init_long() which is the externally instantiated slow
path initialization.

Subsequently changing the copy ctor to be inlined (not externally instantiated)
provides significant speed ups for short string initialization.

Generated code given:

void StringCopyCtor(void* mem, const std::string& s) {
    std::string*p = new(mem) std::string{s};
}

asm:
        cmp     byte ptr [rsi + 23], 0
        js      .LBB0_2
        mov     rax, qword ptr [rsi + 16]
        mov     qword ptr [rdi + 16], rax
        movups  xmm0, xmmword ptr [rsi]
        movups  xmmword ptr [rdi], xmm0
        ret
.LBB0_2:
        jmp     std::basic_string::__init_long # TAILCALL

Benchmark:
BM_StringCopy_Empty                                           5.19ns ± 6%             1.50ns ± 8%  -71.02%        (p=0.000 n=10+10)
BM_StringCopy_Small                                           5.14ns ± 8%             1.53ns ± 7%  -70.17%        (p=0.000 n=10+10)
BM_StringCopy_Large                                           18.9ns ± 0%             19.3ns ± 0%   +1.92%        (p=0.000 n=10+10)
BM_StringCopy_Huge                                             309ns ± 1%              316ns ± 5%     ~            (p=0.633 n=8+10)

Patch from Martijn Vels (mvels@google.com)
Reviewed as D72160.
2020-01-17 16:53:54 -05:00
Petr Hosek 9050d0fb59 [libcxx] Temporarily switch back to pthread backend for Fuchsia
We switched to C11 thread API on Fuchsia in ab9aefe, but further
testing showed that Fuchsia's C11 mutex implementation needs a few
improvements for this to be usable, so we temporarily switch back
to the pthread implementation until those issues are addressed.

Differential Revision: https://reviews.llvm.org/D72862
2020-01-16 14:53:08 -08:00
Eric Fiselier 59919c4d6b [libc++] Fix Windows DLL build for string.
We need to mark string::npos with _LIBCPP_FUNC_VIS on the first
in-class declaration, otherwise it might get ignored
2020-01-16 15:01:12 -05:00
Petr Hosek 3481e5d7ed [libcxx] Use mtx_plain | mtx_recursive following C11 API
The C11 API specifies that to initialize a recursive mutex,
mtx_plain | mtx_recursive should be used with mtx_init.

Differential Revision: https://reviews.llvm.org/D72809
2020-01-15 15:15:39 -08:00
Eric Fiselier 313d89724c [libc++] Fix parsing <string> in C++03.
Specifically, add a space between >> when closing templates.
2020-01-15 17:29:55 -05:00
Eric Fiselier 58c7fa5ade [libc++] Optimize basic_string::operator=(const basic_string&) for SSO assignments
This change optimizes the operator=() assignment for short strings by direcly
copying the raw data from the source into the current instance. This creates an
optimized / inlined mempcy up to over 2X faster for short string assignments.
With inlining enabled for operator=, performance is up to 6X faster.

Benchmarks 'as is':
name                                    old time/op   new time/op    delta
BM_StringAssignStr_Empty_Opaque         6.05ns ± 2%   3.59ns ± 0%  -40.67%
BM_StringAssignStr_Empty_Transparent    5.15ns ± 0%   3.08ns ± 0%  -40.12%
BM_StringAssignStr_Small_Opaque         7.71ns ± 0%   3.59ns ± 0%  -53.45%
BM_StringAssignStr_Small_Transparent    7.66ns ± 0%   3.09ns ± 0%  -59.66%
BM_StringAssignStr_Large_Opaque         24.1ns ± 0%   24.9ns ± 0%   +3.22%
BM_StringAssignStr_Large_Transparent    22.2ns ± 0%   22.8ns ± 0%   +2.77%
BM_StringAssignStr_Huge_Opaque           315ns ± 6%    320ns ± 5%     ~
BM_StringAssignStr_Huge_Transparent      318ns ± 5%    321ns ± 4%     ~

Benchmarks with partial inlining operator=():
name                                    old time/op   new time/op    delta
BM_StringAssignStr_Empty_Opaque         5.94ns ± 2%   1.95ns ± 0%  -67.21%
BM_StringAssignStr_Empty_Transparent    5.14ns ± 0%   1.04ns ± 1%  -79.73%
BM_StringAssignStr_Small_Opaque         7.69ns ± 0%   1.96ns ± 0%  -74.48%
BM_StringAssignStr_Small_Transparent    7.65ns ± 0%   1.04ns ± 0%  -86.40%
BM_StringAssignStr_Large_Opaque         24.1ns ± 0%   24.5ns ± 0%   +1.61%
BM_StringAssignStr_Large_Transparent    22.2ns ± 0%   21.1ns ± 0%   -4.70%
BM_StringAssignStr_Huge_Opaque           317ns ± 5%    323ns ± 4%     ~
BM_StringAssignStr_Huge_Transparent      318ns ± 5%    320ns ± 5%     ~

Patch by Martijn Vels (mvels@google.com)
Reviewed as https://reviews.llvm.org/D72704
2020-01-15 17:27:10 -05:00
Eric Fiselier 288a143639 [libc++] Explicitly enumerate std::string external instantiations - Attempt 2
The GCC build failures have been addressed, and the LLDB failures were
  fixed by LLDB.

   I have also verified that the apple-clang 9.0 segfault no longer
   occurs.

Original Message:

 The external instantiation of std::string is a problem for libc++.
    Additions and removals of inline functions in string can cause ABI
    breakages, including introducing new symbols.

    This patch aims to:
      (1) Make clear which functions are explicitly instatiated.
      (2) Prevent new functions from being accidentally instantiated.
      (3) Allow a migration path for adding or removing functions from the
      explicit instantiation over time.

    Although this new formulation is uglier, it is preferable from a
    maintainability and readability standpoint because it explicitly
    enumerates the functions we've chosen to expose in our ABI. Changing
    this list is non-trivial and requires thought and planning.

    (3) is achieved by making it possible to control the extern template declaration
    separately from it's definition. Meaning we could add a new definition to
    the dylib, wait for it to roll out, then add the extern template
    declaration to the header. Similarly, we could remove existing extern
    template declarations while still keeping the definition to prevent ABI
    breakages.
2020-01-15 17:12:49 -05:00
Eric Fiselier 2d8f23f571 [libc++] Explicitly mark basic_string<...>::npos with default
visibility.

This ensures that the version compiled into the library isn't
accidentally hidden.
2020-01-15 17:02:17 -05:00