Bug 74257 - rpm 4.1 compile fails on Solaris 8
rpm 4.1 compile fails on Solaris 8
Status: CLOSED WORKSFORME
Product: Red Hat Public Beta
Classification: Retired
Component: rpm (Show other bugs)
null
sparcv9 Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Johnson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-09-18 15:43 EDT by David Breitzmann
Modified: 2008-05-01 11:38 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-01-09 09:27:24 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Solaris 8 /usr/include/sys/stat.h (12.91 KB, text/plain)
2002-09-20 12:24 EDT, David Breitzmann
no flags Details
Patch to get rpm 4.1 to compile on Solaris (3.20 KB, patch)
2002-10-10 17:09 EDT, Christopher J. Suleski
no flags Details | Diff

  None (edit)
Description David Breitzmann 2002-09-18 15:43:27 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.78 [en] (Win98; U)

Description of problem:
The RPM 4.1 make fails with syntax errors when compiling rpmio/fts.c on Solaris 8 using GCC 3.2 and GNU binutils 2.13.

source='fts.c' object='fts.lo' libtool=yes \
depfile='.deps/fts.Plo' tmpdepfile='.deps/fts.TPlo' \
depmode=gcc3 /bin/bash ../depcomp \
/bin/bash ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I.. -I../popt -I../zlib    -g -O2 -D_GNU_SOURCE -D_REEN
TRANT -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts -c -o fts.lo `test -f 'fts.c' || echo '
./'`fts.c
rm -f .libs/fts.lo
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I.. -I../popt -I../zlib -g -O2 -D_GNU_SOURCE -D_REENTRANT -Wall -Wpointer-arith -Wstrict-pr
ototypes -Wmissing-prototypes -Wno-char-subscripts -c fts.c -MT fts.lo -MD -MP -MF .deps/fts.TPlo  -fPIC -DPIC -o .libs/fts.lo
fts.c: In function `Fts_open':
fts.c:135: warning: implicit declaration of function `__errno_location'
fts.c:135: invalid type argument of `unary *'
fts.c:176: invalid type argument of `unary *'
fts.c:185: invalid type argument of `unary *'
fts.c: In function `Fts_close':
fts.c:325: invalid type argument of `unary *'
fts.c: In function `Fts_read':
fts.c:499: invalid type argument of `unary *'
fts.c:522: invalid type argument of `unary *'
fts.c: In function `Fts_set':
fts.c:549: invalid type argument of `unary *'
fts.c: In function `Fts_children':
fts.c:565: invalid type argument of `unary *'
fts.c:578: invalid type argument of `unary *'
fts.c: In function `fts_build':
fts.c:716: warning: implicit declaration of function `dirfd'
fts.c:762: warning: implicit declaration of function `_D_EXACT_NAMLEN'
fts.c:779: invalid type argument of `unary *'
fts.c:803: invalid type argument of `unary *'
fts.c: In function `fts_stat':
fts.c:941: invalid type argument of `unary *'
fts.c: In function `fts_palloc':
fts.c:1106: invalid type argument of `unary *'
fts.c: In function `fts_safe_changedir':
fts.c:1175: warning: implicit declaration of function `__fxstat64'
fts.c:1175: `_STAT_VER' undeclared (first use in this function)
fts.c:1175: (Each undeclared identifier is reported only once
fts.c:1175: for each function it appears in.)
fts.c:1181: invalid type argument of `unary *'
fts.c:1192: invalid type argument of `unary *'
make[2]: *** [fts.lo] Error 1
make[2]: Leaving directory `/usr/local/src/rpm-4.1/rpmio'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/rpm-4.1'
make: *** [all] Error 2

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.  Unpack sources from rpm-4.1.tar.gz obtained from ftp.rpm.org and cd into the rpm-4.1 directory
2.  ./configure --prefix=/opt/UEtools
3.  make
	

