Skip to content

Arduino builder builds the same sketch with different size #26

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

Closed
NicoHood opened this issue Oct 3, 2015 · 10 comments
Closed

Arduino builder builds the same sketch with different size #26

NicoHood opened this issue Oct 3, 2015 · 10 comments
Assignees

Comments

@NicoHood
Copy link

NicoHood commented Oct 3, 2015

Very weird bug: Hitting compile several times results in different flash usage, even with no change at all.

Used this IDE for linux64bit (okay I made some changes to the usb code, but this should not matter here. also I compiled this myself, just that you get an idea of the build date).
arduino/Arduino#3896 (comment)

I compiled for Arduino Mega. Uno and leonardo works fine.

Sketch size is between 7238 and 7246. Very useful for debugging and getting the last byte out of the code ;) (not)

The sketch (requires FastLED3.1 release, no dev version or sth like this)
(sketch edited and shrinked after some time)

// FastLED
#include "FastLED.h"

void setup() {

}

void loop() {

}

Arduino builder commands:

/Arduino/build/linux/work/arduino-builder -dump-prefs -logger=machine -hardware "/Arduino/build/linux/work/hardware" -hardware ".arduino15/packages" -hardware "/sketchbook/hardware" -tools "/Arduino/build/linux/work/tools-builder" -tools "/Arduino/build/linux/work/hardware/tools/avr" -tools ".arduino15/packages" -libraries "/sketchbook/libraries" -libraries "/Arduino/build/linux/work/libraries" -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10606 -build-path "/tmp/buildc0fbe65fc3436bea157b420c01dcd579.tmp" -warnings=all -prefs=build.warn_data_percentage=75 -verbose "/tmp/arduino_c0fbe65fc3436bea157b420c01dcd579/sketch_oct03b.ino"
/Arduino/build/linux/work/arduino-builder -compile -logger=machine -hardware "/Arduino/build/linux/work/hardware" -hardware ".arduino15/packages" -hardware "/sketchbook/hardware" -tools "/Arduino/build/linux/work/tools-builder" -tools "/Arduino/build/linux/work/hardware/tools/avr" -tools ".arduino15/packages" -libraries "/sketchbook/libraries" -libraries "/Arduino/build/linux/work/libraries" -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10606 -build-path "/tmp/buildc0fbe65fc3436bea157b420c01dcd579.tmp" -warnings=all -prefs=build.warn_data_percentage=75 -verbose "/tmp/arduino_c0fbe65fc3436bea157b420c01dcd579/sketch_oct03b.ino"

It seems this only happens with the mega and the FastLED3.1 library.

\cc @kriegsman and @focalintent

@NicoHood
Copy link
Author

NicoHood commented Oct 3, 2015

It also compiles the SD Card library for some reason. You can see the warnings here:
https://gist.github.com/NicoHood/8472a52d2bfbe62cc958

\cc @kriegsman and @focalintent

@PaulStoffregen
Copy link

Is the builder parsing all files for includes, or only those which are actually used?

One of the many examples in FastLED includes the SD library. Maybe arduino-builder is mistakenly seeing that?

@NicoHood
Copy link
Author

NicoHood commented Oct 3, 2015

I now got a weird error:
I hit compile, it started to compile. It said a function is not declared (compile error), marked it red in the IDE, skipped and compiled fine till the end. Normally you expect the IDE to halt on a compile error. It just appeared for a few seconds and then continued. The error was there short but compiling finished still fine.

I could not reproduce this error once more.
The sketch I used was this (compiled for leonardo now) and the function complained about was the adalight function:
https://gist.github.com/NicoHood/02599c8322c48e8ed22e/6a942e980d7804528ecf9aa2dda8df4f6f7a280d

This is probably unrelated to this issue but maybe there is a race condition in the code which triggered this error as well. Just that this one is very rare.

@focalintent
Copy link
Contributor

Anything that references the __DATE__ or __TIME__ macros are likely to cause changes in the final output size, ditto any kind of textual time stamping that gcc adds to files. As for the warnings, i'll deal with them later, but they're mostly just noise (and also aren't showing up in 1.6.5).

@focalintent
Copy link
Contributor

and FastLED/FastLED@8021b07 should shut up the FastLED warnings.

As for why it's including the SD library, I think @PaulStoffregen is right - arduino-builder is being a bit too liberal in which files it's including in its search for linked libraries. It should be careful about this, however - in the main library, FastLED does conditional inclusion of other library header files - but just because the library has #include<SmartMatrix.h> doesn't mean that said include is actually going to happen (because in that particular example/case, the include only happens if SmartMatrix_h has been defined - which means the end user would have to have included SmartMatrix.h in their .ino file first)

@ffissore
Copy link
Contributor

ffissore commented Oct 5, 2015

in beta21 arduino-builder also collected example sketches. this is fixed in 45b744f and available with beta22 and latest IDE nightly. As for not parsing all the files, and only those actually used, I'm afraid I can do nothing about it. Both old and new compiling procedures used to compile every single cpp file, delegating to the linker the task of filtering unused code.
You may want to add dot_a_linkage=true to your library.properties and see if sketch size improves.

So @NicoHood and @PaulStoffregen please ensure you're using the very latest hourly build
@NicoHood, about the warning and the successful compilation: may this be due to some gcc params like in arduino/Arduino@7d0355c ?

@ffissore ffissore self-assigned this Oct 5, 2015
@NicoHood
Copy link
Author

NicoHood commented Oct 5, 2015

I will try again today.

The skipped error never showed up again. However the commit you linked doesnt matter for me since I am using avr and not sam.

@ffissore
Copy link
Contributor

ffissore commented Oct 5, 2015

Let me know how your tests go

@NicoHood
Copy link
Author

NicoHood commented Oct 5, 2015

Original Problem (Mega compiling with different size) is gone.
SD Card Warnings also gone.

However the warnings themselves should be fixed. But thats not related to this ;)

@NicoHood NicoHood closed this as completed Oct 5, 2015
@ffissore
Copy link
Contributor

ffissore commented Oct 5, 2015

I can't wait for a new issue @NicoHood . File it asap :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants