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

Makefile: Fix Make.dep not updated by config changes #1470

Merged
merged 1 commit into from
Jul 28, 2020

Conversation

SPRESENSE
Copy link
Contributor

Summary

Make.dep file should be updated by .config changed after first make.
There are 2 cases affected for this problem:

  1. Add source files by config symbol
  2. Include header files in #ifdef directive

These 2 cases may not be included in Make.dep and this may prevent the
differential build from working correctly.

Impact

Build system

Testing

Change configuration and check that Make.dep files are updated

Make.dep file should be updated by .config changed after first make.
There are 2 cases affected for this problem:

 1) Add source files by config symbol
 2) Include header files in #ifdef directive

These 2 cases may not be included in Make.dep and this may prevent the
differential build from working correctly.
@xiaoxiang781216 xiaoxiang781216 merged commit e249a2f into apache:master Jul 28, 2020
@protobits
Copy link
Contributor

protobits commented Jul 28, 2020

I agree with the idea, in fact, it is always problematic to realize a build failure is due to out-of-date Make.dep files. I personally I'm used to deleting Make.dep/.depend files whenever I add new sources files (not so problematic because you know what you're doing) or I change configuration and something does not work right (this is the difficult case, since it becomes trial and error).

However, I'm not so sure that simply recreating dependencies whenever .config changes is the best idea as the dependency generation is REALLY slow. I tried to see why it is so slow and could not find a way to improve it. Again, I agree with the change but I wouldn't like if it add so much overhead after every configuration change.

@patacongo
Copy link
Contributor

However, I'm not so sure that simply recreating dependencies whenever .config changes is the best idea as the dependency generation is REALLY slow. I tried to see why it is so slow and could not find a way to improve it. Again, I agree with the change but I wouldn't like if it add so much overhead after every configuration change.

There is a way to make the dependency generation faster in some cases. The Make.dep file has to be recreated when any .c file modified. Since the Make.dep creation recreates the dependencies for all .c files, that takes a long time.

An alternative is to keep all of the dependencies in separate .d files in a sub-directory. Then when a .c file changes, only one .d file needs to be recreated.

I have not looked at Linux in a long time but I believe that they implemented a lot of tricks to keep from rebuilding everything. I think they did things like:

  • Put the inclusion of config.h on the gcc command line rather than in the C code (that, of course, is not portable to other compilers so we should not consider it).
  • I recall that Linux breaks config.h in many separate, small header files in sub-directories. I am not sure how this helps the rebuild time.

Looking at how Linux has optimized the use of .config files might be worth the time.

@protobits
Copy link
Contributor

It would be interesting to improve mkdep speed considering what Linux or other similar projects do. I think that one of the issues that contribute to longer build times than necessary is that, as you mention, there is one config.h which is included everywhere and most likely only a small subset of files actually depend on the values that changed. I don't know what would be the way to improve it. Splitting the config.h could be one what it also sounds very difficult to work with. Maybe someone with knowledge of Linux build internals can shed some light.

Anyways, I'm concerned that with this change modifying the config will always be so slow because it will force regenerating everything, so any strategy of the ones mentioned would not help.

@SPRESENSE SPRESENSE deleted the fix-depend-issue branch July 29, 2020 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants