Solved

error compiling bash 2.03 from source

Posted on 2009-03-31
7
637 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

820 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