@@ -1817,10 +1817,10 @@ config.status: $(srcdir)/configure $(srcdir)/config.gcc
quickstrap: all
cd $(toplevel_builddir) && $(MAKE) all-target-libgcc
-all.internal: start.encap rest.encap doc
+all.internal: start.encap rest.encap doc selftests
# This is what to compile if making a cross-compiler.
all.cross: native gcc-cross$(exeext) cpp$(exeext) specs \
- libgcc-support lang.all.cross doc @GENINSRC@ srcextra
+ libgcc-support lang.all.cross doc selftests @GENINSRC@ srcextra
# This is what must be made before installing GCC and converting libraries.
start.encap: native xgcc$(exeext) cpp$(exeext) specs \
libgcc-support lang.start.encap @GENINSRC@ srcextra
@@ -1840,6 +1840,21 @@ endif
# This does the things that can't be done on the host machine.
rest.cross: specs
+# Run the selftests during the build once we have a driver and a cc1,
+# so that self-test failures are caught as early as possible.
+# Use "s-selftests" to ensure that we only run the selftests if the
+# driver or cc1 change.
+.PHONY: selftests
+selftests: s-selftests
+s-selftests: $(GCC_PASSES) cc1$(exeext) stmp-int-hdrs
+ $(GCC_FOR_TARGET) -xc -S -c /dev/null -fself-test
+ $(STAMP) $@
+
+# Convenience method for running selftests under gdb:
+.PHONY: selftests-gdb
+selftests-gdb: $(GCC_PASSES) cc1$(exeext) stmp-int-hdrs
+ $(GCC_FOR_TARGET) -xc -S -c /dev/null -fself-test -wrapper gdb,--args
+
# Recompile all the language-independent object files.
# This is used only if the user explicitly asks for it.
compilations: $(BACKEND)
@@ -80,7 +80,8 @@ selftest::run_all_tests ()
runner::runner ()
: m_passes (0),
- m_failures (0)
+ m_failures (0),
+ m_start_time (get_run_time ())
{
}
@@ -88,8 +89,11 @@ runner::runner ()
runner::~runner ()
{
- fprintf (stderr, "NOTE: %i pass(es); %i failure(s)\n",
- m_passes, m_failures);
+ long finish_time = get_run_time ();
+ long elapsed_time = finish_time - m_start_time;
+ fprintf (stderr, "NOTE: %i pass(es); %i failure(s) in %ld.%06ld seconds\n",
+ m_passes, m_failures,
+ elapsed_time / 1000000, elapsed_time % 1000000);
}
/* Notify the user that a particular test is about to be run. */
@@ -54,6 +54,7 @@ public:
private:
int m_passes;
int m_failures;
+ long m_start_time;
};
/* The class ::selftest::test is a base class from which specific
@@ -2079,7 +2079,7 @@ toplev::run_self_tests ()
/* Cleanup. */
bitmap_obstack_release (NULL);
#else
- sorry ("self-tests are not enabled in this build");
+ inform (UNKNOWN_LOCATION, "self-tests are not enabled in this build");
#endif /* #if CHECKING_P */
}