Skip to contentSkip to conversation

Fix QEMU configure / make with Turkish (and maybe other) locale

PATCH In review Stefan Weil 4 participants 8 messages Mar 25, 2012 – Mar 26, 2012 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Fix QEMU configure / make with Turkish (and maybe other) locale

These two patches override the user specific locale settings which can break QEMU builds. They set the default locale C for configure and make:

[PATCH v2 1/2] Makefile: Set default locale C
[PATCH 2/2] configure: Set default locale C (fix build for Turkish

A side effect is that all messages which are produced during configure and make also use the default locale, so for example compiler messages are no longer localized.

I don't know whether this is a problem for anybody. If it is, setting LANGUAGE (which is unset at least in Debian installations) might help.

Regards,
Stefan Weil

#1 lore raw

PATCH v2 1/2 Makefile: Set default locale C

Some locale settings let make fail or create wrong results, so set always the C locale.

* Conversion from lower to upper case with tr does not convert lower case 'i' to 'I' with locale tr_TR.UTF-8. This results in wrong entries in config-host.h like these ones:

  #define CONFIG_QEMU_PREFiX "/usr/local"
  #define CONFIG_QEMU_BiNDiR "/usr/local/bin"

This problem was reported by Emre Ersin.

* The html files created from texi input contain non english titles like "Anhang" with locale de_DE.UTF-8.

The locale variables are not explicitly exported here to avoid possible problems with the 'export' keyword. Either they are already environment variables when make is called - then the new values are passed to child processes, or there are no such environment variables - then the default value C is used.

v2:
Enhanced commit message.

---
 Makefile |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
Makefile +5 -0
index 8d6b558..3f899e2 100644
@@ -37,6 +37,11 @@ $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw)
 
 LIBS+=-lz $(LIBS_TOOLS)
 
+# Set default locale for commands like tr and others.
+LANG=C
+LC_ALL=C
+LC_CTYPE=C
+
 HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF)
 
 ifdef BUILD_DOCS
Signature · 1 line
1.7.9
#2 lore raw

PATCH 2/2 configure: Set default locale C (fix build for Turkish locale)

In reply to Stefan Weil

Some locales don't work with QEMU's configure because they don't convert lower case to upper case as expected.

With the Turkish locale tr_TR.UTF-8 for example the command 'tr' does not convert lower case 'i' which results in wrong definitions in some target specific config-target.mak files:

TARGET_CRiS=y
TARGET_i386=y
TARGET_MiCROBLAZE=y
TARGET_MiPS64=y
TARGET_MiPS=y
TARGET_UNiCORE32=y

Setting the default locale C in configure avoids this problem.

---
 configure |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
configure +5 -0
index 14ef738..2eab795 100755
@@ -2,6 +2,11 @@
 #
 # qemu configure script (c) 2003 Fabrice Bellard
 #
+# Set locale to C (needed for tr).
+export LANG=C
+export LC_ALL=C
+export LC_CTYPE=C
+
 # set temporary file name
 if test ! -z "$TMPDIR" ; then
     TMPDIR1="${TMPDIR}"
Signature · 1 line
1.7.9
#3 lore raw
In reply to Stefan Weil

Am 25.03.2012 21:11, schrieb Stefan Weil:

Quoted 10 lines

These two patches override the user specific locale settings which can break QEMU builds. They set the default locale C for configure and make:

