Skip to content

Commit 2867bc3

Browse files
committed
Add function to hide stderr logs
1 parent b29614a commit 2867bc3

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

gcc/jit/jit-recording.c

+16-9
Original file line numberDiff line numberDiff line change
@@ -1571,15 +1571,21 @@ recording::context::add_error_va (location *loc, const char *fmt, va_list ap)
15711571
if (!ctxt_progname)
15721572
ctxt_progname = "libgccjit.so";
15731573

1574-
if (loc)
1575-
fprintf (stderr, "%s: %s: error: %s\n",
1576-
ctxt_progname,
1577-
loc->get_debug_string (),
1578-
errmsg);
1579-
else
1580-
fprintf (stderr, "%s: error: %s\n",
1581-
ctxt_progname,
1582-
errmsg);
1574+
bool hide_log_stderr =
1575+
get_bool_option (GCC_JIT_BOOL_OPTION_HIDE_LOG_STDERR);
1576+
1577+
if (!hide_log_stderr)
1578+
{
1579+
if (loc)
1580+
fprintf (stderr, "%s: %s: error: %s\n",
1581+
ctxt_progname,
1582+
loc->get_debug_string (),
1583+
errmsg);
1584+
else
1585+
fprintf (stderr, "%s: error: %s\n",
1586+
ctxt_progname,
1587+
errmsg);
1588+
}
15831589

15841590
if (!m_error_count)
15851591
{
@@ -1702,6 +1708,7 @@ static const char * const
17021708
"GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING",
17031709
"GCC_JIT_BOOL_OPTION_SELFCHECK_GC",
17041710
"GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES"
1711+
"GCC_JIT_BOOL_OPTION_HIDE_LOG_STDERR"
17051712
};
17061713

17071714
static const char * const

gcc/jit/libgccjit.h

+3
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ enum gcc_jit_bool_option
241241
their location on stderr. */
242242
GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES,
243243

244+
/* If true, gcc_jit_context_release will not print the errors to stderr. */
245+
GCC_JIT_BOOL_OPTION_HIDE_LOG_STDERR,
246+
244247
GCC_JIT_NUM_BOOL_OPTIONS
245248
};
246249

0 commit comments

Comments
 (0)