PR gdb/21070: Build fix for MIPS with musl libc

Message ID a0d26238-320e-aa4d-8f85-1fdb2ebd8863@att.net
State New, archived
Headers

Commit Message

Alexey Neyman Jan. 21, 2017, 6:12 a.m. UTC
  Hi,

This issue has been reported in crosstool-ng; the patch is from 
OpenEmbedded. Quoting the description from the patch:

[[[[
The MIPS specific header <sgidefs.h> is provided by glibc and uclibc
but not by musl. Regardless of the libc, the kernel headers provide
<asm/sgidefs.h> which provides the same definitions, so use that
instead.
]]]]

I am not the original developer, but the patch appears to be properly 
signed-off. I just edited the commit message to conform to submission 
guidelines.

Regards,
Alexey.
  

Comments

Simon Marchi Jan. 23, 2017, 3:31 p.m. UTC | #1
On 01/21/17 07:12, Alexey Neyman wrote:
> Hi,
>
> This issue has been reported in crosstool-ng; the patch is from 
> OpenEmbedded. Quoting the description from the patch:
>
> [[[[
> The MIPS specific header <sgidefs.h> is provided by glibc and uclibc
> but not by musl. Regardless of the libc, the kernel headers provide
> <asm/sgidefs.h> which provides the same definitions, so use that
> instead.
> ]]]]
>
> I am not the original developer, but the patch appears to be properly 
> signed-off. I just edited the commit message to conform to submission 
> guidelines.
>
> Regards,
> Alexey.
>
Hi Alexey and Andre,

This is the sgidefs.h from glibc:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mips/sgidefs.h;hb=HEAD

And this is asm/sgidefs.h from the kernel:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/mips/include/uapi/asm/sgidefs.h

I wonder what is the history about why the glibc version undoes 
everything the kernel version defines.  Today they seem very similar.  
However, tthere are some defines in the glibc on that are not in the 
kernel one.  In particular, _ABIO32 is not defined by the kernel but is 
used by GDB:

mips-linux-nat.c
456:  if (_MIPS_SIM == _ABIO32)

Does it cause a problem?

Simon
  
Maciej W. Rozycki Jan. 23, 2017, 6:45 p.m. UTC | #2
On Mon, 23 Jan 2017, Simon Marchi wrote:

> > This issue has been reported in crosstool-ng; the patch is from
> > OpenEmbedded. Quoting the description from the patch:
> > 
> > [[[[
> > The MIPS specific header <sgidefs.h> is provided by glibc and uclibc
> > but not by musl. Regardless of the libc, the kernel headers provide
> > <asm/sgidefs.h> which provides the same definitions, so use that
> > instead.
> > ]]]]

 It's a bug in musl then, the header is a part of the MIPS/Linux user API.  
OTOH <asm/sgidefs.h> is an internal kernel header and shouldn't really be 
used by user software.

> I wonder what is the history about why the glibc version undoes everything the
> kernel version defines.  Today they seem very similar.

 See: <https://www.sourceware.org/ml/libc-alpha/2004-11/msg00034.html> and
the thread that follows for a lengthy discussion.

>  However, tthere are
> some defines in the glibc on that are not in the kernel one.  In particular,
> _ABIO32 is not defined by the kernel but is used by GDB:
> 
> mips-linux-nat.c
> 456:  if (_MIPS_SIM == _ABIO32)
> 
> Does it cause a problem?

 Both _MIPS_SIM and _ABIO32 (if relevant) are defined by GCC, though the 
API is awkward.

  Maciej
  
Maciej W. Rozycki Jan. 31, 2017, 3:55 p.m. UTC | #3
On Mon, 23 Jan 2017, Maciej W. Rozycki wrote:

> > > This issue has been reported in crosstool-ng; the patch is from
> > > OpenEmbedded. Quoting the description from the patch:
> > > 
> > > [[[[
> > > The MIPS specific header <sgidefs.h> is provided by glibc and uclibc
> > > but not by musl. Regardless of the libc, the kernel headers provide
> > > <asm/sgidefs.h> which provides the same definitions, so use that
> > > instead.
> > > ]]]]
> 
>  It's a bug in musl then, the header is a part of the MIPS/Linux user API.  
> OTOH <asm/sgidefs.h> is an internal kernel header and shouldn't really be 
> used by user software.

 NB the published API set out by SGI is actually <sys/asm.h> [1][2][3] 
rather than <sgidefs.h>, so if musl does the right thing via the former 
header then I'll be happy to accept a patch to switch.  Otherwise I'll be 
closing the bug as invalid.

References:

[1] "MIPSpro Compiling and Performance Tuning Guide", Silicon Graphics, 
    Inc., Document Number 007-2360-008, Section 6.3.2 "Using Predefined 
    Types", p. 135
    <http://techpubs.sgi.com/library/manuals/2000/007-2360-008/pdf/007-2360-008.pdf>

[2] "MIPSpro 64-Bit Porting and Transition Guide", Silicon Graphics, Inc.,
    Document Number 007-2391-006, Section "Using a Different Subrouting 
    Linkage", p. 45
    <http://techpubs.sgi.com/library/manuals/2000/007-2391-006/pdf/007-2391-006.pdf>

[3] "MIPSpro N32 ABI Handbook", Silicon Graphics, Inc., Document Number 
    007-2816-004, Section "Using a Different Subroutine Linkage", p. 22
    <http://techpubs.sgi.com/library/manuals/2000/007-2816-004/pdf/007-2816-004.pdf>

  Maciej
  

Patch

From c1ca557f184a90961fb9ac114a7977b564bda6a0 Mon Sep 17 00:00:00 2001
From: Andre McCurdy <amccurdy@gmail.com>
Date: Sat, 30 Apr 2016 15:29:06 -0700
Subject: [PATCH] PR gdb/21070: Build fix for MIPS with musl libc

The MIPS specific header <sgidefs.h> is provided by glibc and uclibc
but not by musl. Regardless of the libc, the kernel headers provide
<asm/sgidefs.h> which provides the same definitions, so use that
instead.

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 gdb/mips-linux-nat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index 9d22773..0062c7e 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -31,7 +31,7 @@ 
 #include "gdb_proc_service.h"
 #include "gregset.h"
 
-#include <sgidefs.h>
+#include <asm/sgidefs.h>
 #include "nat/gdb_ptrace.h"
 #include <asm/ptrace.h>
 
-- 
2.9.3