Strange compile errors

Hello

Here is a simple line of code, as an example:int num = (int)round( random( 85 ) / 4.0f );

My problem is that when I enable float support for sprintf/sscanf, as described here, this simple line produces these weird errors:

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(addsf3.o): In function `__addsf3':

(.text.avr-libc.fplib+0x8): relocation truncated to fit: R_AVR_13_PCREL against symbol `__fp_round' defined in .text.avr-libc.fplib section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fp_round.o)

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(addsf3x.o):(.text.avr-libc.fplib+0x0): relocation truncated to fit: R_AVR_13_PCREL against symbol `__fp_pscA' defined in .text.avr-libc.fplib section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fp_pscA.o)

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(addsf3x.o):(.text.avr-libc.fplib+0x4): relocation truncated to fit: R_AVR_13_PCREL against symbol `__fp_pscB' defined in .text.avr-libc.fplib section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fp_pscB.o)

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(addsf3x.o):(.text.avr-libc.fplib+0x10): relocation truncated to fit: R_AVR_13_PCREL against symbol `__fp_nan' defined in .text.avr-libc.fplib section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fp_nan.o)

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(addsf3x.o):(.text.avr-libc.fplib+0x18): relocation truncated to fit: R_AVR_13_PCREL against symbol `__fp_inf' defined in .text.avr-libc.fplib section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fp_inf.o)

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(addsf3x.o): In function `__addsf3x':

(.text.avr-libc.fplib+0x1c): relocation truncated to fit: R_AVR_13_PCREL against symbol `__fp_split3' defined in .text.avr-libc.fplib section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fp_split3.o)

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(addsf3x.o): In function `__addsf3x':

(.text.avr-libc.fplib+0x30): relocation truncated to fit: R_AVR_13_PCREL against symbol `__fp_zero' defined in .text.avr-libc.fplib section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fp_zero.o)

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fixsfsi.o): In function `__fixsfsi':

(.text.avr-libc.fplib+0x6): relocation truncated to fit: R_AVR_13_PCREL against symbol `__fp_szero' defined in .text.avr-libc.fplib section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fp_zero.o)

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fixunssfsi.o): In function `__fixunssfsi':

(.text.avr-libc.fplib+0x0): relocation truncated to fit: R_AVR_13_PCREL against symbol `__fp_splitA' defined in .text.avr-libc.fplib section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fp_split3.o)

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fixunssfsi.o): In function `__fixunssfsi':

(.text.avr-libc.fplib+0x26): relocation truncated to fit: R_AVR_13_PCREL against symbol `__fp_zero' defined in .text.avr-libc.fplib section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fp_zero.o)

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6\libm.a(fixunssfsi.o): In function `__fixunssfsi':

(.text.avr-libc.fplib+0x2c): additional relocation overflows omitted from the output

collect2.exe: error: ld returned 1 exit status

If I disable float support for sprintf/sscanf (renaming platform.local.txt file is enough), it works.

Also, if I replace the call to random() by a number, for example: int num = (int)round( 85 / 4.0f );, then it works.. But the problem is not only with the random() function, it seems to happen with any function returning a call to a function that is not defined in my sketch:

int getNum()
{
  return 85; // this works;
  //return (int)random( 85 ); // this doesn't work
}
...
int num = (int)round( getNum() / 4.0f );

But it used to work perfectly until I don't know when, probably when I updated my IDE to 1.6.7, but only now I notice these errors... It seems to be related to floating point stuff, but I didn't even use sprintf or sscanf in my example :/

Any idea what's happening and how to solve it?

I suspect the solution entails removing round from the Arduino header file.

https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Arduino.h#L88

This is so strange.

When I try in a new sketch, it works, but in the quite big sketch that I'm working on, it doesn't work. I can't find what is exactly the cause of this problem. And it's happening with many native functions too (cos() for example), not just round().

Investigating...