Skip to contentSkip to conversation

package/valgrind: fix build on mips64 n32 for non-R2 CPUs

PATCH New Yegor Yefremov via buildroot 1 participant 1 message Oct 29

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/valgrind: fix build on mips64 n32 for non-R2 CPUs

When Valgrind's configure detects the MIPS64 n32 ABI, it unconditionally sets FLAG_M64 to "-march=mips64r2 -mabi=n32" and prepends it to the compiler flags. Buildroot appends -march=$(GCC_TARGET_ARCH) to CFLAGS to build Valgrind for the right ISA, so for any CPU other than mips64r2 (here mips64), GCC is given two conflicting ISAs and the build fails:

mips64el-linux-gcc ... -march=mips64r2 -mabi=n32 ... -march=mips64 -c -o priv/libvex_mips64_linux_a-main_globals.o priv/main_globals.c
cc1: error: '-mips64r2' conflicts with the other architecture options, which specify a mips64 processor

The same failure was reported for n64 in
https://bugs.kde.org/show_bug.cgi?id=400975 and fixed upstream in Valgrind 3.15.0 by commit e61d13087 ("mips: if revision is specified, use it for compilation"), which makes configure skip its own -march when CFLAGS already contains one. That fix only covered o32 and n64, though, and the n32 code paths still hardcode -march=mips64r2.

Add a patch doing the same for n32, so only -mabi=n32 is added and Buildroot's -march is used. As the patch touches configure.ac, autoreconf the package.

This issue has been present since commit 1172a68ae888 ("valgrind: bump version to 3.14.0"), which brought in Valgrind's n32 support with the hardcoded -march=mips64r2, conflicting with the -march added by commit 4fc3a6fd7472 ("valgrind: build for the right MIPS ISA revision level"). It therefore affects 2018.11 and later, including all current maintenance branches (2025.02.x and later).

Fixes:
https://autobuild.buildroot.org/results/c562eef960c049f1523ed1c6a30c0d5eacf905ea

Fixes 1172a68ae88849834dcb1b6adddc06c836aa7109 ("valgrind: bump version to 3.14.0")
Assisted-by Claude:claude-opus-5-5
---
 ...c-don-t-override-march-on-mips64-n32.patch | 57 +++++++++++++++++++
 package/valgrind/valgrind.mk                  |  2 +
 2 files changed, 59 insertions(+)
 create mode 100644 package/valgrind/0004-configure.ac-don-t-override-march-on-mips64-n32.patch
package/valgrind/0004-configure.ac-don-t-override-march-on-mips64-n32.patch new file +57 -0
new file mode 100644
index 0000000000..5ba01fa30c
@@ -0,0 +1,57 @@
+From 170ac7684d52f44ddbb40e38c1887e870319526d Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Wed, 28 Oct 2026 12:45:25 +0100
+Subject: [PATCH] configure.ac: don't override -march on mips64 n32
+
+When building for the MIPS64 n32 ABI, configure unconditionally sets
+FLAG_M64 to "-march=mips64r2 -mabi=n32", even if the user already
+selected an ISA through CFLAGS. For o32 and n64 the -march/-mips probe
+is skipped in that case, but not for n32.
+
+As FLAG_M64 comes first on the compiler command line and the user's
+CFLAGS come later, a build with e.g. CFLAGS="-march=mips64" ends up
+with two different ISAs, which GCC rejects:
+
+  cc1: error: '-mips64r2' conflicts with the other architecture
+  options, which specify a mips64 processor
+
+Only add -march=mips64r2 to FLAG_M64 for n32 when no -march/-mips
+option was found in CFLAGS, as is already done for o32 and n64 since
+commit e61d13087 ("mips: if revision is specified, use it for
+compilation"), which fixed the same issue for n64 (bug 400975).
+
+Upstream: https://bugs.kde.org/show_bug.cgi?id=527958
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ configure.ac | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 54f9d31..ca777fb 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -2661,7 +2661,11 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ #endif
+ ]])], [
+ VGCONF_ABI=N32
+-FLAG_M64="-march=mips64r2 -mabi=n32"
++# Don't override the ISA if the user already set one in CFLAGS.
++FLAG_M64="-mabi=n32"
++if test -z "$ARCH"; then
++  FLAG_M64="-march=mips64r2 $FLAG_M64"
++fi
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+@@ -2708,7 +2712,10 @@ if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
+         return 0;
+     ]])], [
+     VGCONF_ABI=N32
+-    FLAG_M64="-march=mips64r2 -mabi=n32"
++    FLAG_M64="-mabi=n32"
++    if test -z "$ARCH"; then
++      FLAG_M64="-march=mips64r2 $FLAG_M64"
++    fi
+     AC_MSG_RESULT([yes])
+     ], [
+     AC_MSG_RESULT([no])
package/valgrind/valgrind.mk +2 -0
index 6dca6252d9..c118bb7286 100644
@@ -14,6 +14,8 @@ VALGRIND_CONF_OPTS = \
 	--disable-ubsan \
 	--without-mpicc
 VALGRIND_INSTALL_STAGING = YES
+# 0004-configure.ac-don-t-override-march-on-mips64-n32.patch
+VALGRIND_AUTORECONF = YES
 
 # Valgrind must be compiled with no stack protection, so forcefully
 # pass -fno-stack-protector to override what Buildroot may have in
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot