aboutsummaryrefslogtreecommitdiff
path: root/gcc/Makefile.in
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2024-11-18 17:08:37 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2024-11-18 17:08:37 -0500
commitea1506adbe7544bb51fc74a0fae3fa6fa0c68661 (patch)
tree931325c2296878922e92e2267d5d32c76a6ebcf3 /gcc/Makefile.in
parent66e6e4f131e517344e4f2c16f96de90d391d94e0 (diff)
downloadgcc-ea1506adbe7544bb51fc74a0fae3fa6fa0c68661.zip
gcc-ea1506adbe7544bb51fc74a0fae3fa6fa0c68661.tar.gz
gcc-ea1506adbe7544bb51fc74a0fae3fa6fa0c68661.tar.bz2
libdiagnostics: add a "sarif-replay" command-line tool [PR96032]
This patch adds a new "sarif-replay" command-line tool for viewing .sarif files. It uses libdiagnostics to "replay" any diagnostics found in the .sarif files in text form as if they were GCC diagnostics. contrib/ChangeLog: PR other/96032 * regenerate-sarif-spec-index.py: New file. gcc/ChangeLog: PR other/96032 * Makefile.in (lang_checks): If libdiagnostics is enabled, add check-sarif-replay. (SARIF_REPLAY_OBJS): New. (ALL_HOST_OBJS): If libdiagnostics is enabled, add $(SARIF_REPLAY_OBJS). (sarif-replay): New. (install-libdiagnostics): Add sarif-replay to deps, and install it. * configure: Regenerate. * configure.ac (check_languages): If libdiagnostics is enabled, add check-sarif-replay. (LIBDIAGNOSTICS): If libdiagnostics is enabled, add sarif-replay. * doc/install.texi (--enable-libdiagnostics): Note that it also enables sarif-replay. * libsarifreplay.cc: New file. * libsarifreplay.h: New file. * sarif-replay.cc: New file. * sarif-spec-urls.def: New file. gcc/testsuite/ChangeLog: PR other/96032 * lib/gcc-dg.exp (gcc-dg-test-1): Add "replay-sarif". * lib/sarif-replay-dg.exp: New file. * lib/sarif-replay.exp: New file. * sarif-replay.dg/2.1.0-invalid/3.1-not-an-object.sarif: New test. * sarif-replay.dg/2.1.0-invalid/3.11.11-malformed-placeholder.sarif: New test. * sarif-replay.dg/2.1.0-invalid/3.11.11-missing-arguments-for-placeholders.sarif: New test. * sarif-replay.dg/2.1.0-invalid/3.11.11-not-enough-arguments-for-placeholders.sarif: New test. * sarif-replay.dg/2.1.0-invalid/3.13.2-no-version.sarif: New test. * sarif-replay.dg/2.1.0-invalid/3.13.2-version-not-a-string.sarif: New test. * sarif-replay.dg/2.1.0-invalid/3.13.4-bad-runs.sarif: New test. * sarif-replay.dg/2.1.0-invalid/3.13.4-no-runs.sarif: New test. * sarif-replay.dg/2.1.0-invalid/3.13.4-non-object-in-runs.sarif: New test. * sarif-replay.dg/2.1.0-invalid/3.27.10-bad-level.sarif: New test. * sarif-replay.dg/2.1.0-unhandled/3.27.10-none-level.sarif: New test. * sarif-replay.dg/2.1.0-valid/error-with-note.sarif: New test. * sarif-replay.dg/2.1.0-valid/escaped-braces.sarif: New test. * sarif-replay.dg/2.1.0-valid/null-runs.sarif: New test. * sarif-replay.dg/2.1.0-valid/signal-1.c.sarif: New test. * sarif-replay.dg/2.1.0-valid/spec-example-1.sarif: New test. * sarif-replay.dg/2.1.0-valid/spec-example-2.sarif: New test. * sarif-replay.dg/2.1.0-valid/spec-example-3.sarif: New test. * sarif-replay.dg/2.1.0-valid/spec-example-4.sarif: New test. * sarif-replay.dg/2.1.0-valid/tutorial-example.sarif: New test. * sarif-replay.dg/dg.exp: New script. * sarif-replay.dg/malformed-json/array-missing-comma.sarif: New test. * sarif-replay.dg/malformed-json/array-with-trailing-comma.sarif: New test. * sarif-replay.dg/malformed-json/bad-token.sarif: New test. * sarif-replay.dg/malformed-json/object-missing-comma.sarif: New test. * sarif-replay.dg/malformed-json/object-with-trailing-comma.sarif: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/Makefile.in')
-rw-r--r--gcc/Makefile.in16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 5c8832d..0cbb363 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -621,7 +621,7 @@ xm_defines=@xm_defines@
lang_checks=
lang_checks_parallelized=
ifeq (@enable_libdiagnostics@,yes)
-lang_checks += check-libdiagnostics
+lang_checks += check-libdiagnostics check-sarif-replay
endif
lang_opt_files=@lang_opt_files@ $(srcdir)/c-family/c.opt $(srcdir)/common.opt $(srcdir)/params.opt $(srcdir)/analyzer/analyzer.opt
lang_specs_files=@lang_specs_files@
@@ -1297,6 +1297,8 @@ RUST_TARGET_OBJS=@rust_target_objs@
# Object files for gcc many-languages driver.
GCC_OBJS = gcc.o gcc-main.o ggc-none.o gcc-urlifier.o options-urls.o
+SARIF_REPLAY_OBJS = sarif-replay.o libsarifreplay.o
+
c-family-warn = $(STRICT_WARN)
# Language-specific object files shared by all C-family front ends.
@@ -1886,7 +1888,7 @@ endif
ALL_HOST_OBJS = $(ALL_HOST_FRONTEND_OBJS) $(ALL_HOST_BACKEND_OBJS)
ifeq (@enable_libdiagnostics@,yes)
-ALL_HOST_OBJS += $(libdiagnostics_OBJS)
+ALL_HOST_OBJS += $(libdiagnostics_OBJS) $(SARIF_REPLAY_OBJS)
endif
BACKEND = libbackend.a main.o libcommon-target.a libcommon.a \
@@ -2407,6 +2409,12 @@ $(LIBDIAGNOSTICS_LINKER_NAME_SYMLINK): $(LIBDIAGNOSTICS_SONAME_SYMLINK)
ln -sf $(LIBDIAGNOSTICS_SONAME_SYMLINK) $(LIBDIAGNOSTICS_LINKER_NAME_SYMLINK)
endif
+# sarif-replay: a command-line tool that uses libdiagnostics to
+# replay SARIF files
+sarif-replay: $(SARIF_REPLAY_OBJS) $(LIBDIAGNOSTICS_FILENAME)
+ +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
+ $(SARIF_REPLAY_OBJS) $(LIBDIAGNOSTICS_FILENAME) $(LIBS)
+
# Dump a specs file to make -B./ read these specs over installed ones.
$(SPECS): xgcc$(exeext)
$(GCC_FOR_TARGET) -dumpspecs > tmp-specs
@@ -4167,7 +4175,9 @@ libdiagnostics.install-common: installdirs libdiagnostics.install-headers
endif
endif
-install-libdiagnostics: libdiagnostics.install-common
+install-libdiagnostics: libdiagnostics.install-common sarif-replay
+ -rm -f $(DESTDIR)$(bindir)/sarif-replay
+ -$(INSTALL_PROGRAM) sarif-replay $(DESTDIR)$(bindir)/sarif-replay
# Install the info files.
# $(INSTALL_DATA) might be a relative pathname, so we can't cd into srcdir