diff --git a/base/comps/openbios/0001-config-scripts-switch-arch-fix-build-on-aarch64-and-riscv64.patch b/base/comps/openbios/0001-config-scripts-switch-arch-fix-build-on-aarch64-and-riscv64.patch new file mode 100644 index 00000000000..93df4ad8f36 --- /dev/null +++ b/base/comps/openbios/0001-config-scripts-switch-arch-fix-build-on-aarch64-and-riscv64.patch @@ -0,0 +1,32 @@ +From e5ac46dd24e6216c36aa80462af25457e7029440 Mon Sep 17 00:00:00 2001 +From: Mark Cave-Ayland +Date: Mon, 29 Jun 2026 22:08:12 +0100 +Subject: [PATCH] config/scripts/switch-arch: fix build on aarch64 and riscv64 + hosts + +Ensure that the host compiler builds with -DNATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH +on aarch64 and riscv64 hosts for 32-bit target architectures, otherwise host pointers +can end up being truncated to 32-bits causing a segfault running forthstrap. + +Resolves: https://github.com/openbios/openbios/issues/18 +Resolves: https://github.com/openbios/openbios/issues/25 +Closes: https://github.com/openbios/openbios/pull/12 +Signed-off-by: Mark Cave-Ayland +--- + config/scripts/switch-arch | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/config/scripts/switch-arch b/config/scripts/switch-arch +index 013116bf..2c20d273 100755 +--- a/config/scripts/switch-arch ++++ b/config/scripts/switch-arch +@@ -38,7 +38,8 @@ longbits() + if test "$cpu" = "sparc64" -o "$cpu" = "ia64" \ + -o "$cpu" = "amd64" -o "$cpu" = "x86_64" \ + -o "$cpu" = "powerpc64" -o "$cpu" = "ppc64" \ +- -o "$cpu" = "ppc64le" -o "$cpu" = "alpha" ; then ++ -o "$cpu" = "ppc64le" -o "$cpu" = "alpha" \ ++ -o "$cpu" = "aarch64" -o "$cpu" = "riscv64" ; then + echo 64 + else + echo 32 diff --git a/base/comps/openbios/openbios.comp.toml b/base/comps/openbios/openbios.comp.toml index 4e34e5f6221..35b75a2bfe3 100644 --- a/base/comps/openbios/openbios.comp.toml +++ b/base/comps/openbios/openbios.comp.toml @@ -1,15 +1,29 @@ -# The forthstrap Forth interpreter segfaults on aarch64 due to pointer -# truncation in cell2pointer() — mmap returns addresses above 4 GiB that -# don't fit in a 32-bit cell. Known upstream bug with no fix: -# https://github.com/openbios/openbios/issues/18 -# https://github.com/openbios/openbios/issues/25 -# Restrict to x86_64 builders where the address space layout avoids the bug. +# Backport the upstream fix for forthstrap pointer truncation on aarch64 and +# riscv64 hosts: +# https://github.com/openbios/openbios/commit/e5ac46dd24e6216c36aa80462af25457e7029440 [components.openbios] -# Release: 1.git%{hash}%{?dist} +# Release: %[1 + %{azl_release}].git%{hash}%{?dist} release = { calculation = "manual" } +[components.openbios.build.defines] +# AZL-only release counter. Add this to upstream's Release value (1) so future +# Azure Linux rebuilds only need to increment this define. +azl_release = "1" + +[[components.openbios.overlays]] +description = "Compose azl_release with upstream Release so Azure Linux rebuilds can be bumped independently" +type = "spec-set-tag" +tag = "Release" +value = "%[1 + %{azl_release}].git%{hash}%{?dist}" + +[[components.openbios.overlays]] +description = "Backport upstream host bit-width detection for aarch64 and riscv64 to prevent forthstrap pointer truncation" +type = "patch-add" +source = "0001-config-scripts-switch-arch-fix-build-on-aarch64-and-riscv64.patch" + [[components.openbios.overlays]] -description = "Restrict build to x86_64 — forthstrap segfaults on aarch64 (upstream bug #18/#25)" -type = "spec-add-tag" -tag = "ExclusiveArch" -value = "x86_64" +description = "Use %autosetup so OpenBIOS patches are applied automatically" +type = "spec-search-replace" +section = "%prep" +regex = '^%setup -q -n %\{name\}-%\{date\}-git%\{hash\}$' +replacement = '%autosetup -p1 -n %{name}-%{date}-git%{hash}' diff --git a/locks/openbios.lock b/locks/openbios.lock index 11ad9578e41..619bf0aeaf4 100644 --- a/locks/openbios.lock +++ b/locks/openbios.lock @@ -2,5 +2,5 @@ version = 1 import-commit = '086b64fc6eef1bcae87343c28ec336d54ba778a7' upstream-commit = '086b64fc6eef1bcae87343c28ec336d54ba778a7' -input-fingerprint = 'sha256:104f38be5a6e811d3307d4034085cba0f131888be9fe18120d79dc7bc6c847fa' +input-fingerprint = 'sha256:381c0a720b64262309ce7ffc1dfddc65391b5a434146992de8e6536de20bf65f' resolution-input-hash = 'sha256:466421704711c4fd3c71f0b2ed715a0e61d49e3e26f3a2637fee755795849c8e' diff --git a/specs/o/openbios/0001-config-scripts-switch-arch-fix-build-on-aarch64-and-riscv64.patch b/specs/o/openbios/0001-config-scripts-switch-arch-fix-build-on-aarch64-and-riscv64.patch new file mode 100644 index 00000000000..93df4ad8f36 --- /dev/null +++ b/specs/o/openbios/0001-config-scripts-switch-arch-fix-build-on-aarch64-and-riscv64.patch @@ -0,0 +1,32 @@ +From e5ac46dd24e6216c36aa80462af25457e7029440 Mon Sep 17 00:00:00 2001 +From: Mark Cave-Ayland +Date: Mon, 29 Jun 2026 22:08:12 +0100 +Subject: [PATCH] config/scripts/switch-arch: fix build on aarch64 and riscv64 + hosts + +Ensure that the host compiler builds with -DNATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH +on aarch64 and riscv64 hosts for 32-bit target architectures, otherwise host pointers +can end up being truncated to 32-bits causing a segfault running forthstrap. + +Resolves: https://github.com/openbios/openbios/issues/18 +Resolves: https://github.com/openbios/openbios/issues/25 +Closes: https://github.com/openbios/openbios/pull/12 +Signed-off-by: Mark Cave-Ayland +--- + config/scripts/switch-arch | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/config/scripts/switch-arch b/config/scripts/switch-arch +index 013116bf..2c20d273 100755 +--- a/config/scripts/switch-arch ++++ b/config/scripts/switch-arch +@@ -38,7 +38,8 @@ longbits() + if test "$cpu" = "sparc64" -o "$cpu" = "ia64" \ + -o "$cpu" = "amd64" -o "$cpu" = "x86_64" \ + -o "$cpu" = "powerpc64" -o "$cpu" = "ppc64" \ +- -o "$cpu" = "ppc64le" -o "$cpu" = "alpha" ; then ++ -o "$cpu" = "ppc64le" -o "$cpu" = "alpha" \ ++ -o "$cpu" = "aarch64" -o "$cpu" = "riscv64" ; then + echo 64 + else + echo 32 diff --git a/specs/o/openbios/openbios.azl.macros b/specs/o/openbios/openbios.azl.macros new file mode 100644 index 00000000000..60187b70289 --- /dev/null +++ b/specs/o/openbios/openbios.azl.macros @@ -0,0 +1,3 @@ +# Macros file automatically generated by azldev. +# Do not edit manually; changes will be overwritten. +%azl_release 1 diff --git a/specs/o/openbios/openbios.spec b/specs/o/openbios/openbios.spec index d989500f2d3..840f918e247 100644 --- a/specs/o/openbios/openbios.spec +++ b/specs/o/openbios/openbios.spec @@ -1,6 +1,9 @@ # This spec file has been modified by azldev to include build configuration overlays. # Do not edit manually; changes may be overwritten. +# All Azure Linux specs with overlays include this macro file, irrespective of whether new macros have been added. +%{load:%{_sourcedir}/openbios.azl.macros} + %global hash c3a19c1 %global date 20240913 @@ -13,7 +16,7 @@ Name: openbios Version: %{date} -Release: 1.git%{hash}%{?dist} +Release: %[1 + %{azl_release}].git%{hash}%{?dist} Epoch: 1 Summary: OpenBIOS implementation of IEEE 1275-1994 @@ -29,6 +32,7 @@ BuildArch: noarch # date=`git log -1 --format='%cd' --date=short | tr -d -` # git archive --prefix openbios-${date}-git${hash}/ ${hash} | xz -7e > ../openbios-${date}-git${hash}.tar.xz Source0: %{name}-%{date}-git%{hash}.tar.xz +Source9999: openbios.azl.macros # Note that these packages build 32 bit binaries with the -m32 flag. BuildRequires: make @@ -40,7 +44,7 @@ BuildRequires: fcode-utils BuildRequires: libxslt -ExclusiveArch: x86_64 +Patch0: 0001-config-scripts-switch-arch-fix-build-on-aarch64-and-riscv64.patch %description The OpenBIOS project provides you with most free and open source Open Firmware implementations available. Here you find several @@ -66,7 +70,7 @@ such as coreboot or U-Boot. %prep -%setup -q -n %{name}-%{date}-git%{hash} +%autosetup -p1 -n %{name}-%{date}-git%{hash} %build