Repository: taiki-e/cargo-hack (language: rust)

Issue:
FreeBSD build failed with libc 0.2.138
[The last successful build](https://github.com/taiki-e/cargo-hack/actions/runs/3606337800/jobs/6077577961) used libc 0.2.137 and all failed build used libc 0.2.138, so probably related to the 0.2.137 -> 0.2.138 update.

https://github.com/taiki-e/cargo-hack/actions/runs/3608985912/jobs/6081906097

```
error: linking with `x86_64-unknown-freebsd12-gcc` failed: exit status: 1
  |
  = note: "x86_64-unknown-freebsd12-gcc" "-m64" "/tmp/rustcVB3IQA/symbols.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.0.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.1.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.10.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.11.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.12.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.13.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.14.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.15.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.2.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.3.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.4.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.5.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.6.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.7.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.8.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.cargo_hack.2318d226-cgu.9.rcgu.o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547.591caykrjgsvxhd7.rcgu.o" "-Wl,--as-needed" "-L" "/target/x86_64-unknown-freebsd/debug/deps" "-L" "/target/debug/deps" "-L" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib" "-Wl,-Bstatic" "/target/x86_64-unknown-freebsd/debug/deps/libctrlc-51998d80f6a72864.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libnix-18ba575260dfad93.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libcfg_if-e38878cf087dac5d.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libtoml_edit-28f6cb71c0f6d966.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libitertools-320cf178378eeeaa.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libeither-e7df64a0ed6ac327.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libcombine-23c1f11c3a9ef338.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libmemchr-641fb448d4e1589d.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libbytes-796123aa541d7ea8.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libtoml_datetime-6007df2bfa888181.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libserde_json-25fa7d12aeda0b06.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libryu-c251820d1f9b81c8.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libitoa-88f22cbe8ae56cdb.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libserde-a8313a979998b903.rlib" "/target/x86_64-unknown-freebsd/debug/deps/liblexopt-63123080e1641219.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libindexmap-121d5ed938e48639.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libhashbrown-69ed5b1ddb63db22.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libis_terminal-9dff342a08150e31.rlib" "/target/x86_64-unknown-freebsd/debug/deps/librustix-64848a51b177c873.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libbitflags-2c68063a742fe5a4.rlib" "/target/x86_64-unknown-freebsd/debug/deps/liberrno-3eefe7e4872ad9b4.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libio_lifetimes-f695832c596a10ea.rlib" "/target/x86_64-unknown-freebsd/debug/deps/liblibc-c37ea1fde818e47a.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libtermcolor-b92f43711680adb6.rlib" "/target/x86_64-unknown-freebsd/debug/deps/libanyhow-e4d331e2c107587b.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libstd-2e2ed02d69a9f376.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libpanic_unwind-9833c7b1a3ab3ba0.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libobject-a4819315bc8bd434.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libmemchr-3b3c29eb743e21fd.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libaddr2line-6855750abe51f6eb.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libgimli-3f49948781a939b7.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_demangle-da6d4cb1cee27a7c.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libstd_detect-858666892f335d6e.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libhashbrown-1ad997d3d3a267f6.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libminiz_oxide-2ccf2aa4712c236f.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libadler-418d538a05b92d78.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_std_workspace_alloc-cf5c5dee4dc6005a.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libunwind-71480e653c0efa74.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libcfg_if-bef4f98576d91896.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/liblibc-daed9adcdb4f1c5c.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/liballoc-c461ba80f2ae5f7b.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_std_workspace_core-0f3d942f27fcf4a5.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libcore-b6632458290bd1a1.rlib" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib/libcompiler_builtins-b37c418607db7120.rlib" "-Wl,-Bdynamic" "-lrt" "-lutil" "-lexecinfo" "-lkvm" "-lmemstat" "-lkvm" "-lutil" "-lprocstat" "-lrt" "-ldevstat" "-lexecinfo" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lrt" "-lutil" "-lexecinfo" "-lkvm" "-lutil" "-lprocstat" "-lrt" "-ldevstat" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/rust/lib/rustlib/x86_64-unknown-freebsd/lib" "-o" "/target/x86_64-unknown-freebsd/debug/deps/cargo_hack-fc9c6c512f63e547" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/local/lib/gcc/x86_64-unknown-freebsd12/6.4.0/../../../../x86_64-unknown-freebsd12/bin/ld: cannot find -lmemstat
          collect2: error: ld returned 1 exit status
```          




Discussion / hints:
> x86_64-unknown-freebsd12/bin/ld: cannot find -lmemstat

Probably related: https://github.com/rust-lang/libc/pull/2998
Filed https://github.com/rust-lang/libc/issues/3025 and pinned libc to 0.2.137 for now (a0482fa232897c079c0e345e327ea03bc46a1f6d).

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a97b065f..318e3d8e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -93,25 +93,23 @@ jobs:
       - name: Install Rust
         run: rustup update stable --no-self-update
       - run: rustup target add ${{ matrix.target }}
+      - uses: taiki-e/setup-cross-toolchain-action@v1
+        with:
+          target: ${{ matrix.target }}
+        if: (matrix.os == '' || startsWith(matrix.os, 'ubuntu')) && !contains(matrix.target, '-musl')
       - uses: taiki-e/install-action@cross
-        if: matrix.os == '' || startsWith(matrix.os, 'ubuntu')
+        if: contains(matrix.target, '-musl')
       - run: echo "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >> "${GITHUB_ENV}"
         if: endsWith(matrix.target, 'windows-msvc')
       - run: echo "cargo=cross" >>"${GITHUB_ENV}"
-        if: matrix.target != 'x86_64-unknown-linux-gnu' && (matrix.os == '' || startsWith(matrix.os, 'ubuntu'))
+        if: contains(matrix.target, '-musl')
       - run: $cargo build --target ${{ matrix.target }}
       - run: $cargo build --target ${{ matrix.target }} --release
       # For debugging
-      # - uses: actions/upload-artifact@v3
-      #   with:
-      #     name: ${{ matrix.target }}
-      #     path: target/${{ matrix.target }}/release/cargo-hack.exe
-      #   if: startsWith(matrix.os, 'windows')
-      # - uses: actions/upload-artifact@v3
-      #   with:
-      #     name: ${{ matrix.target }}
-      #     path: target/${{ matrix.target }}/release/cargo-hack
-      #   if: "!startsWith(matrix.os, 'windows')"
+      - uses: actions/upload-artifact@v3
+        with:
+          name: ${{ matrix.target }}
+          path: target/${{ matrix.target }}/release/cargo-hack*
 
   test-compat:
     name: test (1.${{ matrix.rust }})
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8006cd6e..b58b3dd1 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -71,8 +71,12 @@ jobs:
           persist-credentials: false
       - name: Install Rust
         run: rustup update stable --no-self-update
+      - uses: taiki-e/setup-cross-toolchain-action@v1
+        with:
+          target: ${{ matrix.target }}
+        if: (matrix.os == '' || startsWith(matrix.os, 'ubuntu')) && !contains(matrix.target, '-musl')
       - uses: taiki-e/install-action@cross
-        if: matrix.os == '' || startsWith(matrix.os, 'ubuntu')
+        if: contains(matrix.target, '-musl')
       - run: echo "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >> "${GITHUB_ENV}"
         if: endsWith(matrix.target, 'windows-msvc')
       - uses: taiki-e/upload-rust-binary-action@v1
diff --git a/Cargo.toml b/Cargo.toml
index 4d418f6d..20a03828 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,8 +36,6 @@ slab = "0.4.4"
 termcolor = "1.1"
 toml_edit = "0.15"
 
-libc = "=0.2.137" # https://github.com/taiki-e/cargo-hack/issues/174
-
 [dev-dependencies]
 build-info = { path = "tests/auxiliary/build-info" }
 easy-ext = "1"


Test patch: