Comments (7)
I have a new test suite in compiler-builtins-tester that works on both std
and no_std
targets and doesn't require compiling or linking to compiler-rt / gcc_s. I have checked that it mostly (*) passes on x86_64, the arm targets and the thumb targets.
(*) The powi{s,d}f2 tests are disabled because they don't compile on the thumb targets as we are missing some required intrinsics (e.g. aeabi_dmul
). And testing on the thumbv6m target is also disabled because of #150.
The test suite works like this:
For each intrinsic, we randomly generate an integration test file (tests/divdi3.rs
) that contains 10,000 (can be changed) different test cases (e.g. for addsf3
, 1.0 + 1.0
must equal 2.0
). Since the test cases are generated on a x86_64 host the expected results of the test cases are "ground truth" as they were obtained by computing the operation, that the intrinsic emulates, using hardware instructions.
Then we just run cargo test
/ cross test
/ xargo test
(utest
is supported out of the box) as appropriate.
While checking that this new test suite works, I found these issues: #145, #148 #150 and #151. Two of them affected std
targets and should have been caught by the current test suite but weren't. I think the new test suite found them because it does a better job at picking extreme values for the test cases.
Also, with this new test suite, we can test the ARM targets which we are ignoring in the current test suite as some unit tests return results, which are correct, but that don't match compiler-rt / gcc_s results, which are wrong / not as accurate. (cc @mattico)
I propose we move to this new test system as it has wider (target) coverage and doesn't rely on compiler-rt / gcc_s C code bases.
from compiler-builtins.
Sounds like a great idea to me!
from compiler-builtins.
Big 👍 from me. Having to deal with test failures due to gcc_s returning the wrong answer was extremely frustrating.
Are you planning to add the tester to this repo and have it generate test cases on each travis run, or to just use it as a generator and check-in some tests?
from compiler-builtins.
@mattico The former to avoid bloating the repository with giant test files.
compiler-rt does the later for its test suite; it contains these MBs big test file that tests all the possible combinations. We could tweak the test generator to produce exhaustive test suites as well.
from compiler-builtins.
How long would exhaustive tests take to run? Presumably it wouldn't be too bad if compiler-rt does it. We could have bors run the exhaustive tests, but just do small/random tests on PR commits.
from compiler-builtins.
@mattico So actually compiler-rt doesn't have exhaustive tests. Their biggest test, for the i128 division intrinsic, has about 2^16
test cases (the file is 16MB big 😆). I think we'd actually run out of memory for a really exhaustive test suite.
How long would exhaustive tests take to run?
From what I have seen, compiling the test files takes longer than running them, even within QEMU. IIRC, compilation time was already in tens of seconds but this is for all the test files / all the intrinsics.
from compiler-builtins.
Yeah, I wouldn't expect exhaustive tests for i128 😆. I'm just a bit concerned about tests randomly uncovering an old error in an unrelated PR just because those specific numbers haven't been tested before. It's probably not a huge issue in practice, though.
from compiler-builtins.
Related Issues (20)
- The "mangled-names" feature removes intrinsics from compiler_builtins that aren't in compiler_rt HOT 9
- AEABI division function linking problems (again) HOT 2
- duplicated intrinsic implementations linked into libstd HOT 4
- libm directory is missing from 0.1.97 crates.io release HOT 2
- wrong define of 128-bit related functions like `__multi3` and `__floatuntidf` on `csky` HOT 4
- The `USE_NATIVE_FULL_ITERATIONS` codepath in `div64` is broken
- Several functions perform out-of-bounds memory accesses (which is UB) HOT 16
- undefined reference to `memcpy`, undefined reference to `memset` HOT 1
- `__extenddftf2` is found to be missing at runtime when using the WASI SDK to build Rust crates' C code HOT 1
- Getting C-defined intrinsics into a project that uses the stable compiler doesn't work because of all the `#![feature]` checks HOT 2
- Unable to find long double symbols on `aarch64-apple-darwin` HOT 4
- Adding feature to port `libm` for any target HOT 3
- Unable to use static macOS libraries in Unreal Engine projects HOT 2
- Regression: build failure on i686-pc-windows-gnu due to multiple definition of `_alloca` HOT 15
- Undefined reference to __chkstk, __alloca when building target i686-unknown-uefi
- aarch64 windows build failure HOT 1
- `aarch64-linux` `multf3` symbol has incorrect rounding HOT 1
- Unable to `-Zbuild-std` because std depends on `compiler-builtins` without the `no-f16-f128` features HOT 4
- Rounding error in `__mulsf3` HOT 6
- Inconsistent truncation of -0.0 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compiler-builtins.