about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2025-01-27 23:25:00 +0000
committerTrevor Gross <t.gross35@gmail.com>2025-01-28 00:39:45 -0600
commit259e544192999988c2ad7e4264e650c0db0524ce (patch)
tree0251d87389f09cafecfc617ac373255f07606bc8
parent98fd72b62a788772a3939f35ef340fc4a6a16174 (diff)
downloadrust-259e544192999988c2ad7e4264e650c0db0524ce.tar.gz
rust-259e544192999988c2ad7e4264e650c0db0524ce.zip
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.
-rw-r--r--library/compiler-builtins/libm/.github/workflows/main.yaml18
-rw-r--r--library/compiler-builtins/libm/.gitignore1
-rw-r--r--library/compiler-builtins/libm/.gitmodules4
-rw-r--r--library/compiler-builtins/libm/CONTRIBUTING.md4
-rwxr-xr-xlibrary/compiler-builtins/libm/ci/download-musl.sh24
-rw-r--r--library/compiler-builtins/libm/crates/musl-math-sys/build.rs14
m---------library/compiler-builtins/libm/crates/musl-math-sys/musl0
7 files changed, 19 insertions, 46 deletions
diff --git a/library/compiler-builtins/libm/.github/workflows/main.yaml b/library/compiler-builtins/libm/.github/workflows/main.yaml
index 59955271170..e03d7ecd319 100644
--- a/library/compiler-builtins/libm/.github/workflows/main.yaml
+++ b/library/compiler-builtins/libm/.github/workflows/main.yaml
@@ -79,6 +79,8 @@ jobs:
     - name: Print runner information
       run: uname -a
     - uses: actions/checkout@v4
+      with:
+        submodules: true
     - name: Install Rust (rustup)
       shell: bash
       run: |
@@ -94,10 +96,6 @@ jobs:
       with:
         key: ${{ matrix.target }}
 
-    - name: Download musl source
-      run: ./ci/download-musl.sh
-      shell: bash
-
     - name: Verify API list
       if: matrix.os == 'ubuntu-24.04'
       run: python3 etc/update-api-list.py --check
@@ -126,14 +124,14 @@ jobs:
     timeout-minutes: 10
     steps:
     - uses: actions/checkout@master
+      with:
+        submodules: true
     - name: Install Rust
       run: |
         rustup update nightly --no-self-update
         rustup default nightly
         rustup component add clippy
     - uses: Swatinem/rust-cache@v2
-    - name: Download musl source
-      run: ./ci/download-musl.sh
     - run: cargo clippy --all --all-features --all-targets
 
   builtins:
@@ -153,6 +151,8 @@ jobs:
     timeout-minutes: 20
     steps:
     - uses: actions/checkout@master
+      with:
+        submodules: true
     - uses: taiki-e/install-action@cargo-binstall
 
     - name: Set up dependencies
@@ -166,8 +166,6 @@ jobs:
         sudo apt-get install valgrind
 
     - uses: Swatinem/rust-cache@v2
-    - name: Download musl source
-      run: ./ci/download-musl.sh
 
     - name: Run icount benchmarks
       env:
@@ -259,13 +257,13 @@ jobs:
       CHANGED: ${{ matrix.changed }}
     steps:
       - uses: actions/checkout@v4
+        with:
+          submodules: true
       - name: Install Rust
         run: |
           rustup update nightly --no-self-update
           rustup default nightly
       - uses: Swatinem/rust-cache@v2
-      - name: Download musl source
-        run: ./ci/download-musl.sh
       - name: Run extensive tests
         run: |
           echo "Changed: '$CHANGED'"
diff --git a/library/compiler-builtins/libm/.gitignore b/library/compiler-builtins/libm/.gitignore
index a447c34cd0f..d5caba1a0f3 100644
--- a/library/compiler-builtins/libm/.gitignore
+++ b/library/compiler-builtins/libm/.gitignore
@@ -4,7 +4,6 @@
 /math/src
 target
 Cargo.lock
-musl/
 **.tar.gz
 
 # Benchmark cache
