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

fix: library loading errors genereates unneeded compile failures #2139

Merged
merged 1 commit into from
Apr 7, 2023

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Apr 7, 2023

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

  • The library loading errors do not affect compile results anymore.
  • Fixed an error message
  • Library loading warnings are reported only in verbose compile

What is the current behavior?

If an invalid library is installed in the system, all sketch compilations will fail, even if the library is not used:

$ arduino-cli compile -b arduino:avr:uno
Error initializing instance: Loading libraries: &{0xc001c760c0}


Used platform Version Path                                                        
arduino:avr   1.8.5   /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.5
Error during build: rpc error: code = Internal desc = loading library from /home/megabug/Workspace/sketchbook-cores-beta/libraries/Empty: invalid library: no header files found

This behavior has been worsened after merging #2083 which caused more libraries to be reported as invalid.

What is the new behavior?

Any invalid library is silently ignored unless the verbose output is enabled. In that case, a warning is printed explaining the error:

$ arduino-cli compile -b arduino:avr:uno
Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

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

$ 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.5
Using core 'arduino' from platform in folder: /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.5

loading library from /home/megabug/Workspace/sketchbook-cores-beta/libraries/Empty: invalid library: no header files found
Detecting libraries used...
/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 -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/sketch/Blink.ino.cpp -o /dev/null
Using cached library dependencies for file: /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/sketch/Blink.cpp
Generating function prototypes...
/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 -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/sketch/Blink.ino.cpp -o /tmp/arduino/sketches/002050EAA7EFB9A4FC451CDFBC0FA2D3/preproc/ctags_target_for_gcc_minus_e.cpp

Does this PR introduce a breaking change, and is titled accordingly?

Other information

@cmaglie cmaglie added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Apr 7, 2023
@cmaglie cmaglie requested review from ubidefeo, per1234 and umbynos April 7, 2023 10:50
@cmaglie cmaglie self-assigned this Apr 7, 2023
@codecov
Copy link

codecov bot commented Apr 7, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01 🎉

Comparison is base (fe91ec6) 62.59% compared to head (13249e1) 62.60%.

Additional details and impacted files
@@            Coverage Diff             @@
##           0.32.x    #2139      +/-   ##
==========================================
+ Coverage   62.59%   62.60%   +0.01%     
==========================================
  Files         227      227              
  Lines       19533    19534       +1     
==========================================
+ Hits        12226    12230       +4     
  Misses       6210     6210              
+ Partials     1097     1094       -3     
Flag Coverage Δ
unit 62.60% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
commands/instances.go 58.35% <100.00%> (ø)
legacy/builder/libraries_loader.go 55.00% <100.00%> (+16.01%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@cmaglie cmaglie merged commit 9a08fec into arduino:0.32.x Apr 7, 2023
@cmaglie cmaglie deleted the fix_lib_loading_regression branch April 7, 2023 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants