Skip to content
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

Do not recompile the sketch if there are no changes and libraries have not changed #2204

Open
3 tasks done
cmaglie opened this issue Jun 6, 2023 · 0 comments
Open
3 tasks done
Labels
topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@cmaglie
Copy link
Member

cmaglie commented Jun 6, 2023

Describe the request

If a sketch is recompiled twice in a row, the Arduino-preprocessed sketch Sketch.ino.cpp is recompiled and re-linked even if not necessary.

Describe the current behavior

If you do the same compile twice in a row:

~/Arduino/Blink$ LANG=en arduino-cli compile -b arduino:avr:uno --clean
Sketch uses 1636 bytes (5%) of program storage space. Maximum is 32256 bytes.
Global variables use 122 bytes (5%) of dynamic memory, leaving 1926 bytes for local variables. Maximum is 2048 bytes.

Used library Version Path                                                                       
Wire         1.0     /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire

Used platform Version Path                                                        
arduino:avr   1.8.6   /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6

~/Arduino/Blink$ LANG=en arduino-cli compile -b arduino:avr:uno -v
FQBN: arduino:avr:uno
Using board 'uno' from platform in folder: /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6
Using core 'arduino' from platform in folder: /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6

Detecting libraries used...
[...]
Generating function prototypes...
[...]
Compiling sketch...
/home/megabug/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/standard -I/home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire/src /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/sketch/Blink.ino.cpp -o /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/sketch/Blink.ino.cpp.o
Compiling libraries...
Compiling library "Wire"
Using previously compiled file: /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/libraries/Wire/utility/twi.c.o
Using previously compiled file: /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/libraries/Wire/Wire.cpp.o
Compiling core...
Using precompiled core: /tmp/arduino/cores/arduino_avr_uno_12e4cfbdc0590d50ab9cd20e50a4c3c5/core.a
Linking everything together...
/home/megabug/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-gcc -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/Blink.ino.elf /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/sketch/Blink.ino.cpp.o /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/libraries/Wire/Wire.cpp.o /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/libraries/Wire/utility/twi.c.o /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/../../cores/arduino_avr_uno_12e4cfbdc0590d50ab9cd20e50a4c3c5/core.a -L/tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3 -lm
/home/megabug/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/Blink.ino.elf /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/Blink.ino.eep
/home/megabug/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -R .eeprom /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/Blink.ino.elf /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/Blink.ino.hex
Multiple libraries were found for "Wire.h"
  Used: /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire
  Not used: /home/megabug/Workspace/Arduino_Threads
Using library Wire at version 1.0 in folder: /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire 
/home/megabug/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-size -A /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/Blink.ino.elf
Sketch uses 1636 bytes (5%) of program storage space. Maximum is 32256 bytes.
Global variables use 122 bytes (5%) of dynamic memory, leaving 1926 bytes for local variables. Maximum is 2048 bytes.

Used library Version Path                                                                       
Wire         1.0     /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire

Used platform Version Path                                                        
arduino:avr   1.8.6   /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6

🐛 The sketch file Blink.ino.cpp is recompiled even if there are no changes.

The sketch and linking phase could be completely skipped in this particular case.

Arduino CLI version

nightly

Operating system

N/A

Operating system version

N/A

Additional context

Related to #1996

Issue checklist

  • I searched for previous requests in the issue tracker
  • I verified the feature was still missing when using the nightly build
  • My request contains all necessary details
@cmaglie cmaglie added the type: enhancement Proposed improvement label Jun 6, 2023
@per1234 per1234 added topic: code Related to content of the project itself topic: build-process Related to the sketch build process labels Jun 12, 2023
@arduino arduino locked as too heated and limited conversation to collaborators Oct 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

2 participants