linker error ...

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

An hour before compiler/ linker started complaining about may project.

I guess it has something to do with an included library.

The Build process runs okay, the error comes if I try to load & run the project (AS 6.1, pressing F5).

This is the complete output-message:
------ Neues Erstellen gestartet: Projekt: TMC42xLibrary, Konfiguration: Debug AVR ------
Der Buildvorgang wurde gestartet.
Projekt "TMC42xLibrary.cproj", ReBuild Ziel(e):
Erstellung mit der Toolsversion 2.0.
Das Ziel "PreBuildEvent" wurde übersprungen, da die Bedingung "false" war . ('$(PreBuildEvent)'!='') wurde als (''!='') ausgewertet.
Ziel "CoreRebuild" in Datei "C:\Program Files\Atmel\Atmel Studio 6.1\Vs\Compiler.targets" aus Projekt "Y:\Trinamic\TMC428_429\AS61\TMC42xLibrary\TMC42xLibrary\TMC42xLibrary.cproj" (Ziel "ReBuild" ist davon abhängig):
RunCompilerTask-Aufgabe
C:\Program Files\Atmel\Atmel Studio 6.1\shellUtils\make.exe clean all
rm -rf TMC429lib.o TMC429lib.d
rm -rf "libAT90CAN128_TMC429.elf" "libAT90CAN128_TMC429.a" "libAT90CAN128_TMC429.hex" "libAT90CAN128_TMC429.lss" "libAT90CAN128_TMC429.eep" "libAT90CAN128_TMC429.map" "libAT90CAN128_TMC429.srec"
Building file: .././TMC429lib.c
Invoking: AVR/GNU C Compiler :
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-gcc.exe" -funsigned-char -funsigned-bitfields -DDEBUG -DF_CPU=16000000UL -O0 -ffunction-sections -fpack-struct -fshort-enums -g3 -Wall -mmcu=at90can128 -c -std=gnu99 -MD -MP -MF "TMC429lib.d" -MT"TMC429lib.d" -MT"TMC429lib.o" -o"TMC429lib.o" ".././TMC429lib.c"
.././TMC429lib.c: In function 'TMC429_Init':
Y:\Trinamic\TMC428_429\AS61\TMC42xLibrary\TMC42xLibrary\TMC429lib.c(411,11): variable 'tmp' set but not used [-Wunused-but-set-variable]
.././TMC429lib.c: In function 'TMC429_SetMotRamp':
Y:\Trinamic\TMC428_429\AS61\TMC42xLibrary\TMC42xLibrary\TMC429lib.c(491,18): unused variable 'tmp' [-Wunused-variable]
Y:\Trinamic\TMC428_429\AS61\TMC42xLibrary\TMC42xLibrary\TMC429lib.c(491,11): unused variable 'cmd' [-Wunused-variable]
Finished building: .././TMC429lib.c
Building target: libAT90CAN128_TMC429.a
Invoking: AVR/GNU Archiver :
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-ar.exe" -r -o libAT90CAN128_TMC429.a TMC429lib.o
C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-ar.exe: creating libAT90CAN128_TMC429.a
Finished building target: libAT90CAN128_TMC429.a
Ausführen der RunCompilerTask-Aufgabe beendet.
RunOutputFileVerifyTask-Aufgabe
Ausführen der RunOutputFileVerifyTask-Aufgabe beendet.
Die Erstellung des Ziels "CoreRebuild" im Projekt "TMC42xLibrary.cproj" ist abgeschlossen.
Das Ziel "PostBuildEvent" wurde übersprungen, da die Bedingung "false" war . ('$(PostBuildEvent)' != '') wurde als ('' != '') ausgewertet.
Ziel "ReBuild" in Datei "C:\Program Files\Atmel\Atmel Studio 6.1\Vs\Avr.common.targets" aus Projekt "Y:\Trinamic\TMC428_429\AS61\TMC42xLibrary\TMC42xLibrary\TMC42xLibrary.cproj" (Einstiegspunkt):
Die Erstellung des Ziels "ReBuild" im Projekt "TMC42xLibrary.cproj" ist abgeschlossen.
Erstellen des Projekts TMC42xLibrary.cproj beendet.

