diff mbox

[U-Boot] Makefile: remove BUILD_TAG from KBUILD_CFLAGS

Message ID 1454981534-15925-1-git-send-email-swarren@wwwdotorg.org
State Superseded
Headers show

Commit Message

Stephen Warren Feb. 9, 2016, 1:32 a.m. UTC
From: Stephen Warren <swarren@nvidia.com>

If BUILD_TAG is part of KBUILD_CFLAGS, then any time the value changes,
all files get rebuilt. In a continuous integration environment, the value
will change every build. This wastes time assuming that incremental
builds would otherwise occur.

To solve this, remove BUILD_TAG from KBUILD_FLAGS and add it to the end of
"local version".

This has other advantages too:
- The special case for BUILD_TAG in display_options.c can be removed.
- The version printed by the "version" command exactly matches what is
  printed at boot.

Old sign-on message:
U-Boot 2016.03-rc1-00044-g4085db5e767b (Feb ...), Build: bar-bas

New sign-on message:
U-Boot 2016.03-rc1-00044-g4085db5e767b-bar-baz (Feb ...)

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 Makefile                | 4 ----
 lib/display_options.c   | 4 ----
 scripts/setlocalversion | 4 ++++
 3 files changed, 4 insertions(+), 8 deletions(-)

Comments

Jim Chargin Feb. 9, 2016, 4:11 p.m. UTC | #1
On 02/08/2016 05:32 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
>
> If BUILD_TAG is part of KBUILD_CFLAGS, then any time the value changes,
> all files get rebuilt. In a continuous integration environment, the value
> will change every build. This wastes time assuming that incremental
> builds would otherwise occur.
>
> To solve this, remove BUILD_TAG from KBUILD_FLAGS and add it to the end of
> "local version".
>
> This has other advantages too:
> - The special case for BUILD_TAG in display_options.c can be removed.
> - The version printed by the "version" command exactly matches what is
>    printed at boot.
>
> Old sign-on message:
> U-Boot 2016.03-rc1-00044-g4085db5e767b (Feb ...), Build: bar-bas
>
> New sign-on message:
> U-Boot 2016.03-rc1-00044-g4085db5e767b-bar-baz (Feb ...)

I would urge this not be done. The display of the BUILD_TAG on startup 
is pretty useful in my environment. It's been there for a long time and 
some of my users have grown used to it.

Of all the parts of the sign-on message, I'd rather the git hash go away 
than the BUILD_TAG. None of my users really care about the level of 
detail of the git hash and won't spend the time required to use this 
hash to determine if they have the version they want. (Some don't have a 
repo clone, and don't care to, and so can't easily make the 
correspondence even if they wanted to).

Thanks for your consideration.

Jim


