diff --git a/.cargo/config.toml b/.cargo/config.toml index 4f1e843e..e453fe5f 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,34 +1,14 @@ [build] -# Use safer optimization flags to avoid Rust compiler SIGSEGV -# The default Debian build flags are too aggressive and cause crashes +# Use fewer parallel jobs to reduce memory usage in CI +jobs = 2 -[target.'cfg(all())'] -# Override aggressive optimization flags that cause SIGSEGV -rustflags = [ - "-C", "opt-level=2", # Use safer optimization level (was 3) - "-C", "codegen-units=16", # Use multiple codegen units (was 1) - # Remove linker-plugin-lto which causes SIGSEGV with regex-automata - "-C", "lto=false", # Disable LTO to avoid crashes -] +[target.x86_64-unknown-linux-gnu] +# Optimize for CI environments +rustflags = ["-C", "target-cpu=native", "-C", "opt-level=2"] -[profile.release] -# Use safer release profile settings -opt-level = 2 # Safer optimization level -codegen-units = 16 # Multiple codegen units for stability -lto = false # Disable LTO to avoid crashes -panic = "abort" # Abort on panic for release builds -strip = true # Strip debug symbols -debug = false # No debug info in release builds - -[profile.dev] -# Development profile settings -opt-level = 0 # No optimization for faster compilation -debug = true # Include debug info -codegen-units = 16 # Multiple codegen units -lto = false # Disable LTO - -# Environment-specific overrides -[env] -# Set environment variables for safer builds -RUSTFLAGS = "--cfg debug_assertions" -CARGO_INCREMENTAL = "1" +[profile.ci] +# CI-specific profile for memory-constrained environments +opt-level = 2 +lto = false +codegen-units = 4 +debug = false \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 55c12836..9d530156 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,6 +76,14 @@ opt-level = 3 lto = true codegen-units = 1 +# CI-friendly profile for memory-constrained environments +[profile.ci] +inherits = "release" +opt-level = 2 +lto = false +codegen-units = 4 +debug = false + [profile.dev] opt-level = 0 debug = true diff --git a/build-ci.sh b/build-ci.sh new file mode 100755 index 00000000..5faac3ba --- /dev/null +++ b/build-ci.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +echo "๐Ÿ”ง Building apt-ostree for CI environment..." + +# Set memory-friendly environment variables +export CARGO_BUILD_JOBS=2 +export RUSTFLAGS="-C target-cpu=native -C opt-level=2" +export CARGO_TARGET_DIR="target-ci" + +# Clean previous builds +echo "๐Ÿงน Cleaning previous builds..." +cargo clean + +# Build with CI profile +echo "๐Ÿ—๏ธ Building with CI profile..." +cargo build --profile ci --bin apt-ostree +cargo build --profile ci --bin apt-ostreed + +echo "โœ… CI build completed successfully!"