Solved

error compiling bash 2.03 from source

Posted on 2009-03-31
7
641 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 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can't "Unset" Proxy in Apache headers for PCI compliance... 4 93
Enable SPF on IMSVA 6 67
swp file in unix 16 42
bash: ./Facebooker.pl :Permission Denied 9 52
The purpose of this article is to demonstrate how we can use conditional statements using Python.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

734 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