Potential bug in library search for libiconv in static build
From:
gmail
Subject:
Potential bug in library search for libiconv in static build
Date:
Sun, 03 Apr 2011 15:01:48 +0200
User-agent:
Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
Hello,
This is my first contact and mail with bash mailing list, to summarize
i'm a coder maintening a personnal home server using several GNU tools
since the late 90's.
I configure BASH-4.2.0 in a chroot jail (gcc 4.5.2/libc 2.13/binutils
2.21/make 3.82) with an athlon architecture on ext3 FS with
--enable-static-link --with-libiconv-prefix=/ and, as root, and notice
the configure script can't find the jail's static libiconv :
[root@pompomgalli] mkdir bash-4.2_static_build && cd
bash-4.2_static_build
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
Beginning configuration for bash-4.2-release for i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for strerror in -lcposix... no
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
....
checking for ld used by GCC... /bin/ld
checking if the linker (/bin/ld) is GNU ld... yes
checking for shared library run path origin... done
....
checking for __argz_count... yes
checking for __argz_stringify... yes
checking for __argz_next... yes
checking for __fsetlocking... yes
checking for iconv... no, consider installing GNU libiconv
checking for nl_langinfo and CODESET... yes
checking for LC_MESSAGES... yes
checking for bison... bison
checking version of bison... 2.4.3, ok
....
[root@pompomgalli]
I then check if the libiconv library was accessible :
[root@pompomgalli] # ls -ld /lib/libiconv.* /lib
drwxr-xr-x 13 root root 12288 Apr 3 12:14 /lib
-rw-r--r-- 1 root root 1233398 Apr 3 12:14 /lib/libiconv.a
-rw-r--r-- 1 root root 917 Apr 3 12:14 /lib/libiconv.la
Apparently, the static libiconv.a should had been seen by the configure
script. I check then the config.log :
[root@pompomgalli] # less config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by bash configure 4.2-release, which was
generated by GNU Autoconf 2.63. Invocation command line was
/usr/src/bash-4.2_static_build/conftest.c:107: undefined reference
to `libiconv_open'
/usr/src/bash-4.2_static_build/conftest.c:108: undefined reference
to `libiconv'
/usr/src/bash-4.2_static_build/conftest.c:109: undefined reference
to `libiconv_close'
So, as you could see, the configure script try to build a static elf by
linking object output with a shared libiconv.so library.
Guessing that this behavior was not the script real goal, i then adapt
the configure script this way :
--- bash-4.2_static/configure.orig 2011-04-03 14:02:35.000000000 +0200
+++ bash-4.2_static/configure 2011-04-03 14:21:38.000000000 +0200
@@ -9128,7 +9128,7 @@
found_so=
found_a=
if test $use_additional = yes; then
- if test -n "$shlibext" && test -f
"$additional_libdir/lib$name.$shlibext"; then
+ if test -n "$shlibext" && test -f
"$additional_libdir/lib$name.$shlibext" && test $opt_static_link != yes;
then
found_dir="$additional_libdir"
found_so="$additional_libdir/lib$name.$shlibext"
if test -f "$additional_libdir/lib$name.la"; then
@@ -9158,7 +9158,7 @@
case "$x" in
-L*)
dir=`echo "X$x" | sed -e 's/^X-L//'`
- if test -n "$shlibext" && test -f
"$dir/lib$name.$shlibext"; then
+ if test -n "$shlibext" && test -f
"$dir/lib$name.$shlibext" && test $opt_static_link != yes; then
found_dir="$dir"
found_so="$dir/lib$name.$shlibext"
if test -f "$dir/lib$name.la"; then
That giving me the following result :
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
Beginning configuration for bash-4.2-release for i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for strerror in -lcposix... no
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
....
checking for __argz_count... yes
checking for __argz_stringify... yes
checking for __argz_next... yes
checking for __fsetlocking... yes
checking for iconv... yes
checking how to link with libiconv... //lib/libiconv.a
checking for iconv declaration...
checking for nl_langinfo and CODESET... yes
checking for LC_MESSAGES... yes
checking for bison... bison
checking version of bison... 2.4.3, ok
....
[root@pompomgalli] make
....
ls -l bash
-rwxr-xr-x 1 root root 6692431 Apr 3 14:28 bash
size bash
text data bss dec hex filename
1530581 20272 28436 1579289 181919 bash
[root@pompomgalli]
The issue was due to the fact that the configure script postulate that
the host could have a shared libiconv OR a static libiconv, then in fact
a host could have BOTH static and shared libiconv.
For information, the configure script needs other adaptations to produce
a functionnal STATIC bash elf with glibc 2.13 due to specific dlopen issue.
I have currently inhibit getaddrinfo, gethostbyname, getpwent, getpwam,
getpwuid, getservbyname, getservent use in configure script when STATIC
build is required and alter some sources to behave differently if in
static build.
This way i have actually a functionnal static bash 4.2 elf which passes
all the tests except the multybite printf2.sub test (return 195 and not
192, i'm currently investigating).
I can provide the related patchs, if you think it's worth it.
Regards, Cedric.