Commit Graph

6947 Commits

Author SHA1 Message Date
Louis Dionne 8d51969bd4 [runtimes] Avoid overwriting the rpath unconditionally
When building the runtimes, it's very important not to add rpaths unless
the user explicitly asks for them (the standard way being CMAKE_INSTALL_RPATH),
or to change the install name dir unless the user requests it (via
CMAKE_INSTALL_NAME_DIR).

llvm_setup_rpath() would override the install_name_dir of the runtimes
even if CMAKE_INSTALL_NAME_DIR was specified to something, which is wrong
and in fact even "dangerous" for the runtimes.

This issue was discovered when trying to build libc++ and libc++abi as
system libraries for Apple, where we set the install name dir to /usr/lib
explicitly. llvm_setup_rpath() would cause libc++ to have the wrong install
name dir, and for basically everything on the system to fail to load.
This was discovered just now because we previously used something closer
to a standalone build, where llvm_setup_rpath() wouldn't exist, and hence
not be used.

This is a revert of the following commits:

  libunwind: 3a667b9bd8
  libc++abi: 4877063e19
  libc++: 88434fe05f

Those added llvm_setup_rpath() for consistency, so it seems reasonable
to revert.

Differential Revision: https://reviews.llvm.org/D91099
2020-11-09 16:56:03 -05:00
Louis Dionne c1887e3f15 Revert "Allow running back-deployment testing against libc++abi"
This reverts commit 4d79ef814a, which broke a few build bots.
I'm reverting until I have time to investigate.
2020-11-06 17:26:42 -05:00
Louis Dionne 1d53b55e18 [libc++] Try fixing the oss-fuzz build
See https://github.com/google/oss-fuzz/issues/4586.
2020-11-06 10:06:44 -05:00
Louis Dionne 4d79ef814a Allow running back-deployment testing against libc++abi
Summary:
Before this patch, we could only link against the back-deployment libc++abi
dylib. This patch allows linking against the just-built libc++abi, but
running against the back-deployment one -- just like we do for libc++.

Also, add XFAIL markup to flag expected errors.
2020-11-06 08:12:46 -05:00
Louis Dionne 75b6726b57 [libc++] Also allow customizing the build directory when running CI 2020-11-05 19:10:08 -05:00
Louis Dionne 3790e17f46 [libc++] Allow customizing a few paths when running build bots
This allows reusing run-buildbot for downstream testing as well.
2020-11-05 19:02:32 -05:00
Louis Dionne bb43a0cd4a [libc++] Add a Buildkite job that tests back-deployment on Apple
The current way we test this is pretty cheap, i.e. we download previously
released macOS dylibs and run against that. Ideally, we would require a
full host running the appropriate version of macOS, and we'd execute the
tests using SSH on that host. But since we don't have such hosts available
easily for now, this is better than nothing.

At the same time, also fix some tests that were failing when back
deploying.

Differential Revision: https://reviews.llvm.org/D90869
2020-11-05 18:26:08 -05:00
Louis Dionne f7e4f041d6 [libc++] Add a CI job to build the documentation
At the same time, fix an issue that broke the documentation since 2eadbc8614.
2020-11-05 15:33:09 -05:00
Louis Dionne 738d981eb6 [libc++] Update the CI Dockerfile
Remove Phabricator, which isn't needed anymore since we don't report
the job results ourselves. Also, install python3-sphinx instead of
sphinx-doc, since the latter doesn't provide the sphinx-build binary.
2020-11-05 15:33:09 -05:00
Louis Dionne 2eadbc8614 [libc++] Rework the whole availability markup implementation
Currently, vendor-specific availability markup is enabled by default.
This means that even when building against trunk libc++, the headers
will by default prevent you from using some features that were not
released in the dylib on your target platform. This is a source of
frustration since people building libc++ from sources are usually not
trying to use some vendor's released dylib.

For that reason, I've been thinking for a long time that availability
annotations should be off by default, which is the primary change that
this commit enables.

In addition, it reworks the implementation to make it easier for new
vendors to add availability annotations for their platform, and it
refreshes the documentation to reflect the current state of the codebase.

Finally, a CMake configuration option is added to control whether
availability annotations should be turned on for the flavor of libc++
being created. The intent is for vendors like Apple to turn it on, and
for the upstream libc++ to leave it off (the default).

Differential Revision: https://reviews.llvm.org/D90843
2020-11-05 12:28:52 -05:00
Louis Dionne 0e61d02c05 [libc++] Correct XFAILs for the C++20 Synchronization Library
Technically, these tests don't only fail against macosx10.9 to 10.15,
but really against any released macOS yet.
2020-11-05 08:45:57 -05:00
Arthur O'Dwyer 418de7d5d8 Fix UB in one libcxx test, when deleting D through a pointer to B.
This undefined behavior was found by applying Lénárd Szolnoki's proposal
to disable implicit conversion of default_delete<D> to default_delete<B>.

The offending part of the test is circa line 243.

The wording that makes it undefined behavior is http://eel.is/c++draft/expr.delete#3 .

Differential Revision: https://reviews.llvm.org/D90536
2020-11-04 17:34:05 -05:00
Louis Dionne 8e01749bb1 [libc++] Remove stray setting of use_system_cxx_lib left behind 2020-11-04 15:01:59 -05:00
Louis Dionne 70eb30cc81 [libc++] Move availability-related Lit configuration to the DSL
The implementation is not really satisfactory, but it's better than
being in the legacy config, which causes other issues.
2020-11-04 14:56:08 -05:00
Steven Wan 09f2c92e5b Add info about the cherry-picked commit and contributor 2020-11-04 14:23:27 -05:00
Steven Wan 296c2f31f0 [PowerPC] Rename mftbl to mftb
`mftb` and `mftbl` are equivalent, there is no need to have two names for doing the same thing, rename `mftbl` to only have `mftb`.

