nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl: Restore 'libgomp.c/reverse-offload-sm30.c' testing (was: [Patch] nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl)

Message ID 87a5m8ngun.fsf@euler.schwinge.ddns.net
State Committed
Headers
Series nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl: Restore 'libgomp.c/reverse-offload-sm30.c' testing (was: [Patch] nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl) |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm warning Patch is already merged
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 warning Patch is already merged

Commit Message

Thomas Schwinge April 5, 2024, 12:17 p.m. UTC
  Hi!

On 2024-04-03T14:06:45+0200, Tobias Burnus <tburnus@baylibre.com> wrote:
> Nvptx's mkoffload.cc contains 14 'fatal_error' calls and one 'warning_at' call,
> which stands out more clearly (color, bold) when enabling
>    diagnostic_color_init
> which this patch does. — Additionally, the call gcc_init_libintl permits that
> the already translated error messages also show up as translation.
>
> OK for mainline?

But you've not regression-tested this?  Pushed to trunk branch
commit 679f81a32f706645f45900fdb1659fb5fe607f77
"nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl: Restore 'libgomp.c/reverse-offload-sm30.c' testing",
see attached.


Instead of adding support for all the '-fdiagnostics-color' variants, I
suppose we should rather switch the 'mkoffload's to use GCC's standard
option handling machinery (like in 'gcc/lto-wrapper.cc', for example)?


Grüße
 Thomas


> PS: Example: 'nvptx mkoffload:' is bold and 'fatal error:' is in red
> in English and some language variants.
>
> nvptx mkoffload: fatal error: COLLECT_GCC must be set.
> nvptx mkoffload: 致命的エラー: COLLECT_GCC must be set.
> nvptx mkoffload: erreur fatale: COLLECT_GCC doit être défini.
> nvptx mkoffload: schwerwiegender Fehler: COLLECT_GCC muss gesetzt sein.
>
> (BTW: It looks as if many languages did not translate the error string
> itself, e.g. jp or zh or pl or zh_TW/zh_CN or fi or ...)
> nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl
>
> gcc/ChangeLog:
>
> 	* config/nvptx/mkoffload.cc (main): Call
> 	gcc_init_libintl and diagnostic_color_init.
>
>  gcc/config/nvptx/mkoffload.cc | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/gcc/config/nvptx/mkoffload.cc b/gcc/config/nvptx/mkoffload.cc
> index a7fc28cbd3f..503b1abcefd 100644
> --- a/gcc/config/nvptx/mkoffload.cc
> +++ b/gcc/config/nvptx/mkoffload.cc
> @@ -638,7 +638,9 @@ main (int argc, char **argv)
>    const char *outname = 0;
>  
>    progname = tool_name;
> +  gcc_init_libintl ();
>    diagnostic_initialize (global_dc, 0);
> +  diagnostic_color_init (global_dc);
>  
>    if (atexit (mkoffload_cleanup) != 0)
>      fatal_error (input_location, "atexit failed");
  

Patch

From 679f81a32f706645f45900fdb1659fb5fe607f77 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tschwinge@baylibre.com>
Date: Fri, 5 Apr 2024 14:04:53 +0200
Subject: [PATCH] nvptx: In mkoffload.cc, call diagnostic_color_init +
 gcc_init_libintl: Restore 'libgomp.c/reverse-offload-sm30.c' testing

With commit 7520a4992c94254016085a461c58c972497c4483
"nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl",
we regressed:

    [-PASS:-]{+FAIL:+} libgomp.c/reverse-offload-sm30.c  at line 15 (test for warnings, line )
    [-PASS:-]{+FAIL:+} libgomp.c/reverse-offload-sm30.c (test for excess errors)

	libgomp/
	* testsuite/libgomp.c/reverse-offload-sm30.c: Set 'GCC_COLORS' to the empty string.
---
 libgomp/testsuite/libgomp.c/reverse-offload-sm30.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libgomp/testsuite/libgomp.c/reverse-offload-sm30.c b/libgomp/testsuite/libgomp.c/reverse-offload-sm30.c
index 7f10fd4ded9..cae75f03462 100644
--- a/libgomp/testsuite/libgomp.c/reverse-offload-sm30.c
+++ b/libgomp/testsuite/libgomp.c/reverse-offload-sm30.c
@@ -12,4 +12,7 @@  main ()
   return 0;
 }
 
+/* The 'mkoffload's currently don't obey '-fno-diagnostics-color' etc., so use a different way to effect the same thing:
+   { dg-set-compiler-env-var GCC_COLORS "" }
+   ..., so that the following regexp doesn't have to deal with color code escape sequences.  */
 /* { dg-warning "'omp requires reverse_offload' requires at least 'sm_35' for '-foffload-options=nvptx-none=-march=' - disabling offload-code generation for this device type" "" { target *-*-* } 0 } */
-- 
2.34.1