test source importing this crate
This commit is contained in:
parent
a5db661cb1
commit
f556a9bbb4
5 changed files with 30 additions and 2 deletions
|
|
@ -4,4 +4,4 @@ version = "0.1.0"
|
|||
authors = ["Jorge Aparicio <jorge@japaric.io>"]
|
||||
|
||||
[workspace]
|
||||
members = ["test-generator"]
|
||||
members = ["cb", "test-generator"]
|
||||
|
|
@ -32,7 +32,7 @@ $ TARGET=armv7-unknown-linux-gnueabihf bash ci/script.sh
|
|||
- Pick your favorite math function from the [issue tracker].
|
||||
- Look for the C implementation of the function in the [MUSL source code][src].
|
||||
- Copy paste the C code into a Rust file in the `src/math` directory and adjust `src/math/mod.rs`
|
||||
accordingly.
|
||||
accordingly. Also, uncomment the corresponding trait method in `src/lib.rs`.
|
||||
- Run `cargo watch check` and fix the compiler errors.
|
||||
- Tweak the bottom of `test-generator/src/main.rs` to add your function to the test suite.
|
||||
- If you can, run the test suite locally. If you can't, no problem! Your PR will be tested
|
||||
|
|
@ -49,6 +49,9 @@ Check [PR #2] for an example.
|
|||
|
||||
### Notes
|
||||
|
||||
- Only use relative imports within the `math` directory / module, e.g. `use self::fabs::fabs` or
|
||||
`use super::isnanf`. Absolute imports from core are OK, e.g. `use core::u64`.
|
||||
|
||||
- To reinterpret a float as an integer use the `to_bits` method. The MUSL code uses the
|
||||
`GET_FLOAT_WORD` macro, or a union, to do this operation.
|
||||
|
||||
|
|
|
|||
6
library/compiler-builtins/libm/cb/Cargo.toml
Normal file
6
library/compiler-builtins/libm/cb/Cargo.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "cb"
|
||||
version = "0.1.0"
|
||||
authors = ["Jorge Aparicio <jorge@japaric.io>"]
|
||||
|
||||
[dependencies]
|
||||
9
library/compiler-builtins/libm/cb/src/lib.rs
Normal file
9
library/compiler-builtins/libm/cb/src/lib.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
//! Fake compiler-builtins crate
|
||||
//!
|
||||
//! This is used to test that we can source import `libm` into the compiler-builtins crate.
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![no_std]
|
||||
|
||||
#[path = "../../src/math/mod.rs"]
|
||||
mod libm;
|
||||
|
|
@ -1,11 +1,21 @@
|
|||
set -euxo pipefail
|
||||
|
||||
main() {
|
||||
# quick check
|
||||
cargo check
|
||||
|
||||
# check that we can source import libm into compiler-builtins
|
||||
cargo check --package cb
|
||||
|
||||
# generate tests
|
||||
cargo run --package test-generator --target x86_64-unknown-linux-musl
|
||||
|
||||
if cargo fmt --version >/dev/null 2>&1; then
|
||||
# nicer syntax error messages (if any)
|
||||
cargo fmt
|
||||
fi
|
||||
|
||||
# run tests
|
||||
cross test --target $TARGET --release
|
||||
|
||||
# TODO need to fix overflow issues (cf. issue #4)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue