There is a fairly extensive comment inline that explains what is going on, but in a nutshell: * LC_ALL=C is needed for date output * LANG=C may be needed, at worst its harmless * The scope of the settings needs to be global, not include/xen/compile.h * export the variables for consistency sake I have: date (GNU coreutils) 5.97 GNU Make 3.81 And my locale set to Japanese (I can send details if anyone cares) And in that environment Japanese text was ending up in include/xen/compile.h, and coming out as complete garbage on xen console over serial. Signed-Off-By: Simon Horman <horms@verge.net.au> xen/Makefile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) --- x/xen/Makefile +++ x/xen/Makefile @@ -89,8 +89,23 @@ include/xen/acm_policy.h: echo "#define ACM_DEFAULT_SECURITY_POLICY $(ACM_DEFAULT_SECURITY_POLICY)"; \ echo "#endif") >$@ +# These variables need to be set to ensure that date (and possibly others) +# produce information for include/xen/compile.h, which is able +# to be displayed on a dumb console - the contents is displayed on boot. +# Setting them local to include/xen/compile.h, as in the following +# commented out line, does not work as the scope does not extend to +# $(shell blah) +# +# include/xen/compile.h: LANG=C +# +# export isn''t really neccessary, as if the variables are present in +# the environment then they will be exported anyway. And if not there +# is no need to set them at all. But it seems safe enough to consistently +# export them to all child processes of this makefile. +export LANG=C +export LC_ALL=C + # compile.h contains dynamic build info. Rebuilt on every ''make'' invocation. -include/xen/compile.h: LANG=C include/xen/compile.h: include/xen/compile.h.in @sed -e ''s/@@date@@/$(shell date)/g'' \ -e ''s/@@time@@/$(shell date +%T)/g'' \ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-Aug-31 21:49 UTC
Re: [Xen-devel] [PATCH] XEN: use C locale in bootup message
On 31/8/06 5:27 am, "Horms" <horms@verge.net.au> wrote:> And in that environment Japanese text was ending up in > include/xen/compile.h, and coming out as complete garbage > on xen console over serial.Was it just date values coming out in Japanese? If so, can we get away with just setting LC_TIME=C (not setting LANG or LC_ALL at all)? -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Thu, Aug 31, 2006 at 10:49:59PM +0100, Keir Fraser wrote:> > > > On 31/8/06 5:27 am, "Horms" <horms@verge.net.au> wrote: > > > And in that environment Japanese text was ending up in > > include/xen/compile.h, and coming out as complete garbage > > on xen console over serial. > > Was it just date values coming out in Japanese? If so, can we get away with > just setting LC_TIME=C (not setting LANG or LC_ALL at all)?Yes, only date seems to be the problem. The fix could be limited to inside of $(shell date), I think $(shell LC_ALL=C date) would solve the problem that I am seeing. However setting LC_TIME does not resolve the problem, as if LC_ALL is set in the environment it seems that LC_TIME is ignored. As for LANG, I think that is irrelevant for date. I suspect we can get rid of it all together without any ill effects. The reason that I went with a more general (sledge-hammer) approach as I''m not sure what other commands may be affected with other locales. But it is probably safe enough just to set LC_ALL for date. If you would like me to come up with a more minimal patch that fixes the problem for Japanese environments at least, and probably all environments, let me know. Its probably a bit easier for me to test than you. -- Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-Sep-01 15:15 UTC
Re: [Xen-devel] [PATCH] XEN: use C locale in bootup message
On 1/9/06 2:25 am, "Horms" <horms@verge.net.au> wrote:> The reason that I went with a more general (sledge-hammer) approach as > I''m not sure what other commands may be affected with other locales. > But it is probably safe enough just to set LC_ALL for date. If you would > like me to come up with a more minimal patch that fixes the problem for > Japanese environments at least, and probably all environments, let me > know. Its probably a bit easier for me to test than you.I''m just uneasy about a patch that is wider ranging than we need. I''d rather just limit the LC_ALL to the invocation of date. If that works okay for you, please send another patch. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Fri, Sep 01, 2006 at 04:15:28PM +0100, Keir Fraser wrote:> On 1/9/06 2:25 am, "Horms" <horms@verge.net.au> wrote: > > > The reason that I went with a more general (sledge-hammer) approach as > > I''m not sure what other commands may be affected with other locales. > > But it is probably safe enough just to set LC_ALL for date. If you would > > like me to come up with a more minimal patch that fixes the problem for > > Japanese environments at least, and probably all environments, let me > > know. Its probably a bit easier for me to test than you. > > I''m just uneasy about a patch that is wider ranging than we need. I''d rather > just limit the LC_ALL to the invocation of date. If that works okay for you, > please send another patch.I thought about this a bit futher, and I think your uneasyness is well founded. I''ll send a more minimal patch shortly. -- Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Sat, Sep 02, 2006 at 05:23:30PM +0900, Horms wrote:> On Fri, Sep 01, 2006 at 04:15:28PM +0100, Keir Fraser wrote: > > On 1/9/06 2:25 am, "Horms" <horms@verge.net.au> wrote: > > > > > The reason that I went with a more general (sledge-hammer) approach as > > > I''m not sure what other commands may be affected with other locales. > > > But it is probably safe enough just to set LC_ALL for date. If you would > > > like me to come up with a more minimal patch that fixes the problem for > > > Japanese environments at least, and probably all environments, let me > > > know. Its probably a bit easier for me to test than you. > > > > I''m just uneasy about a patch that is wider ranging than we need. I''d rather > > just limit the LC_ALL to the invocation of date. If that works okay for you, > > please send another patch. > > I thought about this a bit futher, and I think your uneasyness is > well founded. I''ll send a more minimal patch shortly.Hi here is the somewhat obvious minimal patch. I tested it this morning and it seems to work just fine in my environment, and I think it should work in any environment. The LANG=C is probably doing nothing, as for starters it holds for the sed, figglet and mv invocations. I think it can be safely removed. Sed is locale sensitive, but I don''t think it takes any notice of LANG. -- Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/ XEN: use C locale in bootup message LC_ALL=C is needed to ensure C locale output in date. Without this locale-specific, and thus potentially non-ascii data will end up in include/xen/compile.h which is displayed on the (often only ascii capable) terminal at bootup. In any case, its good to have a consistent bootup message, regadless of the locale prevailing at build. Signed-Off-By: Simon Horman <horms@verge.net.au> xen/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) xen/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- x/xen/Makefile +++ x/xen/Makefile @@ -92,7 +92,7 @@ include/xen/acm_policy.h: # compile.h contains dynamic build info. Rebuilt on every ''make'' invocation. include/xen/compile.h: LANG=C include/xen/compile.h: include/xen/compile.h.in - @sed -e ''s/@@date@@/$(shell date)/g'' \ + @sed -e ''s/@@date@@/$(shell LC_ALL=C date)/g'' \ -e ''s/@@time@@/$(shell date +%T)/g'' \ -e ''s/@@whoami@@/$(shell whoami)/g'' \ -e ''s/@@domain@@/$(shell ([ -x /bin/dnsdomainname ] && /bin/dnsdomainname) || ([ -x /bin/domainname ] && /bin/domainname || echo [unknown]))/g'' \ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel