Bug 27535 - amd64-linux-siginfo.c fails to compile after updating to glibc-2.33 headers
Summary: amd64-linux-siginfo.c fails to compile after updating to glibc-2.33 headers
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:25 UTC by Kevin Buettner
Modified: 2022-01-10 01:45 UTC (History)
41 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:25:09 UTC
GDB no longer builds after updating to glibc-2.33:

g++  -D_GLIBCXX_DEBUG -g3 -O0    -I. -I../../gdbserver -I../../gdbserver/../gdb/regformats -I../../gdbserver/.. -I../../gdbserver/../include -I../../gdbserver/../gdb -I../../gdbserver/../gnulib/import -I../gnulib/import -I../../gdbserver/.. -I..   -pthread -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-variable -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-error=maybe-uninitialized -Wno-mismatched-tags -Wsuggest-override -Wimplicit-fallthrough=3 -Wduplicated-cond -Wshadow=local -Wdeprecated-copy -Wdeprecated-copy-dtor -Wredundant-move -Wmissing-declarations -Wstrict-null-sentinel -Wformat -Wformat-nonliteral  -DGDBSERVER -E -o nat/amd64-linux-siginfo.i  ../../gdbserver/../gdb/nat/amd64-linux-siginfo.c
In file included from /usr/include/bits/sigstksz.h:24,
                 from /usr/include/signal.h:315,
                 from ../gnulib/import/signal.h:52,
                 from ../../gdbserver/../gdb/nat/amd64-linux-siginfo.c:20:
../gnulib/import/unistd.h:637:3: error: #error "Please include config.h first."
  637 |  #error "Please include config.h first."
      |   ^~~~~

The problem is actually gnulib related.  It turns out that the glibc headers now pull in <unistd.h> (from sigstksz.h, which is now included from signal.h). In the gdb build, this causes the gnulib version of unistd.h to be included, but gnulib's config.h had not been included first, which is the cause of the error.

A fix is already on the trunk:

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

I'm creating this PR so that it may be backported to gdb-10-branch.
Comment 1 Sourceware Commits 2021-03-06 17:58:33 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=aebc4aa2ece0363c16cab5a546df05220227ec31

commit aebc4aa2ece0363c16cab5a546df05220227ec31
Author: Kevin Buettner <kevinb@redhat.com>
Date:   Thu Feb 18 22:46:58 2021 -0700

    amd64-linux-siginfo.c: Adjust include order to avoid gnulib error
    
    On Fedora rawhide, after updating to glibc-2.33, I'm seeing the
    following build failure:
    
      CXX    nat/amd64-linux-siginfo.o
    In file included from /usr/include/bits/sigstksz.h:24,
                     from /usr/include/signal.h:315,
                     from ../gnulib/import/signal.h:52,
                     from /ironwood1/sourceware-git/rawhide-gnulib/bld/../../worktree-gnulib/gdbserver/../gdb/nat/amd64-linux-siginfo.c:20:
    ../gnulib/import/unistd.h:663:3: error: #error "Please include config.h first."
      663 |  #error "Please include config.h first."
          |   ^~~~~
    
    glibc-2.33 has changed signal.h to now include <bits/sigstksz.h> which,
    in turn, includes <unistd.h>. For a gdb build, this causes the gnulib
    version of unistd.h to be pulled in first.  The build failure shown
    above happens because gnulib's config.h has not been included before
    the include of <signal.h>.
    
    The fix is simple - we just rearrange the order of the header file
    includes to make sure that gdbsupport/commondefs.h is included before
    attempting to include signal.h.  Note that gdbsupport/commondefs.h
    includes <gnulib/config.h>.
    
    Build and regression tested on Fedora 33.  On Fedora rawhide, GDB
    builds again.
    
    gdb/ChangeLog:
    
            PR build/27535
            * nat/amd64-linux-siginfo.c: Include "gdbsupport/common-defs.h"
            (which in turn includes <gnulib/config.h>) before include
            of <signal.h>.
