Solved

error compiling bash 2.03 from source

Posted on 2009-03-31
7
622 Views
Last Modified: 2013-12-16
As part of studying for the LPIC-1 certification I'm following my guide's example and compiling GNU bash 2.03 from source.  I'm aware that there are easier ways to install it, but my intent is to become familiar with the compilation process.

I'm running Ubuntu 8.10 32-bit with all of the latest updates.  I've installed build-essential through Synaptic.

I downloaded the package from ftp://ftp.gnu.org/gnu/bash/bash-2.03.tar.gz and extracted it to a directory under my home folder.  I ran ./configure which seemed to complete fine.  I then ran make, which came up with the errors below.

How should I troubleshoot this?

make[1]: Entering directory `/home/student/bash-2.03/lib/malloc'

gcc  -I. -I../.. -I../.. -I../../lib -DHAVE_CONFIG_H -DSHELL  -g -O2 -DRCHECK -Dbotch=programming_error -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -c malloc.c

malloc.c:522: error: conflicting types for malloc

malloc.c: In function free:

malloc.c:645: warning: argument mem doesnt match built-in prototype

malloc.c: At top level:

malloc.c:697: warning: conflicting types for built-in function realloc

malloc.c:799: error: conflicting types for calloc

malloc.c: In function print_malloc_stats:

malloc.c:883: warning: format %12lu expects type long unsigned int, but argument 3 has type u_int32_t

make[1]: *** [malloc.o] Error 1

make[1]: Leaving directory `/home/student/bash-2.03/lib/malloc'

make: *** [lib/malloc/libmalloc.a] Error 1

Open in new window

0
Comment
Question by:Shift-3
  • 4
  • 3
7 Comments
 
LVL 38

Author Comment

by:Shift-3
ID: 24030597
Fixed the apostrophes.


make[1]: Entering directory `/home/student/bash-2.03/lib/malloc'

gcc  -I. -I../.. -I../.. -I../../lib -DHAVE_CONFIG_H -DSHELL  -g -O2 -DRCHECK -Dbotch=programming_error -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -c malloc.c

malloc.c:522: error: conflicting types for 'malloc'

malloc.c: In function 'free':

malloc.c:645: warning: argument 'mem' doesn't match built-in prototype

malloc.c: At top level:

malloc.c:697: warning: conflicting types for built-in function 'realloc'

malloc.c:799: error: conflicting types for 'calloc'

malloc.c: In function 'print_malloc_stats':

malloc.c:883: warning: format '%12lu' expects type 'long unsigned int', but argument 3 has type 'u_int32_t'

make[1]: *** [malloc.o] Error 1

make[1]: Leaving directory `/home/student/bash-2.03/lib/malloc'

make: *** [lib/malloc/libmalloc.a] Error 1

Open in new window

0
 
LVL 38

Author Comment

by:Shift-3
ID: 24031991
And I just compiled bash 3.2 instead and it worked fine.  What went wrong with the first version?
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 24033433
I rather think it must be your gcc version - type "gcc --version" to see what that is. When bash 2.0.3 was current, the gcc compiler of that time would have compiled the source. malloc() and free() were not built-ins at that time - having them so is comparatively recent (in my timescale anyway - but I've been using gcc since 1993).
The phenomenon of new code not compiling with the old compiler and vice versa is quite common with C++ code, not so usual with C but, as you just found out, it does happen.
BTW bash-2.0.3 doesn't build for me either, with gcc as shown below. I only get a calloc error in lib/malloc (which likely comes from glibc rather than gcc) - is your gcc newer?
I only just upgraded mine.
07:14:59$ gcc --version

gcc (GCC) 4.2.4

Copyright (C) 2007 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.

Open in new window

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 38

Author Comment

by:Shift-3
ID: 24038766
Thank you for the reply.  It appears that I'm using gcc version 4.3.2.

If, for the sake of stubbornness, I did still want to compile a really old version of bash, would I first have to install an equally old version of gcc?  And would I run into the same problem trying to compile that?
0
 
LVL 34

Accepted Solution

by:
Duncan Roe earned 500 total points
ID: 24044130
Yes you would have to compile or at least install an old gcc. And having done that, you might still hit the calloc prototype mismatch, but you could patch the bash source to get around that.
If you installed gcc as a package from your distribution, uninstall the it, find a package with an older version (mine looks to be old enough) and install that. reverse the procedure when done.
It's supposed to be possible to have multiple versions of gcc installed simultaneously, although I have never actually managed to do it myself. You would then build using an older gcc by first issuing a command like:

export CC='gcc -V4.2.4'

If you install from source that you have built, you may be able to get multiple revs like that going. I think you would have to run make install in the oldest source directory first, then the current one (again).
I don't expect you would have any problem building gcc - the building process is designed to only use the installed C compiler to build a gcc good enough to build the rest of gcc - including that the installed compiler may not be GNU gcc.

*** I just rebuilt bash with only the patch shown below. Lots of warnings about casting: "cast from pointer to integer of different size". I can run the built bash - there is already some stuff in my .bashrc that it doesn't understand - guess that wouldn't worry you though ...
*** lib/malloc/malloc.c.bu      1998-07-03 00:16:39.000000000 +1000

--- lib/malloc/malloc.c 2009-04-02 08:12:00.000000000 +1100

***************

*** 518,524 ****

    ;

  }

  

! char *

  malloc (n)            /* get a block */

       size_t n;

  {

--- 518,524 ----

    ;

  }

  

! void *

  malloc (n)            /* get a block */

       size_t n;

  {

***************

*** 795,801 ****

  #endif /* !HPUX */

  

  #ifndef NO_CALLOC

! char *

  calloc (n, s)

       size_t n, s;

  {

--- 795,801 ----

  #endif /* !HPUX */

  

  #ifndef NO_CALLOC

! void *

  calloc (n, s)

       size_t n, s;

  {

Open in new window

0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 24044154
You shouldn't get the casting warnings if building on 32-bit platform - I was building on 64-bit
0
 
LVL 38

Author Closing Comment

by:Shift-3
ID: 31564873
Thanks again for the information.  Coding in C is beyond me, but I think I have an idea of how to handle this issue if I run into it in the future.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

After running Ubuntu some time, you will be asked to download updates for fixing bugs and security updates. All the packages you download replace the previous ones, except for the kernel, also called "linux-image". This is due to the fact that w…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now