Actual Results:  source='fts.c' object='fts.lo' libtool=yes \
depfile='.deps/fts.Plo' tmpdepfile='.deps/fts.TPlo' \
depmode=gcc3 /bin/bash ../depcomp \
/bin/bash ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I.. -I../popt -I../zlib    -g -O2 -D_GNU_SOURCE -D_REEN
TRANT -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts -c -o fts.lo `test -f 'fts.c' || echo '
./'`fts.c
rm -f .libs/fts.lo
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I.. -I../popt -I../zlib -g -O2 -D_GNU_SOURCE -D_REENTRANT -Wall -Wpointer-arith -Wstrict-pr
ototypes -Wmissing-prototypes -Wno-char-subscripts -c fts.c -MT fts.lo -MD -MP -MF .deps/fts.TPlo  -fPIC -DPIC -o .libs/fts.lo
fts.c: In function `Fts_open':
fts.c:135: warning: implicit declaration of function `__errno_location'
fts.c:135: invalid type argument of `unary *'
fts.c:176: invalid type argument of `unary *'
fts.c:185: invalid type argument of `unary *'
fts.c: In function `Fts_close':
fts.c:325: invalid type argument of `unary *'
fts.c: In function `Fts_read':
fts.c:499: invalid type argument of `unary *'
fts.c:522: invalid type argument of `unary *'
fts.c: In function `Fts_set':
fts.c:549: invalid type argument of `unary *'
fts.c: In function `Fts_children':
fts.c:565: invalid type argument of `unary *'
fts.c:578: invalid type argument of `unary *'
fts.c: In function `fts_build':
fts.c:716: warning: implicit declaration of function `dirfd'
fts.c:762: warning: implicit declaration of function `_D_EXACT_NAMLEN'
fts.c:779: invalid type argument of `unary *'
fts.c:803: invalid type argument of `unary *'
fts.c: In function `fts_stat':
fts.c:941: invalid type argument of `unary *'
fts.c: In function `fts_palloc':
fts.c:1106: invalid type argument of `unary *'
fts.c: In function `fts_safe_changedir':
fts.c:1175: warning: implicit declaration of function `__fxstat64'
fts.c:1175: `_STAT_VER' undeclared (first use in this function)
fts.c:1175: (Each undeclared identifier is reported only once
fts.c:1175: for each function it appears in.)
fts.c:1181: invalid type argument of `unary *'
fts.c:1192: invalid type argument of `unary *'
make[2]: *** [fts.lo] Error 1
make[2]: Leaving directory `/usr/local/src/rpm-4.1/rpmio'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/rpm-4.1'
make: *** [all] Error 2

Expected Results:  The make should have run to completion.

Additional info:

We're using the following build tools in our environment.

autoconf 2.53
automake 1.6.3
libtool 1.4.2
gcc 3.2
GNU binutils 2.13
Comment 1 Jeff Johnson 2002-09-18 16:27:36 EDT
Yup.

Edit rpmio/fts.c, add to the #if defined(hpux) test
as appropriate (|| defined(sun) is a start), tell
me what else breaks:

...
#if defined(hpux)
# define        _INCLUDE_POSIX_SOURCE
#   define __errno_location()   (&errno)
#   define dirfd(dirp)          -1
#   define stat64               stat
#   define _STAT_VER            0
#   define __fxstat64(_stat_ver, _fd, _sbp)     fstat((_fd), (_sbp))
#endif
#include "system.h"
#include "fts.h"
#include "rpmio.h"
#include "rpmurl.h"
#   define __set_errno(val) (*__errno_location ()) = (val)
#   define __open       open
#   define __close      close
#   define __fchdir     fchdir
#endif
Comment 2 David Breitzmann 2002-09-19 16:36:31 EDT
I changed #if defined(hpux) to #if defined(hpux)||defined(sun) in fts.c as suggested.  The compilation now fails on fts.c with the following errors.

gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I.. -I../popt -I../zlib -g -O2 -D_GNU_SOURCE -D_REENTRANT -Wall -Wpointer-arith -Wstrict-prototypes 
-Wmissing-prototypes -Wno-char-subscripts -c fts.c -MT fts.lo -MD -MP -MF .deps/fts.TPlo  -fPIC -DPIC -o .libs/fts.lo
In file included from ../system.h:25,
                 from fts.c:56:
