Skip to content

Commit de8779b

Browse files
committed
🚧 WIP: provisional README 🚧
1 parent 95ea7b2 commit de8779b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

‎README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# `rustc_apfloat` (Rust port of C++ `llvm::APFloat` library)
2+
3+
## 🚧 Work In Progress 🚧
4+
5+
**NOTE**: the repo (and [`rustc_apfloat-git-history-extraction`](https://github.com/LykenSol/rustc_apfloat-git-history-extraction)) might be public already, but only for convenience of discussion, see [relevant Zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/231349-t-core.2Flicensing/topic/apfloat) for more details.
6+
7+
## Testing
8+
9+
`rustc_apfloat` contains ports of all the tests from the C++ `llvm::APFloat` code,
10+
in `tests/ieee.rs` and `tests/ppc.rs`.
11+
12+
For tests specific to `rustc_apfloat` (without C++ equivalents), `tests/downstream.rs`
13+
is used (which mainly contains tests for now-fixed bugs, found by fuzzing).
14+
15+
### Fuzzing
16+
17+
As `llvm::APFloat` tests are far from comprehensive, the only option for in-depth
18+
comparisons between the original C++ code and the Rust port (and between them and
19+
hardware floating-point behavior) is to employ *fuzzing*.
20+
21+
The fuzzing infrastructure lives in `fuzz/` and requires `cargo-afl`, but also
22+
involves an automated build of the original C++ `llvm::APFloat` code with `clang`
23+
(to be able to instrument it via LLVM, in the same way `cargo-afl` does for the
24+
Rust code), and has been prototyped and tested on Linux (and is unlikely to work
25+
on other platforms, or even some Linux distros, though it mostly assumes UNIX).
26+
27+
Example usage:
28+
<sub>(**TODO**: maybe move this to `fuzz/README.md` and/or expand on it)</sub>
29+
30+
```sh
31+
# Install `cargo-afl` (used below to build/run the fuzzing binary).
32+
cargo install afl
33+
34+
# Build the fuzzing binary (`target/release/rustc_apfloat-fuzz`).
35+
cargo afl build -p rustc_apfloat-fuzz --release
36+
37+
# Seed the inputs for a run `foo` (while not ideal, even this one minimal input works).
38+
mkdir fuzz/in-foo && echo > fuzz/in-foo/empty
39+
40+
# Start the fuzzing run `foo`, which should bring up the AFL++ progress TUI
41+
# (see also `cargo run -p rustc_apfloat-fuzz` for extra flags available).
42+
cargo afl fuzz -i fuzz/in-foo -o fuzz/out-foo target/release/rustc_apfloat-fuzz
43+
```
44+
45+
To visualize the fuzzing testcases, you can use the `decode` subcommand:
46+
```sh
47+
cargo run -p rustc_apfloat-fuzz decode fuzz/out-foo/default/crashes/*
48+
```
49+
(this will work even while `cargo afl fuzz`, i.e. AFL++, is running)

0 commit comments

Comments
 (0)