SCoop icon indicating copy to clipboard operation
SCoop copied to clipboard

`timer0_overflow_count' referenced in section `.text' of ... defined in discarded section `.text' of wiring.c.o (symbol from plugin)

Open marklieberman opened this issue 9 years ago • 9 comments
trafficstars

I'm getting this error on Arduino IDE 1.6.12 with version 1.2 of SCoop. It compiles fine on Arduino IDE 1.6.3.

I've tried adding __attribute__((used)) to timer0_overflow_count in SCoop.cpp, but it didn't help. Google suggests that this issue is caused by Link-Time Optimization (LTO) which was enabled in recent versions of Arduino IDE.

Linking everything together...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc" -w -Os -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p  -o "C:\Users\User\AppData\Local\Temp\arduino_build_421117/Garage3.ino.elf" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\sketch\Events.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\sketch\Garage3.ino.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\libraries\SCoop\SCoop.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\libraries\SPI\SPI.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\libraries\Ethernet\Dhcp.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\libraries\Ethernet\Dns.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\libraries\Ethernet\Ethernet.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\libraries\Ethernet\EthernetClient.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\libraries\Ethernet\EthernetServer.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\libraries\Ethernet\EthernetUdp.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\libraries\Ethernet\utility\socket.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117\libraries\Ethernet\utility\w5100.cpp.o" "C:\Users\User\AppData\Local\Temp\arduino_build_421117/core\core.a" "-LC:\Users\User\AppData\Local\Temp\arduino_build_421117" -lm
`timer0_overflow_count' referenced in section `.text' of C:\Users\User\AppData\Local\Temp\ccIO2cUw.ltrans3.ltrans.o: defined in discarded section `.text' of wiring.c.o (symbol from plugin)

`timer0_overflow_count' referenced in section `.text' of C:\Users\User\AppData\Local\Temp\ccIO2cUw.ltrans3.ltrans.o: defined in discarded section `.text' of wiring.c.o (symbol from plugin)

`timer0_overflow_count' referenced in section `.text' of C:\Users\User\AppData\Local\Temp\ccIO2cUw.ltrans3.ltrans.o: defined in discarded section `.text' of wiring.c.o (symbol from plugin)

`timer0_overflow_count' referenced in section `.text' of C:\Users\User\AppData\Local\Temp\ccIO2cUw.ltrans3.ltrans.o: defined in discarded section `.text' of wiring.c.o (symbol from plugin)

`timer0_overflow_count' referenced in section `.text' of C:\Users\User\AppData\Local\Temp\ccIO2cUw.ltrans7.ltrans.o: defined in discarded section `.text' of wiring.c.o (symbol from plugin)

`timer0_overflow_count' referenced in section `.text' of C:\Users\User\AppData\Local\Temp\ccIO2cUw.ltrans7.ltrans.o: defined in discarded section `.text' of wiring.c.o (symbol from plugin)

collect2.exe: error: ld returned 1 exit status

marklieberman avatar Nov 13 '16 02:11 marklieberman

Hi @marklieberman .

After a long fight against this bug, I think that I've finally understood what is happening. The compiler in newest Arduino IDE, is no longer keeping the 'timer0_overflow_count' variable, despite the "extern" statement, because it can't see the symbol inside the following asm code. while this worked fine in previous Arduino IDE versions.

I've made this ugly hack in this commit from my fix_scoop_compil branch in my fork. This fixed the compilation issue on PlatformIO, and should also work in Arduino ide 1.6.10+, but I did not made extensive checks. Would you please, verify if this ALSO works in your Arduino IDE, and if yes, I will send a PR for this fix.

thank you

soif avatar Mar 18 '17 19:03 soif

Hi @marklieberman .

After a long fight against this bug, I think that I've finally understood what is happening. The compiler in newest Arduino IDE, is no longer keeping the 'timer0_overflow_count' variable, despite the "extern" statement, because it can't see the symbol inside the following asm code. while this worked fine in previous Arduino IDE versions.

I've made this ugly hack in this commit from my fix_scoop_compil branch in my fork. This fixed the compilation issue on PlatformIO, and should also work in Arduino ide 1.6.10+, but I did not made extensive checks. Would you please, verify if this ALSO works in your Arduino IDE, and if yes, I will send a PR for this fix.

thank you

Hi soif, I used your library instead, but it still not work D:\mixly\Mixly0.999Beta_WIN(1.25)\arduino-1.8.8\portable\sketchbook\libraries\SCoop/SCoop.cpp:225: undefined reference to timer0_overflow_count' collect2.exe: error: ld returned 1 exit status ` My Arduino core version is 1.8.8. So how did you fix this problem? Can you give me some advice?

zyctinker avatar Apr 21 '19 09:04 zyctinker

Hi! Not sure. i undestood from other users that since rev 1.8 or so, the timer0 overflow variable is not any more exposed as a public variable... seems you need to go in the arduino core library and make it public... Sory I left this code some years ago and I m not able to help more. Hope you can fix it and continue enjoy this lib!

Fabrice Envoyé de mon iPhone 6!

Le 21 avr. 2019 à 11:40, zyctinker [email protected] a écrit :

Hi @marklieberman .

After a long fight against this bug, I think that I've finally understood what is happening. The compiler in newest Arduino IDE, is no longer keeping the 'timer0_overflow_count' variable, despite the "extern" statement, because it can't see the symbol inside the following asm code. while this worked fine in previous Arduino IDE versions.

I've made this ugly hack in this commit from my fix_scoop_compil branch in my fork. This fixed the compilation issue on PlatformIO, and should also work in Arduino ide 1.6.10+, but I did not made extensive checks. Would you please, verify if this ALSO works in your Arduino IDE, and if yes, I will send a PR for this fix.

thank you

Hi soif, I used your library instead, but it still not work D:\mixly\Mixly0.999Beta_WIN(1.25)\arduino-1.8.8\portable\sketchbook\libraries\SCoop/SCoop.cpp:225: undefined reference to timer0_overflow_count' collect2.exe: error: ld returned 1 exit status ` My Arduino core version is 1.8.8. So how did you fix this problem? Can you give me some advice?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

fabriceo avatar Apr 21 '19 12:04 fabriceo

Hi,

edit SCoop.cpp, under line 184:

extern volatile unsigned long timer0_overflow_count; // use this variable which is incremented at each overflow
static unsigned long tell_compiler_that_i_really_need_this = timer0_overflow_count; // ADD THIS LINE - ugly hack to force the compiler to REALLY keep timer0_overflow_count
static inline micros_t SCoopMicros16(void) __attribute__((always_inline));

ENJOY.

flymorn avatar Mar 05 '20 08:03 flymorn

Hi,

I have editted SCoop.cpp, under line 184 as you said,but this problem is still here.

extern volatile unsigned long timer0_overflow_count; // use this variable which is incremented at each overflow static unsigned long tell_compiler_that_i_really_need_this = timer0_overflow_count; // ADD THIS LINE - ugly hack to force the compiler to REALLY keep timer0_overflow_count static inline micros_t SCoopMicros16(void) attribute((always_inline));

problem: Archiving built core (caching) in: C:\Users\ARNOLD~1\AppData\Local\Temp\arduino_cache_580023\core\core_arduino_avr_uno_f2151d765ac6d8806a73f952b8f45225.a C:\Users\ARNOLD~1\AppData\Local\Temp\ccGjuNgC.ltrans0.ltrans.o: In function `SCoopMicros16':

C:\Users\Arnold Jiang\Documents\Arduino\libraries\SCoop/SCoop.cpp:226: undefined reference to `timer0_overflow_count'

C:\Users\Arnold Jiang\Documents\Arduino\libraries\SCoop/SCoop.cpp:226: undefined reference to `timer0_overflow_count'

C:\Users\Arnold Jiang\Documents\Arduino\libraries\SCoop/SCoop.cpp:226: undefined reference to `timer0_overflow_count'

collect2.exe: error: ld returned 1 exit status

Arnold-Jiang avatar Sep 12 '20 13:09 Arnold-Jiang

My Arduino core version is 1.8.5. So how did you fix this problem? Can you give me some advice?

Arnold-Jiang avatar Sep 12 '20 13:09 Arnold-Jiang

My Arduino core version is 1.8.5. So how did you fix this problem? Can you give me some advice?

Can you clarify what version of the Arduino AVR board you have installed in Boards Manager? The latest seems to be 1.8.3 and I can compile my application using the hack from flymorn.

marklieberman avatar Sep 13 '20 03:09 marklieberman

Can you clarify what version of the Arduino AVR board you have installed in Boards Manager? The latest seems to be 1.8.3 and I can compile my application using the hack from flymorn.

Hi, the Arduino AVR board I have installed in Boards Manager is "Arduino/Genuino Uno". The problem is still here.

problem: Archiving built core (caching) in: C:\Users\ARNOLD1\AppData\Local\Temp\arduino_cache_580023\core\core_arduino_avr_uno_f2151d765ac6d8806a73f952b8f45225.a C:\Users\ARNOLD1\AppData\Local\Temp\ccGjuNgC.ltrans0.ltrans.o: In function `SCoopMicros16':

C:\Users\Arnold Jiang\Documents\Arduino\libraries\SCoop/SCoop.cpp:226: undefined reference to `timer0_overflow_count'

C:\Users\Arnold Jiang\Documents\Arduino\libraries\SCoop/SCoop.cpp:226: undefined reference to `timer0_overflow_count'

C:\Users\Arnold Jiang\Documents\Arduino\libraries\SCoop/SCoop.cpp:226: undefined reference to `timer0_overflow_count'

collect2.exe: error: ld returned 1 exit status

Arnold-Jiang avatar Sep 13 '20 04:09 Arnold-Jiang

The fix is already in the v1.21 branch, and IMHO should be merged in the Master branch. see:

https://github.com/fabriceo/SCoop/issues/6#issuecomment-695929493

soif avatar Sep 21 '20 06:09 soif