User account creation filtered due to spam.

Bug 49764 - [avr-g++] Rejects attribute progmem
Summary: [avr-g++] Rejects attribute progmem
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: 4.6.2
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-07-16 16:44 UTC by _artem_
Modified: 2011-07-27 10:51 UTC (History)
3 users (show)

See Also:
Host:
Target: avr
Build:
Known to work: 4.6.2, 4.7.0
Known to fail: 4.6.1
Last reconfirmed: 2011-07-23 17:25:59


Attachments
test case (168 bytes, text/plain)
2011-07-23 18:41 UTC, Georg-Johann Lay
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _artem_ 2011-07-16 16:44:27 UTC
Compiling any of the examples in arduino (IDE) gives this:

In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Tone.cpp:37:0:
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:66:48: error: variable 'port_to_mode_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:67:49: error: variable 'port_to_input_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:68:50: error: variable 'port_to_output_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:70:54: error: variable 'digital_pin_to_port_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:72:58: error: variable 'digital_pin_to_bit_mask_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:73:55: error: variable 'digital_pin_to_timer_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
/usr/share/arduino/hardware/arduino/cores/arduino/Tone.cpp:108:45: error: variable 'tone_pin_to_timer_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'


Additional info:
Occures only on gcc-avr-4.6.1-1, reinstalling previous (gcc-avr-4.6.0-3) gives successful compilation.
I checked the file files pins_arduino.h, pins_arduino.c and Tone.cpp on both gcc-avr-4.6.1-1 and gcc-avr-4.6.0-3 they are equal. So the issue is in the gcc-avr package.


Steps to reproduce:
1. Open arduino (IDE)
2. Select any example from File->Examples
3. Click on play icon (compile)

Step 2 can be left out, just clicking play icon (compile) on an empty sketch gives same error on gcc-avr-4.6.1-1
Comment 1 _artem_ 2011-07-16 16:47:01 UTC
p.s. I'm using ArchLinux x86_64
Comment 2 Jonathan Wakely 2011-07-16 17:25:59 UTC
http://gcc.gnu.org/bugs/
Comment 3 Jonathan Wakely 2011-07-16 17:34:10 UTC
I suppose I should be a bit more explicit - your bug report is no use to anyone.

"arduino (IDE)" doesn't mean anything to GCC developers, and neither does gcc-avr-4.6.1-1, and noone here has the examples you're talking about

You should either file a proper bug report following the instructions at the URL I provided, or report this to ArchLinux where it might mean something to someone

Since you seem to be talking about ArchLinux packages and a version of GCC provided by ArchLinux, you should probably report it to them
Comment 4 _artem_ 2011-07-16 17:57:28 UTC
thank YOU master clearness!

I did that before I posted the bug here. PROOF: https://bugs.archlinux.org/task/25136

Please don't be stupid, OK?

And please do this on your machine:
1. go to arduino.cc
2. download the ide (EVEN IF YOU DON'T HAVE AN ARDUINO BOARD, just download it TO SEE and TO REALIZE that's a gcc-avr/avr-gcc (call it what you want) bug.
3. start the ide (you even don't need to install it, just extract and run)
4. CLICK ON THE COMPILE ICON (without loading any examples, you don't even need a line of code to reproduce the bug)

please do this on gcc-avr 4.6.0 and then on gcc-avr 4.6.1 and then again on gcc-avr-4.6.1 to realize that you're a stupid moron.

Second proof that you're a stupid and INCOMPETENT person: since gcc/gcc-avr 4.5.2 when you compile a arduino code and upload it to the microcontroller everything goes well, NO ERRORS, but the biggest fail is that on the board ANY delay() function freezes the board. When you upload the SAME (THE SAME) code from a windows (OS) machine the delay() function works as expected.

So don't troll that's not a gcc issue, BECAUSE IT IS GCC bug.

p.s. you won't die if you just download and run the above listed program to see that's a gcc bug and not ide bug. I repeat, everything works except delay() function on 4.6.0 but not on 4.6.1
Comment 5 Jonathan Wakely 2011-07-16 18:10:11 UTC
please follow the bug reporting instructions for GCC, I'm not downloading additional software to verify it if you won't provide the info requested
Comment 6 Jonathan Wakely 2011-07-16 18:12:29 UTC
and don't call people morons if you expect help
Comment 7 _artem_ 2011-07-16 19:05:46 UTC
I don't understand what you want from me.
I read that "How to report, what we need and what we don't" SO?
What info you want from me in addition to the text I posted in the bug report?

I don't know 
"the complete command line that triggers the bug;"

because I don't know how to compile that code outside of IDE.
I upgraded gcc (GCC not gcc-avr) from 4.6.0 to 4.6.1 couple of days ago,
gcc-avr was still 4.6.0. I was able to compile for arduino (ATmega328P-PU). I
installed 4.6.1 of gcc-avr and I'm unable to compile for ATmega328 from IDE. I
downgraded ONLY gcc-avr to 4.6.0 result: IDE compiles code. upgraded to 4.6.1
again and I can't compile again.

You would ONLY need 3 minutes to download and to run that IDE on both versions
of gcc-avr. and You would know what's the reason is. I don't what is causing
this errors, the only thing that was changed on my machine is the GCC-AVR
version, from 4.6.0->4.6.1

lines 66-.. that are in the error:
66 extern const uint16_t PROGMEM port_to_mode_PGM[];
 67 extern const uint16_t PROGMEM port_to_input_PGM[];
 68 extern const uint16_t PROGMEM port_to_output_PGM[];
 69 
 70 extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
 71 // extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
 72 extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
 73 extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];

on gcc-avr 4.6.0 I get no errors on that code, on gcc-avr 4.6.1 I get error
listed in the first message.

"variable 'port_to_mode_PGM' must be const in order to be put into read-only"
produced from this:
extern const uint16_t PROGMEM port_to_mode_PGM[];

was there something changed in gcc-avr that would give such an error?
Comment 8 Jonathan Wakely 2011-07-16 19:36:11 UTC
(In reply to comment #7)
> I don't understand what you want from me.
> I read that "How to report, what we need and what we don't" SO?
> What info you want from me in addition to the text I posted in the bug report?

Exactly the info listed at that URL, which was missing from the bug report
i.e.
the preprocessed source of the code that fails to compile
the output of 'gcc -v'
etc.

> I don't know 
> "the complete command line that triggers the bug;"
>
> because I don't know how to compile that code outside of IDE.

Just because you don't know how to do it doesn't mean we don't want that information.

 
> You would ONLY need 3 minutes to download and to run that IDE on both versions
> of gcc-avr. and You would know what's the reason is. I don't what is causing
> this errors, the only thing that was changed on my machine is the GCC-AVR
> version, from 4.6.0->4.6.1

But the IDE doesn't come with gcc-avr, so I'd need to install that, and my distro doesn't have version 4.6.1, so I'd need to install avr-libc and build avr-gcc myself, and if you think I'm doing that just to help someone who calls me a stupid and incompetent moron then you're sorely mistaken.

> lines 66-.. that are in the error:
> 66 extern const uint16_t PROGMEM port_to_mode_PGM[];
>  67 extern const uint16_t PROGMEM port_to_input_PGM[];
>  68 extern const uint16_t PROGMEM port_to_output_PGM[];
>  69 
>  70 extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
>  71 // extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
>  72 extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
>  73 extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
> 
> on gcc-avr 4.6.0 I get no errors on that code, on gcc-avr 4.6.1 I get error
> listed in the first message.
> 
> "variable 'port_to_mode_PGM' must be const in order to be put into read-only"
> produced from this:
> extern const uint16_t PROGMEM port_to_mode_PGM[];

OK, now we're getting somewhere.  Try putting just this in a file and compiling it with gcc-avr:

extern const int __attribute__((progmem)) p[];
Comment 9 _artem_ 2011-07-16 19:54:28 UTC
[_artem_@linux-void ~]$ avr-gcc -v
Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.6.1/lto-wrapper
Target: avr
Configured with: ../configure --disable-libssp --disable-nls --enable-languages=c,c++ --infodir=/usr/share/info --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --prefix=/usr --target=avr --with-gnu-as --with-gnu-ld --with-as=/usr/bin/avr-as --with-ld=/usr/bin/avr-ld
Thread model: single
gcc version 4.6.1 (GCC) 
[_artem_@linux-void ~]$ 

I don't know how to compile that code with avr-gcc. I only compiled with gcc, but never with avr-gcc.

[_artem_@linux-void ~]$ avr-gcc 1.c -o 2

[_artem_@linux-void ~]$ cat 2
��6�����������6���=d(�D�D�D�D�D�D�
D�
   D�D�D�D�D�d(�D�DDDD D"D$&{standard input}../../../libgcc/../gcc/config/avr/libgcc.S.symtab.strtab.shstrtab.text.stab.stabstrT(!|,
                                    '�=�00�
                                                       	H" (��,?��5>��>=��G��S��`t({(����(����`�����`���	`�#/`�6`�;`�.do_clear_bss_start.do_clear_bss_loop1.c__SREG____SP_H____SP_L____tmp_reg____zero_reg____trampolines_start_etext__data_load_end__trampolines_end__data_load_start__dtors_end__bss_end__do_clear_bss__eeprom_end__data_end__ctors_start__do_copy_data__bss_start__dtors_start__ctors_end_edata_end__data_start[_artem_@linux-void ~]$ 

So I don't know why I can't compile and upload to the microcontroller. 
p.s. when you don't have gcc-avr why are you then answering to my bug report?
Comment 10 Jonathan Wakely 2011-07-16 20:26:19 UTC
(In reply to comment #9)
> p.s. when you don't have gcc-avr why are you then answering to my bug report?

I have avr-gcc-4.5.3-1.fc15.x86_64 installed and it works fine for me.

If you don't want my help that's fine.
Comment 11 _artem_ 2011-07-17 00:30:11 UTC
ok... sorry.

it seams to be a avr-g++ bug or arduino bug. 

Or avr-g++ has changed something in 4.6.1 so const declarations changed. (Then it's arduino teams job to fix the headers)

Ok now I know that the command line is:

avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 1.cpp

1.cpp (as you asked):
extern const int __attribute__((progmem)) p[];

it gives:
1.cpp:1:45: error: variable 'p' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

when I add before the "extern ..." something like:
const int p[];

it gives me:
1.cpp:1:11: error: uninitialized const 'p' [-fpermissive]
1.cpp:1:13: error: storage size of 'p' isn't known
1.cpp:2:45: error: variable 'p' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

So I have now no idea if it's arduino's headers, or avr-g++ is guilty.

p.s. here is the thread I started on arduino forum (maybe it'll be usefull for you...): http://arduino.cc/forum/index.php/topic,66710.0.html
Comment 12 Jonathan Wakely 2011-07-17 09:54:56 UTC
I see on the arduino forum that you've figured out how to run the compiler outside the IDE

Now you can add -E to the end of the command, and attach the output file to this bug report, along with the complete command you used to produce it

That will be most of the information needed for someone to look at this bug report properly
Comment 13 Jonathan Wakely 2011-07-17 09:57:25 UTC
Oops, ignore that - I didn't see your last reply here where you've already confirmed the command and the minimal testcase that produces the error. Thanks for providing that.
Comment 14 Jonathan Wakely 2011-07-17 10:02:39 UTC
CC'ing an avr maintainer, Eric could you take a look please?

avr-g++ 4.6.1 rejects this declaration in the arduino headers:

extern const int __attribute__((progmem)) p[];
Comment 15 Georg-Johann Lay 2011-07-23 18:41:50 UTC
Created attachment 24817 [details]
test case

test case passes with avr-gcc-4.6.1-RC1

avr-gcc -v -S foo.c
Using built-in specs.
COLLECT_GCC=e:\WinAVR\4.6.1\bin\avr-gcc.exe
COLLECT_LTO_WRAPPER=e:/winavr/4.6.1/bin/../libexec/gcc/avr/4.6.1/lto-wrapper.exe
Target: avr
Configured with: ../../gcc.gnu.org/gcc-4_6-branch/configure --target=avr --prefix=/local/gnu/install/gcc-4.6-mingw32 --host=i586-mingw32 --build=i686-linux-gnu --enable-languages=c,c++ --disable-nls --disable-shared --with-dwarf2
Thread model: single
gcc version 4.6.1 20110620 (prerelease) (GCC) 

GNU C (GCC) version 4.6.1 20110620 (prerelease) (avr)
	compiled by GNU C version 3.3.1 (mingw special 20030804-1), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.2
Comment 16 Georg-Johann Lay 2011-07-23 19:27:25 UTC
Ah, now I see the report is for C++. I missed that between all the curses and  scoldings...
Comment 17 Georg-Johann Lay 2011-07-25 10:23:07 UTC
Eric, would you confirm that all works fine with the
current 4.6 and 4.7 sources and close the PR?

This has already been fixed:

4_6-branch:
http://gcc.gnu.org/viewcvs?view=revision&revision=175810

trunk:
http://gcc.gnu.org/viewcvs?view=revision&revision=175809
Comment 18 _artem_ 2011-07-26 19:34:13 UTC
I've compiled gcc-avr from trunk and Arduino IDE stoped complaining about PROGMEM. I downgraded binutils-avr from 2.21 to 2.20 patched and now delay() function works as it should on arduino. Thank you guys. You can close that bug report. I'm hoping that gcc 4.7 will be released soon (so I don't have to compile it myself)
Comment 19 Jonathan Wakely 2011-07-27 01:18:20 UTC
caused by, and fixed by, changes for PR 44643