/usr/include/sys/stat.h:297: redefinition of `struct stat'
fts.c: In function `fts_build':
fts.c:762: warning: implicit declaration of function `_D_EXACT_NAMLEN'
make[2]: *** [fts.lo] Error 1
Comment 3 Jeff Johnson 2002-09-20 10:21:34 EDT
Hmmm, dunno what the redefinition of struct stat
is, that needs some investigation.

Look for the DIR structure in /usr/include/sys
	grep DIR /usr/include/sys/* | grep typedef
and then find the structure definition.

What will be needed is a
	#define _D_EXACT_NAMLEN(d)	some_number_or_variable

Here's what glibc does, solaris may very well do the same:

	# define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
Comment 4 David Breitzmann 2002-09-20 11:57:43 EDT
From its definition in /usr/include/sys/dirent.h, the dirent structure in Solaris 8 has no name length member.  The structure does include a d_reclen 
member, but Solaris 8 defines this length (according to the dirent manpage) to be the number of bytes between the current entry and the next one.  
Since the d_name member is a null terminated string of at most MAXNAMLEN characters, I don't see how computing a length of the d_name member 
would thus be possible using simple arithmetic on the sizes of the members in struct dirent.

With _D_EXACT_NAMLEN(d) defined to be (strlen((d)->d_name)) in the #if defined(hpux) || defined(sun) clause in fts.c, gcc gets past the 
_D_EXACT_NAMLEN error.  From the other code in fts.c, I'm assuming that _D_EXACT_NAMLEN is supposed to return the exact length of the 
directory entry's name.

The make then dies with the "redefinition of struct stat" error.
Comment 5 Jeff Johnson 2002-09-20 12:08:14 EDT
OK, strlen will probably work.

Can you paste the solaris struct stat definition here?
All I can think of is that some manifest constant is
being redefined.

And apologies for this clunky debugging, but I have
not immediate access to a solaris box ...
Comment 6 David Breitzmann 2002-09-20 12:24:38 EDT
Created attachment 76728 [details]
Solaris 8 /usr/include/sys/stat.h
Comment 7 David Breitzmann 2002-09-20 12:26:07 EDT
From /usr/include/sys/dirent.h

typedef struct dirent {
        ino_t           d_ino;          /* "inode number" of entry */
        off_t           d_off;          /* offset of disk directory entry */
        unsigned short  d_reclen;       /* length of this record */
        char            d_name[1];      /* name of file */
} dirent_t;

Also, /usr/include/sys/stat.h defines struct stat once at line 236 because _LP64 is not defined and then again at line 303 because 
_LARGEFILE64_SOURCE is defined (but _LP64 is not).  I have attached /usr/include/sys/stat.h from Solaris 8 for reference.
Comment 8 Jeff Johnson 2002-09-20 13:24:21 EDT
So what happens if you do
	#define	_LP64
before the "system.h" include (which drags in stat.h)

FWIW, rpm does not (yet) support large file systems,
but only rpmcache.c needs/uses rpmio/fts.c ATM.
Comment 9 David Breitzmann 2002-09-20 16:58:15 EDT
Defining _LP64 errors that both _ILP32 and _LP64 are defined.

If I use the following

#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
#undef __PRAGMA_REDEFINE_EXTNAME

for Sun, then I no longer get the "redefinition of struct stat'.  I now get 

fts.c: In function `fts_safe_changedir':
fts.c:1179: storage size of `sb' isn't known
fts.c:1179: warning: unused variable `sb'

Somehow, it's not picking up the #define stat64 stat.
Comment 10 Jeff Johnson 2002-09-20 17:15:06 EDT
Check fts.h, there's another hpux turdlet
that may need "|| defined(sun)".

I'll try to get on a solaris box and figger
what's up in the next couple of days ...
Comment 11 Christopher J. Suleski 2002-10-10 17:09:19 EDT
Created attachment 79844 [details]
Patch to get rpm 4.1 to compile on Solaris
Comment 12 Christopher J. Suleski 2002-10-10 17:12:15 EDT
I attached a patch I made to this bug report above. I used ideas from previous 
comments and some see-compile-error-and-fix changes. I do not guarantee this 
patch does not break other things, but it lets me compile rpm and it appears 
to work.
Comment 13 Jeff Johnson 2003-01-09 09:27:24 EST
I checked in a patch for solaris compilation recently
that is probably what you need/want. See changes
in rpm-4.2-0.54.src.rpm, or checkout from cvs.rpm.org

Note You need to log in before you can comment on or make changes to this bug.