Skip to content

Commit 96d36a9

Browse files
committed
ci: ensure no gcc dependency is reintroduced
1 parent ece7a09 commit 96d36a9

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
20+
- run: rustup target add x86_64-unknown-linux-musl
2021
- run: cargo build --verbose
2122
- run: cargo test --verbose
23+
- run: cargo build --release --target x86_64-unknown-linux-musl
24+
- run: ./scripts/verify-static-linking.sh
25+
2226
release:
2327
if: startsWith(github.ref, 'refs/tags/v')
2428
strategy:
@@ -42,6 +46,9 @@ jobs:
4246
id: extract
4347
run: echo "version=${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT"
4448
- run: cargo build --release --target ${{ matrix.target }}
49+
- name: Verify musl static linking (Linux only)
50+
if: matrix.target == 'x86_64-unknown-linux-musl'
51+
run: ./scripts/verify-static-linking.sh
4552
- name: Archive and rename binary
4653
shell: bash
4754
run: |

scripts/verify-static-linking.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# Script to verify that the musl build produces a statically linked library
4+
# without libgcc_s.so.1 dependency - preventing regressions
5+
6+
set -e
7+
8+
# Build the musl target if not already built
9+
if [ ! -f "target/x86_64-unknown-linux-musl/release/libscal3.so" ]; then
10+
# Check if the musl target is added
11+
if ! rustup target list --installed | grep -q "x86_64-unknown-linux-musl"; then
12+
rustup target add x86_64-unknown-linux-musl
13+
fi
14+
cargo build --release --target x86_64-unknown-linux-musl
15+
fi
16+
17+
# Path to the built library
18+
LIB_PATH="target/x86_64-unknown-linux-musl/release/libscal3.so"
19+
20+
if [ ! -f "$LIB_PATH" ]; then
21+
echo "Library not found at $LIB_PATH"
22+
exit 1
23+
fi
24+
25+
# Check if statically linked
26+
LDD_OUTPUT=$(ldd "$LIB_PATH" 2>&1 || true)
27+
if ! echo "$LDD_OUTPUT" | grep -q "statically linked"; then
28+
echo "Library is not statically linked"
29+
exit 1
30+
fi
31+
32+
# Check for libgcc dependency
33+
if echo "$LDD_OUTPUT" | grep -q "libgcc_s.so"; then
34+
echo "Found unwanted libgcc_s.so dependency"
35+
exit 1
36+
fi
37+
38+
# Check undefined symbols - should only be malloc and free
39+
UNDEFINED_SYMBOLS=$(nm -D "$LIB_PATH" | grep "U " || true)
40+
UNWANTED_SYMBOLS=$(echo "$UNDEFINED_SYMBOLS" | grep -v -E "(malloc|free)" || true)
41+
if [ -n "$UNWANTED_SYMBOLS" ]; then
42+
echo "Found unexpected undefined symbols:"
43+
echo "$UNWANTED_SYMBOLS"
44+
exit 1
45+
fi
46+
47+
echo "✅ Static linking verification passed"

0 commit comments

Comments
 (0)