Bug 74257

Summary: rpm 4.1 compile fails on Solaris 8
Product: [Retired] Red Hat Public Beta Reporter: David Breitzmann <david.breitzmann>
Component: rpmAssignee: Jeff Johnson <jbj>
Status: CLOSED WORKSFORME QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: nullCC: herrold, wtogami
Target Milestone: ---   
Target Release: ---   
Hardware: sparcv9   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-01-09 14:27:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Solaris 8 /usr/include/sys/stat.h
none
Patch to get rpm 4.1 to compile on Solaris none

Description David Breitzmann 2002-09-18 19:43:27 UTC
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 20:27:36 UTC
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 20:36:31 UTC
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 14:21:34 UTC
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 15:57:43 UTC
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 16:08:14 UTC
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 16:24:38 UTC
Created attachment 76728 [details]
Solaris 8 /usr/include/sys/stat.h

Comment 7 David Breitzmann 2002-09-20 16:26:07 UTC
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 17:24:21 UTC
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 20:58:15 UTC
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 21:15:06 UTC
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 21:09:19 UTC
Created attachment 79844 [details]
Patch to get rpm 4.1 to compile on Solaris

Comment 12 Christopher J. Suleski 2002-10-10 21:12:15 UTC
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 14:27:24 UTC
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