Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2017-11

AVR - assembler error when compiling large files

8 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Christo

I am busy adding extra definitions to the AVR mcu files.  I've encountered a problem when building some controller files with lots of record and set definitions.  When I build the RTL the build process fails with lots of assembler errors:
../../rtl/units/avr-embedded/atmega32u4.s: Assembler messages: ../../rtl/units/avr-embedded/atmega32u4.s:37285: Error: value of 65611 too large for field of 2 bytes at 65609

The lines surrounding the first error:
_sATMEGA32U4s_Ld549:
.uleb128 6
.ascii "rtti_enum_basetype_array_rec$00000070\000" .short .La454  <===== line 37285
.La454:
.uleb128 12
.ascii "$RTTI_ENUM_BASETYPE_ARRAY_REC$00000070\000"

It seems as if there are too many data entries to fit into a 16 bit value (.short). Note that this is only an issue for large files, smaller files do not have this problem.

 Is there a way to instruct the compiler to use a larger data type when emitting this information to the assembler file?

Reply by email

Florian Klämpfl
to Christo
Christo wrote 20 lines
I am busy adding extra definitions to the AVR mcu files.  I've encountered a problem when building some controller files with lots of record and set definitions.  When I build the RTL the build process fails with lots of assembler errors: ../../rtl/units/avr-embedded/atmega32u4.s: Assembler messages: ../../rtl/units/avr-embedded/atmega32u4.s:37285: Error: value of 65611 too large for field of 2 bytes at 65609 The lines surrounding the first error: _sATMEGA32U4s_Ld549: .uleb128 6 .ascii "rtti_enum_basetype_array_rec$00000070\000" .short .La454  <===== line 37285 .La454: .uleb128 12 .ascii "$RTTI_ENUM_BASETYPE_ARRAY_REC$00000070\000" It seems as if there are too many data entries to fit into a 16 bit value (.short). Note that this is only an issue for large files, smaller files do not have this problem.

What happens if you compile them with -CX?

 Is there a way to instruct the compiler to use a larger data type when emitting this information to the assembler file?

This makes no sense as the program code using this data would not know about this.

Reply by email

Christo
to Florian Klämpfl
Florian Klämpfl wrote
What happens if you compile them with -CX?

Same problem.

Show quoted text 5 lines
>  Is there a way to instruct the compiler to use a larger data type > when > emitting this information to the assembler file? This makes no sense as the program code using this data would not know about this.

That was a clue to show I'm in unfamiliar territory.

I experienced the problem when using the supplied make file to build an AVR RTL.  When I compiled the unit by hand, it worked.  I then noticed that the problem seems to be related to the -g option.  If I compile the large unit with -gw3 it was fine but when I compile the large unit with -g it gave the "Error: value of 65611 too large for field of 2 bytes at 65609" type errors.

I tried passing OPT=-gw3 to make, but then the system unit cannot compile. Unfortunately this means I cannot use the current makefile to compile AVR RTL with large unit files.

Reply by email

Florian Klämpfl
to Christo
Christo wrote 22 lines
On Sat, 2017-11-25 at 18:27 +0100, Florian Klämpfl wrote: > What happens if you compile them with -CX? Same problem. >>  Is there a way to instruct the compiler to use a larger data type >> when >> emitting this information to the assembler file? > This makes no sense as the program code using this data would not > know about this. That was a clue to show I'm in unfamiliar territory. I experienced the problem when using the supplied make file to build an AVR RTL.  When I compiled the unit by hand, it worked.  I then noticed that the problem seems to be related to the -g option.  If I compile the large unit with -gw3 it was fine but when I compile the large unit with -g it gave the "Error: value of 65611 too large for field of 2 bytes at 65609" type errors. I tried passing OPT=-gw3 to make, but then the system unit cannot compile. Unfortunately this means I cannot use the current makefile to compile AVR RTL with large unit files.

What command line do you use?

Reply by email

