Bug#1121498: libreoffice: Preprocessor macros in pdfium confuse arm64 with sparc64
Source: libreoffice
Version: 4:25.8.3-1
Severity: important
Tags: patch upstream
User: debian-sparc@lists.debian.org
Usertags: sparc64
X-Debbugs-Cc: debian-sparc@lists.debian.org
Hi,
the libreoffice package fails to build from source on sparc64 with:
/tmp/ccLEFgM7.s: Assembler messages:
/tmp/ccLEFgM7.s:10332: Error: Unknown opcode: `qsub'
/tmp/ccLEFgM7.s:10365: Error: Unknown opcode: `qsub'
Further investigation showed that qsub is a valid arm64 instruction, but not
a valid sparc64 instruction. It turned out that the preprocessor check macros
in core/fxcrt/numerics/safe_math_clang_gcc_impl.h contain a typo which causes
arm64 code to be used on sparc64:
#if defined(__ARMEL__) || defined(__arch64__)
#include "core/fxcrt/numerics/safe_math_arm_impl.h" // IWYU pragma: export
#define BASE_HAS_ASSEMBLER_SAFE_MATH (1)
#else
#define BASE_HAS_ASSEMBLER_SAFE_MATH (0)
#endif
The test for __arch64__ is wrong as the proper test should be for __aarch64__
which is defined on arm64:
(sid_arm64-dchroot)glaubitz@amdahl:~$ echo | gcc -E -dM -|grep arch
#define __aarch64__ 1
(sid_arm64-dchroot)glaubitz@amdahl:~$
On sparc64, __arch64__ is defined:
(sid_sparc64-dchroot)glaubitz@stadler:~$ echo | gcc -E -dM -|grep arch
#define __arch64__ 1
(sid_sparc64-dchroot)glaubitz@stadler:~$
On SPARC, 32-bit and 64-bit systems are differentiated from eacher by testing
whether both __sparc__ and __arch64__ are defined or just __sparc__.
I have reported the issue upstream [1] and provided them with the attached patch.
Thanks,
Adrian
> [1] https://issues.chromium.org/issues/464091911
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
>From 1c815bec0324037494840d01fc579f2a3420e624 Mon Sep 17 00:00:00 2001
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date: Thu, 27 Nov 2025 13:22:22 +0100
Subject: [PATCH] core/fxcrt/numerics: Fix incorrect preprocessor check on
aarch64
The preprocessor macro to toggle the use of safe_math_arm_impl.h
currently checks whether __ARMEL__ or __arch64__ are defined. However,
on aarch64, the actual define is called __aarch64__ not __arch64__:
(sid_arm64-dchroot)glaubitz@amdahl:~$ uname -a
Linux amdahl 6.12.57+deb13-arm64 #1 SMP Debian 6.12.57-1 (2025-11-05) aarch64 GNU/Linux
(sid_arm64-dchroot)glaubitz@amdahl:~$ echo | gcc -E -dM -|grep arch
(sid_arm64-dchroot)glaubitz@amdahl:~$
However, the define __arch64__ is used on sparc64:
(sid_sparc64-dchroot)glaubitz@stadler:~$ uname -a
Linux stadler 6.17.0-rc5+ #1 SMP Fri Sep 12 20:37:32 UTC 2025 sparc64 GNU/Linux
(sid_sparc64-dchroot)glaubitz@stadler:~$ echo | gcc -E -dM -|grep arch
(sid_sparc64-dchroot)glaubitz@stadler:~$
This triggers the use of safe_math_arm_impl.h on sparc64 which causes
the compiler to emit the "qsub" instruction which is not recongized:
/tmp/ccLEFgM7.s: Assembler messages:
/tmp/ccLEFgM7.s:10332: Error: Unknown opcode: `qsub'
/tmp/ccLEFgM7.s:10365: Error: Unknown opcode: `qsub'
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
---
core/fxcrt/numerics/safe_math_clang_gcc_impl.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/fxcrt/numerics/safe_math_clang_gcc_impl.h b/core/fxcrt/numerics/safe_math_clang_gcc_impl.h
index 58419d5c9..d395ebd3e 100644
--- a/core/fxcrt/numerics/safe_math_clang_gcc_impl.h
+++ b/core/fxcrt/numerics/safe_math_clang_gcc_impl.h
@@ -14,7 +14,7 @@
#include "core/fxcrt/numerics/safe_conversions.h"
-#if defined(__ARMEL__) || defined(__arch64__)
+#if defined(__ARMEL__) || defined(__aarch64__)
#include "core/fxcrt/numerics/safe_math_arm_impl.h" // IWYU pragma: export
#define BASE_HAS_ASSEMBLER_SAFE_MATH (1)
#else
--
2.47.3
Reply to: