Fix --enable-libctf and --disable-static
authorNick Alcock <nick.alcock@oracle.com>
Wed, 9 Oct 2019 09:42:00 +0000 (10:42 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 26 Jun 2020 14:56:38 +0000 (15:56 +0100)
This fixes test runs and compilation when --disable-libctf,
--disable-static, or --enable-shared are passed.

Changes since v2: Use GCC_ENABLE and fix indentation.  Fix prototype
using 'void'.  Use 'unsupported' and gdb_caching_proc.

Changes since v3: Adapt to upstream changes providing skip_ctf_tests.

Changes since v4: Adapt to upstream changes in the seven months (!)
since I last looked at this.

gdb/ChangeLog
* configure.ac: Add --enable-libctf: handle --disable-static
properly.
* acinclude.m4: sinclude ../config/enable.m4.
* Makefile.in (aclocal_m4_deps): Adjust accordingly.
(LIBCTF): Substitute in.
(CTF_DEPS): New, likewise.
(CLIBS): libctf needs symbols from libbfd: move earlier.
(CDEPS): Use CTF_DEPS, not LIBCTF, now LIBCTF can include rpath
flags.
* ctfread.c: Surround in ENABLE_LIBCTF.
(elfctf_build_psymtabs) [!ENABLE_LIBCTF]: New stub.
* configure: Regenerate.
* config.in: Likewise.

gdb/testsuite/ChangeLog
* configure.ac: Add --enable-libctf.
* aclocal.m4: sinclude ../config/enable.m4.
* Makefile.in (site.exp): Add enable_libctf to site.exp.
* lib/gdb.exp (skip_ctf_tests): Use it.
* gdb.base/ctf-constvars.exp: Error message tweak.
* gdb.base/ctf-ptype.exp: Likewise.
* configure: Regenerate.

15 files changed:
gdb/ChangeLog
gdb/Makefile.in
gdb/acinclude.m4
gdb/config.in
gdb/configure
gdb/configure.ac
gdb/ctfread.c
gdb/testsuite/ChangeLog
gdb/testsuite/Makefile.in
gdb/testsuite/aclocal.m4
gdb/testsuite/configure
gdb/testsuite/configure.ac
gdb/testsuite/gdb.base/ctf-constvars.exp
gdb/testsuite/gdb.base/ctf-ptype.exp
gdb/testsuite/lib/gdb.exp

index ddb5c47d1e75479e8953b9b8781925c8ab56c797..d09d316f76602b021a25a1cf2b824e5585ba27e0 100644 (file)
@@ -1,3 +1,19 @@
+2020-06-26  Nick Alcock  <nick.alcock@oracle.com>
+
+       * configure.ac: Add --enable-libctf: handle --disable-static
+       properly.
+       * acinclude.m4: sinclude ../config/enable.m4.
+       * Makefile.in (aclocal_m4_deps): Adjust accordingly.
+       (LIBCTF): Substitute in.
+       (CTF_DEPS): New, likewise.
+       (CLIBS): libctf needs symbols from libbfd: move earlier.
+       (CDEPS): Use CTF_DEPS, not LIBCTF, now LIBCTF can include rpath
+       flags.
+       * ctfread.c: Surround in ENABLE_LIBCTF.
+       (elfctf_build_psymtabs) [!ENABLE_LIBCTF]: New stub.
+       * configure: Regenerate.
+       * config.in: Likewise.
+
 2020-06-25  Simon Marchi  <simon.marchi@efficios.com>
 
        * infcmd.c (set_inferior_io_terminal): Use make_unique_xstrdup.
index 32d0eee7c6376d0f82aa671560a8cc9ed55c2a3e..9ae9fe2d1e146611325806283e78025d488458e3 100644 (file)
@@ -154,7 +154,8 @@ INCLUDE_CFLAGS = -I$(INCLUDE_DIR)
 LIBIBERTY = ../libiberty/libiberty.a
 
 # Where is the CTF library?  Typically in ../libctf.
-LIBCTF = ../libctf/.libs/libctf.a
+LIBCTF = @LIBCTF@
+CTF_DEPS = @CTF_DEPS@
 
 # Where is the BFD library?  Typically in ../bfd.
 BFD_DIR = ../bfd
@@ -614,7 +615,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) $(BFD) $(LIBCTF) $(ZLIB) \
+CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) \
         $(LIBSUPPORT) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
        $(XM_CLIBS) $(GDBTKLIBS) \
        @LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
@@ -622,7 +623,7 @@ CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(LIBCTF) $(ZLIB) \
        $(WIN32LIBS) $(LIBGNU) $(LIBICONV) \
        $(LIBMPFR) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \
        @LIBDEBUGINFOD@
-CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(LIBCTF) \
+CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(CTF_DEPS) \
        $(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) \
        $(LIBSUPPORT)
 
@@ -2006,6 +2007,7 @@ aclocal_m4_deps = \
        transform.m4 \
        ../bfd/bfd.m4 \
        ../config/acinclude.m4 \
+       ../config/enable.m4 \
        ../config/plugins.m4 \
        ../config/lead-dot.m4 \
        ../config/override.m4 \
index 852a71c3f18b4a5eced5481ddd5c7fa088f21259..6fbc88bb55cd3e28aca9c012ec34cc6ba7db4ec0 100644 (file)
@@ -24,6 +24,9 @@ m4_include(../bfd/bfd.m4)
 dnl This gets the standard macros.
 m4_include(../config/acinclude.m4)
 
+dnl This gets GCC_ENABLE.
+sinclude(../config/enable.m4)
+
 dnl This gets AC_PLUGINS, needed by ACX_LARGEFILE.
 m4_include(../config/plugins.m4)
 
index d950515e513aaf9d57f44b91ed918f9d05cbf337..340c421ca031d927a7784252ea717f68d3dd5261 100644 (file)
@@ -36,6 +36,9 @@
 /* Define to BFD's default target vector. */
 #undef DEFAULT_BFD_VEC
 
+/* Handle .ctf type-info sections */
+#undef ENABLE_LIBCTF
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
index ef10aa717fa583667871a3c234d6b7a1327e45ed..e8bfdbc70996b3867978eeed04d150c3301aa107 100755 (executable)
@@ -631,6 +631,9 @@ GDB_NM_FILE
 LTLIBXXHASH
 LIBXXHASH
 HAVE_LIBXXHASH
+CTF_DEPS
+LIBCTF
+ENABLE_LIBCTF
 LTLIBBABELTRACE
 LIBBABELTRACE
 HAVE_LIBBABELTRACE
@@ -917,6 +920,7 @@ with_babeltrace
 with_libbabeltrace_prefix
 with_libbabeltrace_type
 with_xxhash
+enable_libctf
 with_libxxhash_prefix
 with_libxxhash_type
 enable_unit_tests
@@ -1583,6 +1587,7 @@ Optional Features:
                           gcc is used
   --enable-ubsan          enable undefined behavior sanitizer (auto/yes/no)
   --enable-sim            link gdb with simulator
+  --enable-libctf         Handle .ctf type-info sections [default=yes]
   --enable-unit-tests     Enable the inclusion of unit tests when compiling
                           GDB
 
@@ -18561,6 +18566,41 @@ else
 fi
 
 
+ # Check whether --enable-libctf was given.
+if test "${enable_libctf+set}" = set; then :
+  enableval=$enable_libctf;
+      case "$enableval" in
+       yes|no) ;;
+       *) as_fn_error $? "Argument to enable/disable libctf must be yes or no" "$LINENO" 5 ;;
+      esac
+
+else
+  enable_libctf=yes
+fi
+
+
+if test x${enable_static} = xno; then
+  LIBCTF="-Wl,--rpath,../libctf/.libs ../libctf/.libs/libctf.so"
+  CTF_DEPS="../libctf/.libs/libctf.so"
+else
+  LIBCTF="../libctf/.libs/libctf.a"
+  CTF_DEPS="$LIBCTF"
+fi
+if test "${enable_libctf}" = yes; then
+
+$as_echo "#define ENABLE_LIBCTF 1" >>confdefs.h
+
+else
+  LIBCTF=
+  CTF_DEPS=
+fi
+
+
+
+
+# If nativefile (NAT_FILE) is not set in configure.nat, we link to an
+# empty version.
+
 if test "x$with_xxhash" != "xno"; then
 
 
index 62750804fa26f6ed15200685f986d5575bf3c654..b975cec84fedc2f89a4ed3d96270dcadf70fd5ca 100644 (file)
@@ -2066,6 +2066,27 @@ AC_ARG_WITH(xxhash,
   AC_HELP_STRING([--with-xxhash], [use libxxhash for hashing (faster) (auto/yes/no)]),
   [], [with_xxhash=auto])
 
+GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
+if test x${enable_static} = xno; then
+  LIBCTF="-Wl,--rpath,../libctf/.libs ../libctf/.libs/libctf.so"
+  CTF_DEPS="../libctf/.libs/libctf.so"
+else
+  LIBCTF="../libctf/.libs/libctf.a"
+  CTF_DEPS="$LIBCTF"
+fi
+if test "${enable_libctf}" = yes; then
+  AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
+else
+  LIBCTF=
+  CTF_DEPS=
+fi
+AC_SUBST(ENABLE_LIBCTF)
+AC_SUBST(LIBCTF)
+AC_SUBST(CTF_DEPS)
+
+# If nativefile (NAT_FILE) is not set in configure.nat, we link to an
+# empty version.
+
 if test "x$with_xxhash" != "xno"; then
   AC_LIB_HAVE_LINKFLAGS([xxhash], [],
                        [#include <xxhash.h>],
index e296b133c2f487b9dd1043556c575335100a658c..f44cbecba09a282a53aa5542ba31f171aa41ac65 100644 (file)
@@ -81,6 +81,9 @@
 #include "block.h"
 #include "ctfread.h"
 #include "psympriv.h"
+
+#if ENABLE_LIBCTF
+
 #include "ctf.h"
 #include "ctf-api.h"
 
@@ -1485,3 +1488,13 @@ elfctf_build_psymtabs (struct objfile *of)
 
   scan_partial_symbols (fp, of);
 }
+
+#else
+
+void
+elfctf_build_psymtabs (struct objfile *of)
+{
+  /* Nothing to do if CTF is disabled.  */
+}
+
+#endif /* ENABLE_LIBCTF */
index a01a065d814f1855f413acd867a9e2f2d48cbf1c..bf9d2c499e8ea429a85a5e6f4971bcd3b634bdc3 100644 (file)
@@ -1,3 +1,13 @@
+2020-06-26  Nick Alcock  <nick.alcock@oracle.com>
+
+       * configure.ac: Add --enable-libctf.
+       * aclocal.m4: sinclude ../config/enable.m4.
+       * Makefile.in (site.exp): Add enable_libctf to site.exp.
+       * lib/gdb.exp (skip_ctf_tests): Use it.
+       * gdb.base/ctf-constvars.exp: Error message tweak.
+       * gdb.base/ctf-ptype.exp: Likewise.
+       * configure: Regenerate.
+
 2020-06-26  Gary Benson <gbenson@redhat.com>
 
        * gdb.cp/try_catch.cc: Include string.h.
index dbe95b3491571a7e415d4d84aa9d4d1235ae38ff..61209d881c160ed944b2bbaa40f3dcd9a0558cc0 100644 (file)
@@ -28,6 +28,7 @@ program_transform_name = @program_transform_name@
 build_canonical = @build@
 host_canonical = @host@
 target_canonical = @target@
+enable_libctf = @enable_libctf@
 
 SHELL = @SHELL@
 EXEEXT = @EXEEXT@
@@ -131,6 +132,7 @@ $(abs_builddir)/site.exp site.exp: ./config.status Makefile
        @echo "set build_triplet ${build_canonical}" >> ./tmp0
        @echo "set srcdir ${abs_srcdir}" >> ./tmp0
        @echo "set tool gdb" >> ./tmp0
+       @echo "set enable_libctf ${enable_libctf}" >> ./tmp0
        @echo 'source $${srcdir}/lib/append_gdb_boards_dir.exp' >> ./tmp0
        @echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
                @cat ./tmp0 > site.exp
index 5061eef53724a2a9303e198b284c40fb74bd38d2..c5d3ba527a766843fbeb9f26c72a2bda46595214 100644 (file)
@@ -1,5 +1,6 @@
 m4_include(../../config/acx.m4)
 m4_include(../../config/override.m4)
+m4_include(../../config/enable.m4)
 m4_include(../transform.m4)
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
index cc00f8dfa8a44c1fb7a151fde846dbb46c65f13e..0de607446003ce8f36237efbf6c365cf176817e9 100755 (executable)
@@ -638,6 +638,7 @@ LDFLAGS
 CFLAGS
 CC
 RPATH_ENVVAR
+enable_libctf
 subdirs
 target_noncanonical
 target_os
@@ -694,6 +695,7 @@ ac_subst_files=''
 ac_user_opts='
 enable_option_checking
 enable_gdbtk
+enable_libctf
 enable_shared
 '
       ac_precious_vars='build_alias
@@ -1323,6 +1325,7 @@ Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --enable-gtk            enable gdbtk graphical user interface (GUI)
+  --enable-libctf         Handle .ctf type-info sections [default=yes]
   --enable-shared         build shared libraries deault=yes
 
 Some influential environment variables:
@@ -2189,6 +2192,21 @@ subdirs="$subdirs gdb.gdbtk"
 
 fi
 
+ # Check whether --enable-libctf was given.
+if test "${enable_libctf+set}" = set; then :
+  enableval=$enable_libctf;
+      case "$enableval" in
+       yes|no) ;;
+       *) as_fn_error $? "Argument to enable/disable libctf must be yes or no" "$LINENO" 5 ;;
+      esac
+
+else
+  enable_libctf=yes
+fi
+
+
+
+
 # Enable shared libraries.
 # Check whether --enable-shared was given.
 if test "${enable_shared+set}" = set; then :
index b387efe808d6fff8970b8b2ea262acc6f612219a..cc62c3fc45b2a167da59d79f05fc6db51367bb48 100644 (file)
@@ -43,6 +43,9 @@ if test $enable_gdbtk = yes; then
    AC_CONFIG_SUBDIRS(gdb.gdbtk)
 fi
 
+GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
+AC_SUBST(enable_libctf)
+
 # Enable shared libraries.
 AC_ARG_ENABLE(shared,
 [  --enable-shared         build shared libraries [deault=yes]],,
index b52ba71b1a8217d05bbeb32149157c5b110d23e7..38ee052cd59036749daaa845909858b197861873 100644 (file)
@@ -25,7 +25,7 @@
 # with mixed types.
 
 if [skip_ctf_tests] {
-    unsupported "no ctf debug format support"
+    unsupported "no CTF debug format support, or CTF disabled in GDB"
     return 0
 }
 
index dd1621b5fd77361f1900a2ebf68f0cb1942a51d5..f981477839c600d05df74d0783c77493f96887df 100644 (file)
@@ -16,7 +16,7 @@
 # This file is a subset of ptype.exp written by Rob Savoye. (rob@cygnus.com)
 
 if [skip_ctf_tests] {
-    unsupported "no ctf debug format support"
+    unsupported "no CTF debug format support, or CTF disabled in GDB"
     return 0
 }
 
@@ -24,6 +24,7 @@ standard_testfile .c
 
 # Using `-gt` generates full-fledged CTF debug information.
 set opts "additional_flags=-gt"
+
 if { [prepare_for_testing "failed to prepare" ${testfile} \
          [list $srcfile] [list $opts nowarnings]] } {
     return 0
index 8dbfa7e7a9489c224b9ad1b36140ac4537c45d36..e34513f14d3e8d09a84b2f38fe42c3584f35e120 100644 (file)
@@ -7169,9 +7169,16 @@ proc cmp_file_string { file str msg } {
 }
 
 # Does the compiler support CTF debug output using '-gt' compiler
-# flag?  If not then we should skip these tests.
+# flag?  If not then we should skip these tests.  We should also
+# skip them if libctf was explicitly disabled.
 
 gdb_caching_proc skip_ctf_tests {
+    global enable_libctf
+
+    if {$enable_libctf eq "no"} {
+       return 1
+    }
+
     return ![gdb_can_simple_compile ctfdebug {
        int main () {
            return 0;
This page took 0.051566 seconds and 4 git commands to generate.