Commit Graph

2049 Commits

Author SHA1 Message Date
Trevor Gross
128e572054 Add a helper for cached test inputs
Add a type that caches values used to implement `GenerateInput` on a
variety of signatures.
2024-10-28 12:59:38 -05:00
Trevor Gross
d45f6f6fad Add traits for testing
These traits give us a more generic way to interface with tuples used
for (1) test input, (2) function arguments, and (3) test input.
2024-10-28 12:59:38 -05:00
Trevor Gross
8be6ef1e0a Add numeric traits
These traits are simplified versions of what we have in
`compiler_builtins` and will be used for tests.
2024-10-28 12:59:38 -05:00
Trevor Gross
05c9691f15 Add a test that for_each_fn correctly lists all functions
Create a new test that checks `for_each_fn` against `ALL_FUNCTIONS`,
i.e. the manually entered function list against the automatically
collected list. If any are missing (e.g. new symbol added), then this
will produce an error.
2024-10-28 12:59:38 -05:00
Trevor Gross
0acb3e2b50 Collect all function names to an array
Use a build script for `libm-test` to enumerate all symbols provided by
`libm` and provide this list in a variable. This will allow us to make
sure no functions are missed anytime they must be manually listed.

Additionally, introduce some helper config options.
2024-10-28 12:59:38 -05:00
Trevor Gross
56deb13bd4 Add a procedural macro for expanding all function signatures
Introduce `libm_test::for_each_function`. which macro takes a callback
macro and invokes it once per function signature. This provides an
easier way of registering various tests and benchmarks without
duplicating the function names and signatures each time.
2024-10-28 12:59:38 -05:00
Trevor Gross
5fc3068762 Add a script for downloading musl 2024-10-28 12:59:38 -05:00
Trevor Gross
36b52c7d1b Introduce musl-math-sys for bindings to musl math symbols
This crate builds math symbols from a musl checkout and provides a Rust
interface. The intent is that we will be able to compare our
implementations against musl on more than just linux (which are the only
currently the only targets we run `*-musl` targets against for
comparison).

Musl libc can't compile on anything other than Linux; however, the
routines in `src/math` are cross platform enough to build on MacOS and
windows-gnu with only minor adjustments. We take advantage of this and
build only needed files using `cc`.

