Bug 27536 - aarch64-linux-hw-point.c fails to compile after updating to glibc-2.33
Summary: aarch64-linux-hw-point.c fails to compile after updating to glibc-2.33
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: build (show other bugs)
Version: 10.1
: P2 critical
Target Milestone: 10.2
Assignee: Kevin Buettner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-06 16:35 UTC by Kevin Buettner
Modified: 2021-11-13 19:34 UTC (History)
16 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Buettner 2021-03-06 16:35:20 UTC
GDB no longer builds on aarch64 (native build) after updating to glibc-2.33.

Due to a glibc 2.33 header file change, the file
nat/aarch64-linux-hw-point.c no longer builds on OSes using this version of glibc.

An enum for PTRACE_SYSEMU is now provided by <sys/ptrace.h>.  In the
past, PTRACE_SYSEMU was defined only in <asm/ptrace.h>.  This is
what it looks like...

In <asm/ptrace.h>:

#define PTRACE_SYSEMU		  31

In <sys/ptrace.h>:

enum __ptrace_request
{
  ...
  PTRACE_SYSEMU = 31,
#define PT_SYSEMU PTRACE_SYSEMU

  ...
}

When <asm/ptrace.h> and <sys/ptrace.h> are both included in a source
file, we run into the following build problem when the former is
included before the latter:

In file included from nat/aarch64-linux-hw-point.c:26:
/usr/include/sys/ptrace.h:86:3: error: expected identifier before numeric constant
   86 |   PTRACE_SYSEMU = 31,
      |   ^~~~~~~~~~~~~

(There are more errors after this one too.)

The file builds without error when <asm/ptrace.h> is included after
<sys/ptrace.h>.  I found that this is already done in
nat/aarch64-sve-linux-ptrace.h (which is included by
nat/aarch64-linux-ptrace.c).

A commit for this bug is already on the trunk:

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=665af52ec2a52184d39a76d6e724fa4733dbab3c

I'm creating this PR so that it may be backported to gdb-10-branch.
Comment 1 Sourceware Commits 2021-03-06 17:58:39 UTC
The gdb-10-branch branch has been updated by Kevin Buettner <kevinb@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4cacb6939378ef824b37140886e7ea31c33f14c3

commit 4cacb6939378ef824b37140886e7ea31c33f14c3
Author: Kevin Buettner <kevinb@redhat.com>
Date:   Wed Feb 24 11:48:04 2021 -0700

    Fix aarch64-linux-hw-point.c build problem
    
    Due to a recent glibc header file change, the file
    nat/aarch64-linux-hw-point.c no longer builds on Fedora rawhide.
    
    An enum for PTRACE_SYSEMU is now provided by <sys/ptrace.h>.  In the
    past, PTRACE_SYSEMU was defined only in <asm/ptrace.h>.  This is
    what it looks like...
    
    In <asm/ptrace.h>:
    
     #define PTRACE_SYSEMU            31
    
    In <sys/ptrace.h>:
    
    enum __ptrace_request
    {
      ...
      PTRACE_SYSEMU = 31,
     #define PT_SYSEMU PTRACE_SYSEMU
    
      ...
    }
    
    When <asm/ptrace.h> and <sys/ptrace.h> are both included in a source
    file, we run into the following build problem when the former is
    included before the latter:
    
    In file included from nat/aarch64-linux-hw-point.c:26:
    /usr/include/sys/ptrace.h:86:3: error: expected identifier before numeric constant
       86 |   PTRACE_SYSEMU = 31,
          |   ^~~~~~~~~~~~~
    
    (There are more errors after this one too.)
    
    The file builds without error when <asm/ptrace.h> is included after
    <sys/ptrace.h>.  I found that this is already done in
    nat/aarch64-sve-linux-ptrace.h (which is included by
    nat/aarch64-linux-ptrace.c).
    
    I've tested this change on Fedora rawhide and Fedora 33, both
    running on an aarch64 machine.
    
    gdb/ChangeLog:
    
            PR build/27536
            * nat/aarch64-linux-hw-point.c: Include <asm/ptrace.h> after
            <sys/ptrace.h>.
Comment 2 Kevin Buettner 2021-03-07 06:25:13 UTC
Commit from trunk has been backported to gdb-10-branch.
Comment 3 Ahmed Sayeed 2021-06-27 17:45:25 UTC Comment hidden (spam)
Comment 4 james rohan 2021-09-02 11:06:30 UTC Comment hidden (spam)
Comment 5 Kim Olsun 2021-09-05 07:34:38 UTC Comment hidden (spam)
Comment 6 james robin 2021-09-06 09:08:49 UTC Comment hidden (spam)
Comment 7 Mehmet gelisin 2021-09-10 19:38:21 UTC Comment hidden (spam)
Comment 8 diheto 2021-09-22 10:19:43 UTC Comment hidden (spam)
Comment 9 Kylan 2021-09-26 13:31:32 UTC Comment hidden (spam)
Comment 10 Gulsen Engin 2021-10-09 11:01:01 UTC Comment hidden (spam)
Comment 11 svitvitraga 2021-10-09 17:43:33 UTC Comment hidden (spam)
Comment 12 Canerkin 2021-10-18 19:57:58 UTC Comment hidden (spam)
Comment 13 progonsaytu 2021-10-19 07:13:46 UTC Comment hidden (spam)
Comment 14 glassmtech 2021-10-24 10:01:45 UTC Comment hidden (spam)
Comment 15 tesaso8237@funboxcn.com 2021-11-13 19:34:02 UTC Comment hidden (spam)