-fmerge-all-constants and –fmerge-constants don’t work at AVR target. Example: const char text1[] PROGMEM=”Test”; const char text2[] PROGMEM=”Test”; will still produce duplicated “Test” string in generated code.
I think this is essentially a duplicate of bug #21018.
Yes, it seems that you are right. I mark it as duplicate of bug #21018 *** This bug has been marked as a duplicate of 21018 ***
Reopening this enhancement request. Bug #21018, which this was marked a duplicate of, is now marked as WONTFIX.
Author: gjl Date: Thu Jul 14 07:49:14 2011 New Revision: 176262 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176262 Log: gcc/ PR target/43746 * config/avr/elf.h (TARGET_ASM_SELECT_SECTION): Remove, i.e. use default_elf_select_section. (TARGET_HAVE_SWITCHABLE_BSS_SECTIONS): Remove. (READONLY_DATA_SECTION_ASM_OP): Remove. (TARGET_ASM_NAMED_SECTION): Move from here... * config/avr/avr.c: ...to here. (avr_asm_init_sections): Set unnamed callback of readonly_data_section. (avr_asm_named_section): Make static. testsuite/ PR target/43746 * gcc.dg/array-quals-1.c: Don't xfail on AVR. Modified: trunk/gcc/ChangeLog trunk/gcc/config/avr/avr.c trunk/gcc/config/avr/elf.h trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/array-quals-1.c
Set the status to NEW. The above patch fixes constant merging for constants in .rodata which is mapped into RAM for AVR. To make it work for .progmem (data in Flash) requires a seperate patch.
*** Bug 21018 has been marked as a duplicate of this bug. ***
Author: gjl Date: Mon Sep 12 10:06:46 2011 New Revision: 178779 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178779 Log: gcc/ PR target/43746 * config/avr/avr.c (AVR_SECTION_PROGMEM): New Define. (progmem_section): New Variable. (avr_asm_init_sections): Initialize it. (TARGET_ASM_SELECT_SECTION): Define to... (avr_asm_select_section): ... this new Function. (avr_replace_prefix): New Function. (avr_asm_function_rodata_section): Use it. (avr_insert_attributes): Don't add section attribute for PROGMEM. (avr_section_type_flags): Use avr_progmem_p instead of section name to detect if object is in PROGMEM. (avr_asm_named_section): Set section name prefix for objects in PROGMEM. testsuite/ PR target/43746 * testsuite/gcc.target/avr/torture/avr-torture.exp (AVR_TORTURE_OPTIONS): Add test cases "-O2 -fdata-sections" and "-O2 -fmerge-all-constants". Modified: trunk/gcc/ChangeLog trunk/gcc/config/avr/avr.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp
Closed as fixed for 4.7 Milestone. Initially I intended to add a -fprogmem-sections command line option that works similar but independent to -fdata-section. That way data sections could be used and strings in progmem merged. However, I did not find a straight forward way without cluttering avr BE with lots of code from varasm.c. Thus, for now, there is no -fprogmem-sections, i.e. progmem-sections are in sync with data-sections and you have to decide wether you prefer string merging or fine grained sections.