Moving from gcc 3.3.1 to gcc 4.3.3

OP #1255433
I'm trying to adapt source code and create a makefile accordingly to the 
explanation below.
The code used to be compiled with gcc 3.3.1, used at the time with Keil 
(just as IDE), and also *.s and *.ld files from Keil.

Currently, I have gcc 4.3.3 compiler and Eclipse IDE, still the same *.s 
and *.ld files from Keil and I also had to create a makefile.

The makefile was created accordingly with the previous 
compiler/assembler control strings from Keil options screen. Although, 
some strings had to be added or changed to match the new compiler 
version. The source code was also adapted to match the new compiler 
version.

The result is that I can only get "some life signals" with no 
optimization level (with gcc 3.3.1 I was using O1), but:
- The memory occupied is almost 50% larger then with gcc 3.3.1 
compilation and Keil IDE.
- The program runs something like 4 times slower (related with PLL?)
- Not everything works, such as the LCD.

The uC is the LPC2106 and I'm using Yagarto toolchain.

Any clues?
Thanks in advance!

danr
Moderator
First of all search for missing volatiles. Most but not all problems 
seen when higher optimization levels are enabled are caused by missing 
volatiles (in empty loops or when accessing data from ISRs and the 
"main-thread").

Maybe the LCD does not work since delay-loops are used which get 
"optimized away". Try to add volatile to the loop-counter declaration if 
not already there.

Do you used stdio? IRC the Keil 3.3.1 GNU package uses a different libc 
and different lowlevel interface than most other GNU packages which 
usually use newlib (like Yagarto).

The PLL-configuration should be independent from any optimization 
settings.

How are ISRs declared? Do you use the GCC IRQ attribute, nacked 
attribute with inline-assembler entry/exit code or an assembler-wrapper 
for IRQs?
Regarding 'volatile' read this: 
http://www.embedded.com/columns/beginerscorner/9900209

GCC 4.x performs stronger optimisation than 3.x. I would be surprised if 
it optimised away a variable access when no optimisation was set. That 
said, I would not be surprised if some latent bug or flaw in your code 
manifested itself differently when built with a diferent compiler - 
you'll just have to debug it, because the problem is most likly with 
your code rather then the tool.

Are you using the same CRT start-up code? If not, does the new code set 
the PLL up differently?

I have seen vastly differing performance between newlib builds for code 
using floating-point. You should avoid using floating-point in any case.

Clifford
OP
Hi,

@mthomas
All the behaviours mentioned above are for no optimization level.
stdio is being used.

ISR attributes are declared like this:
1
__attribute__ ((interrupt));

@clifford
I'm using the same start-up code (*.s) and the same file for memory and 
sections definitions (*.ld) as before.


Thanks you both, I've now some topics to explore.

Cheers.

Reply

A question of your own? This thread is over 17 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.