-
Notifications
You must be signed in to change notification settings - Fork 2k
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
WIP Trying to remove recursive makefiles #7670
Conversation
cool (: |
@cladmi is there any significant speed-up due to this? |
5be913e
to
d3de52c
Compare
@miri64: I did not do any measurement. My goal is to get rid of the need to run |
Yes, but if it speeds up stuff regardless, that would be awesome as well ;-) |
Just tested it myself (with |
From looking a bit more into the buildsystem, my handling of SUBMODULES is broken. I do not define the |
For SUBMODULES, I will try adding stuff for |
b4f69fc
to
42dff3e
Compare
tinymt32 dir is required to build 'tinymt32' module, not 'prng_tinymt32'. It was working because tinymt32 is only pulled as a prng_tinymt32 dependency.
Define MODULE_DIR_$(module) for each module in sys. Modules with names matching a subdirectory are automatically created. Others should be explicitely defined. Makefile.modules are made to be importable from any directory.
Use MODULE_DIR_$(module) variables to populate DIRS from USEMODULE. DIRS is now calculaded directly in the main Makefile.
..nothing targets removes print "make[2]: Nothing to be done for 'all'." when changing directory. However, because Makefile.base gets imported multiple times, its overrwritten.
This will allow setting modules specific FLAGS in non recursive mode.
…c to current module.
… makefiles By defining 'NONRECURSIVE', multiple modules Makefile can be included in the same makefile and handled seperately. WARNING: If for any reason, a module includes another Makefile before Makefile.base it will break the including makefile magic. So maybe it would be good separate it to a Makefile.base.head and Makefile.base.tail for this kind of modules.
Define MODULE_DIR_$(module) for each module in drivers. Makefile.modules are made to be importable from any directory.
Use MODULE_DIR_$(module) variables to populate DIRS from USERMODULE DIRS is now calculaded directly in the main Makefile.
Use MODULE_DIR_$(module) variables to populate DIRS from USEMODULE.
Use MODULE_DIR_$(module) variables to populate DIRS from USEMODULE.
42dff3e
to
60e1647
Compare
I will close this for now as I am not going to go further on the whole project right now. I think that this would require other cleanups steps to be useful:
|
This relates to #1242
This PR adds support to build all the
sys
modules without requiring to change directories withmake -C
. It consists of 3 parts:sys
modulesMakefile.base
to add local path to SRC and allow including it multiple times through different modulessys
include all makefiles instead of changing directoryI took care that every commit keeps working (at least compilation of
gcoap
example`) and should be possible to understand by itself. So I would recommend reviewing commit by commit, you could find problems or have remarks without requiring to understand the whole process at once.Also some cleanups/fixups could be put to different PRs to integrate them without the rest.
Static sys modules definition
I created
Makefile.modules
files that define mappings between modules name and absolute path to module directory.I set
MODULE_DIR_modulename = realpath_to_modulename_dir
for all modules that where handled in this directory before. Modules whose directory is in$(MODULE)/Makefile
are detected by a wildcard in the same way as before. The definition is done for all modules and not only the one in USEMODULE.This way I can have a static definition of modules directory for all modules from
sys
.I could then change
sys/Makefile
to include all the definitions and only setDIRS
once.Implementation details
I kept the mapping between module and module directory centralized as it was before. I just moved them to
Makefile.modules
files. Moving them to per module description file is another topic.I chose to include all sub
Makefile.modules
insys/Makefile
and not insys/Makefile.modules
itself but it could be changed.Make
Makefile.base
ready for non-recursive makefileNon-recursive makefile means including all the modules definition before trying to execute anything.
This implies including
Makefile.base
multiple times as one per module. Also, it would be included from another directory than the module directory itself, so it cannot rely onCURDIR
.First step was adding the local directory when doing
wildcard
and in front of all sources for the build targets. TheSRC
variables are still without path to be compatible with the current way of settingSRC
in module makefile. I used$(D)
for the directory name so it is not too intrusive when using it.Then, as some variables have
lazy
value management, they should be undefined at the end so they are not kept between modules.Speaking about sharing values, some module define custom CFLAGS/CXXFLAGS so the build rules should use per module CFLAGS variables. I tried to keep the CXXUWFLAGS and CCASUWFLAGS working but did not really tested the impact. (reminder, the values in the build rule are evaluated at execution time).
I adapted the files I found to use a per module CFLAGS definition.
Non-recursive magic trick to get current directory
To detect the current module directory, I use the 'n - 1' included makefile which should be the including one. Except if
Makefile.base
was included after including another makefile in the module.So, keeping it in this form makes it possible to break if module writer do not put enough care when writing.
A solution would be to put this magic into a
Makefile.base.head
included on top of each module.But this changes many files so I would rather keep this for later in the PR.
To get the last makefile I also saw this from the linux-mag post where they have a
_header.mak
file on top.http://webcache.googleusercontent.com/search?q=cache:LKx_cEDQepQJ:www.linux-mag.com/id/2101/&num=1&hl=en&gl=us&strip=1&vwsrc=0
This is the most magic part and it should be improved to make it reliable by design.
Using non recursive makefiles in
sys
After paying attention that
Makefile.base
should be included first. It just means replacingDIRS +=
by include the directories.Tricks that make it work by chance
Its working now because the build system does
make -C DIR all
in every directory and thatMakefile.base
adds$(MODULE).a
as a target forall
.Also, DIRS is unset when entering a module so everything works as expected.
Testing
Old and new builds output can be compared by saving the verbose output:
And you can find my clean output script here https://gist.github.com/cladmi/29d87b0e66e505f3c6dcea62ed51fa8d it just cleans backslash lines, whitespace, and removes all 'Make -C, 'entering directory' and 'mkdir -p', and sorts the output.