]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Don't include selftests objects in build when unit tests are disabled
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 12 Mar 2020 18:18:21 +0000 (14:18 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 12 Mar 2020 18:18:36 +0000 (14:18 -0400)
While working on the preceding selftests patches, I noticed that some
selftests-specific files are included in the build even when selftests
are disabled, namely disasm-selftest.c and gdbarch-selftests.c.  These
files are entirely #if'ed out when building with selftests disabled.

This is not a huge problem, but I think it would make more sense if
these files were simply not built.

With this patch, I propose to put all the selftests-specific source
files into a SELFTESTS_SRCS Makefile variable (even selftest-arch.c,
which is currently added by the configure script).

gdb/ChangeLog:

* Makefile.in (SUBDIR_UNITTESTS_SRCS): Rename to...
(SELFTESTS_SRCS): ... this.  Add disasm-selftests.c,
gdbarch-selfselftests.c and selftest-arch.c.
(SUBDIR_UNITTESTS_OBS): Rename to...
(SELFTESTS_OBS): ... this.
(COMMON_SFILES): Remove disasm-selftests.c and
gdbarch-selftests.c.
* configure.ac: Don't add selftest-arch.{c,o} to
CONFIG_{SRCS,OBS}.
* disasm-selftests.c, gdbarch-selftests.c: Remove GDB_SELF_TEST
preprocessor conditions.

gdb/ChangeLog
gdb/Makefile.in
gdb/configure
gdb/configure.ac
gdb/disasm-selftests.c
gdb/gdbarch-selftests.c

index eef1e6492cec68526ec7c5edcba8330b7edd5ebe..c592b5614232b4a2140f3c44c4919fd3d7d1530f 100644 (file)
@@ -1,3 +1,17 @@
+2020-03-12  Simon Marchi  <simon.marchi@efficios.com>
+
+       * Makefile.in (SUBDIR_UNITTESTS_SRCS): Rename to...
+       (SELFTESTS_SRCS): ... this.  Add disasm-selftests.c,
+       gdbarch-selfselftests.c and selftest-arch.c.
+       (SUBDIR_UNITTESTS_OBS): Rename to...
+       (SELFTESTS_OBS): ... this.
+       (COMMON_SFILES): Remove disasm-selftests.c and
+       gdbarch-selftests.c.
+       * configure.ac: Don't add selftest-arch.{c,o} to
+       CONFIG_{SRCS,OBS}.
+       * disasm-selftests.c, gdbarch-selftests.c: Remove GDB_SELF_TEST
+       preprocessor conditions.
+
 2020-03-12  Simon Marchi  <simon.marchi@efficios.com>
 
        * configure.ac: Don't source bfd/development.sh.
index 1a837eda8d54ace2224e127e9d88cdbf807f78ea..1db02c07ac280f18a9bfab2f7b5bc2cdadc13cc3 100644 (file)
@@ -420,7 +420,10 @@ SUBDIR_PYTHON_DEPS =
 SUBDIR_PYTHON_LDFLAGS =
 SUBDIR_PYTHON_CFLAGS =
 
-SUBDIR_UNITTESTS_SRCS = \
+SELFTESTS_SRCS = \
+       disasm-selftests.c \
+       gdbarch-selftests.c \
+       selftest-arch.c \
        unittests/array-view-selftests.c \
        unittests/child-path-selftests.c \
        unittests/cli-utils-selftests.c \
@@ -454,7 +457,7 @@ SUBDIR_UNITTESTS_SRCS = \
        unittests/vec-utils-selftests.c \
        unittests/xml-utils-selftests.c
 
-SUBDIR_UNITTESTS_OBS = $(patsubst %.c,%.o,$(SUBDIR_UNITTESTS_SRCS))
+SELFTESTS_OBS = $(patsubst %.c,%.o,$(SELFTESTS_SRCS))
 
 SUBDIR_TARGET_SRCS = target/waitstatus.c
 SUBDIR_TARGET_OBS = $(patsubst %.c,%.o,$(SUBDIR_TARGET_SRCS))
@@ -995,7 +998,6 @@ COMMON_SFILES = \
        debuginfod-support.c \
        dictionary.c \
        disasm.c \
-       disasm-selftests.c \
        dummy-frame.c \
        dwarf2/abbrev.c \
        dwarf2/attribute.c \
@@ -1034,7 +1036,6 @@ COMMON_SFILES = \
        gdb_obstack.c \
        gdb_regex.c \
        gdbarch.c \
-       gdbarch-selftests.c \
        gdbtypes.c \
        gnu-v2-abi.c \
        gnu-v3-abi.c \
index f690cf86078dd087aaa39aa9e082724a2e1230a7..614f3402c3d681967311c8c5bcfaa834753e0b06 100755 (executable)
@@ -19210,8 +19210,8 @@ if $enable_unittests; then
 $as_echo "#define GDB_SELF_TEST 1" >>confdefs.h
 
 
-  CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) selftest-arch.o"
-  CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) selftest-arch.c"
+  CONFIG_OBS="$CONFIG_OBS \$(SELFTESTS_OBS)"
+  CONFIG_SRCS="$CONFIG_SRCS \$(SELFTESTS_SRCS)"
 
 fi
 
index 76c396c6ebc07df411518fcee7397553680c9488..b9dbe13232a1bb0916b4787ed3c6d5d78799f91b 100644 (file)
@@ -2124,8 +2124,8 @@ AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
           [Define to be a string naming the default host character set.])
 
 GDB_AC_SELFTEST([
-  CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) selftest-arch.o"
-  CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) selftest-arch.c"
+  CONFIG_OBS="$CONFIG_OBS \$(SELFTESTS_OBS)"
+  CONFIG_SRCS="$CONFIG_SRCS \$(SELFTESTS_SRCS)"
 ])
 
 GDB_AC_TRANSFORM([gdb], [GDB_TRANSFORM_NAME])
index b63a35ab1e5a458ed8f0f7615f292a639599b408..a24db7f224ff983fa3cc0746e547043243e7ee40 100644 (file)
@@ -19,8 +19,6 @@
 
 #include "defs.h"
 #include "disasm.h"
-
-#if GDB_SELF_TEST
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "gdbarch.h"
@@ -208,16 +206,13 @@ memory_error_test (struct gdbarch *gdbarch)
 }
 
 } // namespace selftests
-#endif /* GDB_SELF_TEST */
 
 void _initialize_disasm_selftests ();
 void
 _initialize_disasm_selftests ()
 {
-#if GDB_SELF_TEST
   selftests::register_test_foreach_arch ("print_one_insn",
                                         selftests::print_one_insn_test);
   selftests::register_test_foreach_arch ("memory_error",
                                         selftests::memory_error_test);
-#endif
 }
index c99a900dbfb252035ddbc18d5ab50aebc127081c..787a3f40589fc1bb9bac4feefe3010f839daa199 100644 (file)
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#if GDB_SELF_TEST
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "inferior.h"
@@ -158,14 +157,11 @@ register_to_value_test (struct gdbarch *gdbarch)
 }
 
 } // namespace selftests
-#endif /* GDB_SELF_TEST */
 
 void _initialize_gdbarch_selftests ();
 void
 _initialize_gdbarch_selftests ()
 {
-#if GDB_SELF_TEST
   selftests::register_test_foreach_arch ("register_to_value",
                                         selftests::register_to_value_test);
-#endif
 }