Skip to content

Commit 7265c11

Browse files
committed
README: fill in most of the remaining details (history, versioning).
1 parent 0728af5 commit 7265c11

File tree

1 file changed

+63
-3
lines changed

1 file changed

+63
-3
lines changed

README.md

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,68 @@
1-
# `rustc_apfloat` (Rust port of C++ `llvm::APFloat` library)
1+
# `rustc_apfloat`<br><sub>(Rust port of the C++ `llvm::APFloat` "softfloat" library)</sub>
2+
3+
## History
4+
5+
LLVM's `APFloat` (aka `llvm::APFloat`) software floating-point (or "softfloat")
6+
library was first ported to Rust (and named `rustc_apfloat`) back in 2017,
7+
in the Rust pull request [`rust-lang/rust#43554`](https://github.com/rust-lang/rust/pull/43554),
8+
as part of an effort to expand Rust compile-time capabilities without sacrificing
9+
determinism (and therefore soundness, if the type-system was involved).
10+
11+
<sub>Note: while using the original C++ `llvm::APFloat` directly would've been an option,
12+
certain high-level API design differences made in the Rust port, without behavioral impact
13+
(C++ raw pointers and dynamic allocations vs Rust generics, traits and `#![no_std]`),
14+
made the Rust port more appealing from a determinism standpoint (mostly thanks to
15+
lacking all 3 of: `unsafe` code, host floating-point use, `std` access - and only
16+
allocating to handle the arbitrary precision needed for conversions to/from decimal),
17+
*even though there was a chance it had correctness issues unique to it*.</sub>
18+
19+
However, that port had a fatal flaw: it was added to the `rust-lang/rust` repository
20+
without its unique licensing status (as a port of a C++ library with its own license)
21+
being properly tracked, communicated, taken into account, etc.
22+
The end result was years of limbo, mostly chronicled in the Rust issue
23+
[`rust-lang/rust#55993`](https://github.com/rust-lang/rust/issues/55993), in which
24+
the in-tree port couldn't really receive proper updated or even maintenance, due
25+
due to its unclear status.
26+
27+
### Revival (as `rust-lang/rustc_apfloat`)
28+
29+
This repository (`rust-lang/rustc_apfloat`) is the result of a 2022 plan on
30+
[the relevant Zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/231349-t-core.2Flicensing/topic/apfloat), fully put into motion during 2023:
31+
* the `git` history of the in-tree `compiler/rustc_apfloat` library was extracted
32+
(see the separate [`rustc_apfloat-git-history-extraction`](https://github.com/LykenSol/rustc_apfloat-git-history-extraction) repository for more details)
33+
* only commits that were *both* necessary *and* had clear copyright status, were kept
34+
* any missing functionality or bug fixes, would have to be either be re-contributed,
35+
or rebuilt from the ground up (mostly the latter ended up being done, see below)
36+
37+
Most changes since the original port had been aesthetic (e.g. spell-checking, `rustfmt`),
38+
so little was lost in the process.
39+
40+
Starting from that much smaller "trusted" base:
41+
* everything could use LLVM's new (since 2019) license, "`Apache-2.0 WITH LLVM-exception`"
42+
(see the ["Licensing"](#licensing) section below and/or [LICENSE-DETAILS.md](./LICENSE-DETAILS.md) for more details)
43+
* new facilities were built (benchmarks, and [a fuzzer comparing Rust/C++/hardware](#fuzzing))
44+
* excessive testing was performed (via a combination of fuzzing and bruteforce search)
45+
* latent bugs were discovered (e.g. LLVM issues
46+
[#63895](https://github.com/llvm/llvm-project/issues/63895) and
47+
[#63938](https://github.com/llvm/llvm-project/issues/63938))
48+
* the port has been forwarded in time, to include upstream (`llvm/llvm-project`) changes
49+
to `llvm::APFloat` over the years (since 2017), removing the need for selective backports
50+
51+
## Versioning
52+
53+
As this is, for the time being, a "living port", tracking upstream (`llvm/llvm-project`)
54+
`llvm::APFloat` changes, the `rustc_apfloat` crate will have versions of the form:
255

3-
## 🚧 Work In Progress 🚧
56+
```
57+
0.X.Y+llvm-ZZZZZZZZZZZZ
58+
```
59+
* `X` is always bumped after semver-incompatible API changes,
60+
or when updating the upstream (`llvm/llvm-project`) commit the port is based on
61+
* `Y` is only bumped when other parts of the version don't need to be (e.g. for bug fixes)
62+
* `+llvm-ZZZZZZZZZZZZ` is ["version metadata"](https://doc.rust-lang.org/cargo/reference/resolver.html#version-metadata) (which Cargo itself ignores),
63+
and `ZZZZZZZZZZZZ` always holds the first 12 hexadecimal digits of
64+
the upstream (`llvm/llvm-project`) `git` commit hash the port is based on
465

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.
666

767
## Testing
868

0 commit comments

Comments
 (0)