[Top][All Lists]

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

Re: conflict between gcc and bash malloc lib with static link

From: Chet Ramey
Subject: Re: conflict between gcc and bash malloc lib with static link
Date: Wed, 08 Apr 2015 09:40:44 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 4/7/15 11:36 AM, address@hidden wrote:

> Machine Type: i686-pc-linux-gnu
> Bash Version: 4.3.30
> Release Status: release
> Description:
>     at link step there is a conflict between gcc library in
>         lib/gcc/i686-linux-gnu/libc.a
>     and bash library
>     lib/malloc/libmalloc.a
>     for malloc and free functions
> Repeat-By:
>     generation with --enable-static-link

Building a static bash on Linux is problematic for several reasons besides
the mysterious malloc conflict:

shell.o: In function `get_current_user_info':
/usr/homes/chet/src/bash/src/shell.c:1718: warning: Using 'endpwent' in
statically linked applications requires at runtime the shared libraries
from the glibc version used for linking

I suspect the problem with malloc is that there are one or more additional
symbols in the file (malloc.o) that glibc uses to satisfy some internal
reference, which causes the rest of the symbols from malloc.o to be
loaded, which causes conflicts with the already-loaded bash malloc library.

> Fix:
>     adding option --without-bash-malloc look a simple fix
>     but this generate another issue because in file
>     lib/sh/shmatch.c there is a reference to sh_xfree
>     The solution is to add
>     #include "xmalloc.h"
>     in file
>     lib/sh/shmatch.c

The actual problem is a missing dependency in lib/sh/Makefile:
shmatch.o needs to depend on config.h so it gets rebuilt when
config.h changes.  shmatch.o already includes xmalloc.h via
shell.h, which includes general.h, which includes xmalloc.h.  Your
editing the file caused it to be rebuilt.

In general, it's good to do a `make clean' before you re-run
configure with different options.


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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