Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
matthijskooijman wants to merge5 commits intoarduino:master
base:master
Choose a base branch
Loading
frommatthijskooijman:include-caching-improved

Conversation

@matthijskooijman
Copy link
Collaborator

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 samerecipe.preproc.macros that 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/null instead?). An alternative approach would be to add a new recipe for include detection and leave therecipe.preproc.macros for 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-MM instead of-MMD to send .d file output to the file specified with -o).

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>
Previously, 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.
@ArduinoBot
Copy link
Contributor

✅ Build completed.

⬇️ Build URL:http://downloads.arduino.cc/PR/arduino-builder/arduino-builder-217.zip

ℹ️ To test this build:

  1. Replacearduino-builder binary (you can find it where you installed the IDE) with the provided one

@facchinm
Copy link
Member

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-MF and-MT presence is totally optional I'd merge this PR and leave the choice whether or not supporting them to the core developers.

@matthijskooijmanmatthijskooijman changed the titleInclude caching improvedWIP: Include caching improvedSep 26, 2017
@ArduinoBot
Copy link
Contributor

✅ Build completed.

⬇️ Build URL:http://downloads.arduino.cc/PR/arduino-builder/arduino-builder-217.zip

ℹ️ To test this build:

  1. Replacearduino-builder binary (you can find it where you installed the IDE) with the provided one

@matthijskooijman
Copy link
CollaboratorAuthor

It seems reusingrecipe.preproc.macros is not a good idea. I just rebased on top of#236, and now:

  • If you add the needed-MMD,-MT and-MF options, gcc errors out withcc1plus: error: to generate dependencies you must specify either -M or -MM. This is becausearduino-builder now more effectively filters out the-MMD option.
  • If you would then not filter out the-MMD option, this would work. However, for platforms that do not specify an explicit depfile name using-MF, would again run into problems with gcc trying to create/dev/null.d.

Hence, a new recipe is probably a good idea. Not sure if-o /dev/null -MMD -MF {dep_file}, or-MM - {depfile} should be preferred yet.

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
Copy link

CLAassistant commentedApr 9, 2021
edited
Loading

CLA assistant check
All committers have signed the CLA.

@per1234per1234 added type: enhancementProposed improvement topic: codeRelated to content of the project itself labelsMay 24, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

topic: codeRelated to content of the project itselftype: enhancementProposed improvement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@matthijskooijman@ArduinoBot@facchinm@CLAassistant@per1234

[8]ページ先頭

©2009-2025 Movatter.jp