[PATCH v2 1/2] Makefile: Set default locale C
[PATCH 2/2] configure: Set default locale C (fix build for Turkish

A side effect is that all messages which are produced during configure and make also use the default locale, so for example compiler messages are no longer localized.

Reading the patches I thought of that issue, too, and don't think a sledge hammer is the best solution here. The issue reported was tr (a user-invisible invokation) misbehaving so why not fix just that? That way user-directed output would still be in the language of the user's choice.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#4 lore raw

Am 25.03.2012 21:27, schrieb Andreas Färber:

Quoted 12 lines

Am 25.03.2012 21:11, schrieb Stefan Weil:

Quoted 10 lines

These two patches override the user specific locale settings which can break QEMU builds. They set the default locale C for configure and make:

[PATCH v2 1/2] Makefile: Set default locale C
[PATCH 2/2] configure: Set default locale C (fix build for Turkish

A side effect is that all messages which are produced during configure and make also use the default locale, so for example compiler messages are no longer localized.

Quoted 7 lines

Reading the patches I thought of that issue, too, and don't think a sledge hammer is the best solution here. The issue reported was tr (a user-invisible invokation) misbehaving so why not fix just that? That way user-directed output would still be in the language of the user's choice.

Andreas

The answer is quite simple: there are lots of places where tr is already used which would have to be modified (in configure and several other scripts), and it's not only tr but also the process which creates the html documentation which depends on the locale (see commit message of patch 1).

As you see in my patch, I had to override three environment variables to (hopefully) handle all cases which lead to wrong results, so adding these overrides to each invocation of tr or other programs which need it would result in rather long command lines.

Of course many different solutions are possible. We could also add a tr wrapper script, but I still prefer my solution because it is easy and clean (only two locations which set the environment) and safe (also works for problems which might exist and which we still don't know, no problem when more scripts and external programs like tr are added by future modifications).

Regards,
Stefan

#5 lore raw
Quoted 3 lines · Stefan Weil

As you see in my patch, I had to override three environment variables to (hopefully) handle all cases which lead to wrong results,

Technically, you only have to modify LC_ALL. Modifications to LANG and LC_CTYPE are pointless once LC_ALL is set, at least on any standards-compliant i18n platform.

Signature · 2 lines
Eric Blake   [email protected]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#6 lore raw
In reply to Andreas Färber
Quoted 12 lines · Andreas Färber

Am 25.03.2012 21:11, schrieb Stefan Weil:

Quoted 10 lines

These two patches override the user specific locale settings which can break QEMU builds. They set the default locale C for configure and make:

[PATCH v2 1/2] Makefile: Set default locale C
[PATCH 2/2] configure: Set default locale C (fix build for Turkish

A side effect is that all messages which are produced during configure and make also use the default locale, so for example compiler messages are no longer localized.

Quoted 5 lines

Reading the patches I thought of that issue, too, and don't think a sledge hammer is the best solution here. The issue reported was tr (a user-invisible invokation) misbehaving so why not fix just that? That way user-directed output would still be in the language of the user's choice.

Well, configure should just set the locale to C, I think. This is how autoconf-generated configure scripts behave, for example. The rationale here is that configure shouldn't be outputting anything except (a) output to log files etc and (b) messages we control [and which we don't localise anyway!]. So we should favour not making it easy to accidentally introduce obscure bugs in some locales.

For make itself the argument is less clear-cut because as you say compiler messages go to the user.

-- PMM

#7 lore raw

Am 25.03.2012 21:52, schrieb Peter Maydell:

Quoted 19 lines · Andreas Färber
Quoted 12 lines

Am 25.03.2012 21:11, schrieb Stefan Weil:

Quoted 10 lines

These two patches override the user specific locale settings which can break QEMU builds. They set the default locale C for configure and make:

[PATCH v2 1/2] Makefile: Set default locale C
[PATCH 2/2] configure: Set default locale C (fix build for Turkish

A side effect is that all messages which are produced during configure and make also use the default locale, so for example compiler messages are no longer localized.

Quoted 5 lines

Reading the patches I thought of that issue, too, and don't think a sledge hammer is the best solution here. The issue reported was tr (a user-invisible invokation) misbehaving so why not fix just that? That way user-directed output would still be in the language of the user's choice.

Quoted 6 lines

Well, configure should just set the locale to C, I think. This is how autoconf-generated configure scripts behave, for example. The rationale here is that configure shouldn't be outputting anything except (a) output to log files etc and (b) messages we control [and which we don't localise anyway!]. So we should favour not making it easy to accidentally introduce obscure bugs in some locales.

I fully agree.

Quoted 5 lines

For make itself the argument is less clear-cut because as you say compiler messages go to the user.

-- PMM

For make, it is still possible to set LANGUAGE.
I don't know whether it works with gcc (none of my native and cross gcc installations has localized messages installed), but I tested setting LANGUAGE with 'ls --help' where it works.

And compiler messages go first to the user, but sometimes also to other developers (bug reports!), so even there are good arguments for the C locale.

Regards,
Stefan W.