mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-16 17:20:33 +00:00
* fix: Resolve zstd-sys Zig compilation issues - Remove specific Zig version constraint in action.yml to use default version - Clean up duplicate environment variable settings in build-rustfs.sh - Add CARGO_TARGET_*_LINKER environment variables for better cross-compilation support - Optimize build configuration for consistent cross-platform compilation Fixes compilation issues with zstd-sys when using Zig cross-compilation. Aligns with previously working configuration that uses default Zig version. * fix: Restore working build configuration from4fb4b353- Restore matrix.cross parameter to differentiate cross-compilation - Use simple cargo zigbuild instead of complex build-rustfs.sh script - Remove unnecessary zstd dependencies from action.yml - Restore console asset download step - Use correct target directory path for packaging - Align with known working configuration from commit4fb4b353This reverts to the proven working build approach that successfully performed cross-platform compilation. * fix: Align build-rustfs.sh with working version logic - Simplify build logic to match working version4fb4b353- Use exact same build commands as the working build.yml: * cargo build for native compilation * cargo zigbuild for Linux ARM64 cross-compilation * cross build for Windows ARM64 cross-compilation - Remove complex environment variable setup that caused conflicts - Add touch rustfs/build.rs to match working version - Use -p rustfs --bins flag consistent with working version This ensures build-rustfs.sh (if used) follows the proven working approach.
This commit is contained in:
@@ -188,12 +188,6 @@ setup_rust_environment() {
|
||||
# Set environment variables for zstd-sys to avoid target parsing issues
|
||||
export ZSTD_SYS_USE_PKG_CONFIG=1
|
||||
export PKG_CONFIG_ALLOW_CROSS=1
|
||||
|
||||
# Use system zstd if available for musl builds
|
||||
if [[ "$PLATFORM" == *"musl"* ]]; then
|
||||
export ZSTD_SYS_USE_PKG_CONFIG=1
|
||||
export PKG_CONFIG_ALLOW_CROSS=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -357,43 +351,41 @@ build_binary() {
|
||||
# Create output directory
|
||||
mkdir -p "${OUTPUT_DIR}/${PLATFORM}"
|
||||
|
||||
# Build command - choose the best tool for cross-compilation
|
||||
local build_cmd="cargo build"
|
||||
# Simple build logic matching the working version (4fb4b353)
|
||||
# Force rebuild by touching build.rs
|
||||
touch rustfs/build.rs
|
||||
|
||||
# Determine build command based on platform and cross-compilation needs
|
||||
local build_cmd=""
|
||||
local current_platform=$(detect_platform)
|
||||
|
||||
print_message $BLUE "📦 Using working version build logic..."
|
||||
|
||||
# Check if we need cross-compilation
|
||||
if [ "$PLATFORM" != "$current_platform" ]; then
|
||||
# Check if the target is a macOS target
|
||||
# Cross-compilation needed
|
||||
if [[ "$PLATFORM" == *"apple-darwin"* ]]; then
|
||||
print_message $YELLOW "🍎 macOS target detected, using native cargo build"
|
||||
print_message $YELLOW "💡 Note: macOS targets must be built natively on macOS runners"
|
||||
build_cmd="cargo build"
|
||||
elif [[ "$PLATFORM" == *"linux"* ]]; then
|
||||
# For Linux targets, prefer cargo-zigbuild over cross for better glibc compatibility
|
||||
if command -v cargo-zigbuild &> /dev/null; then
|
||||
build_cmd="cargo zigbuild"
|
||||
print_message $YELLOW "🔧 Linux cross-compilation detected, using 'cargo-zigbuild' for better glibc compatibility"
|
||||
elif command -v cross &> /dev/null; then
|
||||
build_cmd="cross build"
|
||||
print_message $YELLOW "🔄 Cross-compilation detected, using 'cross' tool"
|
||||
else
|
||||
print_message $YELLOW "⚠️ Cross-compilation detected but neither 'cargo-zigbuild' nor 'cross' tool found"
|
||||
print_message $YELLOW "📦 Installing cross tool as fallback..."
|
||||
cargo install cross --git https://github.com/cross-rs/cross
|
||||
build_cmd="cross build"
|
||||
fi
|
||||
else
|
||||
# For other targets, use cross
|
||||
if command -v cross &> /dev/null; then
|
||||
build_cmd="cross build"
|
||||
print_message $YELLOW "🔄 Cross-compilation detected, using 'cross' tool"
|
||||
else
|
||||
print_message $YELLOW "⚠️ Cross-compilation detected but 'cross' tool not found"
|
||||
print_message $RED "❌ macOS cross-compilation not supported"
|
||||
print_message $YELLOW "💡 macOS targets must be built natively on macOS runners"
|
||||
return 1
|
||||
elif [[ "$PLATFORM" == *"windows"* ]]; then
|
||||
# Use cross for Windows ARM64
|
||||
if ! command -v cross &> /dev/null; then
|
||||
print_message $YELLOW "📦 Installing cross tool..."
|
||||
cargo install cross --git https://github.com/cross-rs/cross
|
||||
build_cmd="cross build"
|
||||
fi
|
||||
build_cmd="cross build"
|
||||
else
|
||||
# Use zigbuild for Linux ARM64 (matches working version)
|
||||
if ! command -v cargo-zigbuild &> /dev/null; then
|
||||
print_message $RED "❌ cargo-zigbuild not found. Please install it first."
|
||||
return 1
|
||||
fi
|
||||
build_cmd="cargo zigbuild"
|
||||
fi
|
||||
else
|
||||
# Native compilation
|
||||
build_cmd="cargo build"
|
||||
fi
|
||||
|
||||
if [ "$BUILD_TYPE" = "release" ]; then
|
||||
@@ -401,11 +393,11 @@ build_binary() {
|
||||
fi
|
||||
|
||||
build_cmd+=" --target $PLATFORM"
|
||||
build_cmd+=" --bin $BINARY_NAME"
|
||||
build_cmd+=" -p rustfs --bins"
|
||||
|
||||
print_message $BLUE "📦 Executing: $build_cmd"
|
||||
|
||||
# Execute build
|
||||
# Execute build (this matches exactly what the working version does)
|
||||
if eval $build_cmd; then
|
||||
print_message $GREEN "✅ Successfully built for $PLATFORM"
|
||||
|
||||
@@ -438,33 +430,6 @@ build_binary() {
|
||||
print_message $GREEN "✅ Build completed successfully"
|
||||
else
|
||||
print_message $RED "❌ Failed to build for $PLATFORM"
|
||||
|
||||
# Provide helpful suggestions for cross-compilation failures
|
||||
if [ "$PLATFORM" != "$(detect_platform)" ]; then
|
||||
if [[ "$PLATFORM" == *"apple-darwin"* ]]; then
|
||||
print_message $YELLOW "💡 macOS build suggestions:"
|
||||
print_message $YELLOW " 1. macOS targets must be built natively on macOS systems"
|
||||
print_message $YELLOW " 2. Use GitHub Actions with macos-latest runner"
|
||||
print_message $YELLOW " 3. Ensure Xcode command line tools are installed"
|
||||
print_message $YELLOW " 4. Try: rustup target add $PLATFORM"
|
||||
elif [[ "$PLATFORM" == *"linux"* ]]; then
|
||||
print_message $YELLOW "💡 Linux cross-compilation suggestions:"
|
||||
print_message $YELLOW " 1. Install cargo-zigbuild for better glibc compatibility:"
|
||||
print_message $YELLOW " cargo install cargo-zigbuild"
|
||||
print_message $YELLOW " 2. Install Zig compiler: https://ziglang.org/download/"
|
||||
print_message $YELLOW " 3. Use Docker build: make build-docker"
|
||||
print_message $YELLOW " 4. Use GitHub Actions for multi-platform builds"
|
||||
print_message $YELLOW " 5. Build natively on the target platform"
|
||||
print_message $YELLOW " 6. Try: rustup target add $PLATFORM"
|
||||
else
|
||||
print_message $YELLOW "💡 Cross-compilation suggestions:"
|
||||
print_message $YELLOW " 1. Use Docker build: make build-docker"
|
||||
print_message $YELLOW " 2. Use GitHub Actions for multi-platform builds"
|
||||
print_message $YELLOW " 3. Build natively on the target platform"
|
||||
print_message $YELLOW " 4. Use 'make docker-buildx' for multi-arch Docker images"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user