-
Notifications
You must be signed in to change notification settings - Fork 86
Empty output object with avr-libc >= 2.3.0 #239
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Since avr-libc v2.3, __call_main() (which calls main() and exit()) has been moved from crt[mcu].o to lib[mcu].a. As lib[mcu].a is not linked, main() never gets called and is opt-out from the output file.
Then, there are several fix:
- add lib[mcu].a to the linked libs and also provide a dummy exit() function (to avoid a missing symbol linker error), but this not the most straightforward way as we do not care about the C-specific details/other symbols defined in lib[mcu].a.
- add
#[link_section = ".init9"]to the main function generated by the#[arduino_hal::entry]proc-macro, so that it replaces __call_main() at the proper step of the initialization process[1]. It would mimic the behavior of the-mno-call-maingcc compiler flag [2][3].
In both cases backward compatibility should not be affected.
I would like to read your comments and I can create a MR if necessary.
[1] https://avrdudes.github.io/avr-libc/avr-libc-user-manual/mem_sections.html#sec_dot_init
[2] https://gcc.gnu.org/onlinedocs/gcc-15.1.0/gcc/AVR-Options.html#index-mno-call-main
[3] https://github.com/avrdudes/avr-libc/blob/753e533671c07cc288d6bf3f005480d2637132c8/crt1/gcrt1.S#L83C31-L83C45
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working