[00/13] Fix various warnings when building on macOS

Message ID 20260817151646.152571-1-simon.marchi@efficios.com
Headers
Series Fix various warnings when building on macOS |

Message

Simon Marchi Aug. 17, 2026, 3:16 p.m. UTC
  I tried a build on macOS with the following configure flags (there is no
native configuration for macOS/AArch64, so I used an alternative target
to at least build the generic parts of GDB):

  --enable-targets=all --target=x86_64-pc-linux-gnu

This series fixes most of the build errors I encountered, mostly about
the uses of "dangerous" functions like sprintf.

There one patch in opcodes, which will require the approval from a
binutils maintainer.

There are 3 patches in sim, which will require the apprival from a sim
maintainer.

The rest is in GDB, and I would of course appreciate some reviews for
those too.

There are still some warnings about vfork being deprecated, like:

      CXX    cli/cli-cmds.o
    /Users/smarchi/src/binutils-gdb/gdb/cli/cli-cmds.c:917:9: error: 'vfork' is deprecated: Use posix_spawn or fork [-Werror,-Wdeprecated-declarations]
      917 |   pid = vfork ();
          |         ^

I have not fixed those, as it requires more thought about the
consequences of changing this on all supported platforms.

Simon Marchi (13):
  gdbsupport: remove uses of vsprintf
  gdbsupport: remove uses of sprintf
  opcodes/z80: remove use of sprintf
  sim/ppc: make defines.h sed command portable
  sim/m32r: fix unused variable warning on non-Linux hosts
  sim/m32r: fix unused function warnings on non-Linux hosts
  gdb/csky: remove uses of sprintf
  gdb/dwarf2: remove uses of sprintf
  gdb/elfread: remove use of sprintf
  gdbsupport: add xstrcpy
  gdb/remote-fileio: remove uses of sprintf
  gdb/remote: remove uses of sprintf
  gdb/tracepoint: remove uses of sprintf

 gdb/csky-tdep.c                        |  15 ++--
 gdb/dwarf2/read.c                      |   9 ++-
 gdb/elfread.c                          |  14 ++--
 gdb/fbsd-nat.c                         |   2 +-
 gdb/nat/netbsd-nat.c                   |   2 +-
 gdb/remote-fileio.c                    |  21 +++--
 gdb/remote.c                           | 103 +++++++++++++------------
 gdb/tracepoint.c                       |  25 ++++--
 gdb/unittests/common-utils-selftests.c |  29 +++++++
 gdbsupport/agent.cc                    |   2 +-
 gdbsupport/common-utils.cc             |  31 +++++---
 gdbsupport/common-utils.h              |   9 +++
 gdbsupport/ptid.cc                     |   4 +-
 gdbsupport/xml-utils.cc                |  35 +++++----
 opcodes/z80-dis.c                      |  52 ++++++++++++-
 sim/Makefile.in                        |   2 +-
 sim/m32r/traps.c                       |   8 +-
 sim/ppc/local.mk                       |   2 +-
 18 files changed, 247 insertions(+), 118 deletions(-)


base-commit: 0f9faaebc91bc1886a563bde6c178601b4be743b
  

Comments

Tom Tromey Aug. 17, 2026, 8:52 p.m. UTC | #1
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:

Simon> I tried a build on macOS with the following configure flags (there is no
Simon> native configuration for macOS/AArch64,

FWIW there was a port, but AFAIK we never heard back about copyright
assignment.

https://inbox.sourceware.org/gdb-patches/20251029200227.91464-1-canacar@imcan.dev/

Tom
  
Simon Marchi Aug. 18, 2026, 6:10 p.m. UTC | #2
On 8/17/26 11:16 AM, Simon Marchi wrote:
> I tried a build on macOS with the following configure flags (there is no
> native configuration for macOS/AArch64, so I used an alternative target
> to at least build the generic parts of GDB):
> 
>   --enable-targets=all --target=x86_64-pc-linux-gnu
> 
> This series fixes most of the build errors I encountered, mostly about
> the uses of "dangerous" functions like sprintf.
> 
> There one patch in opcodes, which will require the approval from a
> binutils maintainer.
> 
> There are 3 patches in sim, which will require the apprival from a sim
> maintainer.
> 
> The rest is in GDB, and I would of course appreciate some reviews for
> those too.
> 
> There are still some warnings about vfork being deprecated, like:
> 
>       CXX    cli/cli-cmds.o
>     /Users/smarchi/src/binutils-gdb/gdb/cli/cli-cmds.c:917:9: error: 'vfork' is deprecated: Use posix_spawn or fork [-Werror,-Wdeprecated-declarations]
>       917 |   pid = vfork ();
>           |         ^
> 
> I have not fixed those, as it requires more thought about the
> consequences of changing this on all supported platforms.

I pushed the patches that were Approved-By and that don't involve
xstrcpy, I will then work on addressing the comments on the rest.

Simon