]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips64: ensure that either n64 or n32 ABI are set
authorPetar Jovanovic <mips32r2@gmail.com>
Tue, 26 Nov 2019 11:51:28 +0000 (11:51 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Tue, 26 Nov 2019 11:52:25 +0000 (11:52 +0000)
Set the ABI to n64 or n32, in that order, in case the compiler is capable
but it is configured for o32 by default.

Patch by Stefan Maksimovic.

README.mips
configure.ac

index 311ab213792e2b5f90f7b2f6b7f908ee6db09919..0df334ae2926e29c926415da5f963e82fc33d3ae 100644 (file)
@@ -47,3 +47,7 @@ Limitations
   then 4.6.1 due to a bug in the toolchain.
 - Older GCC may have issues with some inline assembly blocks. Get a toolchain
   based on newer GCC versions, if possible.
+- Systems with a mips64 cpu having only o32 libraries will misconfigure in case
+  no appropriate architecture flag is specified during configure time.
+  Be sure to set either mips32 or mips32r2 as the target architecture in that
+  case.
index 78c21f58bf0dbe13548232e1383d7b14d220ae11..8e73d8ddb700381a73df47b85e187ba1e7ec4597 100755 (executable)
@@ -1946,6 +1946,43 @@ AC_MSG_RESULT([yes])
 AC_MSG_RESULT([no])
 ])
 
+# We enter the code block below in the following case:
+# Target architecture is set to mips64, the desired abi
+# was not specified and the compiler's default abi setting
+# is neither n32 nor n64.
+# Probe for and set the abi to either n64 or n32, in that order,
+# which is required for a mips64 build of valgrind.
+if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
+  safe_CFLAGS=$CFLAGS
+  CFLAGS="$CFLAGS -mabi=64 -Werror"
+  AC_MSG_CHECKING([if gcc is n64 capable])
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
+      return 0;
+  ]])], [
+  VGCONF_ABI=64
+  AC_MSG_RESULT([yes])
+  ], [
+  AC_MSG_RESULT([no])
+  ])
+  CFLAGS=$safe_CFLAGS
+
+  if test "x$VGCONF_ABI" = "x"; then
+    safe_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -mabi=n32 -Werror"
+    AC_MSG_CHECKING([if gcc is n32 capable])
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
+        return 0;
+    ]])], [
+    VGCONF_ABI=N32
+    FLAG_M64="-march=mips64r2 -mabi=n32"
+    AC_MSG_RESULT([yes])
+    ], [
+    AC_MSG_RESULT([no])
+    ])
+    CFLAGS=$safe_CFLAGS
+  fi
+fi
+
 AM_CONDITIONAL([VGCONF_HAVE_ABI],
                [test x$VGCONF_ABI != x])
 AC_SUBST(VGCONF_ABI)