Bug 30214 - GDB 13.1 does not compile on FreeBSD 13.1
Summary: GDB 13.1 does not compile on FreeBSD 13.1
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 13.1
: P2 normal
Target Milestone: 13.2
Assignee: jhb
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-09 03:19 UTC by Chris Johns
Modified: 2023-03-10 20:10 UTC (History)
3 users (show)

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


Attachments
FreeBSD 13 include path fix (337 bytes, patch)
2023-03-09 03:19 UTC, Chris Johns
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Johns 2023-03-09 03:19:10 UTC
Created attachment 14742 [details]
FreeBSD 13 include path fix

If the binutils package is install GDB 13.1 does not compile when building an ARM GDB for RTEMS. The error is:

 In file included from ../../gdb-13.1/gdb/xml-tdesc.c:23:
 In file included from ../../gdb-13.1/gdb/target.h:42:
 In file included from ../../gdb-13.1/gdb/infrun.h:21:
 In file included from ../../gdb-13.1/gdb/gdbthread.h:26:
 In file included from ../../gdb-13.1/gdb/breakpoint.h:38:
 ../../gdb-13.1/gdb/target/waitstatus.h:113:1: error: use of undeclared
 identifier 'DIAGNOSTIC_ERROR_SWITCH'
 DIAGNOSTIC_ERROR_SWITCH
 ^

The binutils package is:

 $ pkg which /usr/local/include/diagnostics.h
 /usr/local/include/diagnostics.h was installed by package binutils-2.37_2,1

The attached patch from John resolved the problem.
Comment 1 Tom Tromey 2023-03-09 03:24:57 UTC
(In reply to Chris Johns from comment #0)

>  /usr/local/include/diagnostics.h was installed by package binutils-2.37_2,1

Installing these things always seemed like a mistake to me :{
 
> The attached patch from John resolved the problem.

Seems fine, what is John's last name + some email addr for attribution in git?
Comment 2 Mark Wielaard 2023-03-09 08:40:00 UTC
(In reply to Tom Tromey from comment #1)
> (In reply to Chris Johns from comment #0)
> > The attached patch from John resolved the problem.
> 
> Seems fine, what is John's last name + some email addr for attribution in
> git?

John Baldwin <jhb@FreeBSD.org>
https://inbox.sourceware.org/gdb/70b50c1d-29bf-2c5c-2dbb-c2ed7dc55ab2@FreeBSD.org/
Comment 3 Chris Johns 2023-03-09 21:57:13 UTC
Mark, thanks for providing the needed details and Tom I am sorry I should have provided more context in the report.

Is there anything further I need to do to help?
Comment 4 Tom Tromey 2023-03-10 14:40:25 UTC
(In reply to Chris Johns from comment #3)
> Mark, thanks for providing the needed details and Tom I am sorry I should
> have provided more context in the report.

No problem.
 
> Is there anything further I need to do to help?

Nope.
Comment 5 Sourceware Commits 2023-03-10 20:05:26 UTC
The master branch has been updated by John Baldwin <jhb@sourceware.org>:

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

commit a2fbb6903889c8fe32f4f3b890ef4b8c565d6b84
Author: John Baldwin <jhb@FreeBSD.org>
Date:   Fri Mar 10 12:01:40 2023 -0800

    PR gdb/30214: Prefer local include paths to system include paths
    
    Some systems may install binutils headers into a system location
    (e.g. /usr/local/include on FreeBSD) which may also include headers
    for other external packages used by GDB such as zlib or zstd.  If a
    system include path such as /usr/local/include is added before local
    include paths to directories within a clone or release tarball, then
    headers from the external binutils package are used which can result
    in build failures if the external binutils package is out of sync with
    the version of GDB being built.
    
    To fix, sort the include paths in INTERNAL_CFLAGS_BASE to add CFLAGS
    for "local" componenets before external components.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30214
    Reviewed-By: Tom Tromey <tom@tromey.com>
Comment 6 Sourceware Commits 2023-03-10 20:09:22 UTC
The gdb-13-branch branch has been updated by John Baldwin <jhb@sourceware.org>:

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

commit a980a7d24b9ab416a70880182d4e6b4975967d38
Author: John Baldwin <jhb@FreeBSD.org>
Date:   Fri Mar 10 12:01:40 2023 -0800

    PR gdb/30214: Prefer local include paths to system include paths
    
    Some systems may install binutils headers into a system location
    (e.g. /usr/local/include on FreeBSD) which may also include headers
    for other external packages used by GDB such as zlib or zstd.  If a
    system include path such as /usr/local/include is added before local
    include paths to directories within a clone or release tarball, then
    headers from the external binutils package are used which can result
    in build failures if the external binutils package is out of sync with
    the version of GDB being built.
    
    To fix, sort the include paths in INTERNAL_CFLAGS_BASE to add CFLAGS
    for "local" componenets before external components.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30214
    Reviewed-By: Tom Tromey <tom@tromey.com>
    (cherry picked from commit a2fbb6903889c8fe32f4f3b890ef4b8c565d6b84)
Comment 7 jhb 2023-03-10 20:10:42 UTC
Fix merged to master and gdb-13-branch.