Christo
to Florian Klämpfl
Florian Klämpfl wrote 33 lines
Am 25.11.2017 um 22:19 schrieb Christo: > > On Sat, 2017-11-25 at 18:27 +0100, Florian Klämpfl wrote: > > > > What happens if you compile them with -CX? > Same problem. > > > > > > > > >  Is there a way to instruct the compiler to use a larger data > > > type > > > when > > > emitting this information to the assembler file? > > This makes no sense as the program code using this data would not > > know about this. > That was a clue to show I'm in unfamiliar territory. > > I experienced the problem when using the supplied make file to > build an > AVR RTL.  When I compiled the unit by hand, it worked.  I then > noticed > that the problem seems to be related to the -g option.  If I > compile > the large unit with -gw3 it was fine but when I compile the large > unit > with -g it gave the "Error: value of 65611 too large for field of 2 > bytes at 65609" type errors. > > I tried passing OPT=-gw3 to make, but then the system unit cannot > compile. Unfortunately this means I cannot use the current makefile > to > compile AVR RTL with large unit files. What command line do you use?

I'm compiling the RTL with ppcrossavr, so I follow the sequence from the make file from source folder rtl/embedded.  First step: [path]/ppcrossavr -Cpavr5 @rtl.cfg -Ur -Tembedded -Pavr -XPavr- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../avr -FE. -FU../../rtl/units/avr-embedded -davr -dRELEASE -Us -Sg system.pp

Then:
[path]/ppcrossavr -Cpavr5 @rtl.cfg -Ur -Tembedded -Pavr -XPavr- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../avr -FE. -FU../../rtl/units/avr-embedded -davr -dRELEASE ../avr/intrinsics.pp

Then a shortish unit (1363 lines):
[path]/ppcrossavr -Cpavr5 @rtl.cfg -Ur -Tembedded -Pavr -XPavr- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../avr -FE. -FU../../rtl/units/avr-embedded -davr -dRELEASE -g avr/atmega328p.pp

Then a long unit (2425 lines of code):
[path]/ppcrossavr -Cpavr5 @rtl.cfg -Ur -Tembedded -Pavr -XPavr- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../avr -FE. -FU../../rtl/units/avr-embedded -davr -dRELEASE -g avr/atmega32u4.pp

I then get the stated errors for atmega32u4.pp and other "large" files.  The differences in content between the file that compiles/assemble and the one that doesn't is similar, there is just more of the same declarations in the file because the controller has more hardware registers.

I can compile atmega32u4.pp by using the following: [path]/ppcrossavr -Cpavr5 @rtl.cfg -Ur -Tembedded -Pavr -XPavr- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../avr -FE. -FU../../rtl/units/avr-embedded -davr -dRELEASE -gw3 avr/atmega32u4.pp

So simply switching to dwarf3 fixes the assembler problem (error while assembling).

Reply by email

Christo
to Florian Klämpfl: What command line do you use?
Florian Klämpfl wrote
What command line do you use?

Also note that not specifying debug info (no -g) there is also no problem compiling atmega32u4.pp:
ppcrossavr -Cpavr5 @rtl.cfg -Ur -Tembedded -Pavr -XPavr- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../avr -FE. -FU../../rtl/units/avr-embedded -davr  -dRELEASE avr/atmega32u4.pp 

For testing purposes two files can be found here: https://github.com/ccrause/fpc-avr/tree/master /src/rtl-avr-modifications/embedded/avr

The atmega328p.pp file compiles with the default settings in the make file, while atmega32u4.pp doesn't compile/assemble properly with -g.

Reply by email

Florian Klämpfl
to Christo
Christo wrote 5 lines
On Tue, 2017-11-28 at 20:08 +0100, Florian Klämpfl wrote: > What command line do you use? Also note that not specifying debug info (no -g) there is also no problem compiling atmega32u4.pp:

Should be fixed with r37661, avr requires at least dwarf-3 to be used.

Reply by email

Christo
to Florian Klämpfl
Florian Klämpfl wrote 8 lines
Am 30.11.2017 um 21:22 schrieb Christo: > > On Tue, 2017-11-28 at 20:08 +0100, Florian Klämpfl wrote: > > > > What command line do you use? > Also note that not specifying debug info (no -g) there is also no problem compiling > atmega32u4.pp: Should be fixed with r37661, avr requires at least dwarf-3 to be used.

Confirmed, r37661 now compiles AVR RTL with large files, thanks Florian. 

Reply by email