Solved

error compiling bash 2.03 from source

Posted on 2009-03-31
7
632 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
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.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux tcp ports listening for testing 4 62
Help With Shell Script Centos 6 6 51
File and print server with Ubuntu? 7 42
Run DOS2UNIX and then execute the command 21 70
This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

816 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

10 Experts available now in Live!

Get 1:1 Help Now