Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

error compiling bash 2.03 from source

Posted on 2009-03-31
7
Medium Priority
?
655 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 35

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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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 35

Accepted Solution

by:
Duncan Roe earned 2000 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 35

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

722 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