Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(build): build the amd64 native binary on Ubuntu 24.04 so it runs on x86-64-v2 CPUs (#6644)

Attila Kis84442d83ced9
diff --git a/.github/scripts/check-isa-level.sh b/.github/scripts/check-isa-level.sh
new file mode 100755
index 0000000000..e5af194bd5
--- /dev/null
+++ b/.github/scripts/check-isa-level.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+# check-isa-level.sh <binary> [highest allowed level]
+#
+# The amd64 binary must run on x86-64-v2 CPUs (no AVX2). glibc refuses to load a binary whose
+# "x86 ISA needed" property names a level the CPU lacks ("CPU ISA level is lower than required").
+# The linker merges that property over every object it links, so one object from the build host's
+# toolchain raises it whatever -march says. This reads the property and fails when it names a level
+# above the allowed one (default 2, x86-64-v2). A binary without the property passes: glibc then
+# checks nothing. Starting the binary cannot catch this, because the runner's CPU has v3.
+set -euo pipefail
+
+BIN=$1
+MAX=${2:-2}
+
+case $MAX in
+ [1-4]) ;;
+ *) echo "FAIL: the highest allowed level must be 1 to 4, got '$MAX'"; exit 1 ;;
+esac
+
+notes=$(readelf --notes --wide "$BIN")
+line=$(grep 'x86 ISA needed:' <<<"$notes" || true)
+if [ -z "$line" ]; then
+ echo "ok: $BIN has no x86 ISA needed property, so glibc checks no ISA level"
+ exit 0
+fi
+
+needed=$(grep -o 'x86 ISA needed: [^,]*\(, x86-64-[a-z0-9]*\)*' <<<"$line")
+highest=0
+for level in $(grep -o 'x86-64-[a-z0-9]*' <<<"$needed" || true); do
+ case $level in
+ x86-64-baseline) n=1 ;;
+ x86-64-v[2-9]) n=${level#x86-64-v} ;;
+ *) echo "FAIL: cannot read the level '$level' in: $line"; exit 1 ;;
+ esac
+ if [ "$n" -gt "$highest" ]; then
+ highest=$n
+ fi
+done
+if [ "$highest" -gt "$MAX" ]; then
+ echo "FAIL: $BIN needs x86-64-v$highest, above the x86-64-v$MAX limit. readelf: $line"
+ exit 1
+fi
+echo "ok: $needed (limit x86-64-v$MAX)"
diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml
index 80787b70d6..09516e3f89 100644
--- a/.github/workflows/build-images.yml
+++ b/.github/workflows/build-images.yml
@@ -162,7 +162,9 @@ jobs:
name: Build native artifact (amd64)
if: inputs.publish-native
needs: prepare
- runs-on: ubuntu-latest
+ # Pinned, like the arm64 jobs. Built on ubuntu-26.04 the binary asks glibc for x86-64-v3
+ # whatever -march says, and no longer starts on x86-64-v2 CPUs.
+ runs-on: ubuntu-24.04
timeout-minutes: 45
permissions:
contents: read
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 74f5cf03fc..ff6d5594b8 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -44,7 +44,9 @@ jobs:
build-native-amd64:
name: Build native artifact (amd64)
needs: prepare
- runs-on: ubuntu-latest
+ # Pinned, like the arm64 jobs. Built on ubuntu-26.04 the binary asks glibc for x86-64-v3
+ # whatever -march says, and no longer starts on x86-64-v2 CPUs.
+ runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
@@ -87,6 +89,11 @@ jobs:
# The flag only exists on Mandrel, so it is passed here rather than in application.yml.
run: mvn clean package -Dnative -DskipTests -B -Dquarkus.native.additional-build-args-append="-march=x86-64-v2,-H:-AOTSingleCallsiteInline"
+ - name: Check the x86-64 ISA level of the binary
+ # The image must run on x86-64-v2 CPUs. The runner's CPU has v3, so starting the binary
+ # here proves nothing; the script reads the ISA level the binary asks glibc for.
+ run: .github/scripts/check-isa-level.sh "$(ls target/*-runner)"
+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: native-amd64
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 37eb26823c..c0a135a4a0 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -37,7 +37,9 @@ jobs:
# ── Build native artifact — amd64 ────────────────────────────────────────
build-native-amd64:
name: Build native artifact (amd64)
- runs-on: ubuntu-latest
+ # Pinned, like the arm64 jobs. Built on ubuntu-26.04 the binary asks glibc for x86-64-v3
+ # whatever -march says, and no longer starts on x86-64-v2 CPUs.
+ runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
@@ -58,6 +60,12 @@ jobs:
# The flag only exists on Mandrel, so it is passed here rather than in application.yml.
run: mvn clean package -Dnative -DskipTests -B -Dquarkus.native.additional-build-args-append="-march=x86-64-v2,-H:-AOTSingleCallsiteInline"
+ - name: Check the x86-64 ISA level of the binary
+ # The image and the release asset must run on x86-64-v2 CPUs. The runner's CPU has v3, so
+ # starting the binary here proves nothing; the script reads the ISA level the binary asks
+ # glibc for.
+ run: .github/scripts/check-isa-level.sh "$(ls target/*-runner)"
+
- name: Smoke-test the standalone binary
# The same binary is published as a release asset (publish-binaries), so it is checked
# the way a user runs it: on the host, no Docker image around it.