Re: libtool runs compiler command in wrong locale

2008-03-09 Thread Ralf Wildenhues
* Ralf Wildenhues wrote on Thu, Mar 06, 2008 at 08:42:02PM CET:
> Playing on the rather safe side, I consider applying this patch for now.
> OK?

No comments, so I applied this now.

Cheers,
Ralf

> 2008-03-06  Bruno Haible  <[EMAIL PROTECTED]>
>   and Ralf Wildenhues  <[EMAIL PROTECTED]>
> 
>   Fix compiler output to be in the user locale.
>   * libltdl/config/general.m4sh (func_show_eval_locale): New
>   function, for running commands in the user locale.
>   * libltdl/config/ltmain.m4sh (func_mode_compile): Use it for
>   compiling.
>   * tests/localization.at (localized compiler messages): New test.
>   * Makefile.am: Adjust.
>   Report by Bruno Haible.


___
Bug-libtool mailing list
Bug-libtool@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-libtool


Re: libtool runs compiler command in wrong locale

2008-03-06 Thread Ralf Wildenhues
* Ralf Wildenhues wrote on Mon, Jan 21, 2008 at 08:18:26AM CET:
> * Bruno Haible wrote on Mon, Jan 21, 2008 at 12:46:12AM CET:
> [...]
> >   if ${opt_dry_run-false}; then :; else
> > +   eval "$lt_switch_to_user_locale"
> > eval "$my_cmd"
> > my_status=$?
> > +   eval "$lt_switch_to_safe_locale"
> > if test "$my_status" -eq 0; then :; else
> [...]
> 
> > + lt_switch_to_user_locale=\"$lt_var=\$save_$lt_var; 
> > \$lt_switch_to_user_locale\"
> > + lt_switch_to_safe_locale=\"$lt_var=C; \$lt_switch_to_safe_locale\"
> 
> This approach has the advantage of not using an extra fork (as your
> branch-1-5 patch does), but it lacks re-exporting of the changed
> variables, which is needed by some older shells.

Playing on the rather safe side, I consider applying this patch for now.
OK?

I considered doing the same for link mode and some of the other stuff we
pipe through func_show_eval, but that should only be done after an audit
of the various *archive_cmds variables and settings in libtool.m4 to
ensure there are no grep patterns or so that would be influenced.

Thanks,
Ralf

2008-03-06  Bruno Haible  <[EMAIL PROTECTED]>
and Ralf Wildenhues  <[EMAIL PROTECTED]>

Fix compiler output to be in the user locale.
* libltdl/config/general.m4sh (func_show_eval_locale): New
function, for running commands in the user locale.
* libltdl/config/ltmain.m4sh (func_mode_compile): Use it for
compiling.
* tests/localization.at (localized compiler messages): New test.
* Makefile.am: Adjust.
Report by Bruno Haible.

Index: Makefile.am
===
RCS file: /cvsroot/libtool/libtool/Makefile.am,v
retrieving revision 1.230
diff -u -r1.230 Makefile.am
--- Makefile.am 4 Mar 2008 21:25:48 -   1.230
+++ Makefile.am 6 Mar 2008 19:36:08 -
@@ -448,6 +448,7 @@
  tests/indirect_deps.at \
  tests/archive-in-archive.at \
  tests/execute-mode.at \
+ tests/localization.at \
  tests/destdir.at \
  tests/old-m4-iface.at \
  tests/am-subdir.at \
Index: libltdl/config/general.m4sh
===
RCS file: /cvsroot/libtool/libtool/libltdl/config/general.m4sh,v
retrieving revision 1.9
diff -u -r1.9 general.m4sh
--- libltdl/config/general.m4sh 10 May 2007 17:26:45 -  1.9
+++ libltdl/config/general.m4sh 6 Mar 2008 19:36:08 -
@@ -1,6 +1,6 @@
 m4_if([general.m4sh -- general shell script boiler plate -*- Autoconf -*-
 
-   Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
Written by Gary V. Vaughan, 2004
 
This file is part of GNU Cvs-utils.
@@ -344,5 +344,31 @@
   fi
 fi
 }
+
+
+# func_show_eval_locale cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+my_cmd="$1"
+my_fail_exp="${2-:}"
+
+${opt_silent-false} || {
+  func_quote_for_expand "$my_cmd"
+  eval "func_echo $func_quote_for_expand_result"
+}
+
+if ${opt_dry_run-false}; then :; else
+  eval "$lt_user_locale
+   $my_cmd"
+  my_status=$?
+  eval "$lt_safe_locale"
+  if test "$my_status" -eq 0; then :; else
+   eval "(exit $my_status); $my_fail_exp"
+  fi
+fi
+}
 ]])
 
