Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork114
WIP: Include caching improved#217
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
WIP: Include caching improved#217
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This does not change any behaviour, but only passed these variablesalong through the entire stack of functions leading up toObjFileIsUpToDate. This prepares for the next commit.Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
If -debug-level=20 is passed, whenever the cached file is not usable forwhatever reason, a message is displayed. This should help debug cachingproblems.The messages are hardcoded in the source and not put into `constants`,since they are only debug messages.Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
This slightly cleans up a function call.Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
This renames this function and adds a resultFile parameter. ThisresultFile is used for all timestamp checks against other files (sourcefile, dep file, header files from the dep file), while the objectFilepassed is now only used to check against the contents of the dep file.Both calls to this function still pass the same filename as objectFileand resultFile, so this commit should not change any behavior.Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
33fde6d to3b4d090ComparePreviously, the including detection process caching relied on the .dfiles generated by compilation to know what .h files a given sourcefiles depends on. This works correctly, but if a project does notcompile completely, not all .d files are generated, so not all cachedinclude detection results can be used.In practice, this means that if a there is a compilation error in thefirst file that is compiled, include detection will run again for allfiles on the next run. If you have a few errors to solve and a bigproject, this gets annoying quickly.To fix this, the include detection process should generate .d filesitself. At first glance it appears that there is a problematic casewhere the list of included header files changes, the include detectionoverwrites the .d file and then compilation only sees the new list(which was generated later than the .o file was generated). However,since this implies that changes are made to an #include directive in thesource file itself or one of the files that are still included, thisshould be detected normally. There is still a corner case when a file ischanged during the build, but that was already the case.Since include detections uses `-o /dev/null`, the compiler generates aslightly different .d file. During compilation, a file `foo.cpp.d` isgenerated in the output directory starting with: /path/to/foo.cpp.o: \But when just passing `-MMD` to the preproc recipe, it generates a`foo.d` file in the source directory starting with: foo.o: \To make these equal, `-MF` must be passed during include detection toset the .d filename, and `-MT` must be passed to set the .o filenameinside the .d file.To enable this feature, platform.txt should be modified by adding ` -MMD-MF {dep_file} -MT {object_file}` to `preproc.macros.flags` (or`recipe.preproc.macros`). Without any changes to platform.txt, behaviouris unchanged.To allow this, this adds `{dep_file}` and `{object_file}` variables tothe build properties for the preproc macros recipe. For consistency,`{dep_file}` is also added during normal compilation, though it is notcurrently used.3b4d090 tof13ade8CompareArduinoBot commentedMar 2, 2017
✅ Build completed. ⬇️ Build URL: ℹ️ To test this build:
|
facchinm commentedMar 6, 2017
I can see a huge improvement while developing big projects, but the extra complexity seems a bit overwhelming for smaller ones 🙂 I remember that@ffissore had some funny times trying to find out a common dependency method which could work even for older compilers. If |
ArduinoBot commentedNov 29, 2017
✅ Build completed. ⬇️ Build URL: ℹ️ To test this build:
|
matthijskooijman commentedNov 30, 2017
It seems reusing
Hence, a new recipe is probably a good idea. Not sure if Not that I have not pushed the rebased version yet, since it would completely clutter this PR with all of the commits of#236, so I'll push once that one gets merged. |
CLAassistant commentedApr 9, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This PR fixes an issue with the include detection caching where it would not use cached versions because of errors during compilation. This changes the include caching code to generate the same .d files as the compilation process, so they can be used even when compilation fails (which is convenient when working through multiple compilation errors in a big project).
The last commit in this PR is the core of it and is still a work-in-progress. It currently works, but it re-uses the same
recipe.preproc.macrosthat must be modified to take advantage of this new code. However, this recipe is also used by the "preprocess the sketch" code during prototype insertion which currently also overwrites the .d file (which is probably not ideal, perhaps this needs to be changed to pass/dev/nullinstead?). An alternative approach would be to add a new recipe for include detection and leave therecipe.preproc.macrosfor just generating a preprocessed version of a file, without any .d files being generated (and adding a new recipe that generates a .d file and errors, but not any output, perhaps using-MMinstead of-MMDto send .d file output to the file specified with -o).