Comment 2 Kevin Buettner 2021-03-07 06:23:55 UTC
Commit from trunk has been backported to gdb-10-branch.
Comment 3 Ahmed Sayeed 2021-06-27 17:42:51 UTC Comment hidden (spam)
Comment 4 Lennor 2021-07-15 07:39:37 UTC Comment hidden (spam)
Comment 5 Lennor 2021-08-02 04:15:00 UTC Comment hidden (spam)
Comment 6 Ucel Sani 2021-08-19 06:01:57 UTC Comment hidden (spam)
Comment 7 james rohan 2021-09-02 11:07:07 UTC Comment hidden (spam)
Comment 8 james robin 2021-09-06 09:09:46 UTC Comment hidden (spam)
Comment 9 Mehmet gelisin 2021-09-10 19:39:35 UTC Comment hidden (spam)
Comment 10 richard.aidoo 2021-09-17 12:15:40 UTC Comment hidden (spam)
Comment 11 diheto 2021-09-22 10:11:17 UTC Comment hidden (spam)
Comment 12 Kylan 2021-09-26 13:31:33 UTC Comment hidden (spam)
Comment 13 seolab.backlinks 2021-09-29 15:45:01 UTC Comment hidden (spam)
Comment 14 Kas 2021-10-07 02:33:46 UTC Comment hidden (spam)
Comment 15 Gulsen Engin 2021-10-09 11:00:54 UTC Comment hidden (spam)
Comment 16 oficaj3 2021-10-10 16:11:43 UTC Comment hidden (spam)
Comment 17 progonsaytu 2021-10-19 07:13:51 UTC Comment hidden (spam)
Comment 18 fiteva 2021-10-23 13:47:13 UTC Comment hidden (spam)
Comment 19 glassmtech 2021-10-24 10:01:49 UTC Comment hidden (spam)
Comment 20 Johny Kim 2021-10-29 12:04:41 UTC Comment hidden (spam)
Comment 21 Jasmin 2021-10-30 09:28:16 UTC Comment hidden (spam)
Comment 22 Andrew Clous 2021-10-31 06:51:06 UTC Comment hidden (spam)
Comment 23 Jackson Peter 2021-11-01 14:08:16 UTC Comment hidden (spam)
Comment 24 Clarkson 2021-11-02 11:17:01 UTC Comment hidden (spam)
Comment 25 Tyler 2021-11-03 07:54:37 UTC Comment hidden (spam)
Comment 26 Audrey Smith 2021-11-04 09:22:46 UTC Comment hidden (spam)
Comment 27 Troy Jim 2021-11-05 14:19:32 UTC Comment hidden (spam)
Comment 28 bpbniche 2021-11-06 01:45:24 UTC Comment hidden (spam)
Comment 29 Johny Lee 2021-11-06 11:19:44 UTC Comment hidden (spam)
Comment 30 paneki 2021-11-06 21:12:54 UTC Comment hidden (spam)
Comment 31 Johny Lee 2021-11-07 12:00:46 UTC Comment hidden (spam)
Comment 32 Johny Lee 2021-11-07 12:10:57 UTC Comment hidden (spam)
Comment 33 Kobi 2021-11-08 08:29:03 UTC Comment hidden (spam)
Comment 34 Stewart 2021-11-09 11:46:47 UTC Comment hidden (spam)
Comment 35 Jones Chan 2021-11-11 14:14:51 UTC Comment hidden (spam)
Comment 36 Erwan 2021-11-12 11:42:10 UTC Comment hidden (spam)
Comment 37 raidoo8585 2021-11-13 17:49:48 UTC Comment hidden (spam)
Comment 38 bpbniche 2021-11-13 18:06:39 UTC Comment hidden (spam)
Comment 39 tesaso8237@funboxcn.com 2021-11-13 19:33:52 UTC Comment hidden (spam)
Comment 40 brickpavingcl 2021-11-14 03:45:44 UTC Comment hidden (spam)
Comment 41 tesaso8237@funboxcn.comxecana8007@funboxcn.com 2021-11-16 19:04:49 UTC Comment hidden (spam)
Comment 42 tesaso8237@funboxcn.comxecana8007@funboxcn.com 2021-11-16 19:08:27 UTC Comment hidden (spam)
Comment 43 tesaso8237@funboxcn.comxecana8007@funboxcn.com 2021-11-16 19:12:30 UTC Comment hidden (spam)
Comment 44 tesaso8237@funboxcn.comxecana8007@funboxcn.com 2021-11-16 19:15:54 UTC Comment hidden (spam)
Comment 45 gncbilgi 2021-11-19 06:39:34 UTC Comment hidden (spam)
Comment 46 zacmanken 2021-11-22 01:02:45 UTC Comment hidden (spam)
Comment 47 zacmanken 2021-11-22 01:04:27 UTC Comment hidden (spam)
Comment 48 gexed96894 2021-11-22 07:39:26 UTC Comment hidden (spam)
Comment 49 Nicolas 2021-11-24 10:33:23 UTC Comment hidden (spam)
Comment 50 bpbniche 2021-11-25 03:39:18 UTC Comment hidden (spam)
Comment 51 bpbniche 2022-01-10 01:45:06 UTC Comment hidden (spam)