Commit Graph

7282 Commits

Author SHA1 Message Date
Zbigniew Sarbinowski 4d478121f3 [SystemZ][z/OS] exclude nasty_macros.h from check-cxx
Need to exclude nasty_macros.h from check-cxx on z/OS due to conflicts within system headers.

Sample failure in `random_shuffle.depr_in_cxx14.verify.cpp` libcxx test.
```
error: 'error' diagnostics seen but not expected:
Line 1268: expected ')'
Line 1268: unknown type name 'This'
Line 1268: expected ')'
```

caused by the following  macros in `nasty_macros.h`
```
#define NASTY_MACRO This should not be expanded!!!
#define _E NASTY_MACRO
```
The name collision is observed in the following code snippet whre `_E` is being used as parameter name:
```
inline int iswalnum(wint_t _E) {return __iswalnum(_E);}
```

It is reasonable to exclude `nasty_macros.h` on z/OS similarly as it was done on Windows.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D99378
2021-03-26 15:08:37 +00:00
Marek Kurdej 0324b46cd8 [libc++] [C++2b] [P2162] Allow inheritance from std::variant.
This patch changes the variant even in pre-C++2b.
It should not break anything, only allow use cases that didn't work previously.

Notes:
 `__as_variant` is used in `__visitation::__variant::__visit_alt`, but I haven't used it in `__visitation::__variant::__visit_alt_at`.
That's because it is used only in `__visit_value_at`, which in turn is always used on variant specializations (that's in comparison operators).

* https://wg21.link/P2162

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D97394
2021-03-25 18:20:50 +01:00
Arthur O'Dwyer e21ab31f45 [libc++] Eliminate <compare>'s dependency on <array>.
This refactor is not only a good idea, but is in fact required by the standard,
in the sense that <array> is mandated to include <compare>.
So <compare> shouldn't have a circular dependency on <array>!

Differential Revision: https://reviews.llvm.org/D99307
2021-03-25 10:34:35 -04:00
Arthur O'Dwyer 06e2b737aa [libc++] [P1032] Misc constexpr bits in <iterator>, <string_view>, <tuple>, <utility>.
This completes the implementation of P1032's changes to <iterator>,
<string_view>, <tuple>, and <utility> in C++20.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1032r1.html

Drive-by fix a couple of unintended rvalues in "*iterators*/*.fail.cpp".

Differential Revision: https://reviews.llvm.org/D96385
2021-03-25 10:34:35 -04:00
Martin Storsjö b8b23aa80e [libcxx] [test] Quote env variables that are set with a shell "export" in ssh.py
This safeguards against cases if some of the env vars contain chars
that are problematic for shells, e.g. if called with --env "X=Y;Z".

(In cases of cross testing for windows, the PATH variable can end up
specified with semicolon separators - even if specifying a PATH when
cross testing in such differing environments might not make sense or
do anything - but this makes ssh.py not break on such a variable.)

Differential Revision: https://reviews.llvm.org/D99242
2021-03-25 09:46:44 +02:00
Christopher Di Bella 3f143a10cc [libcxx] updates regular_invocable test to actually test regular_invocable
The test wasn't previously testing this concept, but its base.

Differential Revision: https://reviews.llvm.org/D99306
2021-03-25 06:33:48 +00:00
jasonliu 09a84d3047 [libc++] Match declaration for non-member function std::swap(std::packaged_task) with what standard specify
Standard specifies:
```
template<class R, class... ArgTypes>
  void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
```

Differential Revision: https://reviews.llvm.org/D99102
2021-03-24 22:33:32 +00:00
jasonliu 158026301b [libc++][AIX] Initial patch to unblock the libc++ build on AIX
This path would unblock the build of libc++ library on AIX:
1. Add _AIX guard for _LIBCPP_HAS_THREAD_API_PTHREAD
2. Use uselocale to actually take the locale setting
   into account.
3. extract_mtime and extract_atime mod needed for AIX. As stat
   structure on AIX uses internal structure st_timespec to store
   time for binary compatibility reason. So we need to convert it
   back to timespec here.
4. Do not build cxa_thread_atexit.cpp for libcxxabi on AIX.

Differential Revision: https://reviews.llvm.org/D97558
2021-03-24 22:13:20 +00:00
Martin Storsjö 675401e04c [libcxx] Avoid pulling in xlocinfo.h in public headers
Including xlocinfo.h is a bit of a layering violation; locale.h is
the C library header we should use, while xlocinfo.h is essentially
part of the MS C++ library. Including xlocinfo.h brings in yvals.h,
which brings in yvals_core.h, which defines the MS STL's version
support macros, overriding what libc++'s <version> had defined.

Instead just include locale.h, and provide the few defines we need
for locale categories manually.

Differential Revision: https://reviews.llvm.org/D99213
2021-03-24 23:29:59 +02:00
Louis Dionne 6427c53940 [libc++] Use add_lit_testsuite to register the libc++ test suite
The Runtimes build uses variables set by add_lit_testsuite to discover
tests suites to run.

Differential Revision: https://reviews.llvm.org/D97913
2021-03-24 16:47:34 -04:00
Louis Dionne c504c68fac [libc++] Add a CI configuration with static libc++/libc++abi
Differential Revision: https://reviews.llvm.org/D99268
2021-03-24 16:30:48 -04:00
Martin Storsjö b6c4b280a0 [libcxx] [test] Add return values after assert(false) in some experimental tests
When building in MSVC mode (in release mode), the assert(false) don't
make the end of the function unreachable, so add return statements to
silence compiler warnings (treated as errors).

Also change 'virtual' into 'override', which was requested in review,
as these files require C++11.

Differential Revision: https://reviews.llvm.org/D99214
2021-03-24 11:44:01 +02:00
Louis Dionne 6c93eb4477 [libc++] Remove old cache file that was left behind by accident 2021-03-23 14:15:48 -04:00
Arthur O'Dwyer a644920a02 [libc++] Simpler Python script for generating a graph of libc++'s header dependencies
My attempts to play around with the old graph_header_deps.py were mostly fruitless;
I needed to modify it in various ways to make it work, and then even when I got it
working, it generated pretty ugly graphs.

Old graph_header_deps.py (after my local changes to simplify the usage)
(producing https://i.imgur.com/zATrsaP.jpg )

    mkdir foo
    time ./graph_header_deps.py --libcxx-only -o foo --clang-command ~/llvm-project/build/bin/clang++
    dot -Tpng < foo/all_headers.dot > old.png
    file old.png

    real    0m37.453s
    old.png: PNG image data, 25882 x 3035, 8-bit/color RGBA, non-interlaced

New graph_header_deps.py
(producing https://i.imgur.com/ZU0G52U.png )

    time ./graph_header_deps.py | dot -Tpng > new.png
    file new.png

    real    0m1.063s
    new.png: PNG image data, 6162 x 1344, 8-bit/color RGBA, non-interlaced

Differential Revision: https://reviews.llvm.org/D99124
2021-03-23 14:12:05 -04:00
Louis Dionne 2e033b36bf [libc++] NFC: nodebug => no-debug in the CI configurations 2021-03-23 14:10:27 -04:00
Marek Kurdej 28f82bec7f [libc++] [C++20] [P0482] Add missing tests and synopses for char8_t.
Left to finish P0482:
* <cuchar> header.
* Parts of <memory_resource> concerning char8_t. Also, tests for hash<pmr::*string>.

Reviewed By: ldionne, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D99184
2021-03-23 18:45:31 +01:00
Marek Kurdej 00a6d3dfa6 [libc++] Add missing test_macros.h include in tests using TEST_STD_VER. 2021-03-23 18:40:44 +01:00
Martin Storsjö 7a804c0979 [libcxx] Consistently set CMAKE_STATIC_LIBRARY_PREFIX regardless of LIBCXX_ENABLE_STATIC
CMAKE_STATIC_LIBRARY_PREFIX affects the naming of all static libs (in
MSVC configurations), including c++experimental, which only is produced
as static regardless of LIBCXX_ENABLE_STATIC.

Differential Revision: https://reviews.llvm.org/D99176
2021-03-23 18:18:16 +02:00
Arthur O'Dwyer 43aaf87173 [libc++] Include <__config> first in all standard headers.
Mostly, *don't* include <experimental/__config> from C++17 <any>,
because that doesn't make any sense. I think it was just a cut-and-paste
typo when this header moved from experimental/.

Differential Revision: https://reviews.llvm.org/D99089
2021-03-22 19:01:18 -04:00
Martin Storsjö 695ec081a4 [libcxx] [test] Fix fs.op.proximate for windows
Simmilar to many other similar path handling tests, convert the
test reference to preferred separators, and ifdef a few test references
that use network root names.

Additionally, generalize code for trimming off the root path for
generating relative_cwd, and for skipping the root name element
in count_path_elems.

Rename one fictive path for consistency with the other test cases,
and add a bunch of more test cases for completeness.

Differential Revision: https://reviews.llvm.org/D98988
2021-03-23 00:32:44 +02:00
Martin Storsjö 4f7fa06a66 [libcxx] [test] Add XFAIL LIBCXX-WINDOWS-FIXME in 124 tests that fail in the future CI configuration
This makes no attempt yet to look into the why/what for each of them,
but makes the CI configuration useful for tracking further regressions.
After looking into each case, they can either be fixed, or converted
into UNSUPPORTED: windows or XFAIL: windows, once the cause is known
and explained.

A number of the filesystem cases can be fixed by patches that are
currently in review.

Differential Revision: https://reviews.llvm.org/D99095
2021-03-22 23:41:11 +02:00
Martin Storsjö 247f8f6719 [libcxx] [test] Remove a couple outdated XFAIL LIBCXX-WINDOWS-FIXME
With current versions of MSVC, these tests do succeed.

Differential Revision: https://reviews.llvm.org/D99094
2021-03-22 23:41:10 +02:00
Martin Storsjö 4c402ae880 [libcxx] [test] Don't leave test dirs behind in fs.op.current_path on Windows
Fix nesting of static_env and CWDGuard, restore the cwd (with
CWDGuard) before cleaning up the static_env.

Previously, every test run left 2 directories behind in the temp dir.

Differential Revision: https://reviews.llvm.org/D98954
2021-03-22 23:41:10 +02:00
Louis Dionne 1e337b1dd9 [libc++] Revert "[SystemZ][z/OS] Missing wchar functions libc++"
This reverts commit febbf68b42 because it
added files that were not under the LLVM license.

See https://reviews.llvm.org/D98207 for details.
2021-03-22 17:35:43 -04:00
Arthur O'Dwyer 2ac6babcc0 [libc++] Move __libcpp_erase_if_container into <iterator>, and ADL-proof it.
The container headers don't need to include <functional> for any other reason
(or at least, they wouldn't if we moved `less` and `equal_to` out of <functional>),
so let's put `__libcpp_erase_if_container` somewhere that's common to the
containers but outside of <functional>.

Also, calling `std::erase_if(c, pred)` should not trigger ADL.

Differential Revision: https://reviews.llvm.org/D99043
2021-03-22 11:13:33 -04:00
Louis Dionne 116b8525c9 [libc++] Run ninja with --verbose
This makes it easier to see what exact build commands are used.

Differential Revision: https://reviews.llvm.org/D98992
2021-03-22 09:17:52 -04:00
Louis Dionne 976eba51d0 [libc++] NFCI: Remove dead code in the Lit configuration
I was trying to fix something else and I stumbled upon several methods
that are not used anymore in target_info.py.

Differential Revision: https://reviews.llvm.org/D98896
2021-03-19 12:01:30 -07:00
Martin Storsjö 7a154c3230 [libcxx] [test] Account for differences in a trailing slash in weakly_canonical
This seems to be a documented quirk in libc++'s implementation of
weakly_canonical (in a comment in the weakly_canonical test).
Together with a difference between windows and posix regarding whether
paths can go through nonexistent dirs, this results in a difference in
a trailing slash.

Just document this as expected, and degrade the comment from fixme to
a note, as MS STL and libstdc++ behave in the same way.

Differential Revision: https://reviews.llvm.org/D98642
2021-03-19 18:49:05 +02:00
David Spickett 3aa6a4cb39 [libcxx][Arm] Move buildbot flags into cmake files
Reviewed By: #libc, Mordante, curdeius

Differential Revision: https://reviews.llvm.org/D98771
2021-03-19 16:45:09 +00:00
Arthur O'Dwyer 72557476d4 [libc++] Consistency on _LIBCPP_CLANG_VER tests in <type_traits>.
This came out of my review comments on D97283.

This patch re-enables the use of `__is_fundamental`, `__is_signed`, etc.
on non-Clang compilers. Previously, when we found that a builtin didn't
work on old Clangs, we had been reacting by limiting its use to new Clangs
(i.e., we'd also stop using it on new GCCs and new MSVCs, just because of
the old Clang bug). I claim that this was unintentional.

Notice that on Apple Clang, `_LIBCPP_COMPILER_CLANG` is defined and
`_LIBCPP_CLANG_VER` is not defined (therefore `0` in arithmetic expressions).
We assume that Apple Clang has all the bugs of all the Clangs.

Differential Revision: https://reviews.llvm.org/D98720
2021-03-19 10:49:00 -04:00
Martin Storsjö 2ec9239a7b [libcxx] [test] Fix weakly_canonical for windows
Differential Revision: https://reviews.llvm.org/D98643
2021-03-19 16:12:24 +02:00
Martin Storsjö b982c6f5fa [libcxx] [test] Avoid race conditions between tests regarding temp directories
Prior to e0d01294bc, all tests used a
random directory name, but now it is deterministic, based on the
test name. This change was done under the assumption that the filename
portion of the cwd is unique across tests that use the filesystem
test temporary directories.

When running tests locally, the cwd of the test is something like
"<build-dir>/test/<test path>/Output/copy_assign.pass.cpp.dir",
and the filename portion, "copy_assign.pass.cpp.dir", is used as
base for the temp directory names.

The change noted that there's a risk for race conditions if multiple
threads within one test try to create temp directories in parallel, but
that doesn't really happen in practice.

However, if running tests with a large number of parallel workers,
multiple tests with the same filename portion, e.g. "copy_assign.pass.cpp.dir",
can run in parallel, leading to race conditions across processes.

Therefore, add a hash of the full cwd to distinguish such cases
from each other.

Secondly, don't use two separate levels of temporary directories
(<base>/static_env.0). When cleaning up, only the individual
directory is removed, leaving the empty intermediate directory
behind littering the temp directory.

Differential Revision: https://reviews.llvm.org/D98703
2021-03-19 16:12:24 +02:00
Martin Storsjö aee005f912 [libcxx] [test] Fix windows errors in fs.op.rename
Differential Revision: https://reviews.llvm.org/D98640
2021-03-19 16:12:24 +02:00
Martin Storsjö c9fc1a979c [libcxx] [test] Explicitly check that some env vars are ignored in the temp_dir_path test
This was suggested in the review of D98139.

Differential Revision: https://reviews.llvm.org/D98696
2021-03-19 09:33:26 +02:00
Muiez Ahmed f6af5efcec [SystemZ][z/OS] vasprintf fix libc++
The aim is to use the correct vasprintf implementation for z/OS libc++, where a copy of va_list ap is needed. In particular, it avoids the potential that the initial internal call to vsnprintf will modify ap and the subsequent call to vsnprintf will use that modified ap.

Differential Revision: https://reviews.llvm.org/D97473
2021-03-18 15:00:57 -04:00
Markus Böck 6359049c35 [CMake][runtimes] Add file level dependency to merge_archives commands
Both libc++ and libc++abi have options of merging with another archive. In the case of libc++abi, libunwind can be merged into it and in the case of libc++, libc++abi can be merged into it.

This is realized using add_custom_command with POST_BUILD and the usage of the CMake generator expression TARGET_LINKER_FILE in the arguments. For such generator expressions CMake doc states: "This target-level dependency does NOT add a file-level dependency that would cause the custom command to re-run whenever the executable is recompiled" [1]

This patch adds a DEPENDS argument to both add_custom_command invocations so that the archives also have a file-level dependency on the target they are merging with. That way, changes in say, libunwind source code, will be updated in the libc++abi and/or libc++ static libraries as well.

[1] https://cmake.org/cmake/help/v3.20/command/add_custom_command.html

Differential Revision: https://reviews.llvm.org/D98129
2021-03-18 18:51:10 +01:00
Arthur O'Dwyer eb37d3546c [libc++] Future-proof generate_feature_test_macro_components.py against long names.
`__cpp_lib_default_template_type_for_algorithm_values` is 52 characters long,
which is enough to reduce the multiplier to less-than-zero, producing an empty
string between the name of the macro and its numeric value. Ensure there's
always a space between the name of the macro and its value.

Differential Revision: https://reviews.llvm.org/D98869
2021-03-18 13:35:28 -04:00
Louis Dionne 6a9e7b117b [libc++] Remove the Docker files for BuildBot
We don't use them anymore since we're using the BuildKite setup.

Differential Revision: https://reviews.llvm.org/D97779
2021-03-18 10:24:48 -07:00
Christopher Di Bella 580416d573 [libcxx] updates the feature-test macro generator
D97015 didn't correctly update `generate_feature_test_macro_components.py`.

Reviewed By: ldionne, Quuxplusone, #libc, Mordante

Differential Revision: https://reviews.llvm.org/D97904
2021-03-18 17:08:10 +00:00
Martin Storsjö 6718ce4037 [libcxx] [docs] Fix formatting of inline verbatim snippets in the Windows section
Use double backticks instead of single, as single backticks produces
italic formatting.
2021-03-17 11:41:45 +02:00
Martin Storsjö 42d653d294 [libcxx] Simplify rounding of durations in win32 __libcpp_thread_sleep_for
Also fix a comment typo, and remove a superfluous "std::" qualififcation
in __libcpp_semaphore_wait_timed for consistency.

This mirrors what was suggested in review of
1773eec692.

Differential Revision: https://reviews.llvm.org/D98015
2021-03-17 10:09:10 +02:00
Arthur O'Dwyer 0aa637b203 [libc++] Improve src/filesystem's formatting of paths.
This is my attempt to merge D98077 (bugfix the format strings for
Windows paths, which use wchar_t not char)
and D96986 (replace C++ variadic templates with C-style varargs so that
`__attribute__((format(printf)))` can be applied, for better safety)
and D98065 (remove an unused function overload).

The one intentional functional change here is in `__create_what`.
It now prints path1 and path2 in square-brackets _and_ double-quotes,
rather than just square-brackets. Prior to this patch, it would
print either path double-quoted if-and-only-if it was the empty
string. Now the double-quotes are always present. I doubt anybody's
code is relying on the current format, right?

Differential Revision: https://reviews.llvm.org/D98097
2021-03-16 15:00:36 -04:00
Tomas Matheson 64595f9b84 [libcxx][type_traits] add tests for is_signed and is_unsigned
In previous versions of clang, __is_signed and __is_unsigned builtins did not
correspond to is_signed and is_unsigned behaviour for enums.  The builtins were
fixed in D67897 and D98104.

* Disable the fast path of is_unsigned for clang versions < 13

* Add more tests for is_signed, is_unsigned and is_arithmetic

Differential Revision: https://reviews.llvm.org/D97283
2021-03-16 16:36:10 +00:00
Martin Storsjö b5e228fc00 [libcxx] [test] Fix the temp_directory_path test for windows
Check a different set of env vars, don't check the exact value
of the fallback path. (GetTempPath falls back to returning the Windows
folder if nothing better is available in env vars.)

The test still fails one check on windows (due to relying on perms::none),
which will be addressed separately.

Differential Revision: https://reviews.llvm.org/D98139
2021-03-15 19:24:56 +02:00
Martin Storsjö d07e5c23b4 [libcxx] [test] Fix the get_temp_file_name() function for mingw
Add the missing includes for getting the defines and functions used
in the mingw version of get_temp_file_name().

This fixes 31 tests when built in a mingw configuration.

Also remove a redundant ifdef; _WIN32 is defined in mingw targets too.

Differential Revision: https://reviews.llvm.org/D97456
2021-03-15 18:52:49 +02:00
Martin Storsjö f5f3a59837 [libcxx] [test] Disable some allocation checks in class.path tests on windows
On windows, the path internal representation is wchar_t, and
input/output often goes through utf8 inbetween, which causes extra
allocations.

MS STL also fails a number of strict allocation checks, so this
shouldn't be a standards compliance issue.

Differential Revision: https://reviews.llvm.org/D98398
2021-03-15 18:52:48 +02:00
Martin Storsjö 995a128f07 [libcxx] [docs] Update docs about how to build for Windows
Refresh the existing paragraphs on building in MSVC configurations,
add a sample of one working configuration for MinGW, and add more
details on what's necessary to run the tests these days.

Differential Revision: https://reviews.llvm.org/D97166
2021-03-15 17:30:26 +02:00
Muiez Ahmed 62705ee012 [SystemZ][z/OS] Define _LIBCPP_ELAST
The aim is to define _LIBCPP_ELAST for z/OS libc++ since strerror/strerror_r can't handle out-of-range errno values.

Differential Revision: https://reviews.llvm.org/D98541
2021-03-15 09:23:36 -04:00
Muiez Ahmed febbf68b42 [SystemZ][z/OS] Missing wchar functions libc++
The aim is to add the missing z/OS specific implementations for mbsnrtowcs and wcsnrtombs, as part of libc++.

Differential Revision: https://reviews.llvm.org/D98207
2021-03-12 15:39:31 -05:00
Christopher Di Bella 8d4af1b6e0 [libcxx] adds concept std::regular
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D97911

Reviewed By: EricWF, #libc, Quuxplusone

Differential Revision: https://reviews.llvm.org/D98154
2021-03-12 08:54:03 -08:00