[V3] gdb: sim: buildsystem changes to accommodate libsframe

Message ID 20221027182241.3350381-1-indu.bhagat@oracle.com
State New
Headers
Series [V3] gdb: sim: buildsystem changes to accommodate libsframe |

Commit Message

Indu Bhagat Oct. 27, 2022, 6:22 p.m. UTC
  (Intended to send the complete patch but sent the V3-V2 diff by mistake.
 Sending the complete V3 patch.)

[Changes in V3]
  - Added buildsystem changes to sim/ppc/Makefile.in to ensure
    --enable-targets=all does not fail.
[End of changes in V3]

Both gdb and sim need buildsystem fixes to now include libsframe for a
successful build.

Version 2 of the SFrame support patches were posted here
https://sourceware.org/pipermail/binutils/2022-October/123641.html
and approved earlier
https://sourceware.org/pipermail/binutils/2022-October/123810.html

The gdb/ and sim/common/ bits that were posted earlier are here:
https://sourceware.org/pipermail/binutils/2022-October/123650.html
and approved here
https://sourceware.org/pipermail/binutils/2022-October/123500.html

As there is a new diff from V2 (in sim/ppc/Makefile.in), please
review it and let me know.

Thanks
---
 gdb/Makefile.in           |  8 ++++++--
 gdb/acinclude.m4          |  4 ++--
 gdb/configure             | 35 +++++++++++++++++++++++++++++++----
 gdb/configure.ac          | 11 +++++++++++
 sim/common/Make-common.in |  7 +++++--
 sim/ppc/Makefile.in       |  5 +++--
 6 files changed, 58 insertions(+), 12 deletions(-)
 mode change 100755 => 100644 gdb/configure
  

Patch

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index c528ee5aa80..492e08d6c63 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -161,6 +161,10 @@  LIBIBERTY = ../libiberty/libiberty.a
 LIBCTF = @LIBCTF@
 CTF_DEPS = @CTF_DEPS@
 
+# Where is the SFrame library?  Typically in ../libsframe.
+LIBSFRAME = @LIBSFRAME@
+SFRAME_DEPS = @SFRAME_DEPS@
+
 # Where is the BFD library?  Typically in ../bfd.
 BFD_DIR = ../bfd
 BFD = $(BFD_DIR)/libbfd.a
@@ -650,7 +654,7 @@  INTERNAL_LDFLAGS = \
 # Libraries and corresponding dependencies for compiling gdb.
 # XM_CLIBS, defined in *config files, have host-dependent libs.
 # LIBIBERTY appears twice on purpose.
-CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) $(ZSTD_LIBS) \
+CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(LIBSFRAME) $(ZLIB) $(ZSTD_LIBS) \
         $(LIBSUPPORT) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
 	$(XM_CLIBS) $(GDBTKLIBS)  $(LIBBACKTRACE_LIB) \
 	@LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
@@ -658,7 +662,7 @@  CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) $(ZSTD_LIBS) \
 	$(WIN32LIBS) $(LIBGNU) $(LIBGNU_EXTRA_LIBS) $(LIBICONV) \
 	$(LIBMPFR) $(LIBGMP) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \
 	$(DEBUGINFOD_LIBS) $(LIBBABELTRACE_LIB)
-CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(CTF_DEPS) \
+CDEPS = $(NAT_CDEPS) $(SIM) $(SFRAME_DEPS) $(BFD) $(READLINE_DEPS) $(CTF_DEPS) \
 	$(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) \
 	$(LIBSUPPORT)
 
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 62fa66c7af3..8bbc5f0739e 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -234,9 +234,9 @@  AC_DEFUN([GDB_AC_CHECK_BFD], [
   # always want our bfd.
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
-  LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
+  LDFLAGS="-L../bfd -L../libiberty -L../libsframe/.libs/ $ZLIBDIR $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS"
+  LIBS="-lbfd -liberty -lz -lsframe $ZSTD_LIBS $intl $LIBS"
   AC_CACHE_CHECK(
     [$1],
     [$2],
diff --git a/gdb/configure b/gdb/configure
old mode 100755
new mode 100644
index 33677262783..81afd5edac8
--- a/gdb/configure
+++ b/gdb/configure
@@ -631,6 +631,8 @@  GDB_NM_FILE
 LTLIBXXHASH
 LIBXXHASH
 HAVE_LIBXXHASH
+SFRAME_DEPS
+LIBSFRAME
 CTF_DEPS
 LIBCTF
 LTLIBBABELTRACE
@@ -939,6 +941,7 @@  with_libbabeltrace_prefix
 with_libbabeltrace_type
 with_xxhash
 enable_libctf
+enable_libsframe
 with_libxxhash_prefix
 with_libxxhash_type
 enable_unit_tests
@@ -1617,6 +1620,7 @@  Optional Features:
   --enable-libbacktrace   use libbacktrace to write a backtrace after a fatal
                           signal.
   --enable-libctf         Handle .ctf type-info sections [default=yes]
+  --enable-libsframe      Handle .sframe sections [default=yes]
   --enable-unit-tests     Enable the inclusion of unit tests when compiling
                           GDB
 
@@ -17412,9 +17416,9 @@  WIN32LIBS="$WIN32LIBS $WIN32APILIBS"
   # always want our bfd.
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
-  LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
+  LDFLAGS="-L../bfd -L../libiberty -L../libsframe/.libs/ $ZLIBDIR $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS"
+  LIBS="-lbfd -liberty -lz -lsframe $ZSTD_LIBS $intl $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF support in BFD" >&5
 $as_echo_n "checking for ELF support in BFD... " >&6; }
 if ${gdb_cv_var_elf+:} false; then :
@@ -17527,9 +17531,9 @@  fi
   # always want our bfd.
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
-  LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
+  LDFLAGS="-L../bfd -L../libiberty -L../libsframe/.libs/ $ZLIBDIR $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS"
+  LIBS="-lbfd -liberty -lz -lsframe $ZSTD_LIBS $intl $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mach-O support in BFD" >&5
 $as_echo_n "checking for Mach-O support in BFD... " >&6; }
 if ${gdb_cv_var_macho+:} false; then :
@@ -19498,6 +19502,29 @@  fi
 
 
 
+ # Check whether --enable-libsframe was given.
+if test "${enable_libsframe+set}" = set; then :
+  enableval=$enable_libsframe;
+      case "$enableval" in
+       yes|no) ;;
+       *) as_fn_error $? "Argument to enable/disable libsframe must be yes or no" "$LINENO" 5 ;;
+      esac
+
+else
+  enable_libsframe=yes
+fi
+
+
+if test x${enable_static} = xno; then
+  LIBSFRAME="-Wl,--rpath,../libsframe/.libs ../libsframe/.libs/libsframe.so"
+  SFRAME_DEPS="../libsframe/.libs/libsframe.so"
+else
+  LIBSFRAME="../libsframe/.libs/libsframe.a"
+  SFRAME_DEPS="$LIBSFRAME"
+fi
+
+
+
 # If nativefile (NAT_FILE) is not set in configure.nat, we link to an
 # empty version.
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index fceb80e8c9d..c302e58b4bf 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2167,6 +2167,17 @@  fi
 AC_SUBST(LIBCTF)
 AC_SUBST(CTF_DEPS)
 
