Add --enable-codesign to gdb's configure

macOS requires that the gdb executable be signed in order to be able
to successfully use ptrace.  This must be done after each link.

This patch adds a new --enable-codesign configure option so that this
step can be automated.

gdb/ChangeLog
2018-06-28  Tom Tromey  <tom@tromey.com>

	* NEWS: Mention --enable-codesign.
	* silent-rules.mk (ECHO_SIGN): New variable.
	* configure.ac: Add --enable-codesign.
	* configure: Rebuild.
	* Makefile.in (CODESIGN, CODESIGN_CERT): New variables.
	(gdb$(EXEEXT)): Optionally invoke codesign.
This commit is contained in:
Tom Tromey 2018-06-28 10:32:13 -06:00
parent f2ffa92bbc
commit 44cee4fdf4
6 changed files with 42 additions and 0 deletions

View File

@ -1,3 +1,12 @@
2018-06-28 Tom Tromey <tom@tromey.com>
* NEWS: Mention --enable-codesign.
* silent-rules.mk (ECHO_SIGN): New variable.
* configure.ac: Add --enable-codesign.
* configure: Rebuild.
* Makefile.in (CODESIGN, CODESIGN_CERT): New variables.
(gdb$(EXEEXT)): Optionally invoke codesign.
2018-06-28 Pedro Alves <palves@redhat.com> 2018-06-28 Pedro Alves <palves@redhat.com>
* gdbthread.h (struct thread_suspend_state) <stop_pc>: Extend * gdbthread.h (struct thread_suspend_state) <stop_pc>: Extend

View File

@ -222,6 +222,10 @@ LIBICONV = @LIBICONV@
# Did the user give us a --with-gdb-datadir option? # Did the user give us a --with-gdb-datadir option?
GDB_DATADIR = @GDB_DATADIR@ GDB_DATADIR = @GDB_DATADIR@
# Code signing.
CODESIGN = codesign
CODESIGN_CERT = @CODESIGN_CERT@
# Flags to pass to gdb when invoked with "make run". # Flags to pass to gdb when invoked with "make run".
GDBFLAGS = GDBFLAGS =
@ -1916,6 +1920,9 @@ gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
$(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \ $(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
-o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \ -o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \
$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES) $(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
ifneq ($(CODESIGN_CERT),)
$(ECHO_SIGN) $(CODESIGN) -s $(CODESIGN_CERT) gdb$(EXEEXT)
endif
# Convenience rule to handle recursion. # Convenience rule to handle recursion.
$(LIBGNU) $(GNULIB_H): all-lib $(LIBGNU) $(GNULIB_H): all-lib

View File

@ -94,6 +94,13 @@ SH-5/SH64 running OpenBSD SH-5/SH64 support in sh*-*-openbsd*
the tradeoff that there is a possibility of false hits being the tradeoff that there is a possibility of false hits being
reported. reported.
* New configure options
--enable-codesign=CERT
This can be used to invoke "codesign -s CERT" after building gdb.
This option is useful on macOS, where code signing is required for
gdb to work properly.
*** Changes in GDB 8.1 *** Changes in GDB 8.1
* GDB now supports dynamically creating arbitrary register groups specified * GDB now supports dynamically creating arbitrary register groups specified

11
gdb/configure vendored
View File

@ -745,6 +745,7 @@ AWK
REPORT_BUGS_TEXI REPORT_BUGS_TEXI
REPORT_BUGS_TO REPORT_BUGS_TO
PKGVERSION PKGVERSION
CODESIGN_CERT
HAVE_NATIVE_GCORE_TARGET HAVE_NATIVE_GCORE_TARGET
TARGET_OBS TARGET_OBS
subdirs subdirs
@ -861,6 +862,7 @@ enable_gdbtk
with_libunwind_ia64 with_libunwind_ia64
with_curses with_curses
enable_profiling enable_profiling
enable_codesign
with_pkgversion with_pkgversion
with_bugurl with_bugurl
with_system_zlib with_system_zlib
@ -1550,6 +1552,7 @@ Optional Features:
--enable-tui enable full-screen terminal user interface (TUI) --enable-tui enable full-screen terminal user interface (TUI)
--enable-gdbtk enable gdbtk graphical user interface (GUI) --enable-gdbtk enable gdbtk graphical user interface (GUI)
--enable-profiling enable profiling of GDB --enable-profiling enable profiling of GDB
--enable-codesign=CERT sign gdb with 'codesign -s CERT'
--disable-rpath do not hardcode runtime library paths --disable-rpath do not hardcode runtime library paths
--enable-libmcheck Try linking with -lmcheck if available --enable-libmcheck Try linking with -lmcheck if available
--enable-werror treat compile warnings as errors --enable-werror treat compile warnings as errors
@ -7050,6 +7053,14 @@ $as_echo "$ac_cv_cc_supports_pg" >&6; }
CFLAGS="$OLD_CFLAGS" CFLAGS="$OLD_CFLAGS"
fi fi
CODESIGN_CERT=
# Check whether --enable-codesign was given.
if test "${enable_codesign+set}" = set; then :
enableval=$enable_codesign; CODESIGN_CERT=$enableval
fi
# Check whether --with-pkgversion was given. # Check whether --with-pkgversion was given.

View File

@ -471,6 +471,13 @@ if test "$enable_profiling" = yes ; then
CFLAGS="$OLD_CFLAGS" CFLAGS="$OLD_CFLAGS"
fi fi
CODESIGN_CERT=
AC_ARG_ENABLE([codesign],
AS_HELP_STRING([--enable-codesign=CERT],
[sign gdb with 'codesign -s CERT']),
[CODESIGN_CERT=$enableval])
AC_SUBST([CODESIGN_CERT])
ACX_PKGVERSION([GDB]) ACX_PKGVERSION([GDB])
ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/]) ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description]) AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])

View File

@ -10,5 +10,6 @@ ECHO_GEN_XML_BUILTIN = \
ECHO_GEN_XML_BUILTIN_GENERATED = \ ECHO_GEN_XML_BUILTIN_GENERATED = \
@echo " GEN xml-builtin-generated.c"; @echo " GEN xml-builtin-generated.c";
ECHO_INIT_C = echo " GEN init.c" || ECHO_INIT_C = echo " GEN init.c" ||
ECHO_SIGN = @echo " SIGN gdb";
SILENCE = @ SILENCE = @
endif endif