From 48a7b995b95780d20970685370d23f06c9d39d98 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Sat, 10 Oct 2020 14:11:03 +0200 Subject: [PATCH] Remove some glitches to prepare nice pull request Some changes got into this branch by accident. This patch undos them in order to have a pull request which cares only about the experimental/non-experimental namespace/include problem. --- README.md | 68 +----------------------------- test/async_generator_tests.cpp | 6 --- test/counted.hpp | 10 ++--- test/recursive_generator_tests.cpp | 5 +-- test/shared_task_tests.cpp | 2 - test/task_tests.cpp | 5 +-- test/when_all_tests.cpp | 3 -- 7 files changed, 8 insertions(+), 91 deletions(-) diff --git a/README.md b/README.md index c8b8db1d..2eb871b0 100644 --- a/README.md +++ b/README.md @@ -2859,7 +2859,7 @@ Given a type, `S`, that implements the `DelayedScheduler` and an instance, `s` o The cppcoro library supports building under Windows with Visual Studio 2017 and Linux with Clang 5.0+. -This library makes use of either the [Cake build system](https://github.com/lewissbaker/cake) (no, not the [C# one](http://cakebuild.net/)) or CMake. +This library makes use of the [Cake build system](https://github.com/lewissbaker/cake) (no, not the [C# one](http://cakebuild.net/)). The cake build system is checked out automatically as a git submodule so you don't need to download or install it separately. @@ -2867,12 +2867,10 @@ The cake build system is checked out automatically as a git submodule so you don This library currently requires Visual Studio 2017 or later and the Windows 10 SDK. -Support for Linux ([#15](https://github.com/lewissbaker/cppcoro/issues/15)) is planned. +Support for Clang ([#3](https://github.com/lewissbaker/cppcoro/issues/3)) and Linux ([#15](https://github.com/lewissbaker/cppcoro/issues/15)) is planned. ### Prerequisites -The CMakeLists requires version 3.13 or later. - The Cake build-system is implemented in Python and requires Python 2.7 to be installed. Ensure Python 2.7 interpreter is in your PATH and available as 'python'. @@ -2905,68 +2903,6 @@ c:\Code\cppcoro> git submodule update --init --recursive ### Building from the command-line -#### With CMake - -Cppcoro follows the usual CMake workflow with no custom options added. Notable [standard CMake options](https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html): - -| Flag | Description | Default Value | -|----------------------|------------------------------|------------------------| -| BUILD_TESTING | Build the unit tests | ON | -| BUILD_SHARED_LIBS | Build as a shared library | OFF | -| CMAKE_BUILD_TYPE | Build as `Debug`/`Release` | | -| CMAKE_INSTALL_PREFIX | Where to install the library | `/usr/local` (on Unix) | - -CMake also respects the [conventional environment variables](https://cmake.org/cmake/help/latest/manual/cmake-env-variables.7.html): - -| Environment Variable | Description | -|----------------------|-------------------------------| -| CXX | Path to the C++ compiler | -| CXXFLAGS | C++ compiler flags to prepend | -| LDFLAGS | Linker flags to prepend | - -Example: - -```bash -cd -mkdir build -cd build -export CXX=clang++ -export CXXFLAGS="-stdlib=libc++ -march=native" -export LDFLAGS="-stdlib=libc++ -fuse-ld=lld -Wl,--gdb-index" -cmake .. [-GNinja] -DCMAKE_INSTALL_PREFIX=$HOME/.local -DBUILD_SHARED_LIBS=ON -ninja # or make -jN -ninja test # Run the tests -ninja install -``` - -The CMake build scripts will also install a `cppcoroConfig.cmake` file for consumers to use. -It will check at the consumer site that coroutines are indeed supported by the system and enable the appropriate compiler flag for Clang or MSVC, respectively. -Assuming cppcoro has been installed to `$HOME/.local` like in the example above it can be consumed like this: - -```cmake -find_package(cppcoro REQUIRED) -add_executable(app main.cpp) -target_link_libraries(app PRIVATE cppcoro::cppcoro) -``` - -```bash -$ cmake . -Dcppcoro_ROOT=$HOME/.local -# ... --- Performing Test Coroutines_SUPPORTS_MS_FLAG --- Performing Test Coroutines_SUPPORTS_MS_FLAG - Failed --- Performing Test Coroutines_SUPPORTS_GNU_FLAG --- Performing Test Coroutines_SUPPORTS_GNU_FLAG - Success --- Looking for C++ include coroutine --- Looking for C++ include coroutine - not found --- Looking for C++ include experimental/coroutine --- Looking for C++ include experimental/coroutine - found --- Configuring done --- Generating done -# ... -``` - -#### With Cake - To build from the command-line just run 'cake.bat' in the workspace root. eg. diff --git a/test/async_generator_tests.cpp b/test/async_generator_tests.cpp index 1fa0234b..3f0c4af7 100644 --- a/test/async_generator_tests.cpp +++ b/test/async_generator_tests.cpp @@ -256,11 +256,6 @@ TEST_CASE("exception thrown after first yield is rethrown from increment operato }()); } -#if (defined(__GNUC__) && !defined(__clang__)) -#define GCC_COMPILER 1 -#endif -// GCC 10.1 doesn't support "for co_await" -#ifndef GCC_COMPILER TEST_CASE("large number of synchronous completions doesn't result in stack-overflow") { @@ -303,7 +298,6 @@ TEST_CASE("large number of synchronous completions doesn't result in stack-overf consumer(makeSequence(event)), unblocker(event))); } -#endif // GCC_COMPILER TEST_CASE("fmap") { diff --git a/test/counted.hpp b/test/counted.hpp index dff6c89e..380c12e0 100644 --- a/test/counted.hpp +++ b/test/counted.hpp @@ -5,8 +5,6 @@ #ifndef CPPCORO_TESTS_COUNTED_HPP_INCLUDED #define CPPCORO_TESTS_COUNTED_HPP_INCLUDED -#include - struct counted { static int default_construction_count; @@ -34,10 +32,10 @@ struct counted return construction_count() - destruction_count; } - counted() : id(default_construction_count++) { std::cout << "constructed" << std::endl; } - counted(const counted& other) : id(other.id) { ++copy_construction_count; std::cout << "copied" << std::endl; } - counted(counted&& other) : id(other.id) { ++move_construction_count; other.id = -1; std::cout << "moved" << std::endl; } - ~counted() { ++destruction_count; std::cout <<"destructed" << std::endl; } + counted() : id(default_construction_count++) {} + counted(const counted& other) : id(other.id) { ++copy_construction_count; } + counted(counted&& other) : id(other.id) { ++move_construction_count; other.id = -1; } + ~counted() { ++destruction_count; } }; diff --git a/test/recursive_generator_tests.cpp b/test/recursive_generator_tests.cpp index 8551fc31..51343be4 100644 --- a/test/recursive_generator_tests.cpp +++ b/test/recursive_generator_tests.cpp @@ -382,10 +382,7 @@ namespace { while (start < end) { - // GCC 10.1 workaround: "co_yield start++ always returns the same value, resulting in an infinite loop - // ((++start)-1) seems to have the same issue, while ++start works, but breaks the test - start++; - co_yield start-1; + co_yield start++; } } diff --git a/test/shared_task_tests.cpp b/test/shared_task_tests.cpp index 246990de..7bf816cf 100644 --- a/test/shared_task_tests.cpp +++ b/test/shared_task_tests.cpp @@ -120,8 +120,6 @@ TEST_CASE("waiting on shared_task in loop doesn't cause stack-overflow") int result = 0; for (int i = 0; i < 1'000'000; ++i) { - // GCC 10.1 workaround: GCC doesn't generate any code for a for loop with only a co_await in it - [](){}(); result += co_await completesSynchronously(); } CHECK(result == 1'000'000); diff --git a/test/task_tests.cpp b/test/task_tests.cpp index 22c405a0..96b821a7 100644 --- a/test/task_tests.cpp +++ b/test/task_tests.cpp @@ -177,8 +177,7 @@ TEST_CASE("passing parameter by value to task coroutine calls move-constructor e auto t = f(c); // Should have called copy-constructor to pass a copy of 'c' into f by value. - // GCC 10.1 performs 2 copies - CHECK(counted::copy_construction_count >= 1); + CHECK(counted::copy_construction_count == 1); // Inside f it should have move-constructed parameter into coroutine frame variable //WARN_MESSAGE(counted::move_construction_count == 1, @@ -339,8 +338,6 @@ TEST_CASE("lots of synchronous completions doesn't result in stack-overflow") int sum = 0; for (int i = 0; i < 1'000'000; ++i) { - // GCC 10.1 workaround: GCC doesn't generate any code for a for loop with only a co_await in it - [](){}(); sum += co_await completesSynchronously(); } CHECK(sum == 1'000'000); diff --git a/test/when_all_tests.cpp b/test/when_all_tests.cpp index 1e1b6efc..1c616be8 100644 --- a/test/when_all_tests.cpp +++ b/test/when_all_tests.cpp @@ -112,9 +112,6 @@ TEST_CASE("when_all() with all task types") CHECK(a == "foo"); CHECK(b.id == 0); - // GCC 10.1 fails this check: at this point there are 3 objects alive - // * One will be destructed later - // * One object is completely leaked CHECK(counted::active_count() == 1); };