Differential Revision: https://reviews.llvm.org/D89506
2020-11-04 14:23:27 -05:00
Louis Dionne 0df0d0fe2d [libc++] NFC: Remove trailing whitespace 2020-11-04 14:08:06 -05:00
Louis Dionne 6706342f48 [libc++] Remove the ability to not install the support headers
Those are part of the library, and shipping them just adds a tiny bit of
size to the distribution. This was originally added in b422ecc7de to
make it possible to match the Makefile build, which doesn't exist anymore.

The upside is build system simplification.
2020-11-04 11:45:34 -05:00
Louis Dionne 9d58dab6f6 [libc++] Split off part of a test that require signals into a separate test
This will allow running the basic test on all platforms, and the part that
requires signals on platforms that support them only.
2020-11-04 11:20:47 -05:00
Louis Dionne 2dec36e532 [libc++] NFCI: Refactor chrono.cpp to make it easier to support new platforms
Also simplify a few conditionals along the way for readability.
2020-11-04 10:23:36 -05:00
Louis Dionne bbd15062d2 [libc++] Remove test that is irrelevant since f1a96de1bc
We don't want to give the impression that we allow running arbitrary
shell commands under %{exec}, which isn't the case.
2020-11-04 08:47:48 -05:00
Louis Dionne f1a96de1bc [libc++] Don't run tests in a shell in the default executor 2020-11-04 08:29:05 -05:00
zoecarver e2b6987204 [libc++][NFC] Mark LWG issue 2899 as not complete.
Commit 59e26308e6 accidentally
marked this LWG issue as complete but it has not yet been
implemented. D66262 fixes this issue.
2020-11-03 13:35:12 -08:00
Louis Dionne 8e5156f6b0 [libc++] Harden tests against executors not running tests in a shell
Some executors do not run the tests in a shell, and so assuming that
they can understand shell builtins is wrong. Instead, call Bash
directly to do what we need to do.

This still requires the executor to be able to run Bash, but at least
it does not require it to interpret command lines in the Bash language.
2020-11-03 16:03:20 -05:00
Louis Dionne 5369d8cca7 [libc++] Remove support for .run.fail.cpp tests
Unfortunately, executing these tests correctly on platforms that do not
support a shell is very challenging. Since the executor can't just negate
the result of the command, we'd have to ship a portable program capable
of running the actual test executable, and negating its result.

Doing this portably is challenging. Since we do not currently have strong
use cases for tests that fail at runtime (we effectively have no tests
using that capability right now), it is difficult to justify making them
work portably. Instead, it makes more sense to remove this feature until
we can implement it properly (i.e. without requiring shell support).
2020-11-03 15:40:24 -05:00
Louis Dionne d1217be43f [libc++] NFC: Simplify how we run config tests
We can use the convenience substitutions provided by the format instead
of bootstrapping our own.
2020-11-03 14:59:41 -05:00
Louis Dionne d9a4f936d0 [libc++] Move <memory> helpers outside of std::allocator_traits
They don't really belong as members of allocator_traits.
2020-11-03 12:27:26 -05:00
Martin Storsjö 1127ef789c [libcxx] Error out if __libcpp_mbsrtowcs_l fails in __time_get_storage
If __libcpp_mbsrtowcs_l outputs zero wchar_t's for week days or
month names (due to errors in the locale function setup), these are
matched all the time in __time_get_storage::__analyze, ending up in
an infinite loop, allocating more memory until killed.

Differential Revision: https://reviews.llvm.org/D69553
2020-11-03 17:15:05 +02:00
Martin Storsjö 8a73aa8c4c [libcxx] [libcxxabi] Set flags for visibility when statically linking libcxxabi into libcxx for windows
Previously, these had to be set manually when building each of the
projects standalone, in order to get proper symbol visibility when
combining the two libraries.

Differential Revision: https://reviews.llvm.org/D90021
2020-11-03 17:13:48 +02:00
Martin Storsjö 529ba612b0 [libcxx] [test] Use error_code::default_error_condition to check errors against the expected codes
error_code returned from functions might not be of the generic category,
but of the system category, which can have different error code values.
Use default_error_condition() to remap errors to the generic category
where possible, to allow comparing them to the expected values.

Use the ErrorIs() helper instead of a direct comparison against
an excpected value.

Differential Revision: https://reviews.llvm.org/D90602
2020-11-03 09:32:52 +02:00
Martin Storsjö 08b4cc5e0d [libcxx] Avoid double frees of file descriptors in the fallback ifstream/ofstream codepath
So far, most actual uses of libc++ std::filesystem probably use
the sendfile or fcopyfile implementations.

Differential Revision: https://reviews.llvm.org/D90601
2020-11-03 09:32:52 +02:00
Martin Storsjö 11987248c8 [libcxx] [test] Create symlink_to_dir as the right kind, as a directory symlink
This was missed in 5c39eebc12.

Differential Revision: https://reviews.llvm.org/D90600
2020-11-03 09:32:52 +02:00
Martin Storsjö 22e5ee0eef [libcxx] [test] Avoid an unused variable in non-libcpp cases in path.append
Differential Revision: https://reviews.llvm.org/D89947
2020-11-03 09:32:52 +02:00
Martin Storsjö 321f696920 [libcxx] [test] Fix the fs.op.absolute test to cope with windows paths
Prepend the root path on the already_absolute testcase, and construct
a path ending with the preferred separator for the test reference for
"foo/".

Differential Revision: https://reviews.llvm.org/D89944
2020-11-03 09:32:52 +02:00
Louis Dionne 5a829ef6ad [libc++] Fix invalid parsing of ints in a <random> test
The strings were concatenated together without adding spaces between
numbers, which lead to numbers that wouldn't fit in an unsigned int.

Thanks to Casey Carter for the find.
2020-11-02 19:20:59 -05:00
Louis Dionne d6e2bac195 [libc++] Migrate warning flags to the DSL
This makes us closer to running the test suite on platforms where the
legacy test suite configuration doesn't work.

One notable change after this commit is that the tests will be run with
warnings enabled on GCC too, which wasn't the case before. However,
previous commits should have tweaked the test suite to make sure it
passes with warnings enabled on GCC.

Note that warnings can still be disabled with `--param enable_warnings=False`,
as before.