>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>   Makefile                | 4 ----
>   lib/display_options.c   | 4 ----
>   scripts/setlocalversion | 4 ++++
>   3 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 42fad45afee1..2265b8995a7b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -562,10 +562,6 @@ else
>   KBUILD_CFLAGS	+= -O2
>   endif
>
> -ifdef BUILD_TAG
> -KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
> -endif
> -
>   KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
>   KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
>
> diff --git a/lib/display_options.c b/lib/display_options.c
> index 29343fc00e3f..5dcdf4e429af 100644
> --- a/lib/display_options.c
> +++ b/lib/display_options.c
> @@ -15,11 +15,7 @@
>
>   int display_options (void)
>   {
> -#if defined(BUILD_TAG)
> -	printf ("\n\n%s, Build: %s\n\n", version_string, BUILD_TAG);
> -#else
>   	printf ("\n\n%s\n\n", version_string);
> -#endif
>   	return 0;
>   }
>
> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
> index 63d91e22ed7c..4ef6603b5c27 100755
> --- a/scripts/setlocalversion
> +++ b/scripts/setlocalversion
> @@ -171,4 +171,8 @@ else
>   	fi
>   fi
>
> +if test -n "${BUILD_TAG}"; then
> +	res="$res-${BUILD_TAG}"
> +fi
> +
>   echo "$res"
>
Tom Rini Feb. 9, 2016, 5:01 p.m. UTC | #2
On Tue, Feb 09, 2016 at 08:11:15AM -0800, James Chargin wrote:
> 
> 
> On 02/08/2016 05:32 PM, Stephen Warren wrote:
> >From: Stephen Warren <swarren@nvidia.com>
> >
> >If BUILD_TAG is part of KBUILD_CFLAGS, then any time the value changes,
> >all files get rebuilt. In a continuous integration environment, the value
> >will change every build. This wastes time assuming that incremental
> >builds would otherwise occur.
> >
> >To solve this, remove BUILD_TAG from KBUILD_FLAGS and add it to the end of
> >"local version".
> >
> >This has other advantages too:
> >- The special case for BUILD_TAG in display_options.c can be removed.
> >- The version printed by the "version" command exactly matches what is
> >   printed at boot.
> >
> >Old sign-on message:
> >U-Boot 2016.03-rc1-00044-g4085db5e767b (Feb ...), Build: bar-bas
> >
> >New sign-on message:
> >U-Boot 2016.03-rc1-00044-g4085db5e767b-bar-baz (Feb ...)
> 
> I would urge this not be done. The display of the BUILD_TAG on
> startup is pretty useful in my environment. It's been there for a
> long time and some of my users have grown used to it.
> 
> Of all the parts of the sign-on message, I'd rather the git hash go
> away than the BUILD_TAG. None of my users really care about the
> level of detail of the git hash and won't spend the time required to
> use this hash to determine if they have the version they want. (Some
> don't have a repo clone, and don't care to, and so can't easily make
> the correspondence even if they wanted to).

Yeah, I think this is too widely used of a thing to change.  FWIW, I
really like githashes since it means you can see if $random-binary is
something you have in $vendor-tree or not.  So I think in this case, NAK
on the patch and maybe need to poke Travis-CI on how to or not to tag
things?
Stephen Warren Feb. 9, 2016, 5:26 p.m. UTC | #3
On 02/09/2016 10:01 AM, Tom Rini wrote:
> On Tue, Feb 09, 2016 at 08:11:15AM -0800, James Chargin wrote:
>>
>>
>> On 02/08/2016 05:32 PM, Stephen Warren wrote:
>>> From: Stephen Warren <swarren@nvidia.com>
>>>
>>> If BUILD_TAG is part of KBUILD_CFLAGS, then any time the value changes,
>>> all files get rebuilt. In a continuous integration environment, the value
>>> will change every build. This wastes time assuming that incremental
>>> builds would otherwise occur.
>>>
>>> To solve this, remove BUILD_TAG from KBUILD_FLAGS and add it to the end of
>>> "local version".
>>>
>>> This has other advantages too:
>>> - The special case for BUILD_TAG in display_options.c can be removed.
>>> - The version printed by the "version" command exactly matches what is
>>>    printed at boot.
>>>
>>> Old sign-on message:
>>> U-Boot 2016.03-rc1-00044-g4085db5e767b (Feb ...), Build: bar-bas
>>>
>>> New sign-on message:
>>> U-Boot 2016.03-rc1-00044-g4085db5e767b-bar-baz (Feb ...)
>>
>> I would urge this not be done. The display of the BUILD_TAG on
>> startup is pretty useful in my environment. It's been there for a
>> long time and some of my users have grown used to it.
>>
>> Of all the parts of the sign-on message, I'd rather the git hash go
>> away than the BUILD_TAG. None of my users really care about the
>> level of detail of the git hash and won't spend the time required to
>> use this hash to determine if they have the version they want. (Some
>> don't have a repo clone, and don't care to, and so can't easily make
>> the correspondence even if they wanted to).
>
> Yeah, I think this is too widely used of a thing to change.  FWIW, I
> really like githashes since it means you can see if $random-binary is
> something you have in $vendor-tree or not.  So I think in this case, NAK
> on the patch and maybe need to poke Travis-CI on how to or not to tag
> things?

Do you mean you think people currently rely upon the ", Build: xxx" 
format in the sign-on message, and the "version" command /not/ printing 
that information?

If so, I'll go back to trying to work out how to get Kbuild to transfer 
the environment variable into a CONFIG_XXX option so that modifying it 
only causes a rebuild of the one file that uses the value.

I could easily hack my Jenkins build scripts to unset that variable, but 
I do like the test logs showing the Jenkins build ID so I can validate 
the correct binary actually ran. So I'd rather not simply remove the tag 
from the message.
Tom Rini Feb. 9, 2016, 5:43 p.m. UTC | #4
On Tue, Feb 09, 2016 at 10:26:14AM -0700, Stephen Warren wrote:
> On 02/09/2016 10:01 AM, Tom Rini wrote:
> >On Tue, Feb 09, 2016 at 08:11:15AM -0800, James Chargin wrote:
> >>
> >>
> >>On 02/08/2016 05:32 PM, Stephen Warren wrote:
> >>>From: Stephen Warren <swarren@nvidia.com>
> >>>
> >>>If BUILD_TAG is part of KBUILD_CFLAGS, then any time the value changes,
> >>>all files get rebuilt. In a continuous integration environment, the value
> >>>will change every build. This wastes time assuming that incremental
> >>>builds would otherwise occur.
> >>>
> >>>To solve this, remove BUILD_TAG from KBUILD_FLAGS and add it to the end of
> >>>"local version".
> >>>
> >>>This has other advantages too:
> >>>- The special case for BUILD_TAG in display_options.c can be removed.
> >>>- The version printed by the "version" command exactly matches what is
> >>>   printed at boot.
> >>>
> >>>Old sign-on message:
> >>>U-Boot 2016.03-rc1-00044-g4085db5e767b (Feb ...), Build: bar-bas
> >>>
> >>>New sign-on message:
> >>>U-Boot 2016.03-rc1-00044-g4085db5e767b-bar-baz (Feb ...)
> >>
> >>I would urge this not be done. The display of the BUILD_TAG on
> >>startup is pretty useful in my environment. It's been there for a
> >>long time and some of my users have grown used to it.
> >>
> >>Of all the parts of the sign-on message, I'd rather the git hash go
> >>away than the BUILD_TAG. None of my users really care about the
> >>level of detail of the git hash and won't spend the time required to
> >>use this hash to determine if they have the version they want. (Some
> >>don't have a repo clone, and don't care to, and so can't easily make
> >>the correspondence even if they wanted to).
> >
> >Yeah, I think this is too widely used of a thing to change.  FWIW, I
> >really like githashes since it means you can see if $random-binary is
> >something you have in $vendor-tree or not.  So I think in this case, NAK
> >on the patch and maybe need to poke Travis-CI on how to or not to tag
> >things?
> 
> Do you mean you think people currently rely upon the ", Build: xxx"
> format in the sign-on message, and the "version" command /not/
> printing that information?

I mean that the places we construct strings like this are likely relied
upon by people, yes.

> If so, I'll go back to trying to work out how to get Kbuild to
> transfer the environment variable into a CONFIG_XXX option so that
> modifying it only causes a rebuild of the one file that uses the
> value.

A quick peak and I think that:
(a) LOCALVERSION needs a little love somewhere to ensure that it in fact
does not exceed 64 characters (and pushing upstream to the kernel
anything relevant here)
(b) Yes, adjusting BUILD_TAG into CONFIG_BUILD_TAG is probably the best
answer and probably not even that bad.  I don't think we need an
automagic conversion, just noting it in the release emails and the
sudden lack of Build: should get people that are using it to update
their scripts.

> I could easily hack my Jenkins build scripts to unset that variable,
> but I do like the test logs showing the Jenkins build ID so I can
> validate the correct binary actually ran. So I'd rather not simply
> remove the tag from the message.

Good point.
Stephen Warren Feb. 9, 2016, 5:53 p.m. UTC | #5
On 02/09/2016 10:43 AM, Tom Rini wrote:
> On Tue, Feb 09, 2016 at 10:26:14AM -0700, Stephen Warren wrote:
>> On 02/09/2016 10:01 AM, Tom Rini wrote:
>>> On Tue, Feb 09, 2016 at 08:11:15AM -0800, James Chargin wrote:
>>>>
>>>>
>>>> On 02/08/2016 05:32 PM, Stephen Warren wrote:
>>>>> From: Stephen Warren <swarren@nvidia.com>
>>>>>
>>>>> If BUILD_TAG is part of KBUILD_CFLAGS, then any time the value changes,
>>>>> all files get rebuilt. In a continuous integration environment, the value
>>>>> will change every build. This wastes time assuming that incremental
>>>>> builds would otherwise occur.
>>>>>
>>>>> To solve this, remove BUILD_TAG from KBUILD_FLAGS and add it to the end of
>>>>> "local version".
>>>>>
>>>>> This has other advantages too:
>>>>> - The special case for BUILD_TAG in display_options.c can be removed.
>>>>> - The version printed by the "version" command exactly matches what is
>>>>>    printed at boot.
>>>>>
>>>>> Old sign-on message:
>>>>> U-Boot 2016.03-rc1-00044-g4085db5e767b (Feb ...), Build: bar-bas
>>>>>
>>>>> New sign-on message:
>>>>> U-Boot 2016.03-rc1-00044-g4085db5e767b-bar-baz (Feb ...)
>>>>
>>>> I would urge this not be done. The display of the BUILD_TAG on
>>>> startup is pretty useful in my environment. It's been there for a
>>>> long time and some of my users have grown used to it.
>>>>
>>>> Of all the parts of the sign-on message, I'd rather the git hash go
>>>> away than the BUILD_TAG. None of my users really care about the
>>>> level of detail of the git hash and won't spend the time required to
>>>> use this hash to determine if they have the version they want. (Some
>>>> don't have a repo clone, and don't care to, and so can't easily make
>>>> the correspondence even if they wanted to).
>>>
>>> Yeah, I think this is too widely used of a thing to change.  FWIW, I
>>> really like githashes since it means you can see if $random-binary is
>>> something you have in $vendor-tree or not.  So I think in this case, NAK
>>> on the patch and maybe need to poke Travis-CI on how to or not to tag
>>> things?
>>
>> Do you mean you think people currently rely upon the ", Build: xxx"
>> format in the sign-on message, and the "version" command /not/
>> printing that information?
>
> I mean that the places we construct strings like this are likely relied
> upon by people, yes.
>
>> If so, I'll go back to trying to work out how to get Kbuild to
>> transfer the environment variable into a CONFIG_XXX option so that
>> modifying it only causes a rebuild of the one file that uses the
>> value.
>
> A quick peak and I think that:
> (a) LOCALVERSION needs a little love somewhere to ensure that it in fact
> does not exceed 64 characters (and pushing upstream to the kernel
> anything relevant here)
> (b) Yes, adjusting BUILD_TAG into CONFIG_BUILD_TAG is probably the best
> answer and probably not even that bad.  I don't think we need an
> automagic conversion, just noting it in the release emails and the
> sudden lack of Build: should get people that are using it to update
> their scripts.