Das Erstellen war erfolgreich.
------ Neues Erstellen gestartet: Projekt: ADF_Gyro, Konfiguration: Debug AVR ------
Der Buildvorgang wurde gestartet.
Projekt "ADF_Gyro.cproj", ReBuild Ziel(e):
Erstellung mit der Toolsversion 2.0.
Das Ziel "PreBuildEvent" wurde übersprungen, da die Bedingung "false" war . ('$(PreBuildEvent)'!='') wurde als (''!='') ausgewertet.
Ziel "CoreRebuild" in Datei "C:\Program Files\Atmel\Atmel Studio 6.1\Vs\Compiler.targets" aus Projekt "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\ADF_Gyro.cproj" (Ziel "ReBuild" ist davon abhängig):
RunCompilerTask-Aufgabe
C:\Program Files\Atmel\Atmel Studio 6.1\shellUtils\make.exe clean all
rm -rf CAN_RingBuffer.o Simulator_ID_Functions.o ADF_Gyro_HWConfig.o main.o AS5043lib.o CANInterrupt.o AT90CANxxx_CAN_drv.o SPIInterrupt.o CAN_RingBuffer.d Simulator_ID_Functions.d ADF_Gyro_HWConfig.d main.d AS5043lib.d CANInterrupt.d AT90CANxxx_CAN_drv.d SPIInterrupt.d
rm -rf "ADF_Gyro.elf" "ADF_Gyro.a" "ADF_Gyro.hex" "ADF_Gyro.lss" "ADF_Gyro.eep" "ADF_Gyro.map" "ADF_Gyro.srec"
Building file: ../../../../../Allgemein/Module/CAN_RingBuffer.c
Invoking: AVR/GNU C Compiler :
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-gcc.exe" -funsigned-char -funsigned-bitfields -DF_CPU=16000000UL -DCAN_RINGBUFFER_SIZE=4 -O0 -ffunction-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=at90can128 -c -std=gnu99 -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro_HW.h" -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\ADFGyro_General.h" -MD -MP -MF "CAN_RingBuffer.d" -MT"CAN_RingBuffer.d" -MT"CAN_RingBuffer.o" -o"CAN_RingBuffer.o" "../../../../../Allgemein/Module/CAN_RingBuffer.c"
Finished building: ../../../../../Allgemein/Module/CAN_RingBuffer.c
Building file: ../../../../../Allgemein/Module/Simulator_ID_Functions.c
Invoking: AVR/GNU C Compiler :
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-gcc.exe" -funsigned-char -funsigned-bitfields -DF_CPU=16000000UL -DCAN_RINGBUFFER_SIZE=4 -O0 -ffunction-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=at90can128 -c -std=gnu99 -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro_HW.h" -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\ADFGyro_General.h" -MD -MP -MF "Simulator_ID_Functions.d" -MT"Simulator_ID_Functions.d" -MT"Simulator_ID_Functions.o" -o"Simulator_ID_Functions.o" "../../../../../Allgemein/Module/Simulator_ID_Functions.c"
Finished building: ../../../../../Allgemein/Module/Simulator_ID_Functions.c
Building file: ../../../ADF_Gyro_HWConfig.c
Invoking: AVR/GNU C Compiler :
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-gcc.exe" -funsigned-char -funsigned-bitfields -DF_CPU=16000000UL -DCAN_RINGBUFFER_SIZE=4 -O0 -ffunction-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=at90can128 -c -std=gnu99 -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro_HW.h" -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\ADFGyro_General.h" -MD -MP -MF "ADF_Gyro_HWConfig.d" -MT"ADF_Gyro_HWConfig.d" -MT"ADF_Gyro_HWConfig.o" -o"ADF_Gyro_HWConfig.o" "../../../ADF_Gyro_HWConfig.c"
Finished building: ../../../ADF_Gyro_HWConfig.c
Building file: .././main.c
Invoking: AVR/GNU C Compiler :
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-gcc.exe" -funsigned-char -funsigned-bitfields -DF_CPU=16000000UL -DCAN_RINGBUFFER_SIZE=4 -O0 -ffunction-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=at90can128 -c -std=gnu99 -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro_HW.h" -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\ADFGyro_General.h" -MD -MP -MF "main.d" -MT"main.d" -MT"main.o" -o"main.o" ".././main.c"
In file included from .././main.c:11:0:
c:\program files\atmel\atmel toolchain\avr8 gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay.h(95,3): #warning "Compiler optimizations disabled; functions from won't work as designed" [-Wcpp]
.././main.c: In function 'main':
Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\main.c(94,21): unused variable 'tmpAliveMessage' [-Wunused-variable]
Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\main.c(50,45): unused variable 'ChainStatus' [-Wunused-variable]
Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\main.c(50,32): unused variable 'AS5043Chain' [-Wunused-variable]
Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\main.c(50,21): unused variable 'AS5043RAW' [-Wunused-variable]
.././main.c: In function 'PrepareAliveMessage':
Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\main.c(277,20): variable 'tmpAliveMessage' set but not used [-Wunused-but-set-variable]
.././main.c: In function 'SendDiagnostics':
Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\main.c(324,3): implicit declaration of function 'AT90CAN_Load_MOB' [-Wimplicit-function-declaration]
Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\main.c(296,10): unused variable 'result' [-Wunused-variable]
Finished building: .././main.c
Building file: .././AS5043lib.c
Invoking: AVR/GNU C Compiler :
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-gcc.exe" -funsigned-char -funsigned-bitfields -DF_CPU=16000000UL -DCAN_RINGBUFFER_SIZE=4 -O0 -ffunction-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=at90can128 -c -std=gnu99 -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro_HW.h" -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\ADFGyro_General.h" -MD -MP -MF "AS5043lib.d" -MT"AS5043lib.d" -MT"AS5043lib.o" -o"AS5043lib.o" ".././AS5043lib.c"
Finished building: .././AS5043lib.c
Building file: .././CANInterrupt.c
Invoking: AVR/GNU C Compiler :
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-gcc.exe" -funsigned-char -funsigned-bitfields -DF_CPU=16000000UL -DCAN_RINGBUFFER_SIZE=4 -O0 -ffunction-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=at90can128 -c -std=gnu99 -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro_HW.h" -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\ADFGyro_General.h" -MD -MP -MF "CANInterrupt.d" -MT"CANInterrupt.d" -MT"CANInterrupt.o" -o"CANInterrupt.o" ".././CANInterrupt.c"
.././CANInterrupt.c: In function 'CAN_Check_MOb':
Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\CANInterrupt.c(83,7): variable 'tmp_txrx' set but not used [-Wunused-but-set-variable]
Finished building: .././CANInterrupt.c
Building file: Y:/ATMEL/AT90CANxxx/CAN-Driver/AT90CANxxx_CAN_drv.c
Invoking: AVR/GNU C Compiler :
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-gcc.exe" -funsigned-char -funsigned-bitfields -DF_CPU=16000000UL -DCAN_RINGBUFFER_SIZE=4 -O0 -ffunction-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=at90can128 -c -std=gnu99 -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro_HW.h" -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\ADFGyro_General.h" -MD -MP -MF "AT90CANxxx_CAN_drv.d" -MT"AT90CANxxx_CAN_drv.d" -MT"AT90CANxxx_CAN_drv.o" -o"AT90CANxxx_CAN_drv.o" "Y:/ATMEL/AT90CANxxx/CAN-Driver/AT90CANxxx_CAN_drv.c"
In file included from Y:/ATMEL/AT90CANxxx/CAN-Driver/AT90CANxxx_CAN_drv.c:14:0:
c:\program files\atmel\atmel toolchain\avr8 gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay.h(95,3): #warning "Compiler optimizations disabled; functions from won't work as designed" [-Wcpp]
Finished building: Y:/ATMEL/AT90CANxxx/CAN-Driver/AT90CANxxx_CAN_drv.c
Building file: Y:/SPI/SPI_interrupt_driven/SPIInterrupt/SPIInterrupt.c
Invoking: AVR/GNU C Compiler :
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-gcc.exe" -funsigned-char -funsigned-bitfields -DF_CPU=16000000UL -DCAN_RINGBUFFER_SIZE=4 -O0 -ffunction-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=at90can128 -c -std=gnu99 -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro_HW.h" -include "Z:\Simulator-Panel\ADF_Gyro\Firmware\ADF_Gyro\ADF_Gyro\ADFGyro_General.h" -MD -MP -MF "SPIInterrupt.d" -MT"SPIInterrupt.d" -MT"SPIInterrupt.o" -o"SPIInterrupt.o" "Y:/SPI/SPI_interrupt_driven/SPIInterrupt/SPIInterrupt.c"
Finished building: Y:/SPI/SPI_interrupt_driven/SPIInterrupt/SPIInterrupt.c
Building target: ADF_Gyro.elf
Invoking: AVR/GNU Linker :
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.876\avr8-gnu-toolchain\bin\avr-gcc.exe" -o ADF_Gyro.elf CAN_RingBuffer.o Simulator_ID_Functions.o ADF_Gyro_HWConfig.o main.o AS5043lib.o CANInterrupt.o AT90CANxxx_CAN_drv.o SPIInterrupt.o -Wl,-Map="ADF_Gyro.map" -Wl,--start-group -Wl,-lAT90CAN128_TMC429 -Wl,--end-group -Wl,-L"Y:\SPI\SPI_interrupt_driven\SPIInterrupt\Debug" -Wl,-L"Y:\Trinamic\TMC428_429\AS61\TMC42xLibrary\TMC42xLibrary\Debug" -Wl,--gc-sections -mmcu=at90can128
c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/../../../../avr/lib/avr51\libc.a(pow.o):/tbuild/jenkins/workspace/avr8-gnu-toolchain/src/avr-libc/libm/fplib/pow.S:214:(.text.avr-libc.fplib+0x94): relocation truncated to fit: R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr51\libgcc.a(_mul_sf.o)
c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/../../../../avr/lib/avr51\libc.a(inverse.o):/tbuild/jenkins/workspace/avr8-gnu-toolchain/src/avr-libc/libm/fplib/inverse.S:50:(.text.avr-libc.fplib+0xc): relocation truncated to fit: R_AVR_13_PCREL against symbol `__divsf3' defined in .text section in c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr51\libgcc.a(_div_sf.o)
c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/../../../../avr/lib/avr51\libc.a(log.o):/tbuild/jenkins/workspace/avr8-gnu-toolchain/src/avr-libc/libm/fplib/log.S:96:(.text.avr-libc.fplib+0x46): relocation truncated to fit: R_AVR_13_PCREL against symbol `__addsf3' defined in .text section in c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr51\libgcc.a(_addsub_sf.o)
c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/../../../../avr/lib/avr51\libc.a(log.o):/tbuild/jenkins/workspace/avr8-gnu-toolchain/src/avr-libc/libm/fplib/log.S:100:(.text.avr-libc.fplib+0x4e): relocation truncated to fit: R_AVR_13_PCREL against symbol `__addsf3' defined in .text section in c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr51\libgcc.a(_addsub_sf.o)
c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/../../../../avr/lib/avr51\libc.a(log.o):/tbuild/jenkins/workspace/avr8-gnu-toolchain/src/avr-libc/libm/fplib/log.S:116:(.text.avr-libc.fplib+0x6a): relocation truncated to fit: R_AVR_13_PCREL against symbol `__floatsisf' defined in .text section in c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr51\libgcc.a(_si_to_sf.o)
c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/../../../../avr/lib/avr51\libc.a(modf.o):/tbuild/jenkins/workspace/avr8-gnu-toolchain/src/avr-libc/libm/fplib/modf.S:90:(.text.avr-libc.fplib+0x3e): relocation truncated to fit: R_AVR_13_PCREL against symbol `__subsf3' defined in .text section in c:/program files/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr51\libgcc.a(_addsub_sf.o)
collect2.exe(0,0): ld returned 1 exit status
make: *** [ADF_Gyro.elf] Error 1
Der Befehl wurde mit dem Code 2 beendet.
Die Ausführung der RunCompilerTask-Aufgabe ist abgeschlossen -- FEHLER.
Die Erstellung des Ziels "CoreRebuild" im Projekt "ADF_Gyro.cproj" ist abgeschlossen -- FEHLER.
Die Erstellung des Projekts "ADF_Gyro.cproj" ist abgeschlossen -- FEHLER.

Fehler beim Erstellen
========== Alles neu erstellen: 1 erfolgreich, Fehler bei 1, 0 übersprungen ==========

I program like a man:
COPY CON: > firmware.hex

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try with the -lm linker flag.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

-lm is no more needed provided the compiler is configured appropriately. But as I learned, this compiler is not configured for AVR-LibC cooperation.

This looks like AVR-LibC issue #33698. If you are lucky, -lm can work around it.

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the problem has disappeared ... it's magic somehow.

I program like a man:
COPY CON: > firmware.hex

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

... and now I have the same problem again.

It came after I added a routine which uses a float variable together with some floatiing point division and multiplication.

I am using AS 6.1ß.

Where do I have to add the -lm command?

Whar means "If you are lucky" ?

I program like a man:
COPY CON: > firmware.hex

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Where do I have to add the -lm command?

As6 adds it automatically by default...

(however in the build do make sure this leads to the command being given on the END of the linker invocation).

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
What means "If you are lucky"?
It means that a missing -lm is not the root cause of your problem.

A missing -lm would lead to a linker complaint if you use sin() from math.h, for example, because the sin function implementation is shipped in libm.a.

The root cause of the problem is #33698, i.e. AVR-LibC uses RCALL/RJMP instruction to external functions. If the assumption that the call target can be encoded in the instruction does not hold, the linker complains.

There are several cases where adding -lm does not work around the problem or does not work as intended.

Reason is that AVR-LibC turned libm.a into a core library like libgcc.a but using -lm will not use it like a system library. To achieve that, you'll have to patch the specs (e.g. using -dumpspecs, patch them and feed them back into the compiler) and not adding -lm wherever on the command line.

-lm work in most cases because this leads to mode efficient float routines, this the RCALL/RJMP targets are inside the valid range again. However, there are cases where is does not work: Using LTO, fixed-point <-> float conversions, C++, ...

avrfreaks does not support Opera. Profile inactive.