amd64-linux-siginfo.c: Adjust include order to avoid gnulib error 82/294382/3 tizen_dev_8.3.1 accepted/tizen/unified/dev/20230726.115434
authorMarek Szulc <m.szulc3@samsung.com>
Fri, 16 Jun 2023 17:05:43 +0000 (19:05 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Mon, 19 Jun 2023 12:12:28 +0000 (14:12 +0200)
commitafe8f50f120da68ef4b90bb775e92ebc4b980d8f
tree5106806a1b003fca274430cf23c2a7fd80221afd
parentc007885c87db1dd30a5bcb0da2167468c7db861f
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>.

Change-Id: I6d5a1073f2b16b81b94bb2e8f897a943701a4744
Origin: upstream, https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aebc4aa2ece0363c16cab5a546df05220227ec31
Signed-off-by: Marek Szulc <m.szulc3@samsung.com>
gdb/nat/amd64-linux-siginfo.c