diff options
| author | JF Bastien <jfbastien@apple.com> | 2019-02-04 20:31:13 +0000 |
|---|---|---|
| committer | JF Bastien <jfbastien@apple.com> | 2019-02-04 20:31:13 +0000 |
| commit | 2df59c50688c122bbcae7467d3eaf862c3ea3088 (patch) | |
| tree | 29c9a3e1c54fe76a506ffecc0cc4d8fbaba5cb04 /libcxx/test/std/thread/thread.threads | |
| parent | 6fd4e7fe0258ff71fe759535236883ea9060587c (diff) | |
| download | bcm5719-llvm-2df59c50688c122bbcae7467d3eaf862c3ea3088.tar.gz bcm5719-llvm-2df59c50688c122bbcae7467d3eaf862c3ea3088.zip | |
Support tests in freestanding
Summary:
Freestanding is *weird*. The standard allows it to differ in a bunch of odd
manners from regular C++, and the committee would like to improve that
situation. I'd like to make libc++ behave better with what freestanding should
be, so that it can be a tool we use in improving the standard. To do that we
need to try stuff out, both with "freestanding the language mode" and
"freestanding the library subset".
Let's start with the super basic: run the libc++ tests in freestanding, using
clang as the compiler, and see what works. The easiest hack to do this:
In utils/libcxx/test/config.py add:
self.cxx.compile_flags += ['-ffreestanding']
Run the tests and they all fail.
Why? Because in freestanding `main` isn't special. This "not special" property
has two effects: main doesn't get mangled, and main isn't allowed to omit its
`return` statement. The first means main gets mangled and the linker can't
create a valid executable for us to test. The second means we spew out warnings
(ew) and the compiler doesn't insert the `return` we omitted, and main just
falls of the end and does whatever undefined behavior (if you're luck, ud2
leading to non-zero return code).
Let's start my work with the basics. This patch changes all libc++ tests to
declare `main` as `int main(int, char**` so it mangles consistently (enabling us
to declare another `extern "C"` main for freestanding which calls the mangled
one), and adds `return 0;` to all places where it was missing. This touches 6124
files, and I apologize.
The former was done with The Magic Of Sed.
The later was done with a (not quite correct but decent) clang tool:
https://gist.github.com/jfbastien/793819ff360baa845483dde81170feed
This works for most tests, though I did have to adjust a few places when e.g.
the test runs with `-x c`, macros are used for main (such as for the filesystem
tests), etc.
Once this is in we can create a freestanding bot which will prevent further
regressions. After that, we can start the real work of supporting C++
freestanding fairly well in libc++.
<rdar://problem/47754795>
Reviewers: ldionne, mclow.lists, EricWF
Subscribers: christof, jkorous, dexonsmith, arphaman, miyuki, libcxx-commits
Differential Revision: https://reviews.llvm.org/D57624
llvm-svn: 353086
Diffstat (limited to 'libcxx/test/std/thread/thread.threads')
28 files changed, 84 insertions, 28 deletions
diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp index 64a41368627..68f20d7532b 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp @@ -41,7 +41,7 @@ public: int G::n_alive = 0; bool G::op_run = false; -int main() +int main(int, char**) { { G g; @@ -54,4 +54,6 @@ int main() assert(t1.get_id() == id0); t1.join(); } + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp index 1afaaf7bd61..e67ceea5db6 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp @@ -40,11 +40,13 @@ public: int G::n_alive = 0; bool G::op_run = false; -int main() +int main(int, char**) { { std::thread t0(G()); std::thread t1; t1 = t0; } + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp index e2f3d38fc06..cbc32c8c2ce 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp @@ -41,7 +41,7 @@ public: int G::n_alive = 0; bool G::op_run = false; -int main() +int main(int, char**) { { assert(G::n_alive == 0); @@ -59,4 +59,6 @@ int main() assert(G::n_alive == 0); assert(G::op_run); } + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp index 9a4d6e91020..81c6d77e8a7 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp @@ -51,7 +51,7 @@ void f1() std::_Exit(0); } -int main() +int main(int, char**) { std::set_terminate(f1); { @@ -61,4 +61,6 @@ int main() t0 = std::move(t1); assert(false); } + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp index af2450f182f..13c69180a4d 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp @@ -144,7 +144,7 @@ void test_throwing_new_during_thread_creation() { #endif } -int main() +int main(int, char**) { test_throwing_new_during_thread_creation(); { @@ -200,4 +200,6 @@ int main() t.join(); } #endif + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp index c24b0413b20..26231373f80 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp @@ -18,8 +18,10 @@ #include <thread> #include <cassert> -int main() +int main(int, char**) { volatile std::thread t1; std::thread t2 ( t1, 1, 2.0 ); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp index 4a2e6f0d44b..2a3632cd42f 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp @@ -48,7 +48,7 @@ public: int G::n_alive = 0; bool G::op_run = false; -int main() +int main(int, char**) { { assert(G::n_alive == 0); @@ -62,4 +62,6 @@ int main() assert(G::n_alive == 0); assert(G::op_run); } + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp index d635470db31..135d3ceba99 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp @@ -17,8 +17,10 @@ #include <thread> #include <cassert> -int main() +int main(int, char**) { std::thread t; assert(t.get_id() == std::thread::id()); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp index 7e34729b3a7..25703b2c3ca 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp @@ -50,7 +50,7 @@ public: int G::n_alive = 0; bool G::op_run = false; -int main() +int main(int, char**) { { G g; @@ -66,4 +66,6 @@ int main() assert(G::op_run); } assert(G::n_alive == 0); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp index 202d61b8f22..320b4459b94 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp @@ -47,7 +47,7 @@ void f1() std::_Exit(0); } -int main() +int main(int, char**) { std::set_terminate(f1); { @@ -60,4 +60,6 @@ int main() } } assert(false); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp index 4447600486a..fb4b7eb5ae0 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp @@ -17,7 +17,7 @@ #include <thread> #include <cassert> -int main() +int main(int, char**) { std::thread::id id0; std::thread::id id1; @@ -25,4 +25,6 @@ int main() assert(id1 == id0); id1 = std::this_thread::get_id(); assert(id1 != id0); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp index 52d4f2cf377..f95617b4f53 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp @@ -17,9 +17,11 @@ #include <thread> #include <cassert> -int main() +int main(int, char**) { std::thread::id id0; std::thread::id id1 = id0; assert(id1 == id0); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp index a9778f047d2..32a083ca8aa 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp @@ -17,8 +17,10 @@ #include <thread> #include <cassert> -int main() +int main(int, char**) { std::thread::id id; assert(id == std::thread::id()); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp index 7a2fa869d62..3858508e1c9 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp @@ -18,9 +18,11 @@ #include "poisoned_hash_helper.hpp" -int main() { +int main(int, char**) { test_library_hash_specializations_available(); { test_hash_enabled_for_type<std::thread::id>(); } + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp index cf89066a509..5c557fddc7f 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp @@ -18,7 +18,7 @@ #include <thread> #include <cassert> -int main() +int main(int, char**) { std::thread::id id0; std::thread::id id1; @@ -28,4 +28,6 @@ int main() id1 = std::this_thread::get_id(); assert(!(id1 == id0)); assert( (id1 != id0)); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp index 69ea217b506..8af73045a79 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp @@ -20,7 +20,7 @@ #include <thread> #include <cassert> -int main() +int main(int, char**) { std::thread::id id0; std::thread::id id1; @@ -39,4 +39,6 @@ int main() assert( (id0 > id2)); assert( (id0 >= id2)); } + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp index d07f26b1698..a1541c12e22 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp @@ -20,9 +20,11 @@ #include <sstream> #include <cassert> -int main() +int main(int, char**) { std::thread::id id0 = std::this_thread::get_id(); std::ostringstream os; os << id0; + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp index 325c0bfebd4..80bcbf97c1d 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp @@ -24,7 +24,7 @@ #include "test_macros.h" -int main() +int main(int, char**) { std::thread::id id1; std::thread::id id2 = std::this_thread::get_id(); @@ -34,4 +34,6 @@ int main() ASSERT_NOEXCEPT(H()(id2)); H h; assert(h(id1) != h(id2)); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp index 8debe7770dd..bf72e3437a4 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp @@ -61,7 +61,7 @@ bool G::op_run = false; void foo() {} -int main() +int main(int, char**) { { G g; @@ -86,4 +86,6 @@ int main() } } #endif + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp index 99cdec9134c..006bc1e65c4 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp @@ -41,7 +41,7 @@ public: int G::n_alive = 0; bool G::op_run = false; -int main() +int main(int, char**) { { G g; @@ -54,4 +54,6 @@ int main() assert(t1.get_id() == std::thread::id()); t0.join(); } + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp index c21de04ea34..b64a111c6be 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp @@ -46,7 +46,7 @@ bool G::op_run = false; void foo() {} -int main() +int main(int, char**) { { G g; @@ -73,4 +73,6 @@ int main() } } #endif + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp index 3db473ab181..6f1308cbad0 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp @@ -41,7 +41,7 @@ public: int G::n_alive = 0; bool G::op_run = false; -int main() +int main(int, char**) { { G g; @@ -50,4 +50,6 @@ int main() t0.join(); assert(!t0.joinable()); } + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp index 66c810b1b7e..f43805d7fe6 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp @@ -41,7 +41,7 @@ public: int G::n_alive = 0; bool G::op_run = false; -int main() +int main(int, char**) { { G g; @@ -54,4 +54,6 @@ int main() assert(t1.get_id() == id0); t1.join(); } + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp index 3500f2c169a..5493f27a494 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp @@ -17,7 +17,9 @@ #include <thread> #include <cassert> -int main() +int main(int, char**) { assert(std::thread::hardware_concurrency() > 0); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp index 864518dd8ff..1bf46cdb54f 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.this/get_id.pass.cpp @@ -15,8 +15,10 @@ #include <thread> #include <cassert> -int main() +int main(int, char**) { std::thread::id id = std::this_thread::get_id(); assert(id != std::thread::id()); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp index 59791c84cdb..7c8552ea865 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp @@ -16,6 +16,8 @@ // is therefore non-standard. For this reason the test lives under the 'libcxx' // subdirectory. -int main() +int main(int, char**) { + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp index 5fbaf9d8773..c73144db0c1 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp @@ -18,7 +18,7 @@ #include <cstdlib> #include <cassert> -int main() +int main(int, char**) { typedef std::chrono::system_clock Clock; typedef Clock::time_point time_point; @@ -30,4 +30,6 @@ int main() std::chrono::nanoseconds err = 5 * ms / 100; // The time slept is within 5% of 500ms assert(std::abs(ns.count()) < err.count()); + + return 0; } diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp index 5c1caa0cbe0..6f772b5c286 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.this/yield.pass.cpp @@ -15,7 +15,9 @@ #include <thread> #include <cassert> -int main() +int main(int, char**) { std::this_thread::yield(); + + return 0; } |

