https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114968

--- Comment #4 from LIU Hao <lh_mouse at 126 dot com> ---
(In reply to Jakub Jelinek from comment #2)
> Guess you need to add a target hook next to use_aeabi_atexit and
> use_atexit_for_cxa_atexit which returns attributes that should be added to a
> FUNCTION_TYPE constructed by get_atexit_fn_ptr_type
> (build_function_type_list returns a shared type, so if attributes are to be
> added, it needs to go on a variant of the type.
> 
> On all but mingw ia32 it shouldn't add anything, and guess it shouldn't be
> done if
> !flag_use_cxa_atexit || !targetm.cxx.use_atexit_for_cxa_atexit ()
> A question is what to do about the __tcf_* cleanup functions that might be
> sometimes created.
> 
> Anyway, seems to be primarily mingw maintainer responsibility given that it
> is the only target with such requirements.

I think a quick and dirty solution should look like this?

```
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 2af026d255d..311f1ca780b 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -9669,6 +9669,13 @@ get_atexit_fn_ptr_type (void)

       fn_type = build_function_type_list (void_type_node,
                                           arg_type, NULL_TREE);
+#ifdef IX86_CALLCVT_THISCALL
+      if (flag_use_cxa_atexit
+          && !targetm.cxx.use_atexit_for_cxa_atexit ())
+        TYPE_ATTRIBUTES (fn_type) = tree_cons (
+                  get_identifier ("thiscall"), NULL_TREE,
+                  TYPE_ATTRIBUTES (fn_type));
+#endif
       atexit_fn_ptr_type_node = build_pointer_type (fn_type);
     }

```

Reply via email to