diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c index 4d835ce227739..38c4ec0c3d15f 100644 --- a/gcc/jit/jit-recording.c +++ b/gcc/jit/jit-recording.c @@ -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) { @@ -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 diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h index 0ce54a679a3f7..2a0548ab778d8 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 };