Skip to content

Commit

Permalink
Try building musl
Browse files Browse the repository at this point in the history
Add a way to run musl symbols

Mostly building

Musl works

Check for undef symbols

Update

Fix error with using relinked archives

More strict archive checks

Clean up warnings

More tests

Disable more warnings

Update build

Update build

Update build

Update syms

Update syms

More tests passing

More tests

Make libm-test a default crate

Remove unneeded files

Download musl in ci

Fix unresolved symbols

Don't fail fast

UNDO let cc link to get cmd output

panic with linker

Set linker

ld env

ld env

ld env

Update

More prefixes allowed

Add another ppc symbol

better test generation

Multiple dispatch working

Update macros

Add many more tests

Add sin

Try to test more targets

Update ci

Update build scripts

UPdate build

printenv in ci

Update ci

Update ci

Update ci

Update ci

Update ci

Update ci

Update ci

Update ci

Update ci

Update ci

try to fix windows defs

Redefine missing symbolsg

msvc flags

Try inf redefine

Disable on msvc

change aliases

change aliases

x86 symbols

Weak symbols on macos

Weak symbols on macos work!

Refactor traits

Clean up tuplecall

More calls!

frexp

More calls

More calls

Update tests. all passing!

Update tests
  • Loading branch information
tgross35 committed Oct 7, 2024
1 parent e5aa09c commit 9df91b3
Show file tree
Hide file tree
Showing 14 changed files with 1,781 additions and 32 deletions.
102 changes: 75 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,84 @@ env:
jobs:
docker:
name: Docker
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
target:
- aarch64-unknown-linux-gnu
- arm-unknown-linux-gnueabi
- arm-unknown-linux-gnueabihf
- armv7-unknown-linux-gnueabihf
# - i686-unknown-linux-gnu
# MIPS targets disabled since they are dropped to tier 3.
# See https://github.com/rust-lang/compiler-team/issues/648
#- mips-unknown-linux-gnu
#- mips64-unknown-linux-gnuabi64
#- mips64el-unknown-linux-gnuabi64
- powerpc-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
- powerpc64le-unknown-linux-gnu
- x86_64-unknown-linux-gnu
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: arm-unknown-linux-gnueabi
os: ubuntu-latest
- target: arm-unknown-linux-gnueabihf
os: ubuntu-latest
- target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
- target: i686-unknown-linux-gnu
os: ubuntu-latest
- target: powerpc-unknown-linux-gnu
os: ubuntu-latest
- target: powerpc64-unknown-linux-gnu
os: ubuntu-latest
- target: powerpc64le-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-13
# - target: i686-pc-windows-msvc
# os: windows-latest
# - target: x86_64-pc-windows-msvc
# os: windows-latest
- target: i686-pc-windows-gnu
os: windows-latest
- target: x86_64-pc-windows-gnu
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update nightly && rustup default nightly
- run: rustup target add ${{ matrix.target }}
- run: rustup target add x86_64-unknown-linux-musl
- run: cargo generate-lockfile
- run: ./ci/run-docker.sh ${{ matrix.target }}
- name: Print runner information
run: uname -a
- uses: actions/checkout@v4
- name: Install Rust (rustup)
shell: bash
run: |
rustup update nightly --no-self-update
rustup default nightly
rustup target add ${{ matrix.target }}
rustup component add llvm-tools-preview
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}

- name: Download musl source
run: ./ci/download-musl.sh
shell: bash

# Non-linux tests just use our raw script
- name: Run tests locally
run: ./ci/run.sh ${{ matrix.target }}
if: matrix.os != 'ubuntu-latest'
shell: bash

# Otherwise we use our docker containers to run builds
- name: Run in Docker
if: matrix.os == 'ubuntu-latest'
run: |
rustup target add x86_64-unknown-linux-musl
cargo generate-lockfile && ./ci/run-docker.sh ${{ matrix.target }}
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
run: |
rustup update stable --no-self-update
rustup default stable
rustup component add rustfmt
- run: cargo fmt -- --check

wasm:
Expand All @@ -50,8 +94,10 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update nightly && rustup default nightly
run: rustup update nightly --no-self-update && rustup default nightly
- run: rustup target add wasm32-unknown-unknown
- name: Download MUSL source
run: ./ci/download-musl.sh
- run: cargo build --target wasm32-unknown-unknown

cb:
Expand All @@ -60,7 +106,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update nightly && rustup default nightly
run: rustup update nightly --no-self-update && rustup default nightly
- run: cargo build -p cb

benchmarks:
Expand All @@ -69,7 +115,9 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update nightly && rustup default nightly
run: rustup update nightly --no-self-update && rustup default nightly
- name: Download MUSL source
run: ./ci/download-musl.sh
- run: cargo bench --all

success:
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
**/*.rs.bk
**.bk
.#*
/bin
/math/src
/math/target
/target
/tests
Cargo.lock
musl/
**.tar.gz
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ members = [
"crates/compiler-builtins-smoke-test",
"crates/libm-bench",
"crates/libm-test",
"crates/musl-math-sys",
]
default-members = [
".",
Expand Down
25 changes: 25 additions & 0 deletions ci/download-musl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

set -eux

fname=musl-1.2.5.tar.gz
sha=a9a118bbe84d8764da0ea0d28b3ab3fae8477fc7e4085d90102b8596fc7c75e4

mkdir musl
curl "https://musl.libc.org/releases/$fname" -O

echo "$(uname -s)"

case "$(uname -s)" in
MINGW*)
# Need to extract the second line because certutil does human output
fsha=$(certutil -hashfile "$fname" SHA256 | sed -n '2p')
[ "$sha" = "$fsha" ] || exit 1
;;
*)
echo "$sha $fname" | shasum -a 256 --check || exit 1
;;
esac

tar -xzf "$fname" -C musl --strip-components 1
rm "$fname"
8 changes: 5 additions & 3 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ $cmd --release
$cmd --features 'unstable'
$cmd --release --features 'unstable'

# also run the reference tests
$cmd --features 'unstable libm-test/musl-bitwise-tests'
$cmd --release --features 'unstable libm-test/musl-bitwise-tests'
if [ "$(uname -a)" = "Linux" ]; then
# also run the reference tests
$cmd --features 'unstable libm-test/musl-bitwise-tests'
$cmd --release --features 'unstable libm-test/musl-bitwise-tests'
fi
8 changes: 8 additions & 0 deletions crates/libm-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,13 @@ musl-bitwise-tests = ["rand"]
[dependencies]
libm = { path = "../.." }

# We can't build musl on MSVC
[target.'cfg(not(target_env = "msvc"))'.dependencies]
musl-math-sys = { path = "../musl-math-sys" }

[dev-dependencies]
rand = "0.8.5"
rand_chacha = "0.3.1"

[build-dependencies]
rand = { version = "0.8.5", optional = true }
44 changes: 44 additions & 0 deletions crates/libm-test/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,52 @@
use std::fmt::Write;
use std::path::PathBuf;
use std::{env, fs};

fn main() {
list_all_tests();
emit_optimization_cfg();

#[cfg(feature = "musl-bitwise-tests")]
musl_reference_tests::generate();
}

/// Some tests are extremely slow. Emit a config option to
fn emit_optimization_cfg() {
println!("cargo::rustc-check-cfg=cfg(optimizations_enabled)");

let opt_level: u8 = env::var("OPT_LEVEL").unwrap().parse().unwrap();
if opt_level >= 2 {
println!("cargo::rustc-cfg=optimizations_enabled");
}
}

fn list_all_tests() {
let root_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let math_src = root_dir.join("../../src/math");

let mut files = fs::read_dir(math_src)
.unwrap()
.map(|f| f.unwrap().path())
.filter(|entry| entry.is_file())
.map(|f| f.file_stem().unwrap().to_str().unwrap().to_owned())
.collect::<Vec<_>>();
files.sort();

let mut s = "pub const MATH_FILES: &[&str] = &[".to_owned();
for f in files {
if f == "mod" {
// skip mod.rs
continue;
}
write!(s, "\"{f}\",").unwrap();
}
write!(s, "];").unwrap();

let outfile = out_dir.join("all_files.rs");
fs::write(outfile, s).unwrap();
}

#[cfg(feature = "musl-bitwise-tests")]
mod musl_reference_tests {
use rand::seq::SliceRandom;
Expand Down
Loading

0 comments on commit 9df91b3

Please sign in to comment.