Unfortunately, simply renaming the variable won't work; Kconfig/Kbuild 
need to know something about it in order to do their 
rebuild-only-on-change magic (and the value must be removed from CFLAGS 
too). I was having a hard time getting that to work, but I'll take 
another look.
Tom Rini Feb. 9, 2016, 6:18 p.m. UTC | #6
On Tue, Feb 09, 2016 at 10:53:48AM -0700, Stephen Warren wrote:
> On 02/09/2016 10:43 AM, Tom Rini wrote:
> >On Tue, Feb 09, 2016 at 10:26:14AM -0700, Stephen Warren wrote:
> >>On 02/09/2016 10:01 AM, Tom Rini wrote:
> >>>On Tue, Feb 09, 2016 at 08:11:15AM -0800, James Chargin wrote:
> >>>>
> >>>>
> >>>>On 02/08/2016 05:32 PM, Stephen Warren wrote:
> >>>>>From: Stephen Warren <swarren@nvidia.com>
> >>>>>
> >>>>>If BUILD_TAG is part of KBUILD_CFLAGS, then any time the value changes,
> >>>>>all files get rebuilt. In a continuous integration environment, the value
> >>>>>will change every build. This wastes time assuming that incremental
> >>>>>builds would otherwise occur.
> >>>>>
> >>>>>To solve this, remove BUILD_TAG from KBUILD_FLAGS and add it to the end of
> >>>>>"local version".
> >>>>>
> >>>>>This has other advantages too:
> >>>>>- The special case for BUILD_TAG in display_options.c can be removed.
> >>>>>- The version printed by the "version" command exactly matches what is
> >>>>>   printed at boot.
> >>>>>
> >>>>>Old sign-on message:
> >>>>>U-Boot 2016.03-rc1-00044-g4085db5e767b (Feb ...), Build: bar-bas
> >>>>>
> >>>>>New sign-on message:
> >>>>>U-Boot 2016.03-rc1-00044-g4085db5e767b-bar-baz (Feb ...)
> >>>>
> >>>>I would urge this not be done. The display of the BUILD_TAG on
> >>>>startup is pretty useful in my environment. It's been there for a
> >>>>long time and some of my users have grown used to it.
> >>>>
> >>>>Of all the parts of the sign-on message, I'd rather the git hash go
> >>>>away than the BUILD_TAG. None of my users really care about the
> >>>>level of detail of the git hash and won't spend the time required to
> >>>>use this hash to determine if they have the version they want. (Some
> >>>>don't have a repo clone, and don't care to, and so can't easily make
> >>>>the correspondence even if they wanted to).
> >>>
> >>>Yeah, I think this is too widely used of a thing to change.  FWIW, I
> >>>really like githashes since it means you can see if $random-binary is
> >>>something you have in $vendor-tree or not.  So I think in this case, NAK
> >>>on the patch and maybe need to poke Travis-CI on how to or not to tag
> >>>things?
> >>
> >>Do you mean you think people currently rely upon the ", Build: xxx"
> >>format in the sign-on message, and the "version" command /not/
> >>printing that information?
> >
> >I mean that the places we construct strings like this are likely relied
> >upon by people, yes.
> >
> >>If so, I'll go back to trying to work out how to get Kbuild to
> >>transfer the environment variable into a CONFIG_XXX option so that
> >>modifying it only causes a rebuild of the one file that uses the
> >>value.
> >
> >A quick peak and I think that:
> >(a) LOCALVERSION needs a little love somewhere to ensure that it in fact
> >does not exceed 64 characters (and pushing upstream to the kernel
> >anything relevant here)
> >(b) Yes, adjusting BUILD_TAG into CONFIG_BUILD_TAG is probably the best
> >answer and probably not even that bad.  I don't think we need an
> >automagic conversion, just noting it in the release emails and the
> >sudden lack of Build: should get people that are using it to update
> >their scripts.
> 
> Unfortunately, simply renaming the variable won't work;
> Kconfig/Kbuild need to know something about it in order to do their
> rebuild-only-on-change magic (and the value must be removed from
> CFLAGS too). I was having a hard time getting that to work, but I'll
> take another look.

Right.  Can't we just make it another string Kconfig like LOCALVERSION,
not need to pass -D.... and then it's set via poking the config file by
CI, etc?
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 42fad45afee1..2265b8995a7b 100644
--- a/Makefile
+++ b/Makefile
@@ -562,10 +562,6 @@  else
 KBUILD_CFLAGS	+= -O2
 endif
 
-ifdef BUILD_TAG
-KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
-endif
-
 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
 KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
 
diff --git a/lib/display_options.c b/lib/display_options.c
index 29343fc00e3f..5dcdf4e429af 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -15,11 +15,7 @@ 
 
 int display_options (void)
 {
-#if defined(BUILD_TAG)
-	printf ("\n\n%s, Build: %s\n\n", version_string, BUILD_TAG);
-#else
 	printf ("\n\n%s\n\n", version_string);
-#endif
 	return 0;
 }
 
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 63d91e22ed7c..4ef6603b5c27 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -171,4 +171,8 @@  else
 	fi
 fi
 
+if test -n "${BUILD_TAG}"; then
+	res="$res-${BUILD_TAG}"
+fi
+
 echo "$res"