Skip to content

Commit

Permalink
Add function to hide stderr logs
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Jan 9, 2022
1 parent b29614a commit 2867bc3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
25 changes: 16 additions & 9 deletions gcc/jit/jit-recording.c
Original file line number Diff line number Diff line change
Expand Up @@ -1571,15 +1571,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)
{
Expand Down Expand Up @@ -1702,6 +1708,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
Expand Down
3 changes: 3 additions & 0 deletions gcc/jit/libgccjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down

0 comments on commit 2867bc3

Please sign in to comment.