+GCC_ENABLE([libsframe], [yes], [], [Handle .sframe sections])
+if test x${enable_static} = xno; then
+  LIBSFRAME="-Wl,--rpath,../libsframe/.libs ../libsframe/.libs/libsframe.so"
+  SFRAME_DEPS="../libsframe/.libs/libsframe.so"
+else
+  LIBSFRAME="../libsframe/.libs/libsframe.a"
+  SFRAME_DEPS="$LIBSFRAME"
+fi
+AC_SUBST(LIBSFRAME)
+AC_SUBST(SFRAME_DEPS)
+
 # If nativefile (NAT_FILE) is not set in configure.nat, we link to an
 # empty version.
 
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index b07ec96e147..8a49e0b4ef2 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -222,11 +222,14 @@  SIM_HW_DEVICES = cfi core pal glue $(SIM_EXTRA_HW_DEVICES)
 ZLIB = $(zlibdir) -lz
 LIBIBERTY_LIB = ../../libiberty/libiberty.a
 BFD_LIB = ../../bfd/libbfd.a
+LIBSFRAME_LIB = ../../libsframe/.libs/libsframe.a
 OPCODES_LIB = ../../opcodes/libopcodes.a
 CONFIG_LIBS = $(COMMON_LIBS) @LIBS@ $(ZLIB) $(ZSTD_LIBS)
-LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL_DEP) $(LIBIBERTY_LIB)
+LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL_DEP) $(LIBIBERTY_LIB) \
+	  $(LIBSFRAME_LIB)
 EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL) $(LIBIBERTY_LIB) \
-	$(CONFIG_LIBS) $(SIM_EXTRA_LIBS) $(LIBDL) $(LIBGNU) $(LIBGNU_EXTRA_LIBS)
+	     $(LIBSFRAME_LIB) $(CONFIG_LIBS) $(SIM_EXTRA_LIBS) \
+	     $(LIBDL) $(LIBGNU) $(LIBGNU_EXTRA_LIBS)
 
 COMMON_OBJS_NAMES = \
 	callback.o \
diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in
index b0c073b8867..12123d36a66 100644
--- a/sim/ppc/Makefile.in
+++ b/sim/ppc/Makefile.in
@@ -133,6 +133,7 @@  INCLUDES	= -I. -I$(srcdir) $(LIB_INCLUDES) $(BFD_INCLUDES) $(GDB_INCLUDES) -I../
 
 LIBIBERTY_LIB	= ../../libiberty/libiberty.a
 BFD_LIB		= ../../bfd/libbfd.a
+SFRAME_LIB	= ../../libsframe/.libs/libsframe.a
 ZLIB		= $(zlibdir) -lz
 
 
@@ -521,8 +522,8 @@  PACKAGE_SRC = @sim_pk_src@
 PACKAGE_OBJ = @sim_pk_obj@
 
 
-psim$(EXEEXT): $(TARGETLIB) main.o $(LIBIBERTY_LIB) $(BFD_LIB) $(LIBINTL_DEP)
-	$(ECHO_CCLD) $(CC) $(CFLAGS) $(LDFLAGS) -o psim$(EXEEXT) main.o $(TARGETLIB) $(BFD_LIB) $(ZLIB) $(ZSTD_LIBS) $(LIBINTL) $(LIBIBERTY_LIB) $(LIBS)
+psim$(EXEEXT): $(TARGETLIB) main.o $(LIBIBERTY_LIB) $(BFD_LIB) $(SFRAME_LIB) $(LIBINTL_DEP)
+	$(ECHO_CCLD) $(CC) $(CFLAGS) $(LDFLAGS) -o psim$(EXEEXT) main.o $(TARGETLIB) $(BFD_LIB) $(SFRAME_LIB) $(ZLIB) $(ZSTD_LIBS) $(LIBINTL) $(LIBIBERTY_LIB) $(LIBS)
 
 run$(EXEEXT): psim$(EXEEXT)
 	$(SILENCE) rm -f $@