Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 20a0340

Browse files
committed
Switch musl from a script download to a submodule
Rather than keeping a script that downloads the tarball, we can just add musl as a submodule and let git handle the synchronizatoin. Do so here.
1 parent 9c2b157 commit 20a0340

File tree

7 files changed

+20
-46
lines changed

7 files changed

+20
-46
lines changed

libm/.github/workflows/main.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ jobs:
7979
- name: Print runner information
8080
run: uname -a
8181
- uses: actions/checkout@v4
82+
with:
83+
submodules: true
8284
- name: Install Rust (rustup)
8385
shell: bash
8486
run: |
@@ -94,10 +96,6 @@ jobs:
9496
with:
9597
key: ${{ matrix.target }}
9698

97-
- name: Download musl source
98-
run: ./ci/download-musl.sh
99-
shell: bash
100-
10199
- name: Verify API list
102100
if: matrix.os == 'ubuntu-24.04'
103101
run: python3 etc/update-api-list.py --check
@@ -126,14 +124,14 @@ jobs:
126124
timeout-minutes: 10
127125
steps:
128126
- uses: actions/checkout@master
127+
with:
128+
submodules: true
129129
- name: Install Rust
130130
run: |
131131
rustup update nightly --no-self-update
132132
rustup default nightly
133133
rustup component add clippy
134134
- uses: Swatinem/rust-cache@v2
135-
- name: Download musl source
136-
run: ./ci/download-musl.sh
137135
- run: cargo clippy --all --all-features --all-targets
138136

139137
builtins:
@@ -153,6 +151,8 @@ jobs:
153151
timeout-minutes: 20
154152
steps:
155153
- uses: actions/checkout@master
154+
with:
155+
submodules: true
156156
- uses: taiki-e/install-action@cargo-binstall
157157

158158
- name: Set up dependencies
@@ -166,8 +166,6 @@ jobs:
166166
sudo apt-get install valgrind
167167
168168
- uses: Swatinem/rust-cache@v2
169-
- name: Download musl source
170-
run: ./ci/download-musl.sh
171169

172170
- name: Run icount benchmarks
173171
env:
@@ -259,13 +257,13 @@ jobs:
259257
CHANGED: ${{ matrix.changed }}
260258
steps:
261259
- uses: actions/checkout@v4
260+
with:
261+
submodules: true
262262
- name: Install Rust
263263
run: |
264264
rustup update nightly --no-self-update
265265
rustup default nightly
266266
- uses: Swatinem/rust-cache@v2
267-
- name: Download musl source
268-
run: ./ci/download-musl.sh
269267
- name: Run extensive tests
270268
run: |
271269
echo "Changed: '$CHANGED'"

libm/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
/math/src
55
target
66
Cargo.lock
7-
musl/
87
**.tar.gz
98

109
# Benchmark cache

libm/.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "musl"]
2+
path = crates/musl-math-sys/musl
3+
url = https://git.musl-libc.org/git/musl
4+
shallow = true

libm/CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ Check [PR #65] for an example.
6262
Normal tests can be executed with:
6363

6464
```sh
65+
# Tests against musl require that the submodule is up to date.
66+
git submodule init
67+
git submodule update
68+
6569
# `--release` ables more test cases
6670
cargo test --release
6771
```

libm/ci/download-musl.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

libm/crates/musl-math-sys/build.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,12 @@ impl Config {
7979
let target_features = env::var("CARGO_CFG_TARGET_FEATURE")
8080
.map(|feats| feats.split(',').map(ToOwned::to_owned).collect())
8181
.unwrap_or_default();
82-
83-
// Default to the `{workspace_root}/musl` if not specified
84-
let musl_dir = env::var("MUSL_SOURCE_DIR")
85-
.map(PathBuf::from)
86-
.unwrap_or_else(|_| manifest_dir.parent().unwrap().parent().unwrap().join("musl"));
82+
let musl_dir = manifest_dir.join("musl");
8783

8884
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
8985
let musl_arch = if target_arch == "x86" { "i386".to_owned() } else { target_arch.clone() };
9086

9187
println!("cargo::rerun-if-changed={}/c_patches", manifest_dir.display());
92-
println!("cargo::rerun-if-env-changed=MUSL_SOURCE_DIR");
9388
println!("cargo::rerun-if-changed={}", musl_dir.display());
9489

9590
Self {
@@ -111,13 +106,10 @@ impl Config {
111106
/// Build musl math symbols to a static library
112107
fn build_musl_math(cfg: &Config) {
113108
let musl_dir = &cfg.musl_dir;
114-
assert!(
115-
musl_dir.exists(),
116-
"musl source is missing. it can be downloaded with ./ci/download-musl.sh"
117-
);
118-
119109
let math = musl_dir.join("src/math");
120110
let arch_dir = musl_dir.join("arch").join(&cfg.musl_arch);
111+
assert!(math.exists(), "musl source not found. Is the submodule up to date?");
112+
121113
let source_map = find_math_source(&math, cfg);
122114
let out_path = cfg.out_dir.join(format!("lib{LIB_NAME}.a"));
123115

libm/crates/musl-math-sys/musl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 0784374d561435f7c787a555aeab8ede699ed298

0 commit comments

Comments
 (0)