diff --git a/library/compiler-builtins/libm/.gitmodules b/library/compiler-builtins/libm/.gitmodules
new file mode 100644
index 00000000000..35b269eadd4
--- /dev/null
+++ b/library/compiler-builtins/libm/.gitmodules
@@ -0,0 +1,4 @@
+[submodule "musl"]
+	path = crates/musl-math-sys/musl
+	url = https://git.musl-libc.org/git/musl
+	shallow = true
diff --git a/library/compiler-builtins/libm/CONTRIBUTING.md b/library/compiler-builtins/libm/CONTRIBUTING.md
index ba7f78ca014..dc40060357c 100644
--- a/library/compiler-builtins/libm/CONTRIBUTING.md
+++ b/library/compiler-builtins/libm/CONTRIBUTING.md
@@ -62,6 +62,10 @@ Check [PR #65] for an example.
 Normal tests can be executed with:
 
 ```sh
+# Tests against musl require that the submodule is up to date.
+git submodule init
+git submodule update
+
 # `--release` ables more test cases
 cargo test --release
 ```
diff --git a/library/compiler-builtins/libm/ci/download-musl.sh b/library/compiler-builtins/libm/ci/download-musl.sh
deleted file mode 100755
index 8a8c58550bb..00000000000
--- a/library/compiler-builtins/libm/ci/download-musl.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-# Download the expected version of musl to a directory `musl`
-
-set -eux
-
-fname=musl-1.2.5.tar.gz
-sha=a9a118bbe84d8764da0ea0d28b3ab3fae8477fc7e4085d90102b8596fc7c75e4
-
-mkdir musl
-curl -L "https://musl.libc.org/releases/$fname" -O --retry 5
-
-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"
diff --git a/library/compiler-builtins/libm/crates/musl-math-sys/build.rs b/library/compiler-builtins/libm/crates/musl-math-sys/build.rs
index d75748159ca..f06d84ee267 100644
--- a/library/compiler-builtins/libm/crates/musl-math-sys/build.rs
+++ b/library/compiler-builtins/libm/crates/musl-math-sys/build.rs
@@ -79,17 +79,12 @@ impl Config {
         let target_features = env::var("CARGO_CFG_TARGET_FEATURE")
             .map(|feats| feats.split(',').map(ToOwned::to_owned).collect())
             .unwrap_or_default();
-
-        // Default to the `{workspace_root}/musl` if not specified
-        let musl_dir = env::var("MUSL_SOURCE_DIR")
-            .map(PathBuf::from)
-            .unwrap_or_else(|_| manifest_dir.parent().unwrap().parent().unwrap().join("musl"));
+        let musl_dir = manifest_dir.join("musl");
 
         let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
         let musl_arch = if target_arch == "x86" { "i386".to_owned() } else { target_arch.clone() };
 
         println!("cargo::rerun-if-changed={}/c_patches", manifest_dir.display());
-        println!("cargo::rerun-if-env-changed=MUSL_SOURCE_DIR");
         println!("cargo::rerun-if-changed={}", musl_dir.display());
 
         Self {
@@ -111,13 +106,10 @@ impl Config {
 /// Build musl math symbols to a static library
 fn build_musl_math(cfg: &Config) {
     let musl_dir = &cfg.musl_dir;
-    assert!(
-        musl_dir.exists(),
-        "musl source is missing. it can be downloaded with ./ci/download-musl.sh"
-    );
-
     let math = musl_dir.join("src/math");
     let arch_dir = musl_dir.join("arch").join(&cfg.musl_arch);
+    assert!(math.exists(), "musl source not found. Is the submodule up to date?");
+
     let source_map = find_math_source(&math, cfg);
     let out_path = cfg.out_dir.join(format!("lib{LIB_NAME}.a"));
 
diff --git a/library/compiler-builtins/libm/crates/musl-math-sys/musl b/library/compiler-builtins/libm/crates/musl-math-sys/musl
new file mode 160000
+Subproject 0784374d561435f7c787a555aeab8ede699ed29