From 98f9d0ca902c48b58d3d9adee53c3a1800fd3e6d Mon Sep 17 00:00:00 2001 From: Georg-Johann Lay Date: Wed, 5 Jul 2017 13:57:28 +0000 Subject: [PATCH] Graceful degrade if Binutils PR21472 is not available. gcc/ Graceful degrade if Binutils PR21472 is not available. PR target/81072 * configure.ac [target=avr]: WARN instead of ERROR if avrxmega3 .rodata in flash test fails. (HAVE_LD_AVR_AVRXMEGA3_RODATA_IN_FLASH): Define it if test passes. * confgure: Regenerate. * config.in: Regenerate. * config/avr/avr.c (avr_asm_named_section) [HAVE_LD_AVR_AVRXMEGA3_RODATA_IN_FLASH]: Only trigger __do_copy_data for stuff in .rodata if flash_pm_offset = 0. (avr_asm_init_sections): Same. From-SVN: r250000 --- gcc/ChangeLog | 15 +++++++++++++++ gcc/config.in | 7 +++++++ gcc/config/avr/avr.c | 7 ++++++- gcc/configure | 15 +++++++++------ gcc/configure.ac | 12 ++++++------ 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c566a3a6cf9..5e1eecde448 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2017-07-05 Georg-Johann Lay + + Graceful degrade if Binutils PR21472 is not available. + + PR target/81072 + * configure.ac [target=avr]: WARN instead of ERROR if avrxmega3 + .rodata in flash test fails. + (HAVE_LD_AVR_AVRXMEGA3_RODATA_IN_FLASH): Define it if test passes. + * confgure: Regenerate. + * config.in: Regenerate. + * config/avr/avr.c (avr_asm_named_section) + [HAVE_LD_AVR_AVRXMEGA3_RODATA_IN_FLASH]: Only trigger + __do_copy_data for stuff in .rodata if flash_pm_offset = 0. + (avr_asm_init_sections): Same. + 2017-07-05 Ramana Radhakrishnan * config/arm/neon.md (fma4): Remove %?. diff --git a/gcc/config.in b/gcc/config.in index bf2aa7b2e7d..44c7a68eaa8 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1460,6 +1460,13 @@ #endif +/* Define if your default avr linker script for avrxmega3 leaves .rodata in + flash. */ +#ifndef USED_FOR_TARGET +#undef HAVE_LD_AVR_AVRXMEGA3_RODATA_IN_FLASH +#endif + + /* Define if your linker supports -z bndplt */ #ifndef USED_FOR_TARGET #undef HAVE_LD_BNDPLT_SUPPORT diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 030a9d9ee97..ba35b9e1542 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -10000,7 +10000,9 @@ avr_asm_init_sections (void) resp. `avr_need_copy_data_p'. If flash is not mapped to RAM then we have also to track .rodata because it is located in RAM then. */ +#if defined HAVE_LD_AVR_AVRXMEGA3_RODATA_IN_FLASH if (0 == avr_arch->flash_pm_offset) +#endif readonly_data_section->unnamed.callback = avr_output_data_section_asm_op; data_section->unnamed.callback = avr_output_data_section_asm_op; bss_section->unnamed.callback = avr_output_bss_section_asm_op; @@ -10036,7 +10038,10 @@ avr_asm_named_section (const char *name, unsigned int flags, tree decl) || STR_PREFIX_P (name, ".gnu.linkonce.d")); if (!avr_need_copy_data_p - && 0 == avr_arch->flash_pm_offset) +#if defined HAVE_LD_AVR_AVRXMEGA3_RODATA_IN_FLASH + && 0 == avr_arch->flash_pm_offset +#endif + ) avr_need_copy_data_p = (STR_PREFIX_P (name, ".rodata") || STR_PREFIX_P (name, ".gnu.linkonce.r")); diff --git a/gcc/configure b/gcc/configure index 317517c1ab0..4c5900fc1ba 100755 --- a/gcc/configure +++ b/gcc/configure @@ -24851,29 +24851,32 @@ EOF ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } - if test -f conftest.nm + if test -s conftest.nm then if grep ' R xxvaryy' conftest.nm > /dev/null; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - rm -f conftest.s conftest.o conftest.elf conftest.nm + +$as_echo "#define HAVE_LD_AVR_AVRXMEGA3_RODATA_IN_FLASH 1" >>confdefs.h + else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no: avrxmega3 .rodata located in RAM" >&5 $as_echo "no: avrxmega3 .rodata located in RAM" >&6; } echo "$as_me: nm output was" >&5 cat conftest.nm >&5 - rm -f conftest.s conftest.o conftest.elf conftest.nm avr_ld_ver="`$gcc_cv_ld -v | sed -e 's:^.* ::'`" - as_fn_error "support for avrxmega3 needs Binutils 2.29 or higher (have $avr_ld_ver)" "$LINENO" 5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: support for avrxmega3 .rodata in flash needs Binutils 2.29 or higher (have $avr_ld_ver)" >&5 +$as_echo "$as_me: WARNING: support for avrxmega3 .rodata in flash needs Binutils 2.29 or higher (have $avr_ld_ver)" >&2;} fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: test failed" >&5 $as_echo "test failed" >&6; } echo "$as_me: failed program was" >&5 cat conftest.s >&5 - rm -f conftest.s conftest.o conftest.elf - as_fn_error "see \`config.log' for details" "$LINENO" 5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: see \`config.log' for details" >&5 +$as_echo "$as_me: WARNING: see \`config.log' for details" >&2;} fi + rm -f conftest.s conftest.o conftest.elf conftest.nm ;; cris-*-*) diff --git a/gcc/configure.ac b/gcc/configure.ac index e1b03a9ac96..f50223a70ba 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -3832,26 +3832,26 @@ EOF AC_TRY_COMMAND([$gcc_cv_as -mmcu=avrxmega3 conftest.s -o conftest.o]) AC_TRY_COMMAND([$gcc_cv_ld -mavrxmega3 conftest.o -o conftest.elf]) AC_TRY_COMMAND([$gcc_cv_nm conftest.elf > conftest.nm]) - if test -f conftest.nm + if test -s conftest.nm then if grep ' R xxvaryy' conftest.nm > /dev/null; then AC_MSG_RESULT(yes) - rm -f conftest.s conftest.o conftest.elf conftest.nm + AC_DEFINE(HAVE_LD_AVR_AVRXMEGA3_RODATA_IN_FLASH, 1, + [Define if your default avr linker script for avrxmega3 leaves .rodata in flash.]) else AC_MSG_RESULT(no: avrxmega3 .rodata located in RAM) echo "$as_me: nm output was" >&AS_MESSAGE_LOG_FD cat conftest.nm >&AS_MESSAGE_LOG_FD - rm -f conftest.s conftest.o conftest.elf conftest.nm avr_ld_ver="`$gcc_cv_ld -v | sed -e 's:^.* ::'`" - AC_MSG_ERROR([[support for avrxmega3 needs Binutils 2.29 or higher (have $avr_ld_ver)]]) + AC_MSG_WARN([[support for avrxmega3 .rodata in flash needs Binutils 2.29 or higher (have $avr_ld_ver)]]) fi else AC_MSG_RESULT(test failed) echo "$as_me: failed program was" >&AS_MESSAGE_LOG_FD cat conftest.s >&AS_MESSAGE_LOG_FD - rm -f conftest.s conftest.o conftest.elf - AC_MSG_ERROR([[see `config.log' for details]]) + AC_MSG_WARN([[see `config.log' for details]]) fi + rm -f conftest.s conftest.o conftest.elf conftest.nm ;; cris-*-*) -- 2.30.2