From cc87cdfb3e7552e4d09e7edad5f0991697081dd3 Mon Sep 17 00:00:00 2001 From: naoNao89 <90588855+naoNao89@users.noreply.github.com> Date: Tue, 14 Oct 2025 06:54:22 +0700 Subject: [PATCH 1/3] ci: patch codspeed v4.0.4 for gnu11 compatibility Dynamically patches codspeed build.rs during CI to use gnu11 instead of gnu17, addressing CodSpeedHQ/codspeed-rust#139 for older GCC toolchain compatibility in cross-compilation containers. Implementation: - Clone and patch codspeed v4.0.4 with retry logic - Validate build.rs and verify patch application - Inject [patch.crates-io] configuration at runtime - Platform-aware sed handling (macOS/Linux) - Update Cargo.lock for patched dependency The patch applies only during CI runs and does not persist in source control. --- .github/workflows/CICD.yml | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index c5bbf7f11fa..968aecb27a1 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -777,6 +777,45 @@ jobs: echo 200:x:2000: | sudo tee -a /etc/group ;; esac + - name: Apply CodSpeed gnu11 compatibility patch + shell: bash + run: | + ## CodSpeed gnu11 compatibility patch (addresses CodSpeedHQ/codspeed-rust#139) + set -euo pipefail + CODSPEED_VERSION="v4.0.4" + CODSPEED_REPO="https://github.com/CodSpeedHQ/codspeed-rust" + CODSPEED_TMP="${RUNNER_TEMP:-/tmp}/codspeed-rust" + BUILD_RS="$CODSPEED_TMP/crates/codspeed/build.rs" + # clone with retry + for attempt in 1 2 3; do + git clone --depth 1 --branch "$CODSPEED_VERSION" "$CODSPEED_REPO" "$CODSPEED_TMP" 2>/dev/null && break + [ $attempt -eq 3 ] && { echo "::error::Failed to clone codspeed-rust"; exit 1; } + sleep 2 + done + # validate and patch build.rs + [ ! -f "$BUILD_RS" ] && { echo "::error::build.rs not found"; exit 1; } + if grep -q '\-std=gnu17' "$BUILD_RS"; then + if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' 's/-std=gnu17/-std=gnu11/g' "$BUILD_RS" + else + sed -i 's/-std=gnu17/-std=gnu11/g' "$BUILD_RS" + fi + grep -q '\-std=gnu11' "$BUILD_RS" && ! grep -q '\-std=gnu17' "$BUILD_RS" || { echo "::error::Patch failed"; exit 1; } + fi + # inject cargo patch + PATCH_ENTRY="codspeed = { path = \"$CODSPEED_TMP/crates/codspeed\" }" + if grep -q '^\[patch\.crates-io\]' Cargo.toml; then + if grep -q '^codspeed\s*=' Cargo.toml; then + [[ "$OSTYPE" == "darwin"* ]] && sed -i '' "s|^codspeed\s*=.*|$PATCH_ENTRY|" Cargo.toml || sed -i "s|^codspeed\s*=.*|$PATCH_ENTRY|" Cargo.toml + else + awk -v entry="$PATCH_ENTRY" '/^\[patch\.crates-io\]/ { print; print entry; next } { print }' Cargo.toml > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml + fi + else + printf "\n[patch.crates-io]\n%s\n" "$PATCH_ENTRY" >> Cargo.toml + fi + grep -q "codspeed.*=.*path.*$CODSPEED_TMP" Cargo.toml || { echo "::error::Failed to add patch"; exit 1; } + # update lockfile + cargo update -p codspeed 2>/dev/null || cargo update -p codspeed-divan-compat 2>/dev/null || true - uses: taiki-e/install-action@v2 if: steps.vars.outputs.CARGO_CMD == 'redoxer' with: From c490777868b51f2171f99dc4658be461903a889d Mon Sep 17 00:00:00 2001 From: naoNao89 <90588855+naoNao89@users.noreply.github.com> Date: Tue, 14 Oct 2025 07:44:21 +0700 Subject: [PATCH 2/3] fix: add OSTYPE to cspell shell wordlist Fixes cspell error for OSTYPE shell variable used in CI workflow --- .vscode/cspell.dictionaries/shell.wordlist.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/cspell.dictionaries/shell.wordlist.txt b/.vscode/cspell.dictionaries/shell.wordlist.txt index b1ddec7a4e0..c82fd819923 100644 --- a/.vscode/cspell.dictionaries/shell.wordlist.txt +++ b/.vscode/cspell.dictionaries/shell.wordlist.txt @@ -2,6 +2,7 @@ clonefile # * POSIX +OSTYPE TMPDIR adduser csh From 4d310fdefb48036f8aa5bbf186b24f1f1d6263e7 Mon Sep 17 00:00:00 2001 From: naoNao89 <90588855+naoNao89@users.noreply.github.com> Date: Tue, 14 Oct 2025 09:28:50 +0700 Subject: [PATCH 3/3] ci: fix codspeed patch directory accessibility for cross builds Move CODSPEED_TMP from system temp (/tmp) to workspace directory (.codspeed-patch) to ensure Docker containers used by cross can access the patched source. Add cleanup to remove temporary directory after use. --- .github/workflows/CICD.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 968aecb27a1..6dd9643cfb5 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -784,7 +784,7 @@ jobs: set -euo pipefail CODSPEED_VERSION="v4.0.4" CODSPEED_REPO="https://github.com/CodSpeedHQ/codspeed-rust" - CODSPEED_TMP="${RUNNER_TEMP:-/tmp}/codspeed-rust" + CODSPEED_TMP="$PWD/.codspeed-patch" BUILD_RS="$CODSPEED_TMP/crates/codspeed/build.rs" # clone with retry for attempt in 1 2 3; do @@ -816,6 +816,8 @@ jobs: grep -q "codspeed.*=.*path.*$CODSPEED_TMP" Cargo.toml || { echo "::error::Failed to add patch"; exit 1; } # update lockfile cargo update -p codspeed 2>/dev/null || cargo update -p codspeed-divan-compat 2>/dev/null || true + # cleanup temp directory + rm -rf "$CODSPEED_TMP" - uses: taiki-e/install-action@v2 if: steps.vars.outputs.CARGO_CMD == 'redoxer' with: