Skip to content

Commit 305819c

Browse files
committed
More fixes for static linking on Linux
1 parent 04068f8 commit 305819c

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

.github/workflows/docker.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ jobs:
7979
echo 'Build completed successfully for x86_64'
8080
"
8181
else
82-
# Cross-compilation for ARM64 using Swift cross-compilation
83-
echo "Cross-compiling for aarch64..."
82+
# Cross-compilation for ARM64 using static Swift stdlib with proper resource directory
83+
echo "Cross-compiling for aarch64 with static linking..."
8484
docker run --rm \
8585
--platform linux/amd64 \
8686
-v $PWD:/workspace \
@@ -94,8 +94,8 @@ jobs:
9494
apt-get update && apt-get install -y gcc-aarch64-linux-gnu && \
9595
echo 'Resolving dependencies...' && \
9696
swift package resolve && \
97-
echo 'Building release binary with cross-compilation...' && \
98-
swift build -c release --triple aarch64-unknown-linux-gnu -Xswiftc -Osize -Xcc -target -Xcc aarch64-unknown-linux-gnu --static-swift-stdlib && \
97+
echo 'Building release binary with static cross-compilation...' && \
98+
swift build -c release --triple aarch64-unknown-linux-gnu -Xswiftc -Osize -Xcc -target -Xcc aarch64-unknown-linux-gnu --static-swift-stdlib -Xswiftc -resource-dir -Xswiftc /usr/lib/swift_static && \
9999
echo 'Stripping binary with cross-compilation tools...' && \
100100
aarch64-linux-gnu-strip .build/aarch64-unknown-linux-gnu/release/swift-dependency-audit && \
101101
echo 'Build completed successfully for aarch64'
@@ -110,13 +110,21 @@ jobs:
110110
du -h .build/${{ matrix.arch }}-unknown-linux-gnu/release/swift-dependency-audit
111111
112112
- name: Test binary functionality (x86_64 only)
113-
if: matrix.arch == 'x86_64'
113+
if: matrix.arch == 'x86_64'
114114
run: |
115115
# Test static binary (should work without Swift runtime libraries)
116116
echo "Testing static binary functionality..."
117117
.build/x86_64-unknown-linux-gnu/release/swift-dependency-audit --version
118118
.build/x86_64-unknown-linux-gnu/release/swift-dependency-audit --help
119119
echo "✅ Static binary functionality tests passed"
120+
121+
- name: Test binary functionality (aarch64 only)
122+
if: matrix.arch == 'aarch64'
123+
run: |
124+
# Test that ARM64 static binary was built correctly (can't execute on x86_64 runner)
125+
echo "Verifying ARM64 static binary properties..."
126+
file .build/aarch64-unknown-linux-gnu/release/swift-dependency-audit
127+
ldd .build/aarch64-unknown-linux-gnu/release/swift-dependency-audit || echo "✅ Static binary - no dynamic dependencies"
120128
121129
122130
- name: Upload Linux binary artifacts

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ jobs:
257257
## Supported Platforms
258258
259259
- macOS (Universal: ARM64 + x86_64)
260-
- Linux x86_64
261-
- Linux ARM64
260+
- Linux x86_64 (static binary, no Swift runtime required)
261+
- Linux ARM64 (static binary, no Swift runtime required)
262262
263263
## Plugin Usage
264264

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ build_linux_aarch64:
8484
echo 'Installing cross-compilation tools...' && \
8585
apt-get update && apt-get install -y gcc-aarch64-linux-gnu && \
8686
echo 'Cross-compiling for ARM64...' && \
87-
swift build $(SWIFT_BUILD_FLAGS) --triple aarch64-unknown-linux-gnu -Xcc -target -Xcc aarch64-unknown-linux-gnu --static-swift-stdlib && \
87+
swift build $(SWIFT_BUILD_FLAGS) --triple aarch64-unknown-linux-gnu -Xcc -target -Xcc aarch64-unknown-linux-gnu --static-swift-stdlib -Xswiftc -resource-dir -Xswiftc /usr/lib/swift_static && \
8888
aarch64-linux-gnu-strip .build/aarch64-unknown-linux-gnu/release/$(EXECUTABLE_NAME) \
8989
"
9090
@echo "✅ Linux ARM64 binary built at $(LINUX_AARCH64_BUILD_DIR)/$(EXECUTABLE_NAME)"

0 commit comments

Comments
 (0)