Skip to content

Commit 3dab1b6

Browse files
committed
build: add musl/Alpine Linux build support
- Add musl-specific cargo config to disable static CRT linking (required for ext-php-rs) - Add build-musl and build-musl-release Makefile targets - Update help text to document new build options
1 parent ab494ed commit 3dab1b6

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

.cargo/config.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ rustflags = [
1616
CFLAGS = "-D_FORTIFY_SOURCE=0"
1717
CXXFLAGS = "-D_FORTIFY_SOURCE=0"
1818

19+
# Alpine Linux (musl) configuration
20+
# ext-php-rs requires dynamic CRT linking for musl to work properly
21+
[target.'cfg(target_env = "musl")']
22+
rustflags = ["-C", "target-feature=-crt-static"]
23+
24+

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ help:
3232
@echo " make ci - Run all CI checks locally"
3333
@echo ""
3434
@echo "Cross-platform builds:"
35-
@echo " make build-linux - Build for Linux"
35+
@echo " make build-linux - Build for Linux (glibc)"
3636
@echo " make build-macos - Build for macOS"
3737
@echo " make build-windows - Build for Windows"
38+
@echo " make build-musl - Build for Alpine/musl (debug)"
39+
@echo " make build-musl-release - Build for Alpine/musl (release)"
3840
@echo ""
3941
@echo "Current platform: $(UNAME_S)"
4042
@echo "Extension file: $(EXT_FILE)"
@@ -160,3 +162,16 @@ build-windows:
160162

161163
build-windows-release:
162164
cargo build --release --target x86_64-pc-windows-msvc
165+
166+
# Build for musl (Alpine Linux) with dynamic CRT linking
167+
build-musl:
168+
@echo "Building for musl (Alpine Linux) - debug mode..."
169+
@echo "Note: Requires clang-dev and llvm-dev packages"
170+
LIBCLANG_PATH=/usr/lib \
171+
cargo build --target x86_64-unknown-linux-musl
172+
173+
build-musl-release:
174+
@echo "Building for musl (Alpine Linux) - release mode..."
175+
@echo "Note: Requires clang-dev and llvm-dev packages"
176+
LIBCLANG_PATH=/usr/lib \
177+
cargo build --release --target x86_64-unknown-linux-musl

0 commit comments

Comments
 (0)