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/numerics/rand/rand.eng/rand.eng.sub | |
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/numerics/rand/rand.eng/rand.eng.sub')
12 files changed, 36 insertions, 12 deletions
diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp index c05831165f8..e6cce1b2da7 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp @@ -48,8 +48,10 @@ test2() assert(e1 == e2); } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp index 70a2b5b2cf7..c39f39858e4 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp @@ -46,8 +46,10 @@ test2() assert(e1 == e2); } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp index 3045b06c92f..5a178e82e6f 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp @@ -43,8 +43,10 @@ test2() assert(os.str() == a); } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp index 361a0fc25dd..0ed496e71af 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp @@ -47,8 +47,10 @@ test2() assert(os.str() == a); } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp index 13dede1aa94..dbc4c5b4cb8 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp @@ -34,8 +34,10 @@ test2() assert(e1() == 23459059301164ull); } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp index f4824cd9a1c..4d039289bff 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp @@ -44,8 +44,10 @@ test2() assert(e1 == e2); } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp index 818d66c441e..d8d03c09ee5 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp @@ -34,8 +34,10 @@ test2() assert(e() == 276846226770426ull); } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp index 88d0910d2e7..d3eeda3be4a 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp @@ -55,8 +55,10 @@ test2() assert(e1 == e2); } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp index cc0fa903adc..5312bb1ff3a 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp @@ -34,8 +34,10 @@ test2() std::uint_fast64_t>::value), ""); } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp index 201ec38d1e5..637841a679b 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp @@ -42,8 +42,10 @@ test2() } } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp index 2a178388ce0..85199c0ef3b 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp @@ -40,8 +40,10 @@ test2() assert(e1 == e2); } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp index 758a5957f12..a877eff1383 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp @@ -74,8 +74,10 @@ test2() where(E::default_seed); } -int main() +int main(int, char**) { test1(); test2(); + + return 0; } |