diff --git a/ChangeLog b/ChangeLog index 9e8443269101736dd09dd497212126d2e16a8295..19b3c5eb229b3e57ded3431fcc8817769bb11a4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ +2019-12-11 Jozef Lawrynowicz <jozef.l@mittosystems.com> + + * config-ml.in (msp430-*-*): Support --disable-no-exceptions configure + flag. + 2019-12-10 Lewis Hyatt <lhyatt@gmail.com> - * MAINTAINERS (Write After Approval): Add myself. + * MAINTAINERS (Write After Approval): Add myself. 2019-11-27 Tobias Burnus <tobias@codesourcery.com> diff --git a/config-ml.in b/config-ml.in index 3e37f875c88feccccbe4c7940d1c0ce7af55bb92..5720d38d23f9a0b0a429efd870e6350b1fb83fbe 100644 --- a/config-ml.in +++ b/config-ml.in @@ -383,6 +383,19 @@ mips*-*-*) done fi ;; +msp430-*-*) + if [ x$enable_no_exceptions = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *no-exceptions* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + ;; powerpc*-*-* | rs6000*-*-*) if [ x$enable_aix64 = xno ] then diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 747b04dd5f2ec13614031971002cdb4473d151e5..77723836c29bb9a36752cb301bf6cc0102277793 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2019-12-11 Jozef Lawrynowicz <jozef.l@mittosystems.com> + + * config/msp430/msp430.h (STARTFILE_SPEC) [!fexceptions]: Use + crtbegin_no_eh.o if building for the C language. + [fno-exceptions]: Use crtbegin_no_eh.o if building for any language + except C. + (ENDFILE_SPEC) [!fexceptions]: Use crtend_no_eh.o if building for + the C language. + [fno-exceptions]: Use crtend_no_eh.o if building for any language + except C. + * config/msp430/t-msp430: Add -fno-exceptions multilib. + * doc/install.texi: Document --disable-no-exceptions multilib configure + option. + * doc/sourcebuild.texi: Document exceptions_enabled effective target. + 2019-12-11 David Malcolm <dmalcolm@redhat.com> * pretty-print.c (pretty_printer::pretty_printer): New copy-ctor. diff --git a/gcc/config/msp430/msp430.h b/gcc/config/msp430/msp430.h index 0ea6b0a093e64951776d9c998a0d609a18fc578d..7b94918a55dc835635437f2f856f23e808eddd02 100644 --- a/gcc/config/msp430/msp430.h +++ b/gcc/config/msp430/msp430.h @@ -44,13 +44,20 @@ extern bool msp430x; } \ while (0) +/* For the "c" language where exceptions are implicitly disabled, use + crt*_no_eh.o unless -fexceptions is passed. For other languages, only use + crt*_no_eh.o if -fno-exceptions is explicitly passed. */ #undef STARTFILE_SPEC #define STARTFILE_SPEC "%{pg:gcrt0.o%s}" \ - "%{!pg:%{minrt:crt0-minrt.o%s}%{!minrt:crt0.o%s}} %{!minrt:crtbegin.o%s}" + "%{!pg:%{minrt:crt0-minrt.o%s}%{!minrt:crt0.o%s}} " \ + "%{!minrt:%{,c:%{!fexceptions:crtbegin_no_eh.o%s; :crtbegin.o%s}; " \ + ":%{fno-exceptions:crtbegin_no_eh.o%s; :crtbegin.o%s}}}" /* -lgcc is included because crtend.o needs __mspabi_func_epilog_1. */ #undef ENDFILE_SPEC -#define ENDFILE_SPEC "%{!minrt:crtend.o%s} " \ +#define ENDFILE_SPEC \ + "%{!minrt:%{,c:%{!fexceptions:crtend_no_eh.o%s; :crtend.o%s}; " \ + ":%{fno-exceptions:crtend_no_eh.o%s; :crtend.o%s}}} " \ "%{minrt:%:if-exists(crtn-minrt.o%s)}%{!minrt:%:if-exists(crtn.o%s)} -lgcc" #define ASM_SPEC "-mP " /* Enable polymorphic instructions. */ \ diff --git a/gcc/config/msp430/t-msp430 b/gcc/config/msp430/t-msp430 index f8ba7751123d26ce85d5c95e92f047437a7d3d7d..e180ce3efdbf6e16a63cdbc2291e7b848270295c 100644 --- a/gcc/config/msp430/t-msp430 +++ b/gcc/config/msp430/t-msp430 @@ -28,8 +28,8 @@ msp430-devices.o: $(srcdir)/config/msp430/msp430-devices.c \ # Enable multilibs: -MULTILIB_OPTIONS = mcpu=msp430 mlarge mdata-region=none -MULTILIB_DIRNAMES = 430 large full-memory-range +MULTILIB_OPTIONS = mcpu=msp430 mlarge mdata-region=none fno-exceptions +MULTILIB_DIRNAMES = 430 large full-memory-range no-exceptions # Match -mcpu=430 MULTILIB_MATCHES = mcpu?msp430=mcpu?430 @@ -41,9 +41,10 @@ MULTILIB_MATCHES += mdata-region?none=mdata-region?either # hard-coded data here, because DRIVER_SELF_SPECS will place the correct # -mcpu option for a given mcu onto the command line. -MULTILIB_REQUIRED = mcpu=msp430 -MULTILIB_REQUIRED += mlarge +MULTILIB_REQUIRED = mcpu=msp430 mlarge +MULTILIB_REQUIRED += fno-exceptions mcpu=msp430/fno-exceptions mlarge/fno-exceptions MULTILIB_REQUIRED += mlarge/mdata-region=none +MULTILIB_REQUIRED += mlarge/mdata-region=none/fno-exceptions MULTILIB_EXTRA_OPTS = diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 80b47812fe66a8ef50edf3aad9708ab3409ba7dc..19d649ccc83c938f71ebbee44a6197df7ea252ec 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -1086,6 +1086,9 @@ softfloat, m68881, m68000, m68020. @item mips*-*-* single-float, biendian, softfloat. +@item msp430-*-* +no-exceptions + @item powerpc*-*-*, rs6000*-*-* aix64, pthread, softfloat, powercpu, powerpccpu, powerpcos, biendian, sysv, aix. diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 3950c82c685d55cb8aada0465b5337555fafbd92..85573a49a2b28de71ef4ca9659cd5af86ea46b81 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2274,6 +2274,10 @@ Target has packed layout of structure members by default. @item exceptions Target supports exceptions. +@item exceptions_enabled +Target supports exceptions and they are enabled in the current +testing configuration. + @item fgraphite Target supports Graphite optimizations. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0c22a9cdd2f8047d8d2ae054424ecff84ff8b28d..57d2a1162c6d96e790b4627c03a55e1970f51672 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-12-11 Jozef Lawrynowicz <jozef.l@mittosystems.com> + + * lib/gcc-dg.exp: Add dg-prune messages for when exception handling is + disabled. + * lib/target-supports.exp (check_effective_target_exceptions_enabled): + New. + 2019-12-11 Jakub Jelinek <jakub@redhat.com> PR c++/92869 diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 1df645e283c46c9c5debfc7f1762f1a05e71cc65..7396daa4a1d274ad999c47029a8c9971f08964f0 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -417,6 +417,18 @@ proc gcc-dg-prune { system text } { return "::unsupported::large return values" } + # If exceptions are disabled, mark tests expecting exceptions to be enabled + # as unsupported. + if { ![check_effective_target_exceptions_enabled] } { + if [regexp "(^|\n)\[^\n\]*: error: exception handling disabled" $text] { + return "::unsupported::exception handling disabled" + } + + if [regexp "(^|\n)\[^\n\]*: error: #error .__cpp_exceptions." $text] { + return "::unsupported::exception handling disabled" + } + } + return $text } diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 5b4cc02f9219ed8cfa329f97732abffca677883c..80e9d6720bd167180dcc11344396db5b2895820e 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -8990,6 +8990,24 @@ proc check_effective_target_exceptions {} { return 1 } +# Used to check if the testing configuration supports exceptions. +# Returns 0 if exceptions are unsupported or disabled (e.g. by passing +# -fno-exceptions). Returns 1 if exceptions are enabled. +proc check_effective_target_exceptions_enabled {} { + return [check_cached_effective_target exceptions_enabled { + if { [check_effective_target_exceptions] } { + return [check_no_compiler_messages exceptions_enabled assembly { + void foo (void) + { + throw 1; + } + }] + } else { + # If exceptions aren't supported, then they're not enabled. + return 0 + } + }] +} proc check_effective_target_tiny {} { return [check_cached_effective_target tiny { diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index b415d78a8af8f563f6c6a0621f11f84e61d81bd8..90ea2a48b3cf98db3ea68952f686d12bede84de0 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,9 @@ +2019-12-11 Jozef Lawrynowicz <jozef.l@mittosystems.com> + + * config.host (msp430*-*-elf): Add crt{begin,end}_no_eh.o to + "extra_parts". + * config/msp430/t-msp430: Add rules to build crt{begin,end}_no_eh.o. + 2019-12-11 Jozef Lawrynowicz <jozef.l@mittosystems.com> * crtstuff.c: Declare __dso_handle only if DEFAULT_USE_CXA_ATEXIT is diff --git a/libgcc/config.host b/libgcc/config.host index bc3e497739f84946bba11bc256434229b43a3055..56868719fc8c048d61d3014309f1bf1c05114b38 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -1045,7 +1045,8 @@ moxie-*-elf | moxie-*-moxiebox* | moxie-*-uclinux* | moxie-*-rtems*) ;; msp430*-*-elf) tmake_file="$tm_file t-crtstuff t-fdpbit msp430/t-msp430" - extra_parts="$extra_parts libmul_none.a libmul_16.a libmul_32.a libmul_f5.a" + extra_parts="$extra_parts crtbegin_no_eh.o crtend_no_eh.o" + extra_parts="$extra_parts libmul_none.a libmul_16.a libmul_32.a libmul_f5.a" ;; nds32*-linux*) # Basic makefile fragment and extra_parts for crt stuff. diff --git a/libgcc/config/msp430/t-msp430 b/libgcc/config/msp430/t-msp430 index 17d85b6cb237f31d30180aaf5d29713e7dbfafc4..72ae93a8daeab6d30039ebc505b41da099b72b6c 100644 --- a/libgcc/config/msp430/t-msp430 +++ b/libgcc/config/msp430/t-msp430 @@ -42,6 +42,12 @@ LIB2ADD = \ HOST_LIBGCC2_CFLAGS += -Os -ffunction-sections -fdata-sections -mhwmult=none +crtbegin_no_eh.o: $(srcdir)/crtstuff.c + $(crt_compile) -U__LIBGCC_EH_FRAME_SECTION_NAME__ -c $< -DCRT_BEGIN + +crtend_no_eh.o: $(srcdir)/crtstuff.c + $(crt_compile) -U__LIBGCC_EH_FRAME_SECTION_NAME__ -c $< -DCRT_END + mpy.o: $(srcdir)/config/msp430/mpy.c $(gcc_compile) $< -c