The main motivation for this change to enable the libstdc++
testsuite with stand-alone GCN testing (gcn-run). Without, the
support file libstdc++-v3/testsuite/util/testsuite_abi.cc fails:
  util/testsuite_abi.h:68: sorry, unimplemented: exception handling not 
supported

As mentioned in the patch description, libstdc++ works when
the attached patch is attached. That patch just disables for the
non-offload compiler -fexceptions by default, but not if explicitly
enabled by the user. The latter will then run into the sorry mentioned
above, unless -mfake-exceptions has been specified on top.

This seems to be somewhat sensible and consistent behavior and
also one of the simplest and cleanest ways to permit running the
libstdc++ testsuite.

OK for mainline?

* * *

I have tested this with stand-alone offloading to an MI210; while it hasn't
finished, the in-between result looks fine:
PASS    5616, FAIL    311, UNSUPPORTED     798, XFAIL   40

I have also run the c++.exp testcases of libgomp with x86-64 + GCN offload,
which seem to still work fine.

Tobias
GCN: Default to -fno-exceptions

GCN does not support exception handling; however, for offloading,
the -mfake-exceptions permits to use host code compiled with exception with
device code.

However, when using the GCN compiler itself to generate stand-alone programs,
runnable with gcn-run, it makes sense to disable C++ by default. Therefore,
this commit defaults to -fno-exceptions -fno-non-call-exceptions, but permits
overriding this (only sensible with -mfake-exceptions). Thus, the default result
for code throwing exceptions is:
  error: exception handling disabled, use '-fexceptions' to enable
with -fexceptions this becomes
  sorry, unimplemented: exception handling not supported
and with exception -fno-non-call-exceptions

The main advantage of this change is that the libstdc++ testsuite no longer
fails with:
   ...util/testsuite_abi.cc
 sorry, unimplemented: exception handling not supported
 ...
 ERROR: could not compile testsuite_abi.cc
    while executing
  "error "could not compile $f""
    (procedure "v3-build_support" line 92)
but just works.

gcc/ChangeLog:

	* config/gcn/gcn.cc (gcn_option_override): If not explicitly set,
	set flag_non_call_exceptions and flag_exceptions to false for
	non-offload compilers.

 gcc/config/gcn/gcn.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc
index 3822febc721..6b3a4bfc728 100644
--- a/gcc/config/gcn/gcn.cc
+++ b/gcc/config/gcn/gcn.cc
@@ -147,6 +147,16 @@ gcn_option_override (void)
   gcc_assert (gcn_arch >= 0 && gcn_arch < PROCESSOR_COUNT);
   gcn_isa = gcn_devices[gcn_arch].isa;
 
+  /* Exceptions are unsupported; for offloading -mfake-exceptions are
+     supported. However, for stand-alone the default should be disabled by default;
+     note that -fnon-call-exceptions implies -fexceptions.   */
+  #ifndef ACCEL_COMPILER
+     if (!global_options.x_flag_non_call_exceptions
+	 || !flag_non_call_exceptions)
+       SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+			    flag_exceptions, false);
+  #endif
+
   /* Reserve 1Kb (somewhat arbitrarily) of LDS space for reduction results and
      worker broadcasts.  */
   if (gang_private_size_opt == -1)

Reply via email to