The build script also performs remapping (via defines) so that e.g.
`cos` gets defined as `musl_cos`. This gives us more certainty that we
are actually testing against the intended symbol; without it, it is easy
to unknowingly link to system libraries or even Rust's `libm` itself and
wind up with an ineffective test. There is also a small procedure to
verify remapping worked correctly by checking symbols in object files.
2024-10-28 12:59:38 -05:00
quaternic
750027cbbe fix type of constants in ported sincosf (#331)
* fix type of constants in ported sincosf
2024-10-28 12:59:21 -05:00
Johanna Sörngård
db55857a73 Add basic docstrings to some functions (#337)
* Add docstring to Bessel functions
* Add docstrings to logarithm functions
* Add docstrings to pow functions
* Specify argument bit-size of the Bessel functions
* Specify argument bit-size for pow functions
* Specify argument bit-size for logarithms
* Add docstrings to sin, cos, sincos and sinh functions
* Add docstrings to sqrt
* Add docstrings to tan and tanh functions
* Add an inline link to https://en.wikipedia.org/wiki/Bessel_function to the docstrings of all Bessel functions.
2024-10-28 12:12:45 -05:00
Trevor Gross
a3fd7732f0 ci: rustup --no-self-update and reuqire MSRV checks
Pass `--no-self-update` to `rustup`, which is typical for CI. Also add
the MSRV job to `success` so GitHub won't merge without it passing.
2024-10-27 23:41:29 -05:00
Trevor Gross
b49ef8c510 Don't deny warnings when checking MSRV
1.63 reports some false positive lints that we don't need to worry
about. Make sure we don't fail CI for this.
2024-10-27 23:28:24 -05:00
github-actions[bot]
476585d6a0 chore: release v0.2.10 2024-10-27 22:51:02 -05:00
Trevor Gross
3541e834df Set the MSRV to 1.63 and document it as such
Fixes: https://github.com/rust-lang/libm/issues/330
2024-10-27 22:47:06 -05:00
Trevor Gross
3180b04aa3 Change build.rs to use the older : rather than ::
This allows supporting Rust < 1.77.
2024-10-27 22:46:17 -05:00
Trevor Gross
4d6aeca6b3 Add a CI test that the crate builds on stable
Currently everything we have runs with nightly Rust. Add a stable test
to make sure we don't accidentally make use of behavior that isn't yet
stable without gating it.
2024-10-27 01:10:26 -05:00
Trevor Gross
79f065ab24 Add a .git-blame-ignore-revs file
Include the recent formatting commit.
2024-10-26 20:30:41 -05:00
Trevor Gross
ab0c8e84fb Run cargo fmt with new settings
Apply the changes from the `.rustfmt.toml` file added in the previous
commit.
2024-10-26 20:28:28 -05:00
Trevor Gross
710ca6e38e Add a rustfmt.toml file matching rust-lang/rust
Duplicate the settings from rust-lang/rust to this repository. This is
mostly for consistency, but `use_small_heuristics = "Max"` does make a
large difference with lookup tables.

Also apply the needed CI changes to run nightly rustfmt.
2024-10-26 20:28:28 -05:00
github-actions[bot]
f9914e98b3 chore: release v0.1.136 2024-10-26 23:29:14 +00:00
Trevor Gross
01a2a13a01 Update the libm submodule 2024-10-26 18:22:14 -05:00
github-actions[bot]
4f3418a4d7 chore: release v0.2.9 2024-10-26 18:10:21 -05:00
Trevor Gross
0433caa0ba Fix release-plz workflow configuration 2024-10-26 18:01:56 -05:00
Trevor Gross
47961340db Add release-plz for automated releases 2024-10-26 17:58:38 -05:00
Trevor Gross
6399bed36c Update licensing to MIT AND Apache-2.0 WITH LLVM-exception
Currently, Cargo.toml specifies Apache-2.0 OR MIT, but LICENSE.txt
describes MIT OR NCSA. compiler-builtins is derived from LLVM's
compiler-rt. LICENSE.txt correctly reflects the state of compiler-rt
prior to relicensing on 2019-01-19, during which time software was
available for use under either MIT or the University of Illinois NCSA
license. After relicensing, however, compiler-rt is available for use
only under Apache-2.0 with the LLVM exception; this is not reflected
anywhere in the repository.

Update the SPDX license identifier to `MIT AND Apache-2.0 WITH
LLVM-exception AND (MIT OR Apache-2.0)`. Each AND portion covers
something specific:

* Apache-2.0 WITH LLVM-exception: this covers work that is derived from
  the LLVM repository since after the LLVM relicensing.
* MIT: This covers work that is derived from LLVM before the LLVM
  relicensing (under MIT OR NCSA), as well as the vendored `libm`
  components.
* MIT AND Apache-2.0: This ensures that any contributions to this
  repository, in addition to meeting the above required licenses, is
  also released for use under the Rust-standard Apache-2.0 with no LLVM
  exception.

See also the parallel license update in rust-lang/libm [1].

Fixes: https://github.com/rust-lang/compiler-builtins/issues/307
Closes: https://github.com/rust-lang/compiler-builtins/pull/511
Link: https://rust-lang.zulipchat.com/#narrow/channel/335408-foundation/topic/Request.20for.20legal.20team.20input.20on.20crate.20licensing
Link: https://github.com/rust-lang/libm/pull/317 [1]
2024-10-26 17:35:26 -05:00
Trevor Gross
bd82e67afc Update licensing to MIT AND (MIT OR Apache-2.0)
Currently both Cargo.toml and the license files indicate that this
library may be used under either MIT or Apache-2.0. However, this is not
accurate; since portions of this library were derived from musl libc,
which is available under the MIT license, this terms of use for this
library must also include use under the MIT license. That is, it is not
correct that this library may be used under only the Apache-2.0 license.

Update the SPDX license identifier to `MIT OR (MIT AND Apache-2.0)` to
indicate that use must include the MIT license, but to clarify that
contributions are made under `MIT OR Apache-2.0`. This is compatible
with the current state of this repository since it has always contained
both license files, and the `Cargo.toml` license field has indicated
`MIT OR Apache-2.0` since it was added.

In accordance with the above, replace the two license files with a
combined LICENSE.txt that makes these terms clear and gives attribution
to works from which this library is derived.

Fixes: https://github.com/rust-lang/libm/issues/215
Link: https://rust-lang.zulipchat.com/#narrow/channel/335408-foundation/topic/Request.20for.20legal.20team.20input.20on.20crate.20licensing
Link: https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
2024-10-26 17:09:57 -05:00
Trevor Gross
79bf4fe1f2 Don't deny warnings in lib.rs
Having `#![deny(warnings)]` for the entire crate is a bit of a
development annoyance. We already run CI with `RUSTFLAGS=-Dwarnings` so
there isn't much of a reason to check this locally. Thus, remove the
attribute.

Additionally, sort the clippy allows.
2024-10-26 00:54:26 -05:00
Trevor Gross
a68516ed6a Rename the musl-bitwise-tests feature to test-musl-serialized
We will have more test features in the near future, and it would be nice
for them all to have a common `test-` prefix. Reverse the existing
feature so this is the case.
2024-10-25 20:57:19 -04:00
Trevor Gross
394fb9f2bc Add an abs function to the Float trait
There is no in-crate use for this yet, but we will make use of it in
`libm`.
2024-10-25 14:30:03 -05:00
Trevor Gross
2f7fafd182 Rename Float::repr and Float::from_repr
`to_bits` and `from_bits` are builtin methods on float types. Rename
`repr` to `to_bits` and `from_repr` to `from_bits` so this is consistent
with usage that doesn't go through the trait.
2024-10-25 14:18:53 -05:00
github-actions[bot]
ce89a70ae4 chore: release v0.1.135 2024-10-23 09:57:03 +00:00
Niklas Sombert
68b820187b Re-enable math module on i686-unknown-uefi
In 9ba77d1583e6de5ab9cf7c9b82827ba8fcb9062f, this was disabled for x86
without sse2. It should be fine to re-enable it for UEFI, as explained at
<https://github.com/rust-lang/rust/issues/128533#issuecomment-2408699671>.
2024-10-23 11:39:33 +02:00
github-actions[bot]
3e922da156 chore: release v0.1.134 2024-10-17 23:55:25 +00:00
Ben Kimock
2a738c50ab Use wrapping pointer arithmetic in mem/impls.rs
Add a comment (and fix a typo)
2024-10-16 22:37:42 -04:00
Trevor Gross
d3943b1863 Set edition to 2021 for all crates 2024-10-07 00:22:14 -05:00
Trevor Gross
d82eb88722 Fix shellcheck warnings in scripts 2024-10-06 13:44:25 -05:00
Trevor Gross
d0f1dd6010 Set target-specific AR and CC arguments
The Rust `cc` crate reads these, so make sure they are set for when we
start making use of `cc`.
2024-10-06 00:18:00 -05:00
Trevor Gross
0be441d5ad Update Ubuntu images to 24.04
We don't have any specific reason to stay on 18.04, so upgrade to the
latest LTS version.
2024-10-06 00:10:12 -05:00
Trevor Gross
d8c234b959 Do library updates necessary with dependency upgrades 2024-10-05 22:28:38 -05:00
Trevor Gross
cb305df194 Upgrade all dependencies
None of these affect the distributed library.
2024-10-05 22:24:14 -05:00
Trevor Gross
c236051681 Rename the musl-reference-tests feature to musl-bitwise-tests
The plan is to add more test related features that could be considered
"reference tests". Rename the feature here to avoid future confusion.
2024-10-05 21:42:28 -05:00
github-actions[bot]
fedfc6aaab chore: release 2024-10-06 02:08:00 +00:00
Trevor Gross
996799a896 Add a note about avoiding default implemenations in some places
Link: https://github.com/rust-lang/compiler-builtins/pull/707
2024-10-05 20:55:47 -05:00
Enzo "raskyld" Nocera
8153729f91 fix(int): avoid infinite recursion on left shift
Please, see this discussion for the full
context: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.5Bwasm32.5D.20Infinite.20recursion.20.60compiler-builtins.60.20.60__multi3.60

Signed-off-by: Enzo "raskyld" Nocera <enzo@nocera.eu>

We determined that some recursion problems on SPARC and WASM were due to
infinite recusion. This was introduced at 9c6fcb56e8 ("Split Int into
Int and MinInt") when moving the implementation of `widen_hi` from
something on each `impl` block to a default on the trait. The reasoning
is not fully understood, but undoing this portion of the change seems to
resolve the issue.

[ add the above context - Trevor ]

Signed-off-by: Trevor Gross <tmgross@umich.edu>
2024-10-05 20:49:45 -05:00
Trevor Gross
f59dd82cca Move musl-reference-tests to a new libm-test crate
There isn't any reason for this feature to be exposed or part of the
build script. Move it to a separate crate.

We will also want more tests that require some support functions; this
will create a place for them.
2024-10-05 15:54:39 -05:00
github-actions[bot]
3edc27ef56 chore: release 2024-10-04 17:17:03 +00:00
Alan Wu
3f70601e3c Allow implicit function decl on A64
Testing in <https://github.com/rust-lang/rust/pull/131221>, we found
that <https://github.com/rust-lang/compiler-builtins/pull/627> is
unusable with the current LLVM version.
2024-10-04 12:33:16 -04:00
Trevor Gross
76580a96a7 Upgrade CI LLVM version to 19.1
19.1 is the latest stable release from 2024-09-17. This will match what
is currently being used in rust-lang/rust.
2024-10-03 11:49:45 -04:00
github-actions[bot]
859e22b4ae chore: release 2024-10-03 15:37:33 +00:00
Alan Wu
edc6f80dcc Build with -Werror=implicit-function-declaration
To prevent fail-fast in situations like
https://github.com/rust-lang/rust/issues/125619, where an upstream
source compiles but creates a link error way downstream.
2024-10-03 11:24:49 -04:00