Discussion:
host-cpu-c-abi: fix detection of MIPS ABI
Bruno Haible
2017-07-19 00:37:59 UTC
Permalink
With the mips-linux-gnu-gcc-5 cross compiler on Debian,
host-cpu-c-abi reports the n32 ABI, when it's in fact the 32 (a.k.a. o32) ABI.
This fixes it.


2017-07-18 Bruno Haible <***@clisp.org>

host-cpu-c-abi: Fix detection of MIPS ABI.
* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI): For MIPS, really test the
ABI, not the CPU instruction set.

diff --git a/m4/host-cpu-c-abi.m4 b/m4/host-cpu-c-abi.m4
index a3a3d43..3017f6c 100644
--- a/m4/host-cpu-c-abi.m4
+++ b/m4/host-cpu-c-abi.m4
@@ -1,4 +1,4 @@
-# host-cpu-c-abi.m4 serial 4
+# host-cpu-c-abi.m4 serial 5
dnl Copyright (C) 2002-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -146,12 +146,12 @@ changequote([,])dnl
yes
#endif],
[gl_cv_host_cpu_c_abi=mips64],
- [# Strictly speaking, the MIPS ABI (-32 or -n32) is independent
- # from the CPU identification (-mips[12] or -mips[34]). But -n32
- # is commonly used together with -mips3, and it's easier to test
- # the CPU identification.
+ [# In the n32 ABI, _ABIN32 is defined, _ABIO32 is not defined, and
+ # _MIPS_SIM == _ABIN32.
+ # In the 32 ABI, _ABIO32 is defined, _ABIN32 is not defined, and
+ # _MIPS_SIM == _ABIO32.
AC_EGREP_CPP([yes],
- [#if __mips >= 3
+ [#if defined _ABIN32
yes
#endif],
[gl_cv_host_cpu_c_abi=mipsn32],
Bruno Haible
2017-08-19 23:28:14 UTC
Permalink
Post by Bruno Haible
+ [# In the n32 ABI, _ABIN32 is defined, _ABIO32 is not defined, and
+ # _MIPS_SIM == _ABIN32.
+ # In the 32 ABI, _ABIO32 is defined, _ABIN32 is not defined, and
+ # _MIPS_SIM == _ABIO32.
AC_EGREP_CPP([yes],
- [#if __mips >= 3
+ [#if defined _ABIN32
yes
#endif],
[gl_cv_host_cpu_c_abi=mipsn32],
Well, it turns out it is not a good practice to test 'defined _ABIN32' or
'defined _ABIO32' because once <sgidefs.h> gets included, they are both defined!
It's better to test _MIPS_SIM.


2017-08-19 Bruno Haible <***@clisp.org>

host-cpu-c-abi: Improve detection of MIPS ABI.
* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI): For MIPS, test the value of
_MIPS_SIM.

diff --git a/m4/host-cpu-c-abi.m4 b/m4/host-cpu-c-abi.m4
index 01c5a66..02f7b8a 100644
--- a/m4/host-cpu-c-abi.m4
+++ b/m4/host-cpu-c-abi.m4
@@ -1,4 +1,4 @@
-# host-cpu-c-abi.m4 serial 6
+# host-cpu-c-abi.m4 serial 7
dnl Copyright (C) 2002-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -157,12 +157,12 @@ changequote([,])dnl
yes
#endif],
[gl_cv_host_cpu_c_abi=mips64],
- [# In the n32 ABI, _ABIN32 is defined, _ABIO32 is not defined, and
- # _MIPS_SIM == _ABIN32.
- # In the 32 ABI, _ABIO32 is defined, _ABIN32 is not defined, and
- # _MIPS_SIM == _ABIO32.
+ [# In the n32 ABI, _ABIN32 is defined, _ABIO32 is not defined (but
+ # may later get defined by <sgidefs.h>), and _MIPS_SIM == _ABIN32.
+ # In the 32 ABI, _ABIO32 is defined, _ABIN32 is not defined (but
+ # may later get defined by <sgidefs.h>), and _MIPS_SIM == _ABIO32.
AC_EGREP_CPP([yes],
- [#if defined _ABIN32
+ [#if (_MIPS_SIM == _ABIN32)
yes
#endif],
[gl_cv_host_cpu_c_abi=mipsn32],

Loading...