-
-
Notifications
You must be signed in to change notification settings - Fork 114
initVariant() function not being linked in 1.6.6 #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@kmclifton When I compile it I get
Is there some missing piece? Core, libs...? |
Apologies, @ffissore. Yes, there is a missing piece. We have the following definition in our pins_arduino.h file (located in variants/standard in the installed package directory).
|
@ffissore Some more clues after experimenting a bit: One difference between 1.6.5 and 1.6.6 relates to the command that generates the elf file. The comparison: 1.6.5 1.6.6 Note how in 1.6.5, initvariant.cpp.o is included, but it's not there in 1.6.6. Using 1.6.6 - if I add initvariant.cpp explicitly to the sketch (Sketch | Add File), then when I compile, it's listed in the command that generates the elf file, and we're back to working again. |
Please provide the actual sketch, core and libs and error message you're getting: I can't reproduce your issue.
Everything compiles as expected. Maybe a bug we've already solved in hourly builds? http://www.arduino.cc/en/Main/Software#hourly |
Package at link below, including core etc. Library referenced in sketch also at link.
Sketch:
|
So the forum post suggests that calling a weak function from within the same compilation unit (cpp file) as where the empty weak stub is defined, causes problems. Presumably the compiler then inlines the function, or otherwise directly references it, without involving the linker, so the call will not use the other, strong, definition of the function. To fix this this, moving the weak empty I'm not 100% sure this analysis is correct, especially since the disassembler dump shows that no inlining takes place. I wonder if somehow the linking order, and/or .a archive linking affects which initVariant function is selected as well. |
To be honest, I'm not sure of the technical reason why this works. What I can say is that I spent hours on this issue, including moving the linker order and putting the external library before the ArduinoCore library, with no outcome. The .mpp file just showed the empty initVariant() function, not inlined. Simply moving the attribute((weak)) function definitions to another file solved the problem. Still, it would be nice to know why this solution works. |
Turned out the problem was in a wrong porting from java to go. Variant files were archived in core.a while they MUST be passed to the linker one by one |
A fix is available with latest IDE hourly build http://www.arduino.cc/en/Main/Software#hourly |
Thanks, @ffissore. That seems to have fixed things. I assume that this will then make it into 1.6.7? |
Yes |
From @kmclifton on November 23, 2015 3:5
We have some custom init code that needs to run to initialise our hardware (not Arduino). In version 1.6.5 of the IDE we simply included a file called initvariant.cpp (defining void initVariant() ) alongside pins_arduino.h under variants/standard in our package directory. See contents of initvariant.cpp below. With the upgrade to 1.6.6 that seems to have broken. The init code no longer runs at all. It isn't linked in.
Possibly related to this issue: aee32ff
Copied from original issue: arduino/Arduino#4205
The text was updated successfully, but these errors were encountered: