diff --git a/Jenkinsfile b/Jenkinsfile index 4015acf..dd58791 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,11 +52,34 @@ pipeline { if ! command -v mold >/dev/null 2>&1; then echo "mold not found — installing it..." + pkg install -y mold else echo "mold already installed." fi + echo + echo "Testing mold..." + + if mold --version >/tmp/mold-version.txt 2>&1; then + echo "mold is usable:" + cat /tmp/mold-version.txt + echo "mold" > .ci-linker + else + status=$? + + echo + echo "WARNING: mold is installed but unusable." + echo "mold exited with status ${status}." + echo "Falling back to the native FreeBSD linker." + + cat /tmp/mold-version.txt || true + + echo "native" > .ci-linker + fi + + rm -f /tmp/mold-version.txt + # --------------------------------------------------------- # Environment information # --------------------------------------------------------- @@ -82,12 +105,8 @@ pipeline { cc --version || true echo - echo "mold:" - mold --version - - echo - echo "mold location:" - command -v mold + echo "Selected linker mode:" + cat .ci-linker echo echo "Linker-related environment:" @@ -96,11 +115,44 @@ pipeline { } } + stage('Prepare Linker') { + steps { + sh ''' + set -eu + + linker="$(cat .ci-linker)" + + if [ "${linker}" = "mold" ]; then + echo "Using mold linker configuration." + else + echo "Using native FreeBSD linker." + + # Remove any worker/project environment override that + # injects '-fuse-ld=mold'. + unset RUSTFLAGS || true + unset CARGO_ENCODED_RUSTFLAGS || true + + # Store an environment fragment for later stages. + cat > .ci-env <<'EOF' +unset RUSTFLAGS +unset CARGO_ENCODED_RUSTFLAGS +EOF + fi + + if [ ! -f .ci-env ]; then + : > .ci-env + fi + ''' + } + } + stage('Format') { steps { sh ''' set -eu + . ./.ci-env + echo "Checking Rust formatting..." cargo fmt \ @@ -116,6 +168,8 @@ pipeline { sh ''' set -eu + . ./.ci-env + echo "Checking all IdleFox targets..." cargo check \ @@ -130,6 +184,8 @@ pipeline { sh ''' set -eu + . ./.ci-env + echo "Running IdleFox tests..." cargo test \ @@ -144,6 +200,8 @@ pipeline { sh ''' set -eu + . ./.ci-env + echo "Running Clippy..." cargo clippy \ @@ -158,6 +216,8 @@ pipeline { sh ''' set -eu + . ./.ci-env + echo "Checking benchmark compilation..." cargo check \ @@ -172,6 +232,8 @@ pipeline { sh ''' set -eu + . ./.ci-env + echo "Building IdleFox release..." cargo build \ @@ -227,5 +289,11 @@ pipeline { echo '⚠️ IdleFox CI is unstable.' } + + always { + sh ''' + rm -f .ci-linker .ci-env + ''' + } } } \ No newline at end of file