Hi Adrian,
Then, there is this autoconf macro[2] they use to detect if the target requires
aligned access.
This script does not actually trigger bus errors, but it's meant to detect if
the lower address
bits are ignored on non-byte-aligned memory access.
However, my assumption is that it will also work if the test program crashes
with a bus error.
That's not really important. What is important is figuring out how to patch the
m4 script that
it works properly. In fact, this particular script is also part of texlive-bin
[1] and the test
there works correctly [2]:
That was the idea: "working correctly" would translate to "raise a bus error
reliably on sparc", to detect that unaligned access is a no-go. It looks like this is going to
be difficult, though.
Look at the version of the script from [1], it has a hard-coded list for
cross-compiling:
[1]
https://sources.debian.org/src/texlive-bin/2025.20250727.75242+ds-4/libs/zziplib/zziplib-src/m4/ax_check_aligned_access_required.m4
That script won't work out of the box because we're not cross-compiling. But, I
added a little something to force aligned access when compiling on sparc. A
patch against xdelta3 source is attached at the end. I didn't know about the
other architectures, so I didn't touch them.
This does the trick on sparc64 - detection is now circumvented and the result
is always yes, and I also did a quick check on amd64, to make sure it doesn't
trigger.
Regards,
Gregor
diff --git a/m4/ax_check_aligned_access_required.m4
b/m4/ax_check_aligned_access_required.m4
index b078275..7118531 100644
--- a/m4/ax_check_aligned_access_required.m4
+++ b/m4/ax_check_aligned_access_required.m4
@@ -54,7 +54,19 @@
AC_DEFUN([AX_CHECK_ALIGNED_ACCESS_REQUIRED],
[AC_CACHE_CHECK([if pointers to integers require aligned access],
[ax_cv_have_aligned_access_required],
- [AC_TRY_RUN([
+ [if test "$cross_compiling" = "yes"; then
+ case "$host_cpu" in alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
+ ax_cv_have_aligned_access_required="yes"
+ ;; esac
+else
+ case "$host_cpu" in
+ sparc*)
+ # these architectures always require aligned memory access
+ # and detection by programmatic means is not reliable
+ ax_cv_have_aligned_access_required="yes"
+ ;;
+ *)
+ AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
@@ -77,6 +89,9 @@ int main()
[ax_cv_have_aligned_access_required=no],
[ax_cv_have_aligned_access_required=no])
])
+ ;;
+ esac
+fi
if test "$ax_cv_have_aligned_access_required" = yes ; then
AC_DEFINE([HAVE_ALIGNED_ACCESS_REQUIRED], [1],
[Define if pointers to integers require aligned access])