Tobias Burnus wrote:
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.

Thomas mentioned that in principle it should work without this
patch as there is the following in commit
  r15-8052-g1268924a2eed4e  GCN, nvptx: Allow for "hosted" libstdc++ build
https://gcc.gnu.org/cgit/gcc/commit?id=1268924a2eed4e

Namely, it adds code to libstdc++-v3/configure.host to add -fno-exceptions
with the goal that it enables testing.

I have no idea why it worked for Thomas in one way of testing and fails here
with another - nor whether it makes sense to have this patch nonetheless or
not. I find the error with this patch more helpful than without and it also
permits using
  #if __EXCEPTIONS  (with GCC and Clang)
or more modern
  #if __cpp_exceptions
which seems to be sensible

Thus, with the caveat that it is not quite clear to me what Thomas' patch
does nor why it worked for him but not here, I still think that this patch
makes sense.

Thoughts?

Tobias

PS: If this patch is applied, I wonder whether the amdgcn part of the
host config could be removed? This requires removing the if-not-offload
compiler and the setting has to be based on -mfake-exceptions that mkoffload
passes unconditionally (see attached patch, untested).
diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc
index 3822febc721..51dcbb0fda3 100644
--- a/gcc/config/gcn/gcn.cc
+++ b/gcc/config/gcn/gcn.cc
@@ -147,6 +147,20 @@ 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 (mkoffload passes it uncondiionally) as the host code might use
+     exceptions. However, for pure GCN code (i.e. directly compiling GCN
+     code. e.g. using the stand alone compiler or a pure GCN library),
+     disabling it by default makes sense.
+     Hence: With -mfake-exceptions, keep current settings, otherwise, if
+     not explicitly set, set -fnon-call-exceptions and -fexceptions to
+     false (-fnon-call-exceptions implies -fexceptions).  */
+     if (!fake_exceptions
+	 && (!global_options.x_flag_non_call_exceptions
+	     || !flag_non_call_exceptions))
+       SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+			    flag_exceptions, false);
+
   /* Reserve 1Kb (somewhat arbitrarily) of LDS space for reduction results and
      worker broadcasts.  */
   if (gang_private_size_opt == -1)

Reply via email to