delay, timer & MEGA board

Hi,
I'm currently face to an issue:
I did recompile the arduino Mega lib, using avr studio, with the following options:
avr-g++
-Wall -Os -fpack-struct -fshort-enums -funsigned-char -funsigned-bitfields -fno-exceptions -mmcu=atmega1280 -DF_CPU=16000000UL

using the created library, it seems that the "standard" delay doesn't work:

from wiring.c

unsigned long micros() {
unsigned long m;
uint8_t oldSREG = SREG, t;

cli();
m = timer0_overflow_count;
#if defined(TCNT0)
t = TCNT0;
#elif defined(TCNT0L)
t = TCNT0L;
#else
#error TIMER 0 not defined
#endif

#ifdef TIFR0
if ((TIFR0 & _BV(TOV0)) && (t < 255))
m++;
#else
if ((TIFR & _BV(TOV0)) && (t < 255))
m++;
#endif

SREG = oldSREG;

return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
}

void delay(unsigned long ms)
{
uint16_t start = (uint16_t)micros();

while (ms > 0) {
if (((uint16_t)micros() - start) >= 1000) {
ms--;
start += 1000;
}
}
}

As far as I remember, I already saw a post regarding this, and it was some compiling option that you can see when compiling with arduino tools.

Any link or idea ?
Thanks per advance

The cool smiley looks rather good in that code, don't you think ?
Nevertheless, it would help if you were to edit your post and put the code in code tags (# icon above the smileys in the editor)

You should never use delay, see blink without delay and then FSM (finite state machines).

Mark

Thanks Mark for your hint.
For the moment, as I tried to recompile an existing project, I would avoid to rewrite it.
I will check the options in the makefile, and probably find an issue there.

Samuel