feat: Do not compile unused libraries listed in a sketch profile.#3144
Merged
Conversation
d1feb7d to
6661cb4
Compare
It could be possible that the compilation is unsuccessful, due to preprocessor errors.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3144 +/- ##
==========================================
+ Coverage 69.31% 69.36% +0.04%
==========================================
Files 252 252
Lines 19406 19422 +16
==========================================
+ Hits 13452 13472 +20
+ Misses 4708 4706 -2
+ Partials 1246 1244 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
giulio93
reviewed
Mar 31, 2026
giulio93
approved these changes
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please check if the PR fulfills these requirements
See how to contribute
before creating one)
our contributing guidelines
UPGRADING.mdhas been updated with a migration guide (for breaking changes)configuration.schema.jsonupdated if new parameters are added.What kind of change does this PR introduce?
When using a sketch profile, the libraries listed in the profile are always added for compilation by the Arduino CLI, even if the libraries are not actually used/included in the sketch.
This differs from the "classic" behavior (without the profiles), where the libraries are checked by the library discovery process and only compiled if actually used in the sketch, and this difference may lead to some problems like the one described in this issue.
This PR updates the library discovery process and allows the builder to detect if a library listed in the profile is not in use.
The change can be summarized as follows:
This hybrid approach should enable us to add the libraries listed in the profile quickly, without undergoing the slow full-discovery process, while also preventing us from compiling unnecessary libraries.
What is the current behavior?
The libraries listed in a profile are always compiled.
What is the new behavior?
The libraries listed in a profile are compiled only if used.
Does this PR introduce a breaking change, and is titled accordingly?
No
Other information
Fix #3085