public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: Antoni Boucher <bouanto@zoho.com>
To: gcc-patches@gcc.gnu.org, jit@gcc.gnu.org
Subject: [PATCH] libgccjit: Add option to hide stderr logs [PR104073]
Date: Mon, 17 Jan 2022 21:02:08 -0500	[thread overview]
Message-ID: <26928da47b7f5cbcef6c9db31221fe59a83ef4b2.camel@zoho.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]

Hi.
This option will be useful for rustc_codegen_gcc to hide the error
about unsupported 128-bit integer types.

David, if you know of a better way to check if these types are
supported than creating such a type and checking if it causes an error,
I will not need this patch.

Thanks for the reviews!

[-- Attachment #2: 0001-libgccjit-Add-option-to-hide-stderr-logs-PR104073.patch --]
[-- Type: text/x-patch, Size: 3079 bytes --]

From 002c6803ac7069bf18eabd6729e31de8e2be6128 Mon Sep 17 00:00:00 2001
From: Antoni Boucher <bouanto@zoho.com>
Date: Sun, 9 Jan 2022 13:46:35 -0500
Subject: [PATCH] libgccjit: Add option to hide stderr logs [PR104073]

2022-01-17  Antoni Boucher <bouanto@zoho.com

gcc/jit/
	PR target/104073
	* docs/topics/contexts.rst: Add documentation for the new option
	GCC_JIT_BOOL_OPTION_HIDE_LOG_STDERR.
	* jit-recording.c: handle the option
	GCC_JIT_BOOL_OPTION_HIDE_LOG_STDERR.
	* libgccjit.h: New option GCC_JIT_BOOL_OPTION_HIDE_LOG_STDERR.
---
 gcc/jit/docs/topics/contexts.rst |  4 ++++
 gcc/jit/jit-recording.c          | 25 ++++++++++++++++---------
 gcc/jit/libgccjit.h              |  3 +++
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/gcc/jit/docs/topics/contexts.rst b/gcc/jit/docs/topics/contexts.rst
index 68ab7ab1321..193f5096de9 100644
--- a/gcc/jit/docs/topics/contexts.rst
+++ b/gcc/jit/docs/topics/contexts.rst
@@ -453,6 +453,10 @@ Boolean options
      If true, the :type:`gcc_jit_context` will not clean up intermediate files
      written to the filesystem, and will display their location on stderr.
 
+  .. macro:: GCC_JIT_BOOL_OPTION_HIDE_LOG_STDERR
+
+     If true, libgccjit will not log the errors on stderr.
+
 .. function:: void \
               gcc_jit_context_set_bool_allow_unreachable_blocks (gcc_jit_context *ctxt, \
                                                                  int bool_value)
diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
index ee8934131d1..a6928005e9b 100644
--- a/gcc/jit/jit-recording.c
+++ b/gcc/jit/jit-recording.c
@@ -1551,15 +1551,21 @@ recording::context::add_error_va (location *loc, const char *fmt, va_list ap)
   if (!ctxt_progname)
     ctxt_progname = "libgccjit.so";
 
-  if (loc)
-    fprintf (stderr, "%s: %s: error: %s\n",
-	     ctxt_progname,
-	     loc->get_debug_string (),
-	     errmsg);
-  else
-    fprintf (stderr, "%s: error: %s\n",
-	     ctxt_progname,
-	     errmsg);
+  bool hide_log_stderr =
+    get_bool_option (GCC_JIT_BOOL_OPTION_HIDE_LOG_STDERR);
+
+  if (!hide_log_stderr)
+  {
+    if (loc)
+      fprintf (stderr, "%s: %s: error: %s\n",
+	       ctxt_progname,
+	       loc->get_debug_string (),
+	       errmsg);
+    else
+      fprintf (stderr, "%s: error: %s\n",
+	       ctxt_progname,
+	       errmsg);
+  }
 
   if (!m_error_count)
     {
@@ -1682,6 +1688,7 @@ static const char * const
   "GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING",
   "GCC_JIT_BOOL_OPTION_SELFCHECK_GC",
   "GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES"
+  "GCC_JIT_BOOL_OPTION_HIDE_LOG_STDERR"
 };
 
 static const char * const
diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
index 2a5ffacb1fe..272b862c164 100644
--- a/gcc/jit/libgccjit.h
+++ b/gcc/jit/libgccjit.h
@@ -241,6 +241,9 @@ enum gcc_jit_bool_option
      their location on stderr.  */
   GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES,
 
+  /* If true, gcc_jit_context_release will not print the errors to stderr.  */
+  GCC_JIT_BOOL_OPTION_HIDE_LOG_STDERR,
+
   GCC_JIT_NUM_BOOL_OPTIONS
 };
 
-- 
2.26.2.7.g19db9cfb68.dirty


             reply	other threads:[~2022-01-18  2:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18  2:02 Antoni Boucher [this message]
2022-01-18 23:22 ` David Malcolm
2022-01-23 17:34   ` Antoni Boucher
2022-01-24 22:55     ` David Malcolm
2022-04-12 21:48       ` David Malcolm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26928da47b7f5cbcef6c9db31221fe59a83ef4b2.camel@zoho.com \
    --to=bouanto@zoho.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jit@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).