mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
fix(build): build the amd64 native binary on Ubuntu 24.04 so it runs on x86-64-v2 CPUs (#6644)
On Ubuntu 26.04, which ubuntu-latest is moving to, the amd64 native binary asks glibc for x86-64-v3 whatever -march says, so it does not start on x86-64-v2 CPUs. Pin the amd64 native jobs to ubuntu-24.04, as the arm64 jobs are, and check the ISA level after the nightly and release builds, so CI catches it next time.
This commit is contained in:
1 parent
c6927cca96
commit
84442d83ce
4 files changed
+63
-3
No files matched your search
Executable
+43
@@ -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)"
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user