bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Potential bug in library search for libiconv in static build


From: gmail
Subject: Re: Potential bug in library search for libiconv in static build
Date: Tue, 05 Apr 2011 01:18:37 +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,


I have take a deep breath and dive in the autotools documentation.

Here is the resulting patch that i think (hope ?) should be ok with any hosts/shells/archs :


--- bash-4.2_static/aclocal.m4.orig     2011-04-03 14:02:35.000000000 +0200
+++ bash-4.2_static/aclocal.m4  2011-04-05 00:24:55.000000000 +0200
@@ -3098,7 +3098,9 @@
           found_so=
           found_a=
           if test $use_additional = yes; then
- if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + dnl A shared AND a static version of the same library could be present, + dnl therefore if build is static only the static version must be looked for. + if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext" && test "$opt_static_link" = no; then
               found_dir="$additional_libdir"
               found_so="$additional_libdir/lib$name.$shlibext"
               if test -f "$additional_libdir/lib$name.la"; then
@@ -3120,7 +3122,9 @@
               case "$x" in
                 -L*)
                   dir=`echo "X$x" | sed -e 's/^X-L//'`
- if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + dnl A shared AND a static version of the same library could be present, + dnl therefore if build is static only the static version must be looked for. + if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext" && test "$opt_static_link" = no; then
                     found_dir="$dir"
                     found_so="$dir/lib$name.$shlibext"
                     if test -f "$dir/lib$name.la"; then


The m4 compile is ok and work correctly for both static and shared build of bash-4.2 :


    [root@pompomgalli] cd bash-4.2_static_build

    [root@pompomgalli] make configure

    cd ../bash-4.2_static && autoconf
configure.in:923: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body ../../../autoconf-2.68/lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from... ../../../autoconf-2.68/lib/autoconf/general.m4:2730: _AC_RUN_IFELSE is expanded from... ../../../autoconf-2.68/lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../../autoconf-2.68/lib/autoconf/general.m4:2749: AC_RUN_IFELSE is expanded from... ../../../autoconf-2.68/lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../../autoconf-2.68/lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from...
    aclocal.m4:4127: BASH_STRUCT_WEXITSTATUS_OFFSET is expanded from...
    configure.in:923: the top level
    /bin/sh ./config.status --recheck
running CONFIG_SHELL=/bin/sh /bin/sh ../bash-4.2_static/configure --prefix=/ --without-bash-malloc --with-curses --enable-static-link --with-libiconv-prefix=/ CC=gcc CFLAGS=-g -O2 -fomit-frame-pointer -march
    =athlon CPPFLAGS=-fexceptions --no-create --no-recursion
    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 whether we are using the GNU C Library 2.1 or newer... yes
    checking whether integer division by zero raises SIGFPE... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unsigned long long... yes
    checking for inttypes.h... yes
    checking whether the inttypes.h PRIxNN macros are broken... no
    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... yes
    checking how to link with libiconv... //lib/libiconv.a
    checking for iconv declaration...
extern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);

    ....

    configure: creating ./config.status
    CONFIG_FILES=Makefile CONFIG_HEADERS= /bin/sh ./config.status
    config.status: creating Makefile
    config.status: executing default-1 commands
    config.status: executing default commands

    [root@pompomgalli] make

    ....

gcc -L./builtins -L./lib/readline -L./lib/readline -L./lib/glob -L./lib/tilde -L./lib/sh -static -static -rdynamic -g -O2 -fomit-frame-pointer -march=athlon -o bash shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o expr.o flags.o jobs.o subst.o hashcmd.o hashlib.o mailcheck.o trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o alias.o array.o arrayfunc.o assoc.o braces.o bracecomp.o bashhist.o bashline.o list.o stringlib.o locale.o findcmd.o redir.o pcomplete.o pcomplib.o syntax.o xmalloc.o -lbuiltins -lglob -lsh -lreadline -lhistory -ltinfo -ltilde //lib/libiconv.a
    ls -l bash
    -rwxr-xr-x 1 root root 6222300 Apr  5 00:34 bash
    size bash
       text    data     bss     dec     hex filename
    1463582   20264   27368 1511214  170f2e bash





And then the shared build :




    [root@pompomgalli] rm -rf *

    [root@pompomgalli] ls -ld ../bash-4.2_static/configure

    -rwxr-xr-x 1 root root 456649 Apr  5 00:24 ../bash-4.2_static/configure

[root@pompomgalli] ../bash-4.2_static/configure --prefix=/ --without-bash-malloc --with-curses --with-libiconv-prefix=/

    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 whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    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 __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.so -Wl,-rpath -Wl,//lib
    checking for iconv declaration...
extern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);

    ....
    checking shared object configuration for loadable builtins... supported
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating builtins/Makefile
    config.status: creating lib/readline/Makefile
    config.status: creating lib/glob/Makefile
    config.status: creating lib/intl/Makefile
    config.status: creating lib/malloc/Makefile
    config.status: creating lib/sh/Makefile
    config.status: creating lib/termcap/Makefile
    config.status: creating lib/tilde/Makefile
    config.status: creating doc/Makefile
    config.status: creating support/Makefile
    config.status: creating po/Makefile.in
    config.status: creating examples/loadables/Makefile
    config.status: creating examples/loadables/perl/Makefile
    config.status: creating config.h
    config.status: executing default-1 commands
    config.status: creating po/POTFILES
    config.status: creating po/Makefile
    config.status: executing default commands

    [root@pompomgalli] make

    ....

gcc -L./builtins -L./lib/readline -L./lib/readline -L./lib/glob -L./lib/tilde -L./lib/sh -rdynamic -g -O2 -fomit-frame-pointer -march=athlon -o bash shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o expr.o flags.o jobs.o subst.o hashcmd.o hashlib.o mailcheck.o trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o alias.o array.o arrayfunc.o assoc.o braces.o bracecomp.o bashhist.o bashline.o list.o stringlib.o locale.o findcmd.o redir.o pcomplete.o pcomplib.o syntax.o xmalloc.o -lbuiltins -lglob -lsh -lreadline -lhistory -ltinfo -ltilde //lib/libiconv.so -Wl,-rpath -Wl,//lib -ldl
    ls -l bash
    -rwxr-xr-x 1 root root 2587203 Apr  5 00:40 bash
    size bash
       text    data     bss     dec     hex filename
     858781   18468   20040  897289   db109 bash

    [root@pompomgalli] ./bash

    [root@pompomgalli]



   -- Caution --

This patch will apply for EVERY library required by the AC_LIB_LINKFLAGS_BODY, the resulting configure script will search ONLY for the static version of the library if static link option is enabled.

   -- Caution --

It's seems that the macro currently only concerns libintl and libiconv.


For the other "static patch", i will see how that could be translated in autotools, considering the issue is Linux libc issue.
(Not sure it will be ever done ... ^^)


Regards, Cedric



04/04/2011 16:04, Chet Ramey :
On 4/3/11 9:01 AM, gmail wrote:
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 :
                [...]
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 :
It's usually better to modify configure.in/aclocal.m4 and then rebuild
configure, but I see what you're trying to do.  I picked up these macros
from the libiconv distribution, so I'll have to take a look at what that
distribution needs to inhibit searching for static libraries.  It's
probably something as simple as setting a different shell variable in
configure.


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.
Sure, I'd be interested in taking a look at your patches.  Note that this
is mostly a linux-specific issue.

Chet




reply via email to

[Prev in Thread] Current Thread [Next in Thread]