Differential Revision: https://reviews.llvm.org/D90432
2020-11-02 12:25:05 -05:00
Louis Dionne 6b2de7c53a [libc++][CI] Allow retries in case an agent is lost
We see this fairly often on our Linux bots, which appear to be killed
by GCE from time to time.
2020-11-02 11:58:45 -05:00
Louis Dionne 2ca4406de8 [libc++] NFC: Re-generate the ABI lists with the new script
The new script keeps the results sorted, which is why the ABI lists appear
to have changed so much. However, this commit makes no actual ABI change.
2020-11-02 11:36:35 -05:00
Louis Dionne b128373eb8 [libc++] Make it easier to re-generate the ABI lists
Instead of having to remember the command-line to use every time, this
commit adds a CMake target to generate the ABI list in the current
configuration, if it is supported.

As a fly-by change, remove scripts that are now unused (sym_match.py
and sym_extract.py).
2020-11-02 11:36:35 -05:00
Louis Dionne 1b2fa6e46e [libc++/libc++abi] Use Python3_EXECUTABLE consistently to run utilities 2020-11-02 11:07:31 -05:00
Louis Dionne c6eaa14e11 [libc++] Split off iostreams explicit instantiations into its own source file
This makes it cleaner to add more instantiations without cluttering the
actual implementation of ios.
2020-11-02 10:36:34 -05:00
Louis Dionne ca62b8673b [libc++] NFC: Remove warning about non-void function returning void 2020-11-02 08:25:44 -05:00
Nico Weber 8954fd436c [libcxx] Fix regression where `ninja all` doesn't copy libcxx headers
Before 6db314e86b, when running cmake with clang, libcxx, and
compiler-rt enabled, building `ninja all` would run the
generate-cxx-headers target, due to the sanitizers depending on it.

