From 2f7b484bb1909e2ec28a77ac8e7638dfdf9c9e12 Mon Sep 17 00:00:00 2001 From: robojerk Date: Sun, 10 Aug 2025 09:10:46 -0700 Subject: [PATCH] Fix Rust build: add target specification, fix cargo arguments, improve error handling --- .forgejo/workflows/build-artifacts.yml | 16 +++++++++++----- .forgejo/workflows/simple-build.yml | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.forgejo/workflows/build-artifacts.yml b/.forgejo/workflows/build-artifacts.yml index b813e3a..07ed863 100644 --- a/.forgejo/workflows/build-artifacts.yml +++ b/.forgejo/workflows/build-artifacts.yml @@ -146,7 +146,7 @@ jobs: cd /tmp/deb-bootupd # Set Rust compilation safeguards - export RUSTFLAGS="-C target-cpu=native -C target-feature=+crt-static" + export RUSTFLAGS="-C target-cpu=native" export CARGO_INCREMENTAL=0 export CARGO_NET_RETRY=3 @@ -156,14 +156,20 @@ jobs: echo "Building deb-bootupd in release mode..." echo "Rust flags: $RUSTFLAGS" echo "Memory limit: $(ulimit -v) KB" + echo "Current target: $(rustc --print target-list | grep x86_64-unknown-linux-gnu)" - # Try building with increased verbosity - RUST_BACKTRACE=1 cargo build --release --verbose || { - echo "❌ Build failed, trying with debug mode..." - RUST_BACKTRACE=1 cargo build --debug --verbose || { + # Ensure we have the correct target + rustup target add x86_64-unknown-linux-gnu + + # Try building with release mode first + RUST_BACKTRACE=1 cargo build --release --target x86_64-unknown-linux-gnu --verbose || { + echo "❌ Release build failed, trying with debug mode..." + RUST_BACKTRACE=1 cargo build --target x86_64-unknown-linux-gnu --verbose || { echo "❌ Debug build also failed, checking Rust installation..." rustc --version --verbose cargo --version --verbose + echo "Available targets:" + rustup target list --installed exit 1 } } diff --git a/.forgejo/workflows/simple-build.yml b/.forgejo/workflows/simple-build.yml index 7d97c54..177c4a4 100644 --- a/.forgejo/workflows/simple-build.yml +++ b/.forgejo/workflows/simple-build.yml @@ -138,12 +138,12 @@ jobs: echo "CARGO_HOME: $CARGO_HOME" echo "PATH includes: $PATH" - - name: Build project + - name: Build Rust project run: | cd /tmp/deb-bootupd # Set Rust compilation safeguards - export RUSTFLAGS="-C target-cpu=native -C target-feature=+crt-static" + export RUSTFLAGS="-C target-cpu=native" export CARGO_INCREMENTAL=0 export CARGO_NET_RETRY=3 @@ -153,14 +153,20 @@ jobs: echo "Building deb-bootupd in release mode..." echo "Rust flags: $RUSTFLAGS" echo "Memory limit: $(ulimit -v) KB" + echo "Current target: $(rustc --print target-list | grep x86_64-unknown-linux-gnu)" - # Try building with increased verbosity - RUST_BACKTRACE=1 cargo build --release --verbose || { - echo "❌ Build failed, trying with debug mode..." - RUST_BACKTRACE=1 cargo build --debug --verbose || { + # Ensure we have the correct target + rustup target add x86_64-unknown-linux-gnu + + # Try building with release mode first + RUST_BACKTRACE=1 cargo build --release --target x86_64-unknown-linux-gnu --verbose || { + echo "❌ Release build failed, trying with debug mode..." + RUST_BACKTRACE=1 cargo build --target x86_64-unknown-linux-gnu --verbose || { echo "❌ Debug build also failed, checking Rust installation..." rustc --version --verbose cargo --version --verbose + echo "Available targets:" + rustup target list --installed exit 1 } }