Index: libltdl/config/ltmain.m4sh
===
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.99
diff -u -r1.99 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  5 Mar 2008 20:14:43 -   1.99
+++ libltdl/config/ltmain.m4sh  6 Mar 2008 19:36:10 -
@@ -96,12 +96,16 @@
 # Only set LANG and LC_ALL to C if already set.
 # These must not be set unconditionally because not all systems understand
 # e.g. LANG=C (notably SCO).
+lt_user_locale=
+lt_safe_locale=
 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
 do
   eval "if test \"\${$lt_var+set}\" = set; then
   save_$lt_var=\$$lt_var
   $lt_var=C
  export $lt_var
+ lt_user_locale=\"$lt_var=\$save_$lt_var; \$lt_user_locale\"
+ lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
fi"
 done
 
@@ -1515,7 +1519,7 @@
 
   $opt_dry_run || $RM "$lobj" "$output_obj"
 
-  func_show_eval "$command"\
+  func_show_eval_locale "$command" \
   'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
 
   if test "$need_locks" = warn &&
@@ -1565,7 +1569,7 @@
   # Suppress compiler output if we already did a PIC compilation.
   command="$command$suppress_output"
   $opt_dry_run || $RM "$obj" "

Re: libtool runs compiler command in wrong locale

2008-01-20 Thread Ralf Wildenhues
* Bruno Haible wrote on Mon, Jan 21, 2008 at 12:46:12AM CET:
[...]
>   if ${opt_dry_run-false}; then :; else
> +   eval "$lt_switch_to_user_locale"
> eval "$my_cmd"
> my_status=$?
> +   eval "$lt_switch_to_safe_locale"
> if test "$my_status" -eq 0; then :; else
[...]

> +   lt_switch_to_user_locale=\"$lt_var=\$save_$lt_var; 
> \$lt_switch_to_user_locale\"
> +   lt_switch_to_safe_locale=\"$lt_var=C; \$lt_switch_to_safe_locale\"

This approach has the advantage of not using an extra fork (as your
branch-1-5 patch does), but it lacks re-exporting of the changed
variables, which is needed by some older shells.

Cheers,
Ralf


___
Bug-libtool mailing list
Bug-libtool@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-libtool


Re: libtool runs compiler command in wrong locale

2008-01-20 Thread Ralf Wildenhues
Hello Bruno,

* Bruno Haible wrote on Mon, Jan 21, 2008 at 12:46:12AM CET:
> Ralf Wildenhues wrote:
> > func_show_eval is also called like this:
> > 
> > |  func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S 
> > "../$outputname" "$outputname" )' 'exit $?'
> 
> OK, what about this patch, then? (Untested.)

Thanks, but with commands like
|  func_show_eval '$EGREP -e "$export_symbols_regex" 
"$export_symbols" > "${export_symbols}T"'

with application developer-provided $export_symbols_regex, it is a bug
if we switch away from the C locale.  The simplest way is to define a
func_show_eval_locale that does what you want and use that in the
appropriate places.

Cheers,
Ralf

> 2008-01-20  Bruno Haible  <[EMAIL PROTECTED]>
> 
>   * libltdl/config/ltmain.m4sh (lt_switch_to_user_locale,
>   lt_switch_to_safe_locale): New variables.
>   * libltdl/config/general.m4sh (func_show_eval): Use them.


___
Bug-libtool mailing list
Bug-libtool@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-libtool


Re: libtool runs compiler command in wrong locale

2008-01-20 Thread Bruno Haible
Ralf Wildenhues wrote:
> func_show_eval is also called like this:
> 
> |  func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S 
> "../$outputname" "$outputname" )' 'exit $?'

OK, what about this patch, then? (Untested.)

Bruno

2008-01-20  Bruno Haible  <[EMAIL PROTECTED]>

	* libltdl/config/ltmain.m4sh (lt_switch_to_user_locale,
	lt_switch_to_safe_locale): New variables.
	* libltdl/config/general.m4sh (func_show_eval): Use them.

*** libltdl/config/general.m4sh.bak	2008-01-20 17:22:16.0 +0100
--- libltdl/config/general.m4sh	2008-01-21 00:41:49.0 +0100
***
*** 1,6 
  m4_if([general.m4sh -- general shell script boiler plate -*- Autoconf -*-
  
!Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
 Written by Gary V. Vaughan, 2004
  
 This file is part of GNU Cvs-utils.
--- 1,6 
  m4_if([general.m4sh -- general shell script boiler plate -*- Autoconf -*-
  
!Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
 Written by Gary V. Vaughan, 2004
  
 This file is part of GNU Cvs-utils.
***
*** 337,344 
--- 337,346 
  }
  
  if ${opt_dry_run-false}; then :; else
+   eval "$lt_switch_to_user_locale"
eval "$my_cmd"
my_status=$?
+   eval "$lt_switch_to_safe_locale"
if test "$my_status" -eq 0; then :; else
  	eval "(exit $my_status); $my_fail_exp"
fi
*** libltdl/config/ltmain.m4sh.bak	2008-01-20 17:08:53.0 +0100
--- libltdl/config/ltmain.m4sh	2008-01-21 00:41:42.0 +0100
***
*** 4,10 
  # ltmain.sh (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
  # Written by Gordon Matzigkeit <[EMAIL PROTECTED]>, 1996
  
! # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
  # This is free software; see the source for copying conditions.  There is NO
  # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  
--- 4,10 
  # ltmain.sh (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
  # Written by Gordon Matzigkeit <[EMAIL PROTECTED]>, 1996
  
! # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
  # This is free software; see the source for copying conditions.  There is NO
  # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  
***
*** 96,107 
--- 96,111 
  # Only set LANG and LC_ALL to C if already set.
  # These must not be set unconditionally because not all systems understand
  # e.g. LANG=C (notably SCO).
+ lt_switch_to_user_locale=
+ lt_switch_to_safe_locale=
  for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
  do
eval "if test \"\${$lt_var+set}\" = set; then
save_$lt_var=\$$lt_var
$lt_var=C
  	  export $lt_var
+ 	  lt_switch_to_user_locale=\"$lt_var=\$save_$lt_var; \$lt_switch_to_user_locale\"
+ 	  lt_switch_to_safe_locale=\"$lt_var=C; \$lt_switch_to_safe_locale\"
  	fi"
  done
  
___
Bug-libtool mailing list
Bug-libtool@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-libtool


Re: libtool runs compiler command in wrong locale

2008-01-20 Thread Ralf Wildenhues
Hello Bruno,

* Bruno Haible wrote on Sun, Jan 20, 2008 at 05:28:40PM CET:
> 
> I have my environment variables set to German (LANG=de_DE.UTF-8), and
> nevertheless the gcc compiler emits its warnings in English *if* invoked
> by libtool.

Thank you for the bug report.

> Find attached a patch for it, relative to libtool-1.5.24 (tested),
> and a tentative patch relative to the libtool CVS (untested).

The branch-1-5 patch looks good to me, except that is fixes compile mode
only and not link mode, but I'll leave it at Peter's discretion as to
when it should be applied.

> Note that $ltenv can only be applied to commands that run a program, not to
> shell builtins like "eval ..." or "(cd ... && ...)".

Yes, which is why the HEAD patch is not ok as it is now; func_show_eval
is also called like this:

|  func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S 
"../$outputname" "$outputname" )' 'exit $?'

> 2008-01-20  Bruno Haible  <[EMAIL PROTECTED]>
> 
>   * ltmain.in (lt_env): New variable. Use it when running commands.

(I might work on this, but not right away.)

Cheers,
Ralf


___
Bug-libtool mailing list
Bug-libtool@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-libtool


libtool runs compiler command in wrong locale

2008-01-20 Thread Bruno Haible
Hi,

I have my environment variables set to German (LANG=de_DE.UTF-8), and
nevertheless the gcc compiler emits its warnings in English *if* invoked
by libtool.

Example (when compiling CLN-1.2.0):

$ /bin/sh ../libtool --mode=compile g++ -g -O2 -Wall -I../include -I../include 
-I./base  -c ./base/cl_as_exception.cc
 g++ -g -O2 -Wall -I../include -I../include -I./base -c 
./base/cl_as_exception.cc  -fPIC -DPIC -o .libs/cl_as_exception.o
In file included from ./base/cl_N.h:6,
 from ./base/cl_as_exception.cc:13:
../include/cln/number.h: In constructor 'cln::cl_number::cl_number(float)':
../include/cln/number.h:238: warning: type-punning to incomplete type might 
break strict-aliasing rules
../include/cln/number.h: In member function 'cln::cl_number& 
cln::cl_number::operator=(float)':
../include/cln/number.h:238: warning: type-punning to incomplete type might 
break strict-aliasing rules
../include/cln/number.h: In constructor 'cln::cl_number::cl_number(double)':
../include/cln/number.h:239: warning: type-punning to incomplete type might 
break strict-aliasing rules
../include/cln/number.h: In member function 'cln::cl_number& 
cln::cl_number::operator=(double)':
../include/cln/number.h:239: warning: type-punning to incomplete type might 
break strict-aliasing rules
 g++ -g -O2 -Wall -I../include -I../include -I./base -c 
./base/cl_as_exception.cc -o cl_as_exception.o >/dev/null 2>&1

But just copying the shown command into a shell prompt yields the warnings
in English:

$ g++ -g -O2 -Wall -I../include -I../include -I./base -c 
./base/cl_as_exception.cc  -fPIC -DPIC -o .libs/cl_as_exception.o
In file included from ./base/cl_N.h:6,
 from ./base/cl_as_exception.cc:13:
../include/cln/number.h: In constructor »cln::cl_number::cl_number(float)«:
../include/cln/number.h:238: Warnung: Type-Punning auf unvollständigen Typen 
kann strict-aliasing-Regeln verletzen
../include/cln/number.h: In member function »cln::cl_number& 
cln::cl_number::operator=(float)«:
../include/cln/number.h:238: Warnung: Type-Punning auf unvollständigen Typen 
kann strict-aliasing-Regeln verletzen
../include/cln/number.h: In constructor »cln::cl_number::cl_number(double)«:
../include/cln/number.h:239: Warnung: Type-Punning auf unvollständigen Typen 
kann strict-aliasing-Regeln verletzen
../include/cln/number.h: In member function »cln::cl_number& 
cln::cl_number::operator=(double)«:
../include/cln/number.h:239: Warnung: Type-Punning auf unvollständigen Typen 
kann strict-aliasing-Regeln verletzen

Find attached a patch for it, relative to libtool-1.5.24 (tested),
and a tentative patch relative to the libtool CVS (untested).

Note that $ltenv can only be applied to commands that run a program, not to
shell builtins like "eval ..." or "(cd ... && ...)".

Bruno

2008-01-20  Bruno Haible  <[EMAIL PROTECTED]>

	* ltmain.in (lt_env): New variable. Use it when running commands.

*** ltmain.in.bak	2007-06-24 03:30:51.0 +0200
--- ltmain.in	2008-01-20 17:11:15.0 +0100
***
*** 113,126 
--- 113,131 
  # These must not be set unconditionally because not all systems understand
  # e.g. LANG=C (notably SCO).
  # We save the old values to restore during execute mode.
+ lt_env=
  for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
  do
eval "if test \"\${$lt_var+set}\" = set; then
  	  save_$lt_var=\$$lt_var
+ 	  lt_env=\"$lt_var=\$$lt_var \$lt_env\"
  	  $lt_var=C
  	  export $lt_var
  	fi"
  done
+ if test -n "$lt_env"; then
+   lt_env="env $lt_env"
+ fi
  
  # Make sure IFS has a sensible default
  lt_nl='
***
*** 956,962 
$run $rm "$lobj" "$output_obj"
  
$show "$command"
!   if $run eval "$command"; then :
else
  	test -n "$output_obj" && $run $rm $removelist
  	exit $EXIT_FAILURE
--- 961,967 
$run $rm "$lobj" "$output_obj"
  
$show "$command"
!   if $run eval $lt_env "$command"; then :
else
  	test -n "$output_obj" && $run $rm $removelist
  	exit $EXIT_FAILURE
***
*** 1028,1034 
command="$command$suppress_output"
$run $rm "$obj" "$output_obj"
$show "$command"
!   if $run eval "$command"; then :
else
  	$run $rm $removelist
  	exit $EXIT_FAILURE
--- 1033,1039 
command="$command$suppress_output"
$run $rm "$obj" "$output_obj"
$show "$command"
!   if $run eval $lt_env "$command"; then :
else
  	$run $rm $removelist
  	exit $EXIT_FAILURE
2008-01-20  Bruno Haible  <[EMAIL PROTECTED]>

	* libltdl/config/ltmain.m4sh (lt_env): New variable.
	* libltdl/config/general.m4sh (func_show_eval): Use it.

*** libltdl/config/ltmain.m4sh.bak	2008-01-20 17:08:53.0 +0100
--- libltdl/config/ltmain.m4sh	2008-01-20 17:13:06.0 +0100
***
*** 96,109 
--- 96,114 
  # Only set LANG and LC_ALL to C if already set.
  # These must not be set unconditionally because not all systems understand
  # e.g. LANG=C (n