-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
builder: use ar-chives for linking big sketches (was: use the @ syntax to reduce command line length if needed) #961
Conversation
Testing with Marlin firmware 2.0.7 and building for
It seems that the |
That sounds plausible. Probably Windows has something like Linux' |
it does indeed 😞 |
@facchinm |
@ubidefeo sure, the "recipe" is the same we already use to archive the core and libraries with |
Note that if you put things in an archive that are not normally in there, you also have to wrap the .a file on the commandline between |
This should fix the command line too big issue on Windows.
This is required because gcc-ar checks if an object file is already in the archive by looking ONLY at the filename WITHOUT the path, so it may happens that, for example, an object file named "subdir/spi.o", already inside the archive, may be overwritten by an object file in "anotherdir/spi.o" only because they are both named spi.o and even if they are compiled on different directories.
7669f24
to
8177510
Compare
Hi everybody :-) I've scratched the Some interesting facts:
I've also increased the minimum command line length that triggers the
|
Nope. If you put a
Good point. I have a little doubt about your implementation, though: It now groups object files per directory which could change the order of object files in the link (I suspect this works out in practice because the files in Still, some alternative solutions to consider:
Yup, agreed. |
Thanks! that explains a bit, but still not everything, because wrt the ordering of .a files:
in the current implementation of this PR (8177510) the list of archive files is kept in a
that was my first approach but, in the end, I did not like it because I found chaotic the resulting build folder, even if we use the |
Yes, I think that is true. And in most cases, link order is not really relevant, but I think it can be relevant when multiple but different definitions of symbols are available (i.e. weak or inline symbols), where the link order can determine which of these is selected.
Well, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested on Windows 10 and Mac OS 10.14.6 to compile Marlin, which previously failed.
It now works as expected, so approved on my side
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
I've checked the binary produced by compiling the Marlin firmware before and after the patch:
After this analysis, I'm for merging this PR as it is now. @matthijskooijman do you have any other concerns? |
@cmaglie let's wait a bit longer for any comment from @matthijskooijman which are always insightful, but I'd like this to be merged asap and move on :) |
@ubidefeo Thanks for the prod :-) I think merging this would be ok. I do still think that the compilation order could be subtly modified and I can probably construct an example where the actual behaviour would be different (between regular and archified commandlines, or between multiple invocations of archivified commandlines) because of that, but I'm pretty sure this is pretty edge casey behavior. So I still think it would be good to fix this and 1) use a consistent order between multiple invocations and 2) use a consistent order between with and without archive files (e.g. compiling on Windows and Linux), but I'm not sure if this should block merging this fix now. Maybe merge and create an issue to track this for later? |
Yours are all valid observations, @matthijskooijman
I am ok with this as it fixes something that has been lurking around for a while. As for creating another issue, feel free to open one which also includes the edge cases you're thinking of |
This is our no. 1 support issue with Arduino at the moment, so not blocking on it would be very helpful on our end. |
@janjongboom this will end up in CLI |
EDIT:
I've changed the implementation, see: #961 (comment) for more info.
The previous solution (with the
@file.txt
) is here: 7669f24OLD solution:
When there are a lot of object files the command line becomes very long.
In this case, the
@file.txt
format is used to write down the list into a file and offload the command line.Fix #839