From: Saurabh Jha <[email protected]>
Fixes regression in C++ support without exception handling by:
1. Creating Makefile fragments, t-seh-eh and t-sjlj-eh, that configures
C++ exception handling. This is sufficient to fix the regression
even if the exception handling itself is not implemented yet.
2. Adding the new Makefile fragments, t-sjlj-eh and t-seh-eh, in
libgcc/config.host.
With these changes, the compiler can now be built with C and C++.
This patch doesn't add support for Structured Exception Handling (SEH)
which will be done separately.
libgcc/ChangeLog:
* config.host: Set tmake_eh_file for aarch64-*-mingw*.
* config/aarch64/t-no-eh: Removed.
* config/aarch64/t-seh-eh: New file.
* config/aarch64/t-sjlj-eh: New file.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/mingw/mingw.exp: Add support for .cc files.
* gcc.target/aarch64/mingw/minimal_new_del.cc: New test.
Co-Authored-By: Evgeny Karpov <[email protected]>
---
.../gcc.target/aarch64/mingw/mingw.exp | 2 +-
.../aarch64/mingw/minimal_new_del.cc | 12 ++++++++++
libgcc/config.host | 9 ++++++-
libgcc/config/aarch64/t-no-eh | 2 --
libgcc/config/aarch64/t-seh-eh | 24 +++++++++++++++++++
libgcc/config/aarch64/t-sjlj-eh | 21 ++++++++++++++++
6 files changed, 66 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/aarch64/mingw/minimal_new_del.cc
delete mode 100644 libgcc/config/aarch64/t-no-eh
create mode 100644 libgcc/config/aarch64/t-seh-eh
create mode 100644 libgcc/config/aarch64/t-sjlj-eh
diff --git a/gcc/testsuite/gcc.target/aarch64/mingw/mingw.exp
b/gcc/testsuite/gcc.target/aarch64/mingw/mingw.exp
index 98622e270f76..26d65b22e750 100644
--- a/gcc/testsuite/gcc.target/aarch64/mingw/mingw.exp
+++ b/gcc/testsuite/gcc.target/aarch64/mingw/mingw.exp
@@ -34,7 +34,7 @@ if ![info exists DEFAULT_CFLAGS] then {
dg-init
# Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]*]] \
"" $DEFAULT_CFLAGS
# All done.
diff --git a/gcc/testsuite/gcc.target/aarch64/mingw/minimal_new_del.cc
b/gcc/testsuite/gcc.target/aarch64/mingw/minimal_new_del.cc
new file mode 100644
index 000000000000..d0e7a9e6e0ca
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/mingw/minimal_new_del.cc
@@ -0,0 +1,12 @@
+/* { dg-do run } */
+/* { dg-additional-options "-O2" } */
+
+/* A minimal test to validate that C++ support works. */
+
+int
+main()
+{
+ int *x = new int;
+ delete x;
+ return 0;
+}
diff --git a/libgcc/config.host b/libgcc/config.host
index 850a37b05558..d46019f363dd 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -463,7 +463,14 @@ aarch64-*-mingw*)
tmake_thr_file="mingw/t-mingw-mcfgthread"
;;
esac
- tmake_file="${tmake_file} ${cpu_type}/t-no-eh ${tmake_thr_file}"
+ # This has to match the logic for DWARF2_UNWIND_INFO in
+ # gcc/config/aarch64/cygming.h
+ if test x$ac_cv_sjlj_exceptions = xyes; then
+ tmake_eh_file="aarch64/t-sjlj-eh"
+ else
+ tmake_eh_file="aarch64/t-seh-eh"
+ fi
+ tmake_file="${tmake_file} ${tmake_eh_file} ${tmake_thr_file}"
tmake_file="${tmake_file} t-dfprules"
tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
tmake_file="${tmake_file} ${cpu_type}/t-mingw"
diff --git a/libgcc/config/aarch64/t-no-eh b/libgcc/config/aarch64/t-no-eh
deleted file mode 100644
index 1802339a5834..000000000000
--- a/libgcc/config/aarch64/t-no-eh
+++ /dev/null
@@ -1,2 +0,0 @@
-# Not using EH
-LIB2ADDEH =
diff --git a/libgcc/config/aarch64/t-seh-eh b/libgcc/config/aarch64/t-seh-eh
new file mode 100644
index 000000000000..ce87ec812be9
--- /dev/null
+++ b/libgcc/config/aarch64/t-seh-eh
@@ -0,0 +1,24 @@
+# Copyright (C) 2026 Free Software Foundation, Inc.
+# Contributed by ARM Ltd.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# We are using SEH EH.
+EH_MODEL = seh
+
+# Use SEH exception handling.
+LIB2ADDEH = $(srcdir)/unwind-seh.c $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
diff --git a/libgcc/config/aarch64/t-sjlj-eh b/libgcc/config/aarch64/t-sjlj-eh
new file mode 100644
index 000000000000..df0ac6418972
--- /dev/null
+++ b/libgcc/config/aarch64/t-sjlj-eh
@@ -0,0 +1,21 @@
+# Copyright (C) 2026 Free Software Foundation, Inc.
+# Contributed by ARM Ltd.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# We are using SjLj EH.
+EH_MODEL = sjlj
--
2.52.0