makefiles: Introduce GIT_VERSION and use it for RIOT_VERSION#11881
makefiles: Introduce GIT_VERSION and use it for RIOT_VERSION#11881miri64 merged 3 commits intoRIOT-OS:masterfrom
Conversation
Move git version evaluation to a separate file. The definition has been updated it to a deferred only definition. This way git is not called when GIT_VERSION is not used.
Use 'GIT_VERSION' for 'RIOT_VERSION'. This prevents evaluating 'git describe' and 'git rev-parse' when their value is not used.
This changes CFLAGS_WITH_MACROS to be: * a deferred variable * not exported so only evaluated when actually used The value is only used by `Makefile.include` and `makefiles/eclipse.inc.mk` so not required to export it.
|
This also speeds up running After running Where it was in master: @aabadie I think you are using |
There was a problem hiding this comment.
ACK, I tested building and running examples/hello-world
- on master (should give e.g.
2019.10-devel-128-g7d381, i.e. should not append the branch name and no extra-at the end) - on a detached HEAD (should give e.g.
2019.10-devel-128-g7d381-HEAD) - on a branch (should give e.g.
2019.10-devel-128-g7d381-test-pr-11881, i.e. with the branch name appended, prefixed with a-) - on a release tag (should just print the release name e.g.
2019.07) - the content of a release tar ball (should just print the release name e.g.
2019.07).
For all cherry-picked the commits from this PR on top (or just applied as patch in the tar ball case git -C ../RIOT diff HEAD~3 > patch.txt; patch -p1 < patch.txt).
All had the expected output.
I tried to verify the speed updates you claimed:
In this PR
$ time for i in {0..100}; do RIOT_CI_BUILD=1 make --no-print-directory -C examples/hello-world/ info-debug-variable-CFLAGS_WITH_MACROS >/dev/null 2>/dev/null; done
real 0m35,414s
user 0m27,379s
sys 0m11,662s
$ time for i in {0..100}; do make --no-print-directory -C examples/hello-world/ info-debug-variable-CFLAGS_WITH_MACROS >/dev/null 2>/dev/null; done
real 0m47,847s
user 0m37,648s
sys 0m13,471s
$ time for i in {0..100}; do RIOT_CI_BUILD=1 make --no-print-directory -C examples/hello-world/ clean >/dev/null 2>/dev/null; done
real 0m36,378s
user 0m27,814s
sys 0m12,369s
and a significant speed boost is visible when not using RIOT_VERSION (done on git reset --hard HEAD~3 form this PR as HEAD):
$ time for i in {0..100}; do RIOT_CI_BUILD=1 make --no-print-directory -C examples/hello-world/ info-debug-variable-CFLAGS_WITH_MACROS >/dev/null 2>/dev/null; done
real 0m48,188s
user 0m38,251s
sys 0m13,398s
$ time for i in {0..100}; do make --no-print-directory -C examples/hello-world/ info-debug-variable-CFLAGS_WITH_MACROS >/dev/null 2>/dev/null; done
real 0m47,909s
user 0m38,107s
sys 0m13,474s
$ time for i in {0..100}; do RIOT_CI_BUILD=1 make --no-print-directory -C examples/hello-world/ clean >/dev/null 2>/dev/null; done
real 0m48,806s
user 0m38,538s
sys 0m13,919s
=> ACK
|
Thank you for the review.
I did not thought about these ones, and the release tag is one of the most important one. I will do another PR to document these in
I indeed forgot to show this was not changed. Good catch. |
Now that I think about it... It makes no sense, that they have a different result in describ than the devel tag... Maybe they were also just read from the VERSION file? |
|
Indeed, if there is a Now that you say it, with the current and previous behavior, the I could propose to change this. Which then would make being on We could also remove the When I noticed the branch name was in the version, it felt for me a bit off somehow. It is a source on non reproducibility and local machine information. |
Personally when I clone a PR, I have my own naming scheme, so when building would have a different binary than the one on the developer machine, even when building in docker. |
|
I'm not sure either, why the branch name / the word |
Contribution description
This is an alternative to #11771 and fixes the root of the problem for all normal uses outside of
RIOT_CI_BUILD=1. #11771 (comment)It only call 'git describe' and 'git rev-parse' through
GIT_VERSIONwhen it is used.There are three steps
GIT_VERSIONthat only calls 'git' when used. It will also only call each commands only once thanks tomemoizedRIOT_VERSION.At that point, when
RIOT_VERSION_OVERRIDEis set,gitwill not be called for this.CFLAGS_WITH_MACROS.This prevents evaluating the value when unused, so not evaluated when doing
make cleanfor example as it would have been before.Testing procedure
I will compare different uses and the evolution starting from step 3, step 2 and what was in master.
State at pull request
When
RIOT_VERSIONis not used, it is not called:Each command is still called only once (two git calls) when the value is used
It is not called when
RIOT_VERSION_OVERRIDEis set, here throughRIOT_CI_BUILD=1Step 2, when
CFLAGS_WITH_MACROSwas still evaluatedWithout the third commit, when the value was not used, like for `clean` for example, `git` would still be called.
In master
The value was always called
even when
RIOT_VERSION_OVERRIDEwas setSpeed update
On my machine I do not manage to have reliable timing anymore… Like they are completely inconsistent. I use the one from my build machine that are consistent:
Speed update from 14.5 to 7.5 seconds
Here
GIT_VERSIONis not evaluated as it is usingRIOT_VERSION_OVERRIDEinstead:The normal build with RIOT_VERSION being used:
Commands not using
RIOT_VERSIONhave speedup without overwriting:Where in master it gives
The
RIOT_VERSIONhas still the same behavior as before.The `RIOT_VERSION` given to the program as the same value as before
Version includes branch name:
In master it removes the branch name
Outside of a git repository, the version is said to be unknown
The value is given to the compiler in
CFLAGS_WITH_MACROSAnd overwritten when using
RIOT_CI_BUILD=1Issues/PRs references
A real fix compared to only the workaround done in #11771
Tracking: remove harmful use of
exportin make and immediate evaluation #10850