CC65: Local label overflow
Moderator: Moderators
CC65: Local label overflow
Hello everyone:
There is a time in the development of my game that despite having plenty of space to use (it is a 128Kb rom), the cc65 compiler gives me the error "Local label overflow" as soon as I try to add some more code, or chr data , Or nametables, etc. . .
It's like I'm on top of it despite having space.
Does anyone know what happens?
There is a time in the development of my game that despite having plenty of space to use (it is a 128Kb rom), the cc65 compiler gives me the error "Local label overflow" as soon as I try to add some more code, or chr data , Or nametables, etc. . .
It's like I'm on top of it despite having space.
Does anyone know what happens?
Re: CC65: Local label overflow
Do you have any local labelling structures that exceed 65535 generated labels? You really need to post code, I'm sorry to say.
Re: CC65: Local label overflow
I'm always worrying that I'm gonna reach some kind of limit because I often use labels in unconventional ways in ca65, so I have to say this is pretty scary.
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: CC65: Local label overflow
That's a new one, for me.
https://github.com/cc65/cc65/blob/maste ... asmlabel.c
So... you've made 65,000 local labels? Are you using some kind of macro library that generates hundreds of labels in a single statement?
https://github.com/cc65/cc65/blob/maste ... asmlabel.c
So... you've made 65,000 local labels? Are you using some kind of macro library that generates hundreds of labels in a single statement?
Re: CC65: Local label overflow
I have been with this project for months and the truth is that I am already used to this kind of thing.tokumaru wrote:I'm always worrying that I'm gonna reach some kind of limit because I often use labels in unconventional ways in ca65, so I have to say this is pretty scary.
Luckily I already have a first version of the game finished. . . But without music.
Let's see where I put the music now
With the few knowledge I have. . . No, I have not used macros.rainwarrior wrote:That's a new one, for me.
https://github.com/cc65/cc65/blob/maste ... asmlabel.c
So... you've made 65,000 local labels? Are you using some kind of macro library that generates hundreds of labels in a single statement?
Could it be that I've gotten to write 65,000 lines of code? Not really how many lines I wrote because I have everything separated in several files and the truth is that it would take me quite a while to get the count.
I have just written the program like any other that a junior writes: variables, arrays to store position data, functions with their if, some for, etc. . .
The overflow also happens if I modify some screen graphically to the point of exceeding a few kb the previous space.
Re: CC65: Local label overflow
What about exceeding 65535 labels? Is this C code you've written or pure assembly code?
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: CC65: Local label overflow
The error you're getting should be an assembly-time error, not a link-time error. It should be specific to assembling one .s file, and anything you put in other files is unrelated.Diskover wrote:Let's see where I put the music now
...
I have everything separated in several files
So... you should be able to put music in its own translation unit, unrelated to this problem.
Are you properly combining objects together at link time, or are you building everything in a single assembly? (i.e. is everything .included into a single file that you assemble?)
Re: CC65: Local label overflow
I'm guessing it's C code (asmlabel.c is part of the C compiler), and a huge amount of code all in one compilation unit ("C file").
The "local label" in this case refers to the throwaway assembly labels generated by the C compiler. The label is local to the compilation unit. For example:
(cl65 -Oirs -c --listing loclab.lst loclab.c) =>
(Some of the labels like L0004 have been removed in the optimization passes.)
The fix is to split your project into more than one compilation unit ("C file"), compile them separately and link. Whether this is easy or hard depends on how your project is structured.
The limit of 65536 labels is probably an artificial one, intended to catch compilations gone awry, so another option would be to persuade the cc65 devs to increase the limit.
EDIT: Changed "file" to "C file" to try to drive home the point that it's not enough to have multiple files and just #include them from one file, that'd still be a single compilation unit.
The "local label" in this case refers to the throwaway assembly labels generated by the C compiler. The label is local to the compilation unit. For example:
Code: Select all
int main(void) {
static char i, sum;
for(i = 0; i < 10; ++i)
sum += i;
return sum;
}
Code: Select all
000000r 1 .proc _main: near
000000r 1
000000r 1 .segment "BSS"
000000r 1
000000r 1 L0002:
000000r 1 00 .res 1,$00
000001r 1 L0003:
000001r 1 00 .res 1,$00
000002r 1
000002r 1 .segment "CODE"
000000r 1
000000r 1 A9 00 lda #$00
000002r 1 8D rr rr sta L0002
000005r 1 AD rr rr L000F: lda L0002
000008r 1 C9 0A cmp #$0A
00000Ar 1 B0 0D bcs L0010
00000Cr 1 18 clc
00000Dr 1 6D rr rr adc L0003
000010r 1 8D rr rr sta L0003
000013r 1 EE rr rr inc L0002
000016r 1 4C rr rr jmp L000F
000019r 1 AD rr rr L0010: lda L0003
00001Cr 1 A2 00 ldx #$00
00001Er 1 60 rts
00001Fr 1
00001Fr 1 .endproc
The fix is to split your project into more than one compilation unit ("C file"), compile them separately and link. Whether this is easy or hard depends on how your project is structured.
The limit of 65536 labels is probably an artificial one, intended to catch compilations gone awry, so another option would be to persuade the cc65 devs to increase the limit.
EDIT: Changed "file" to "C file" to try to drive home the point that it's not enough to have multiple files and just #include them from one file, that'd still be a single compilation unit.
Last edited by thefox on Tue Dec 13, 2016 6:21 pm, edited 1 time in total.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: CC65: Local label overflow
Ah, right, sorry. I should have been saying "compile" instead of "assemble".thefox wrote:I'm guessing it's C code (asmlabel.c is part of the C compiler)
I think it would be better to check for broken code generation before trying to increase the limit. This might be a symptom of a different problem, rather than simply "running out".thefox wrote:The limit of 65536 labels is probably an artificial one, intended to catch compilations gone awry, so another option would be to persuade the cc65 devs to increase the limit.
Again, if you can, post the files being built by the step that fails, or share them privately with someone you can help.
Re: CC65: Local label overflow
Yeah, it could be a code generation problem, depends on how many lines of code there actually are in the op's files. The simple example I made has about 4 lines, but already generates 16 local labels. It's not out of the question that you might run out with a lot of code in one file. The listing file will have the answer.rainwarrior wrote:I think it would be better to check for broken code generation before trying to increase the limit. This might be a symptom of a different problem, rather than simply "running out".
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
- OscarRichard
- Posts: 30
- Joined: Sun Jul 29, 2012 9:58 am
- Location: Mexico
- Contact:
Re: CC65: Local label overflow
In my case I'm doing several arrays for my level, but I already got the message Local Label Overflow when compiling.
My game got the UNROM mapping with 16 prg banks (got the half so far) and also uses C code.
Any way/tool about increasing the limit in my project or do I must go back to 8 banks and make 2 roms with that?
My game got the UNROM mapping with 16 prg banks (got the half so far) and also uses C code.
Any way/tool about increasing the limit in my project or do I must go back to 8 banks and make 2 roms with that?
Re: CC65: Local label overflow
Stop putting everything in one file. It's ugly.