Arduino Compiler Dependencies Caching

The Arduino IDE (and Visual Micro) use dependency files (*.d) generated during the build process, to work out if the sketch/core/libraries need to be re-compiled.

If these files are not generated as part of the build process, then no caching takes place, and the items are built every time, which can lead to a long build time if only minor changes have taken place.

In builds since 1.2022.0611 there will be the below warning shown in the build output if the dependencies are not being generated:

Build Output Warning when no Dependencies are being generated

How Are They Generated?

These are generated using the additional GCC option "-MMD".

They can be added to the extra_flags for testing, and then to the full c/cxx/cpp.flags options when integrating into platform.txt

(These can also be overridden in Visual Micro using the local board.txt file, and the extra_flags entries).


Project Property Example

Project Properties with Additional flag to Generate Dependencies

Local Board.txt Examples

# Generate Dependencies using extra_flags (Only set ones present in your core)


# Generate Dependencies using extra_flags (Example for MBED Sparkfun Core Below)
#compiler.c.flags=-iprefix{runtime.platform.path}/cores/ @{build.variant.path}/mbed/.c-flags 
-MMD {compiler.c.extra_flags}
#compiler.cxx.flags=-include {build.variant.path}/mbed/mbed_config.h -include {cores.path}/arduino/sdk/ArduinoSDK.h -iprefix{runtime.platform.path}/cores/ @{build.variant.path}/mbed/.cxx-flags -MMD {compiler.cxx.extra_flags}