Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] Makefile: generate KBUILD_BUILD_TIMESTAMP date whith LANG=C
@ 2016-12-06 10:10 Jean-Baptiste Trédez
  2016-12-06 10:33 ` Thomas Petazzoni
  2016-12-06 13:02 ` Jérôme Pouiller
  0 siblings, 2 replies; 5+ messages in thread
From: Jean-Baptiste Trédez @ 2016-12-06 10:10 UTC (permalink / raw)
  To: buildroot

Fix kernel reproducible build if LANG=fr_FR.UTF-8 in host system.

when building linux kernel, scripts/gen_initramfs_list.sh do 'date -d"$KBUILD_BUILD_TIMESTAMP" +%s'
In buildroot makefile, KBUILD_BUILD_TIMESTAMP="$(shell date -d @$(SOURCE_DATE_EPOCH))"
if LANG=fr_FR.UTF-8 in host system, it does not work :
- LANG=C date -d"$(LANG=C date)" : ok
- LANG=C date -d"$(LANG=fr_FR.UTF-8 date)" : error

Signed-off-by: Jean-Baptiste Tr?dez <jean-baptiste.tredez@basystemes.fr>
---
 linux/linux.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux/linux.mk b/linux/linux.mk
index a63d1f3..554c5f1 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -99,7 +99,7 @@ LINUX_MAKE_ENV += \
 	KBUILD_BUILD_VERSION=1 \
 	KBUILD_BUILD_USER=buildroot \
 	KBUILD_BUILD_HOST=buildroot \
-	KBUILD_BUILD_TIMESTAMP="$(shell date -d @$(SOURCE_DATE_EPOCH))"
+	KBUILD_BUILD_TIMESTAMP="$(shell LANG=C date -d @$(SOURCE_DATE_EPOCH))"
 endif
 
 # Get the real Linux version, which tells us where kernel modules are
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH] Makefile: generate KBUILD_BUILD_TIMESTAMP date whith LANG=C
  2016-12-06 10:10 [Buildroot] [PATCH] Makefile: generate KBUILD_BUILD_TIMESTAMP date whith LANG=C Jean-Baptiste Trédez
@ 2016-12-06 10:33 ` Thomas Petazzoni
  2016-12-06 10:48   ` Jean-Baptiste Tredez
  2016-12-06 13:02 ` Jérôme Pouiller
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Petazzoni @ 2016-12-06 10:33 UTC (permalink / raw)
  To: buildroot

Hello,

On Tue,  6 Dec 2016 11:10:01 +0100, Jean-Baptiste Tr?dez wrote:
> Fix kernel reproducible build if LANG=fr_FR.UTF-8 in host system.
> 
> when building linux kernel, scripts/gen_initramfs_list.sh do 'date -d"$KBUILD_BUILD_TIMESTAMP" +%s'
> In buildroot makefile, KBUILD_BUILD_TIMESTAMP="$(shell date -d @$(SOURCE_DATE_EPOCH))"
> if LANG=fr_FR.UTF-8 in host system, it does not work :
> - LANG=C date -d"$(LANG=C date)" : ok
> - LANG=C date -d"$(LANG=fr_FR.UTF-8 date)" : error
> 
> Signed-off-by: Jean-Baptiste Tr?dez <jean-baptiste.tredez@basystemes.fr>

Indeed, seems like the LANG/LC_ALL variables exported in the main
Makefile are not used in the $(shell ...) sub-shells.

However, are you sure it works with LANG=C ? It seems like LC_ALL=C is
needed instead:

thomas at skate:/tmp$ LANG=C date
mardi 6 d?cembre 2016, 11:31:52 (UTC+0100)
thomas at skate:/tmp$ LC_ALL=C date
Tue Dec  6 11:31:59 CET 2016

I also tested with the following test makefile:

====

export LC_ALL=C

foo = $(shell LC_ALL=C date)

all:
	date
	echo "$(foo)"

====

And indeed, the "export LC_ALL" is enough for the direct "date" call to
work. But for the date call whose output is stored in the "foo"
variable, passing again LC_ALL in the sub-shell is necessary.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH] Makefile: generate KBUILD_BUILD_TIMESTAMP date whith LANG=C
  2016-12-06 10:33 ` Thomas Petazzoni
@ 2016-12-06 10:48   ` Jean-Baptiste Tredez
  0 siblings, 0 replies; 5+ messages in thread
From: Jean-Baptiste Tredez @ 2016-12-06 10:48 UTC (permalink / raw)
  To: buildroot

Le 06/12/2016 ? 11:33, Thomas Petazzoni a ?crit :
> Hello,
>
> On Tue,  6 Dec 2016 11:10:01 +0100, Jean-Baptiste Tr?dez wrote:
>> Fix kernel reproducible build if LANG=fr_FR.UTF-8 in host system.
>>
>> when building linux kernel, scripts/gen_initramfs_list.sh do 'date -d"$KBUILD_BUILD_TIMESTAMP" +%s'
>> In buildroot makefile, KBUILD_BUILD_TIMESTAMP="$(shell date -d @$(SOURCE_DATE_EPOCH))"
>> if LANG=fr_FR.UTF-8 in host system, it does not work :
>> - LANG=C date -d"$(LANG=C date)" : ok
>> - LANG=C date -d"$(LANG=fr_FR.UTF-8 date)" : error
>>
>> Signed-off-by: Jean-Baptiste Tr?dez <jean-baptiste.tredez@basystemes.fr>
> Indeed, seems like the LANG/LC_ALL variables exported in the main
> Makefile are not used in the $(shell ...) sub-shells.
>
> However, are you sure it works with LANG=C ? It seems like LC_ALL=C is
> needed instead:
>
> thomas at skate:/tmp$ LANG=C date
> mardi 6 d?cembre 2016, 11:31:52 (UTC+0100)
> thomas at skate:/tmp$ LC_ALL=C date
> Tue Dec  6 11:31:59 CET 2016
$ date
mardi 6 d?cembre 2016, 11:36:21 (UTC+0100)
$ LANG=C date
Tue Dec  6 11:36:49 CET 2016
$ LC_ALL=C date
Tue Dec  6 11:36:57 CET 2016

It works fine on my machine with LANG=C. I will change to LC_ALL=C.
>
> I also tested with the following test makefile:
>
> ====
>
> export LC_ALL=C
>
> foo = $(shell LC_ALL=C date)
>
> all:
> 	date
> 	echo "$(foo)"
>
> ====
>
> And indeed, the "export LC_ALL" is enough for the direct "date" call to
> work. But for the date call whose output is stored in the "foo"
> variable, passing again LC_ALL in the sub-shell is necessary.
>
> Thomas

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH] Makefile: generate KBUILD_BUILD_TIMESTAMP date whith LANG=C
  2016-12-06 10:10 [Buildroot] [PATCH] Makefile: generate KBUILD_BUILD_TIMESTAMP date whith LANG=C Jean-Baptiste Trédez
  2016-12-06 10:33 ` Thomas Petazzoni
@ 2016-12-06 13:02 ` Jérôme Pouiller
  2016-12-06 16:41   ` Jean-Baptiste Tredez
  1 sibling, 1 reply; 5+ messages in thread
From: Jérôme Pouiller @ 2016-12-06 13:02 UTC (permalink / raw)
  To: buildroot

Hello Jean-Baptiste,

On Tuesday 06 December 2016 11:10:01 Jean-Baptiste Tr?dez wrote:
> Fix kernel reproducible build if LANG=fr_FR.UTF-8 in host system.
> 
> when building linux kernel, scripts/gen_initramfs_list.sh do 'date -d"$KBUILD_BUILD_TIMESTAMP" +%s'
> In buildroot makefile, KBUILD_BUILD_TIMESTAMP="$(shell date -d @$(SOURCE_DATE_EPOCH))"
> if LANG=fr_FR.UTF-8 in host system, it does not work :
> - LANG=C date -d"$(LANG=C date)" : ok
> - LANG=C date -d"$(LANG=fr_FR.UTF-8 date)" : error

