aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2024-12-09 07:56:06 -0300
committerMarc Poulhiès <dkm@gcc.gnu.org>2025-01-06 10:14:46 +0100
commitb8a94b0ba884bdd36f285565dbdf095e076fd63c (patch)
tree5c28ab4bcf70fbd103677810ab292416d7f3b276
parent0fe74112722fd342283a84147a94782a11fe853e (diff)
downloadgcc-b8a94b0ba884bdd36f285565dbdf095e076fd63c.zip
gcc-b8a94b0ba884bdd36f285565dbdf095e076fd63c.tar.gz
gcc-b8a94b0ba884bdd36f285565dbdf095e076fd63c.tar.bz2
ada: C++ exception hierarchies: adjust for gnat-llvm
gnat-llvm doesn't support C++ imports, so arrange for the GNAT.CPP* units to be omitted from gnat-llvm builds. Drop G++ exception interoperability support from raise-gcc.c, so as to not require the GNAT.CPP* units that define some of the required symbols. Co-Authored-By: Olivier Hainque <hainque@adacore.com> gcc/ada/ChangeLog: * Makefile.rtl (LLVM_BUILD): Define based on LLVM_CONFIG. (GNATRTL_NONTASKING_OBJS): Make g-cpp, g-cppstd, and g-cstyin conditional on -gcc or -arm EH, and on no LLVM_BUILD. * raise-gcc.c (GXX_EH_INTEROP): Define as 0 on gnat-llvm or CERT, and 1 otherwise. (__gnat_get_cxx_dependent_exception) Omit on !GXX_EH_INTEROP. (__gnat_maybe_get_cxx_dependent_exception): Likewise. (__gnat_get_cxx_exception_type_info): Likewise. (__gnat_obtain_caught_object): Likewise. (is_handled_by): Omit eid parameter and G++ interop on !GXX_EH_INTEROP. Adjust callers.
-rw-r--r--gcc/ada/Makefile.rtl23
-rw-r--r--gcc/ada/raise-gcc.c40
2 files changed, 47 insertions, 16 deletions
diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
index cd112d3..34bc5c8 100644
--- a/gcc/ada/Makefile.rtl
+++ b/gcc/ada/Makefile.rtl
@@ -26,6 +26,12 @@ ifndef ADAC
ADAC=$(CC)
endif
+ifeq ($(LLVM_CONFIG),)
+LLVM_BUILD := $(shell $(ADAC) -v | grep ^llvm-gcc)
+else
+LLVM_BUILD := llvm-gcc
+endif
+
# Objects needed only for tasking
GNATRTL_TASKING_OBJS= \
a-dispat$(objext) \
@@ -419,9 +425,6 @@ GNATRTL_NONTASKING_OBJS= \
g-comlin$(objext) \
g-comver$(objext) \
g-crc32$(objext) \
- g-cpp$(objext) \
- g-cppstd$(objext) \
- g-cstyin$(objext) \
g-ctrl_c$(objext) \
g-curexc$(objext) \
g-debpoo$(objext) \
@@ -3152,7 +3155,12 @@ ifeq ($(EH_MECHANISM),-gcc)
s-excmac.ads<libgnat/s-excmac__gcc.ads \
s-excmac.adb<libgnat/s-excmac__gcc.adb
EXTRA_LIBGNAT_OBJS+=raise-gcc.o
- EXTRA_GNATRTL_NONTASKING_OBJS+=g-cppexc.o s-excmac.o
+ifeq ($(LLVM_BUILD),)
+ EXTRA_GNATRTL_NONTASKING_OBJS+=g-cppexc.o s-excmac.o \
+ g-cpp$(objext) g-cppstd$(objext) g-cstyin$(objext)
+else
+ EXTRA_GNATRTL_NONTASKING_OBJS+=s-excmac.o
+endif
endif
ifeq ($(EH_MECHANISM),-arm)
@@ -3160,7 +3168,12 @@ ifeq ($(EH_MECHANISM),-arm)
s-excmac.ads<libgnat/s-excmac__arm.ads \
s-excmac.adb<libgnat/s-excmac__arm.adb
EXTRA_LIBGNAT_OBJS+=raise-gcc.o
- EXTRA_GNATRTL_NONTASKING_OBJS+=g-cppexc.o s-excmac.o
+ifeq ($(LLVM_BUILD),)
+ EXTRA_GNATRTL_NONTASKING_OBJS+=g-cppexc.o s-excmac.o \
+ g-cpp$(objext) g-cppstd$(objext) g-cstyin$(objext)
+else
+ EXTRA_GNATRTL_NONTASKING_OBJS+=s-excmac.o
+endif
endif
ifeq ($(strip $(filter-out linux%,$(target_os))),)
diff --git a/gcc/ada/raise-gcc.c b/gcc/ada/raise-gcc.c
index 1ea2963..9a75df4 100644
--- a/gcc/ada/raise-gcc.c
+++ b/gcc/ada/raise-gcc.c
@@ -48,6 +48,22 @@
# endif
#endif
+/* Arrange to include the Ada/G++ exceptions interoperability support only in
+ contexts where it is actually needed and supported, in particular not in
+ gnat-llvm, that doesn't support C++ imports. This interoperability hasn't
+ been certified, so leave it out of CERT runtimes as well. */
+
+#if !defined GXX_EH_INTEROP
+# if defined(__clang_major__) && defined(__clang_minor__)
+/* GNAT-LLVM does not support C++ imports. */
+# define GXX_EH_INTEROP 0
+# elif defined(CERT)
+# define GXX_EH_INTEROP 0
+# else
+# define GXX_EH_INTEROP 1
+# endif
+#endif
+
#ifdef __cplusplus
# include <cstdarg>
# include <cstddef>
@@ -975,6 +991,8 @@ __gnat_exception_language_is_ada (_Unwind_Exception *except)
return (exception_class_eq (except, GNAT_EXCEPTION_CLASS));
}
+#if GXX_EH_INTEROP
+
/* Check whether *THROWN_PTR of EXCEPT_TYPEINFO is to be caught by a
CHOICE_TYPEINFO handler under LANG convention.
Implemented by GNAT.CPP_Exception.Convert_Caught_Object. */
@@ -1099,20 +1117,17 @@ __gnat_obtain_caught_object (int *success_p, void **thrown_ptr_p,
}
}
+#endif /* GXX_EH_INTEROP */
+
/* Return how CHOICE matches PROPAGATED_EXCEPTION. */
static enum action_kind
is_handled_by (Exception_Id choice,
-#ifndef CERT
+#if GXX_EH_INTEROP
Exception_Id *eid,
-#endif
+#endif /* GXX_EH_INTEROP */
_Unwind_Exception *propagated_exception)
{
-#ifndef CERT
- char lang;
- bool primary;
-#endif
-
/* All others choice match everything. */
if (choice == GNAT_ALL_OTHERS)
return handler;
@@ -1144,7 +1159,10 @@ is_handled_by (Exception_Id choice,
)
return handler;
-#ifndef CERT
+#if GXX_EH_INTEROP
+ char lang;
+ bool primary;
+
/* C++ exception occurrences with exact (C) or base (B) type matching. */
if (((primary = exception_class_eq (propagated_exception,
CXX_EXCEPTION_CLASS))
@@ -1171,7 +1189,7 @@ is_handled_by (Exception_Id choice,
return handler;
}
}
-#endif
+#endif /* GXX_EH_INTEROP */
return nothing;
}
@@ -1259,9 +1277,9 @@ get_action_description_for (_Unwind_Ptr ip,
= (Exception_Id) get_ttype_entry_for (region, ar_filter);
act = is_handled_by (choice,
-#ifndef CERT
+#if GXX_EH_INTEROP
eid,
-#endif
+#endif /* GXX_EH_INTEROP */
uw_exception);
if (act != nothing)
{