After 6db314e86b, if LIBCXX_ENABLE_SHARED and LIBCXX_ENABLE_STATIC
and LIBCXX_INCLUDE_TESTS and LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY are
disabled (https://reviews.llvm.org/D82702#2153627), `ninja all`
no longer copies the libcxx headers, which means clang can't compile
programs like `#include <string>` on macOS.

Explicitly add the copy target to the all target to restore the old
behavior.
2020-11-01 21:34:51 -05:00
Louis Dionne 81b6aa0e27 [libc++] Fix tests failing with Clang after removing GCC warnings 2020-10-30 14:56:12 -04:00
Louis Dionne 4dfe014a12 [libc++] Add -Wno-sized-deallocation to avoid spurious GCC warnings
GCC tries to be nice and tell us that we probably want to also implement
sized deallocation functions when we override the normal ones. However,
we know what we're doing in the test suite and don't want to override
them.
2020-10-30 12:51:07 -04:00
Louis Dionne c479e0c994 [libc++] NFC: Fix several GCC warnings in the test suite
- Several -Wshadow warnings
- Several places where we did not initialize our base class explicitly
- Unused variable warnings
- Some tautological comparisons
- Some places where we'd pass null arguments to functions expecting
  non-null (in unevaluated contexts)
- Add a few pragmas to turn off spurious warnings
- Fix warnings about declarations that don't declare anything
- Properly disable deprecation warnings in ext/ tests (the pragmas we
  were using didn't work on GCC)
- Disable include_as_c.sh.cpp because GCC complains about C++ flags
  when compiling as C. I couldn't find a way to fix this one properly,
  so I'm disabling the test. This isn't great, but at least we'll be
  able to enable warnings in the whole test suite with GCC.
2020-10-30 12:48:05 -04:00
Louis Dionne d085697013 [libc++] Add a new concept of ConfigAction, and use it in the DSL
This will allow adding bare compiler flags through the new
configuration DSL. Previously, this would have required adding
a Lit feature for each such flag.

Differential Revision: https://reviews.llvm.org/D90429
2020-10-30 09:27:15 -04:00
Louis Dionne bffdc241a6 [libc++] Minor cleanup in the test suite 2020-10-29 13:58:02 -04:00
Louis Dionne bd8884f05e [libc++] Remove additional uses of std::rand() missed by 63aeadb484 2020-10-29 11:11:29 -04:00
Marek Kurdej 6648414b2b [libcxx] [docs] [NFC] Fix typo. 2020-10-29 14:39:09 +01:00
Daniel Kiss fd1c064845 [libcxx] Add targets to available features.
This patch add the target-* (x86_64-*) as used elsewhere in llvm.

Reviewed By: #libc, #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D88027
2020-10-29 14:04:11 +01:00
Michael Park 35d2269111 [libc++] Re-apply the switch-based std::variant implementation
This commit is a mass re-application of the following commits:

  7d15ece79c
  e0ec7a0206
  02197f7e50
  a175a96517

Those were temporarily reverted in 057028ed39, and never re-applied.
Re-committed by @ldionne (author edited for credit).

Differential Revision: https://reviews.llvm.org/D90168
2020-10-28 17:09:11 -04:00
YAMAMOTO Takashi acd7be74ca [libc++] Fix a few warnings
Found during a NuttX porting effort.
But these changes are not directly relevant to NuttX.

Differential Revision: https://reviews.llvm.org/D90139
2020-10-28 15:41:10 -04:00
Louis Dionne 63aeadb484 [libc++] Refactor tests to remove uses of std::rand()
This allows running these tests on systems that do not support std::rand().
2020-10-28 15:22:51 -04:00
Louis Dionne 91336a0c61 [libc++] Move the #error message for no localization to <locale.h>
<locale.h> is lower level than <__locale>, so that's where we want the
error to live for systems that don't provide localization support.
2020-10-28 09:49:37 -04:00
Louis Dionne 201184b30b [libc++] Remove <clocale> from some system_error tests
The explicit call to `std::setlocale(LC_ALL, "C")` isn't required, since
the Standard already says the equivalent of this call is performed on
program startup.
2020-10-28 09:49:36 -04:00
Martin Storsjö 70bba9ef35 [libcxx] Don't truncate intermediates to wchar_t when widening
On windows, wchar_t is 16 bit, while we might be widening chars to
char32_t.

This cast had been present since the initial commit, and removing it
doesn't seem to make any tests fail.

Differential Revision: https://reviews.llvm.org/D90228
2020-10-27 23:58:27 +02:00
Louis Dionne 2089e762d0 [libc++] Try to fix cross-loading of lit.local.cfg on Windows
On windows, the previous path replacement using forward slashes wouldn't
work, and so we'd end up including the same file again. We would do that
until we'd hit the recursion limit of the Python interpreter.

Instead, use `os.path` to properly replace without assuming a specific
path separator.
2020-10-27 16:28:29 -04:00
Louis Dionne c56bbb3961 [libc++] Make sure we include a header when checking compiler macros
Otherwise, it's possible for some __config_site macros not to be
picked up.
2020-10-27 15:58:43 -04:00
Louis Dionne 88ffc72717 [libc++] Add a libc++ configuration that does not support localization
When porting libc++ to embedded systems, it can be useful to drop support
for localization, which these systems don't implement or care about.

Differential Revision: https://reviews.llvm.org/D90072
2020-10-27 14:56:30 -04:00
Martin Storsjö 0be27302d4 [libcxx] Fix typo in spelling of 'sentinel'. NFC.
Differential Revision: https://reviews.llvm.org/D90220
2020-10-27 20:38:32 +02:00
Louis Dionne cfa1376a01 [libc++] Get rid of iostreams in the to_string tests 2020-10-27 13:36:13 -04:00
Louis Dionne 87d3a5365e [libc++] Remove references to CONDUIT_TOKEN
It's not required anymore, since we rely on another job to report
the results back to Phabricator.
2020-10-27 12:26:44 -04:00
Louis Dionne 2479b3d7c6 [libc++] Fix filesystem test in C++11/14
Before C++17, std::string::data() was marked as const, so we can't use
it to write to the contents of the string.
2020-10-27 11:21:33 -04:00
Louis Dionne d1afe2e25c [libc++] Remove the reliance of several <random> tests on <iostream> 2020-10-26 18:02:01 -04:00
Louis Dionne 89ec5091cc [libc++] Get rid of <iostream> in a filesystem test 2020-10-26 17:00:12 -04:00
Louis Dionne b03ea054db [libc++] NFC: Minor refactoring in filesystem_test_helper.h to ease readability
The variable declarations interleaved with logic was really difficult
to read. Instead, simply have two different implementations for _WIN32
and others.
2020-10-26 16:34:20 -04:00
Louis Dionne 8cd7786e48 [libc++] NFC: Consistent indentation for buildkite-pipeline.yml 2020-10-26 14:54:13 -04:00
Louis Dionne b888463f8d [libc++abi] Make sure we can run the tests in Standalone mode
The tests would previously fail if the `python` executable wasn't found,
because we were missing the mandatory find_package.
2020-10-26 14:26:44 -04:00
Louis Dionne 88374f76ee [libc++] Fix indentation of buildkite-pipeline.yml 2020-10-26 12:58:37 -04:00
Louis Dionne d3024a074b [libc++] Add a CI jobs to test the Standalone builds 2020-10-26 12:13:19 -04:00
Louis Dionne 9f4b888c32 [libc++] NFC: Remove unused includes from the test suite
- <iostream> include from a <chrono> test
- <regex> include from the filesystem tests
2020-10-23 15:51:54 -04:00
Louis Dionne cb9f6c4c8c [libc++] Clean up unused CI files
Those were useful during CI experimentation, but are not used anymore.
2020-10-23 15:21:04 -04:00
Louis Dionne 2f8dd2687f [libc++] Refactor the run-buildbot script to make it more modular, and run the benchmarks
As a fly-by fix, unbreak the benchmarks on Apple platforms.

Differential Revision: https://reviews.llvm.org/D90043
2020-10-23 15:11:41 -04:00
Louis Dionne 48e4b0fd3a [runtimes] Revert the libc++ __config_site change
This is a massive revert of the following commits (from most revent to oldest):

	2b9b7b5775.
	529ac33197
	28270234f1
	69c2087283
	b5aa67446e
	5d796645d6

After checking-in the __config_site change, a lot of things started breaking
due to widespread reliance on various aspects of libc++'s build, notably the
fact that we can include the headers from the source tree, but also reliance
on various "internal" CMake variables used by the runtimes build and compiler-rt.

These were unintended consequences of the change, and after two days, we
still haven't restored all the bots to being green. Instead, now that I
understand what specific areas this will blow up in, I should be able to
chop up the patch into smaller ones that are easier to digest.

See https://reviews.llvm.org/D89041 for more details on this adventure.
2020-10-23 09:41:48 -04:00
Louis Dionne d098bb39aa [libc++] Allow running the tests in the experimental runtimes-only build 2020-10-22 17:04:22 -04:00
Louis Dionne ce565861c7 [libc++] Drop old workaround for iostreams instantiations missing from the dylib
On old Apple platforms (pre 10.9), we couldn't rely on the iostreams
explicit instantiations being part of the dylib. However, we don't
support back-deploying to such old deployment targets anymore, so the
workaround can be dropped.
2020-10-22 14:51:25 -04:00
Mikhail Goncharov 40f360c2e9 [libc++] Update continous integration scripts
Now libc++ pipeline will be triggered from the "premerge-checks" and the
combined result are going to be returned to Harbormaster.

Reviewed-by: ldionne

Differential Revision: https://reviews.llvm.org/D89113
2020-10-22 10:49:40 +02:00
Martin Storsjö 78ba1e93a6 [libcxx] [test] Move use of statvfs to helper header
Implement the corresponding thing using windows functions as well.

Differential Revision: https://reviews.llvm.org/D89864
2020-10-22 09:00:57 +03:00
Martin Storsjö 545fb7a71c [libcxx] [test] Mark bits of fs.enum tests as libcpp specific
The individual enum values in copy_options and file_type aren't
specified in the standard.

The standard doesn't require fs::path::format to be a scoped enum.

Differential Revision: https://reviews.llvm.org/D89866
2020-10-22 09:00:57 +03:00
Martin Storsjö 586892d583 [libcxx] [test] Add another (void) cast for a function marked nodiscard in MS STL
Differential Revision: https://reviews.llvm.org/D89867
2020-10-22 09:00:57 +03:00
Louis Dionne 28270234f1 [libc++] Fix the benchmarks build 2020-10-21 17:55:35 -04:00
Louis Dionne 1913bb622c [libc++][ci] Also install the library in the CI scripts
It's good to run the installation step to make sure it works properly,
as build system changes can break that.
2020-10-21 17:34:58 -04:00
Louis Dionne 69c2087283 [libc++] Fix compiler-rt build by copying libc++ headers to <build>/include
This commit should really be named "Workaround external projects depending
on libc++ build system implementation details". It seems that the compiler-rt
build (and perhaps other projects) is relying on the fact that we copy libc++
and libc++abi headers to `<build-root>/include/c++/v1`. This was changed
by 5d796645, which moved the headers to `<build-root>/projects/libcxx/include/c++/v1`
and broke the compiler-rt build.

I'm committing this workaround to fix the compiler-rt build, but we should
remove reliance on implementation details like that. The correct way to
setup the compiler-rt build would be to "link" against the `cxx-headers`
target in CMake, or to run `install-cxx-headers` using an appropriate
installation prefix, and then manually add a `-I` path to that location.
2020-10-21 16:56:33 -04:00
Louis Dionne b5aa67446e [libc++] Fix the installation of libc++ headers since the __config_site change 2020-10-21 12:54:42 -04:00
Louis Dionne 5d796645d6 [take 2] [libc++] Include <__config_site> from <__config>
Prior to this patch, we would generate a fancy <__config> header by
concatenating <__config_site> and <__config>. This complexifies the
build system and also increases the difference between what's tested
and what's actually installed.

This patch removes that complexity and instead simply installs <__config_site>
alongside the libc++ headers. <__config_site> is then included by <__config>,
which is much simpler. Doing this also opens the door to having different
<__config_site> headers depending on the target, which was impossible before.

It does change the workflow for testing header-only changes to libc++.
Previously, we would run `lit` against the headers in libcxx/include.
After this patch, we run it against a fake installation root of the
headers (containing a proper <__config_site> header). This makes use
closer to testing what we actually install, which is good, however it
does mean that we have to update that root before testing header changes.
Thus, we now need to run `ninja check-cxx-deps` before running `lit` by
hand.

This commit was originally applied in 1e46d1aa3 and reverted in eb60c487
because it broke the libc++abi and libunwind test suites. This has now
been fixed.

Differential Revision: https://reviews.llvm.org/D89041
2020-10-21 10:40:33 -04:00
Louis Dionne eb60c48744 [libc++] Revert "Include <__config_site> from <__config>"
This temporarily reverts commit 1e46d1aa until I find a solution to fix
the libc++abi and libunwind test suites with that change.
2020-10-21 09:18:29 -04:00
Louis Dionne 1e46d1aa3f [libc++] Include <__config_site> from <__config>
Prior to this patch, we would generate a fancy <__config> header by
concatenating <__config_site> and <__config>. This complexifies the
build system and also increases the difference between what's tested
and what's actually installed.

This patch removes that complexity and instead simply installs <__config_site>
alongside the libc++ headers. <__config_site> is then included by <__config>,
which is much simpler. Doing this also opens the door to having different
<__config_site> headers depending on the target, which was impossible before.

It does change the workflow for testing header-only changes to libc++.
Previously, we would run `lit` against the headers in libcxx/include.
After this patch, we run it against a fake installation root of the
headers (containing a proper <__config_site> header). This makes use
closer to testing what we actually install, which is good, however it
does mean that we have to update that root before testing header changes.
Thus, we now need to run `ninja check-cxx-deps` before running `lit` by
hand.

Differential Revision: https://reviews.llvm.org/D89041
2020-10-21 08:46:57 -04:00
Martin Storsjö b4a289b03c [libcxx] [test] Split the file_time_type synopsis test
Split the resolution check to a separate test, which is marked as
unsupported on windows.

On windows (both with MS STL and libstdc++), the file time has
100 ns resolution; the standard doesn't mandate a specific resolution.

Differential Revision: https://reviews.llvm.org/D89535
2020-10-21 10:00:02 +03:00
Louis Dionne 9339ab30fb [libc++] Get rid of <sstream> in the valarray tests 2020-10-20 18:15:57 -04:00
Louis Dionne e557b6a66d [libc++] Remove uses of verbose_assert.h in Filesystem tests
For a modest loss of debugability in the tests, this allows more tests
to run on platforms that do not have support for <iostream>.
2020-10-20 16:57:00 -04:00
Louis Dionne c2279b262f [libc++] Make it easier to add new restrictions for feature-test macro tests 2020-10-20 15:52:57 -04:00
Louis Dionne a037059577 [libc++] Decouple debug mode tests from iostreams 2020-10-20 15:48:42 -04:00
Martin Storsjö 87d7c00092 [libcxx] [test] Fix path.modifiers/make_preferred for windows
Use p.string() instead of p.native() for comparing with the expected
value.

Explicitly list the expected values for both posix and windos, even if
the operation is an identity operation on posix.

Differential Revision: https://reviews.llvm.org/D89532
2020-10-20 19:44:21 +03:00
Martin Storsjö b30e42922a [libcxx] [test] Avoid conflicting definitions of _CRT_SECURE_NO_WARNINGS
This is defined both by libcxx/utils/libcxx/test/config.py (for
any windows target) and msvc_stdlib_force_include.h (when testing
specifically the MSVC C++ library).

The command line define (-D_CRT_SECURE_NO_WARNINGS) defines it to the
value 1; change the header define to match that.

Keeping both instances, to keep the fix for cases when not building
in cases that don't use config.py.

Also remove a comment about whether this can be removed; it can't at
least be removed altogether - doing that breaks a number of tests that
otherwise succeed.

Differential Revision: https://reviews.llvm.org/D89588
2020-10-20 19:44:21 +03:00
Eric Fiselier 229db36474 [libc++] Make __shared_weak_count vtable consistent across all build configurations
This patch ensures that __shared_weak_count provides a consistent vtable
regardless of if RTTI is enabled or if we are targeting a static or shared
libc++ build.

This patch is technically ABI breaking, but only for a very specific
configuration that no vendor should be shipping.

Note that _LIBCPP_BUILD_STATIC is not normally defined when building
libc++.a, but instead it must be manually provided by the user or the
__config_site.

Differential Revision: https://reviews.llvm.org/D32838
2020-10-20 08:19:43 -04:00
Casey Carter a668ad92d5 [libc++][test] MSVC has no __PRETTY_FUNCTION__
Use `__FUNCSIG__` instead when compiling with MSVC. While we're touching `makeTypeIDImp`, remove the warning suppression for C4640 "construction of local static object is not thread safe" since C1XX now correctly constant-initializes `id`.
2020-10-19 17:20:47 -07:00
Casey Carter 7f82352a2c [libc++][test] Test nonconforming atomic_fetch_XXX overloads only on libc++
The Standard doesn't include the
```c++
template<class T>
T* atomic_fetch_meow(atomic<T*>, ...);
```
templates these tests are testing.

(See https://bugs.llvm.org/show_bug.cgi?id=47908)
2020-10-19 17:19:52 -07:00
Casey Carter f92d874fe5 [libc++][test] Silence MSVC "comparison of signed and unsigned" warning 2020-10-19 17:18:44 -07:00
Casey Carter d5971a63ca [libc++][test] test allocator<const T> extension only on libc++ 2020-10-19 17:14:51 -07:00
Casey Carter 877766573b [libc++][test] Don't violate precondition [atomics.flag]/6
... which forbids passing `memory_order_release` or `memory_order_acq_rel` to either overload of `atomic_flag_test_explicit`.
2020-10-19 17:14:01 -07:00
Casey Carter dccc742c22 [libc++][test] atomic<T> requires trivially copyable T
The author of these tests apparently forgot that `atomic_{,un}signed_lock_free` are already specializations of `atomic`.
2020-10-19 17:13:18 -07:00
Casey Carter fce9ca3c1e [libc++][test] Pass correct ordering to std::merge
The predicate passed to `merge` must induce a strict weak ordering on its arguments.
2020-10-19 17:12:06 -07:00
Casey Carter 24ab5787b4 [libc++][test] Spell "TEST_CONSTEXPR_CXX17" correctly
These three algorithm tests are incorrectly using `_LIBCPP_CONSTEXPR_AFTER_CXX17` instead of `TEST_CONSTEXPR_CXX17`.
2020-10-19 17:11:26 -07:00
Martin Storsjö 93671fffb5 [libcxx] [test] Use _putenv instead of setenv/unsetenv on windows
Move the functions to the helper header and keep the arch specific
logic there.

Differential Revision: https://reviews.llvm.org/D89681
2020-10-20 00:07:02 +03:00
Martin Storsjö 81db3c31aa [libcxx] [test] Fix all remaining issues with fs::path::string_type being wstring
Use fs::path as variable type instead of std::string, when the input
potentially is a path, as they can't be implicitly converted back to
string.

Differential Revision: https://reviews.llvm.org/D89674
2020-10-20 00:07:02 +03:00
Martin Storsjö 5c39eebc12 [libcxx] [test] Fix filesystem_test_helper.h to compile for windows
Use .string() instead of .native() in places where we want to combine
paths with std::string.

Convert some methods to take a fs::path as parameter instead of
std::string, for cases where they are called with paths as
parameters (which can't be implicitly converted to std::string if
the path's string_type is wstring).

Differential Revision: https://reviews.llvm.org/D89530
2020-10-20 00:07:02 +03:00
Martin Storsjö afe40b305d [libcxx] [test] Mark tests that require specific allocation behaviours as libcpp only
This fixes/silences a few failures on libstdc++ on linux.

Differential Revision: https://reviews.llvm.org/D89676
2020-10-20 00:07:01 +03:00
Martin Storsjö fa88f61ef5 [libcxx] [test] Exclude domain socket tests on windows, like bsd/darwin
Differential Revision: https://reviews.llvm.org/D89673
2020-10-20 00:07:01 +03:00
Martin Storsjö cf9831b843 [libcxx] [test] Add LIBCPP_ONLY() around another test for an implementation detail
Differential Revision: https://reviews.llvm.org/D89675
2020-10-20 00:07:01 +03:00
Martin Storsjö 41c5070888 [libcxx] [test] Don't require fs::path::operator(string_type&&) to be noexcept
Mark this as a libcpp specific test; the standard doesn't say that
this method should be noexcept.

Differential Revision: https://reviews.llvm.org/D89677
2020-10-20 00:07:01 +03:00
Martin Storsjö e2ddd515ab [libcxx] [test] Allow fs::permissions(path, perms, perm_options, error_code) to be noexcept
The standard doesn't declare this overload as noexcept, but doesn't
either say that it strictly cannot be noexcept either. The function
doesn't throw on errors that are signaled via error_code, but the
standard says that it may throw a bad_alloc.

This fixes an error with libstdc++ on linux.

Differential Revision: https://reviews.llvm.org/D89678
2020-10-20 00:07:01 +03:00
Martin Storsjö c61c7ba595 [libcxx] [test] Do error printfs to stderr in filesystems tests
This makes them more readable in llvm-lit's output on failures.

This only applies the change on the filesystem test subdir.

Differential Revision: https://reviews.llvm.org/D89680
2020-10-20 00:07:01 +03:00
Louis Dionne ec0dc70efc [libc++] Add more tests for operator<< on std::complex 2020-10-19 13:23:59 -04:00
Alex Richardson 8041f13e62 [libc++] Skip tests using constexpr destructors with older clang versions
It appears that the released version of clang that supports constexpr
destructors is clang 10 and the oldest one that accepts -std=c++2a is 5,
so mark these as UNSUPPORTED for clang-5 to clang-9.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D89704
2020-10-19 17:23:02 +01:00
Louis Dionne b4bd194378 [libc++] Refactor the fuzzing tests
Define all the fuzzing tests in libcxx/test/libcxx/fuzzing, and get
rid of the ad-hoc libcxx/fuzzing directory, which wasn't properly
integrated with the build system or test suite.

As a fly-by change, this also reduces the dependencies of fuzzing tests
on large library components like <iostream>, to make them work on more
platforms.
2020-10-19 12:11:50 -04:00
Louis Dionne 9b40ee8eb0 [libc++] Define new/delete in libc++abi only by default
Previously, we would define new/delete in both libc++ and libc++abi.
Not only does this cause code bloat, but also it's technically an ODR
violation since we don't know which operator will be selected. Furthermore,
since those are weak definitions, we should strive to have as few of them
as possible (to improve load times).

My preferred choice would have been to put the operators in libc++ only
by default, however that would create a circular dependency between
libc++ and libc++abi, which GNU linkers don't handle.

Folks who want to ship new/delete in libc++ instead of libc++abi are
free to do so by turning on LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS at
CMake configure time.

On Apple platforms, this shouldn't be an ABI break because we re-export
the new/delete symbols from libc++abi. This change actually makes libc++
behave closer to the system libc++ shipped on Apple platforms.

On other platforms, this is an ABI break for people linking against libc++
but not libc++abi. However, vendors have been consulted in D68269 and no
objection was raised. Furthermore, the definitions can be controlled to
appear in libc++ instead with the CMake option.

Differential Revision: https://reviews.llvm.org/D68269
2020-10-19 11:35:01 -04:00
Casey Carter b20918997a [libc++][test] Portably silence warnings
... in `<numbers>` tests with `[[maybe_unused]]`.
2020-10-19 08:33:58 -07:00
Alex Richardson 7928d40c6b [libc++][dsl] Run checks for locale names aliases using a single %exec
This changes the checking for available locales to use one program that
iterates over argv to test multiple locale names instead of checking each
name with a separate executable.

This massively speeds up running individual tests using an SSH executor
(it can take up to 10 seconds to compile and run a single test in some
emulated environments) in case no locales are installed since then all
fallback names are tested idividually. But even on a native machine
this reduces the libc++ lit startup time by ~1-2 second for me on a machine
that does not have locale data installed.

Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D88884
2020-10-18 18:17:50 +01:00
Alex Richardson 82b0ac4f1f [libc++] Fix aligned_alloc tests FreeBSD
On FreeBSD we get the following error when passing zero as the requested
alignment: error: requested alignment is not a power of 2

Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D88820
2020-10-18 18:17:50 +01:00
Martin Storsjö 3784bdf217 [libcxx] [test] Fix string type handling in a few fairly trivial class.path tests
Use string() for convenience for testing where possible, but keep using
native() for move tests where we want to check that no allocations are
made, constructing a reference fs::path::string_type instead.

Use the right value_type in a few places.

Make the synop test check for the right types and for the expected
preferred separator.

Differential Revision: https://reviews.llvm.org/D89537
2020-10-16 21:04:23 +03:00
Louis Dionne 2408fc2a1e [libc++] Avoid relying on `realpath` being installed on the system
It doesn't appear to be a standard utility.
2020-10-16 13:07:18 -04:00
Louis Dionne 880fc4d581 [libc++] Move the oss-fuzz script to libcxx/utils/ci 2020-10-16 12:40:43 -04:00
Louis Dionne e1612c3866 [libc++] Move the oss-fuzz script to libc++
Instead of having this script be part of the OSS-Fuzz repository, I think
it makes more sense to have it alongside the rest of the fuzzing targets
in libc++.
2020-10-16 12:23:03 -04:00
Martin Storsjö ddb4693a92 [libcxx] [test] Add (void) return casts on functions marked nodiscard in MS STL
Differential Revision: https://reviews.llvm.org/D89533
2020-10-16 17:36:56 +03:00
Martin Storsjö 66427d7359 [libcxx] [test] Mark tests for libcxx specific implementation details with LIBCPP_ONLY()
This matches an existing marking in enum.path.format.pass.cpp.

Differential Revision: https://reviews.llvm.org/D89534
2020-10-16 17:36:56 +03:00
Martin Storsjö 701fa703fc [libcxx] [test] Use fs::path::string_type instead of std::string in fs.op.relative
Differential Revision: https://reviews.llvm.org/D89538
2020-10-16 17:36:56 +03:00
Martin Storsjö fdbfff8fd4 [libcxx] [test] Use string() instead of native() as parameter to std::ifstream/ofstream in copy_file_large.pass.cpp
This fixes building with libstdc++ for windows. MS STL has got
ifstream/ofstream overloads that taken wide strings though.

Differential Revision: https://reviews.llvm.org/D89539
2020-10-16 17:36:56 +03:00
Simon Tatham 4d60467f99 [libcxx] Fix printf formats in two tests.
rGcc69d211d0d65d7b introduced several uses of `printf` with format
directives `%lu` and `%ld` to format values of type `size_t` and
`ptrdiff_t` respectively.

That doesn't reliably work in all C implementations, because those
types aren't necessarily the same thing as 'long int': sometimes
they're not even the same size, and when they are the same size, they
might be officially defined as int rather than long (for example),
which causes clang to emit a diagnostic for the mismatch.

C has special-purpose printf modifier letters for these two types, so
it's safer to use them. Changed all `%lu` on `size_t` to `%zu`, and
all `%ld` on `ptrdiff_t` to `%td`.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D89545
2020-10-16 13:47:45 +01:00
Louis Dionne 13410fa79f [libc++] NFCI: Use Lit features to disable tests instead of #if 2020-10-16 08:35:34 -04:00
Louis Dionne c474d829d0 [libc++] NFC: Move iterator.range tests into the right place
They seem to have been placed under stream.iterators by mistake.
This is relevant for some upcoming UNSUPPORTED markup.
2020-10-16 08:35:34 -04:00
Louis Dionne 6abc15ae3c [libc++] Reduce dependencies on <iostream> from <random>
We included <istream> and <ostream> from <random>, but really it is
sufficient to include <iosfwd> if we make sure we access ios_base
members through a dependent type. This allows us to break a hard
dependency of <random> on locales.
2020-10-15 13:40:18 -04:00
Louis Dionne 17dcf85ebe [libc++][filesystem] Only include <fstream> when we actually need it in copy_file_impl
This allows building <filesystem> on systems that don't support <fstream>,
such as systems that don't support localization.
2020-10-15 13:21:14 -04:00
Louis Dionne 54f7ad2d6f [libc++] NFC: Remove unused include 2020-10-15 12:54:50 -04:00
Louis Dionne e0d01294bc [libc++] Allow building libc++ on platforms without a random device
Some platforms, like several embedded platforms, do not provide a source
of randomness through a random device. This commit makes it possible to
build and test libc++ for such platforms, i.e. without std::random_device.

Surprisingly, the only functionality that doesn't work on such platforms
is std::random_device itself -- everything else in <random> still works,
one just has to find alternative ways to seed the PRNGs.
2020-10-15 12:20:29 -04:00
Louis Dionne 0728b67b27 [libc++] Mark two tests as unsupported in C++03
This was dropped when I split the tests into individual source files
to make sure they would actually run (in 2908eb20ba).
2020-10-14 12:42:11 -04:00
Louis Dionne 4212533961 [libc++] Use ADDITIONAL_COMPILE_FLAGS instead of #define for _LIBCPP_DEBUG 2020-10-14 12:02:37 -04:00
Louis Dionne 2908eb20ba [libc++] Split off debug tests that were missed by ce1365f8f7 into test/libcxx
Also, some tests had multiple death tests in them, so split them into
separate tests instead. The second death test would obviously never
get run, because the first one would kill the program before.
2020-10-14 12:02:37 -04:00
Louis Dionne 41d85fe0e1 [libc++] Remove signal-based checkpoints in libc++ tests
While this adds some convenience to the test suite, it prevents the tests
using these checkpoints from being used on systems where signals are not
available, such as some embedded systems. It will also prevent these tests
from being constexpr-friendly once e.g. std::map is made constexpr, due
to the use of statics.

Instead, one can always use a debugger to figure out exactly where a
test is failing when that isn't clear from the log output without
checkpoints.
2020-10-14 10:38:32 -04:00
Dominik Montada 8c03fdf34a [libcxxabi,libunwind] support running tests in standalone mode
Remove check for standalone and shared library mode in libcxxabi to
allow including tests in said mode. This check prevented running the
tests in standalone mode with static libraries, which is the case for
baremetal targets.

Fix check-unwind target trying to use a non-existent llvm-lit executable
in standalone mode. Copy the HandleOutOfTreeLLVM logic from libcxxabi to
libunwind in order to make the tests work in standalone mode.

Reviewed By: ldionne, #libc_abi, #libc

Differential Revision: https://reviews.llvm.org/D86540
2020-10-14 09:10:20 +02:00
Louis Dionne cc69d211d0 [libc++/abi] Clean up uses of <iostream> in the test suite
We used <iostream> in several places where we don't actually need the
full power of <iostream>, and where using basic `std::printf` is enough.
This is better, since `std::printf` can be supported on systems that don't
have a notion of locales, while <iostream> can't.
2020-10-13 20:25:33 -04:00
Louis Dionne ab55897817 [libc++] Allow passing relative paths to the Apple install script 2020-10-13 12:27:47 -04:00
Raphael Isemann 6b7a49bb43 Fix all the CMake code that can only handle -stdlib= but not --stdlib=
There are several places in LLVM's CMake setup that try to remove the
`stdlib=...` flag from the CMake flags. All this code however only considered
the `-stdlib=` variant of the flag but not the alternative spelling with a
double dash. This causes that when one adds `--stdlib=...` to the user-provided
CMake flags that this gets transformed into just `-` which ends up causing the
build system to think it should read the source from stdin (which then lead to
very confusing build errors).

This just adds the alternative spelling before the`-stdlib=` variant in all
these places

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D87133
2020-10-13 16:05:21 +02:00
Louis Dionne 647fb6b374 [libc++] Update the <version> header in-place from generate_feature_test_macro_components
This simplifies the workflow for adding new feature-test macros for
contributors. Previously, they would have to move the generated <version>
header from a temporary directory to libc++'s include directory by hand.
This makes the behavior for the <version> header consistent with what's
done for the tests and the documentation.
2020-10-13 09:18:35 -04:00
Louis Dionne 2dc9b26c00 [libc++] Remove code to prevent overwriting the system libc++ on Darwin
The system partition is read-only since Catalina.
2020-10-09 17:02:39 -04:00
Louis Dionne 4bd3d16c2d [libc++] Remove redundant if(LIBCXX_INSTALL_LIBRARY)
The individual LIBCXX_INSTALL_(SHARED|STATIC)_LIBRARY are already
dependent on whether LIBCXX_INSTALL_LIBRARY is ON or OFF.
2020-10-09 17:02:39 -04:00
Louis Dionne 877667287f [libc++] Fixup a missing occurrence of LIBCXX_ENABLE_DEBUG_MODE 2020-10-09 14:40:47 -04:00
Louis Dionne e0d66ccf06 [libc++] Rename LIBCXX_ENABLE_DEBUG_MODE to LIBCXX_ENABLE_DEBUG_MODE_SUPPORT
To make it clearer this is about whether the library supports the debug
mode at all, not whether the debug mode is enabled. Per comment by Nico
Weber on IRC.
2020-10-09 14:39:20 -04:00
Louis Dionne 4abb519619 [libc++] NFCI: Define small methods of basic_stringstream inline
It greatly increases readability because defining the methods out-of-line
involves a ton of boilerplate template declarations.
2020-10-09 14:33:49 -04:00
Louis Dionne c778f6c4f9 [libc++] Clean up logic around aligned/sized allocation and deallocation
Due to the need to support compilers that implement builtin operator
new/delete but not their align_val_t overloaded versions, there was a
lot of complexity. By assuming that a compiler that supports the builtin
new/delete operators also supports their align_val_t overloads, the code
can be simplified quite a bit.

Differential Revision: https://reviews.llvm.org/D88301
2020-10-09 12:43:28 -04:00