Good catch.

> ---
>  linux/linux.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux/linux.mk b/linux/linux.mk
> index a63d1f3..554c5f1 100644
> --- a/linux/linux.mk
> +++ b/linux/linux.mk
> @@ -99,7 +99,7 @@ LINUX_MAKE_ENV += \
>  	KBUILD_BUILD_VERSION=1 \
>  	KBUILD_BUILD_USER=buildroot \
>  	KBUILD_BUILD_HOST=buildroot \
> -	KBUILD_BUILD_TIMESTAMP="$(shell date -d @$(SOURCE_DATE_EPOCH))"
> +	KBUILD_BUILD_TIMESTAMP="$(shell LANG=C date -d @$(SOURCE_DATE_EPOCH))"

It should also possible to fix problem using backquotes:

  KBUILD_BUILD_TIMESTAMP="`date -d @$(SOURCE_DATE_EPOCH)`"

I find it lighter.



BR,

-- 
J?r?me Pouiller, Sysmic
Embedded Linux specialist
http://www.sysmic.fr

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH] Makefile: generate KBUILD_BUILD_TIMESTAMP date whith LANG=C
  2016-12-06 13:02 ` Jérôme Pouiller
@ 2016-12-06 16:41   ` Jean-Baptiste Tredez
  0 siblings, 0 replies; 5+ messages in thread
From: Jean-Baptiste Tredez @ 2016-12-06 16:41 UTC (permalink / raw)
  To: buildroot

Hello,

Le 06/12/2016 ? 14:02, J?r?me Pouiller a ?crit :
> Hello Jean-Baptiste,
>
> On Tuesday 06 December 2016 11:10:01 Jean-Baptiste Tr?dez wrote:
>> Fix kernel reproducible build if LANG=fr_FR.UTF-8 in host system.
>>
>> when building linux kernel, scripts/gen_initramfs_list.sh do 'date -d"$KBUILD_BUILD_TIMESTAMP" +%s'
>> In buildroot makefile, KBUILD_BUILD_TIMESTAMP="$(shell date -d @$(SOURCE_DATE_EPOCH))"
>> if LANG=fr_FR.UTF-8 in host system, it does not work :
>> - LANG=C date -d"$(LANG=C date)" : ok
>> - LANG=C date -d"$(LANG=fr_FR.UTF-8 date)" : error
> Good catch.
>
>> ---
>>   linux/linux.mk | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/linux/linux.mk b/linux/linux.mk
>> index a63d1f3..554c5f1 100644
>> --- a/linux/linux.mk
>> +++ b/linux/linux.mk
>> @@ -99,7 +99,7 @@ LINUX_MAKE_ENV += \
>>   	KBUILD_BUILD_VERSION=1 \
>>   	KBUILD_BUILD_USER=buildroot \
>>   	KBUILD_BUILD_HOST=buildroot \
>> -	KBUILD_BUILD_TIMESTAMP="$(shell date -d @$(SOURCE_DATE_EPOCH))"
>> +	KBUILD_BUILD_TIMESTAMP="$(shell LANG=C date -d @$(SOURCE_DATE_EPOCH))"
> It should also possible to fix problem using backquotes:
>
>    KBUILD_BUILD_TIMESTAMP="`date -d @$(SOURCE_DATE_EPOCH)`"
>
> I find it lighter.
It should work but may require a comment. One may not see the importance 
of the backquotes and it is hard to track (since the compilation do not 
fail in case of error only a binary compare on vmlinux will show the issue).

>
>
> BR,
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-12-06 16:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-06 10:10 [Buildroot] [PATCH] Makefile: generate KBUILD_BUILD_TIMESTAMP date whith LANG=C Jean-Baptiste Trédez
2016-12-06 10:33 ` Thomas Petazzoni
2016-12-06 10:48   ` Jean-Baptiste Tredez
2016-12-06 13:02 ` Jérôme Pouiller
2016-12-06 16:41   ` Jean-Baptiste Tredez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox