On 2023/08/16 20:15, Theo Buehler wrote: > I found on one sparc64 box that reposync stopped working and it turned > out that rsync on sparc64 is busted due to xxhash not dealing correctly > with unaligned access. > > Program terminated with signal SIGBUS, Bus error. > #0 XXH_read64 (ptr=0xfffffe7ed9467bbe) at /usr/local/include/xxhash.h:2996 > > xxhash.h claims XXH_FORCE_MEMORY_ACCESS=0 to be the default, but that > doesn't seem to be true (anymore?). I haven't tried to find out why.
default eh, what a lie. #ifndef XXH_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */ /* prefer __packed__ structures (method 1) for GCC * < ARMv7 with unaligned access (e.g. Raspbian armhf) still uses byte shifting, so we use memcpy * which for some reason does unaligned loads. */ # if defined(__GNUC__) && !(defined(__ARM_ARCH) && __ARM_ARCH < 7 && defined(__ARM_FEATURE_UNALIGNED)) # define XXH_FORCE_MEMORY_ACCESS 1 # endif #endif > rsync built with the diff below that forces the use of memcpy() to > avoid unaligned access seems to work fine and xxhash passes regress on > sparc64 (after removing -Wvla from ${WRKSRC}/Makefile). > > Maybe we only want to set this conditionally on the architectures that > need this for performance reasons. I also haven't looked into what > consumes xxhash.h. > > I'd appreciate if you could take it from here. I'm ok with your diff, or perhaps we could do this (then rsync just needs a bump rather than another change) Index: Makefile =================================================================== RCS file: /cvs/ports/sysutils/xxhash/Makefile,v retrieving revision 1.13 diff -u -p -r1.13 Makefile --- Makefile 23 Jul 2023 04:29:44 -0000 1.13 +++ Makefile 16 Aug 2023 18:37:00 -0000 @@ -3,6 +3,7 @@ COMMENT = extremely fast non-cryptograph GH_ACCOUNT = Cyan4973 GH_PROJECT = xxHash GH_TAGNAME = v0.8.2 +REVISION = 0 PKGNAME = ${DISTNAME:L} SHARED_LIBS = xxhash 0.3 # 0.8.1 Index: patches/patch-xxhash_h =================================================================== RCS file: patches/patch-xxhash_h diff -N patches/patch-xxhash_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-xxhash_h 16 Aug 2023 18:37:00 -0000 @@ -0,0 +1,14 @@ +XXH_FORCE_MEMORY_ACCESS=1 results in unaligned access on sparc64 + +Index: xxhash.h +--- xxhash.h.orig ++++ xxhash.h +@@ -1983,7 +1983,7 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3 + /* prefer __packed__ structures (method 1) for GCC + * < ARMv7 with unaligned access (e.g. Raspbian armhf) still uses byte shifting, so we use memcpy + * which for some reason does unaligned loads. */ +-# if defined(__GNUC__) && !(defined(__ARM_ARCH) && __ARM_ARCH < 7 && defined(__ARM_FEATURE_UNALIGNED)) ++# if defined(__GNUC__) && !(defined(__ARM_ARCH) && __ARM_ARCH < 7 && defined(__ARM_FEATURE_UNALIGNED)) && !defined(__sparc64__) + # define XXH_FORCE_MEMORY_ACCESS 1 + # endif + #endif