Bug 114747 - Compile error in ksycoca.cpp on Solaris 9 (temp. solution incl.)
Summary: Compile error in ksycoca.cpp on Solaris 9 (temp. solution incl.)
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: ksycoca (show other bugs)
Version: unspecified
Platform: Compiled Sources Solaris
: NOR normal with 20 votes (vote)
Target Milestone: ---
Assignee: Dirk Mueller
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-20 09:35 UTC by Bernd Kuhls
Modified: 2006-06-01 19:47 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernd Kuhls 2005-10-20 09:35:06 UTC
Version:            (using KDE KDE 3.4.92)
Installed from:    Compiled From Sources
Compiler:          gcc-3.3.5 
OS:                Solaris

This patch:
http://websvn.kde.org/branches/KDE/3.5/kdelibs/kdecore/ksycoca.cpp?rev=469271&r1=465272&r2=469271
fails on Solaris 9/Sparc:

if /bin/bash ../libtool --silent --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../dcop -I. -I../kio/kssl -I../kjs -I../kdefx -I../kdecore/network -I../dcop -I../libltdl -I../kdefx -I../kdecore -I../kdecore -I../kdeui -I../kio -I../kio/kio -I../kio/kfile -I.. -I/usr/local/qt-050201/include  -I/usr/local/KDE-3.5b2/include  -I/usr/local2/lude/soft/libart_lgpl-2.3.16/run/default/sparc_sun_solaris2.9//include/libart-2.0  -DQT_THREAD_SUPPORT  -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_SOLARIS -DSVR4  -Wno-long-long -Wundef -Wall -W -Wpointer-arith -DNDEBUG -DNO_DEBUG -O2 -Wno-non-virtual-dtor -fno-exceptions -fno-check-new -fno-common  -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION  -MT ksycoca.lo -MD -MP -MF ".deps/ksycoca.Tpo" -c -o ksycoca.lo ksycoca.cpp; \
then mv -f ".deps/ksycoca.Tpo" ".deps/ksycoca.Plo"; else rm -f ".deps/ksycoca.Tpo"; exit 1; fi
ksycoca.cpp: In member function `bool KSycoca::openDatabase(bool)':
ksycoca.cpp:147: error: `madvise' undeclared (first use this function)
ksycoca.cpp:147: error: (Each undeclared identifier is reported only once for
   each function it appears in.)

although <sys/mman.h> is present on this system but I think madvise is not
defined there. Removing the offending line from ksycoca.cpp lets the file compile.
Comment 1 Steve Evans 2005-10-20 11:10:55 UTC
I have a similar problem on Solaris 8. However for me the fix of removing <sys/mman.h> does *not* work. Examining <sys/mman.h> shows that it does contain a prototype for madvise, but if this statement:

#if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)

is true then the prototype is not available. Neither of these #defines is explictly set, either on the command line or in config.h, so I am guessing that the compiler sets them.
Comment 2 Bernd Kuhls 2005-11-11 16:35:35 UTC
Not solved in kdelibs-479465 snapshot
Comment 3 Bernd Kuhls 2005-11-17 11:14:00 UTC
Still not solved in kdelibs-480871 snapshot
Comment 4 Bernd Kuhls 2005-11-29 16:53:23 UTC
Not fixed in KDE-3.5.0 release version.
Comment 5 Dirk Mueller 2005-11-29 18:40:23 UTC
whoops. 
Comment 6 Dirk Mueller 2005-11-29 19:01:15 UTC
SVN commit 484188 by mueller:

conditionalize madvise() for less linux-compatible systems
CCBUG:114747


 M  +1 -1      configure.in.in  
 M  +2 -1      ksycoca.cpp  


--- branches/KDE/3.5/kdelibs/kdecore/configure.in.in #484187:484188
@@ -83,7 +83,7 @@
 
 KDE_CHECK_HEADERS([netinet/in.h net/if.h],,,[$netincludes])
 KDE_CHECK_HEADERS([sys/filio.h])
-AC_CHECK_FUNCS([usleep poll])
+AC_CHECK_FUNCS([usleep poll madvise])
 
 dnl Check for struct addrinfo
 AC_CHECK_TYPES([struct addrinfo],,,[$netincludes])
--- branches/KDE/3.5/kdelibs/kdecore/ksycoca.cpp #484187:484188
@@ -144,8 +144,9 @@
      }
      else
      {
+#ifdef HAVE_MADVISE
 	(void) madvise((void*)m_sycoca_mmap, m_sycoca_size, MADV_WILLNEED);
-
+#endif
         QByteArray b_array;
         b_array.setRawData(m_sycoca_mmap, m_sycoca_size);
         QBuffer *buffer = new QBuffer( b_array );
Comment 7 Dirk Mueller 2005-11-29 19:02:33 UTC
SVN commit 484189 by mueller:

conditionalize madvise() for less-linux-compatible systems
BUG: 114747


 M  +1 -1      configure.in.in  
 M  +2 -0      ksycoca.cpp  


--- trunk/KDE/kdelibs/kdecore/configure.in.in #484188:484189
@@ -83,7 +83,7 @@
 
 KDE_CHECK_HEADERS([netinet/in.h net/if.h],,,[$netincludes])
 KDE_CHECK_HEADERS([sys/filio.h])
-AC_CHECK_FUNCS([usleep poll])
+AC_CHECK_FUNCS([usleep poll madvise])
 
 dnl Check for struct addrinfo
 AC_CHECK_TYPES([struct addrinfo],,,[$netincludes])
--- trunk/KDE/kdelibs/kdecore/ksycoca.cpp #484188:484189
@@ -141,7 +141,9 @@
      }
      else
      {
+#ifdef HAVE_MADVISE
         (void) madvise((void*)m_sycoca_mmap, m_sycoca_size, MADV_WILLNEED);
+#endif
         QByteArray b = QByteArray::fromRawData(m_sycoca_mmap, m_sycoca_size);
         QBuffer *buffer = new QBuffer( new QByteArray(b) );
         buffer->open(QIODevice::ReadOnly);
Comment 8 Jens Hatlak 2005-12-08 23:41:05 UTC
I'm still seeing this on Sparc/Solaris 8, KDE 3.5, gcc 4.0.2, patches applied, configure rebuilt. The problem seems to be that the madvise test in configure passes even though the function is not available in the form used in ksycoca.cpp.

The error is:

ksycoca.cpp: In member function 'bool KSycoca::openDatabase(bool)':
ksycoca.cpp:148: error: 'madvise' was not declared in this scope

The relevant lines from config.log:

configure:43591: checking for madvise
configure:43648: gcc -o conftest -O2    -DQT_THREAD_SUPPORT -I/usr/local/include
 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_SOLARIS -DSVR4 -L/usr/local/lib/qt-3.3/lib-g++3 -R/usr/local/lib/qt-3.3/lib-g++3 -L/usr/local/lib -R/usr/local/lib conftest.c  >&5
configure:43654: $? = 0
configure:43658: test -z
                         || test ! -s conftest.err
configure:43661: $? = 0
configure:43664: test -s conftest
configure:43667: $? = 0
configure:43679: result: yes

Some lines from /usr/include/sys/mman.h:

#ifdef  __STDC__
#if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
extern void *mmap(void *, size_t, int, int, int, off_t);
extern int munmap(void *, size_t);
extern int mprotect(void *, size_t, int);
extern int msync(void *, size_t, int);
#if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
extern int mlock(const void *, size_t);
extern int munlock(const void *, size_t);
extern int shm_open(const char *, int, mode_t);
extern int shm_unlink(const char *);
#endif  /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2))... */
/* transitional large file interface version */
#if     defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
            !defined(__PRAGMA_REDEFINE_EXTNAME))
extern void *mmap64(void *, size_t, int, int, int, off64_t);
#endif  /* _LARGEFILE64_SOURCE... */
#else   /* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */
extern caddr_t mmap(caddr_t, size_t, int, int, int, off_t);
extern int munmap(caddr_t, size_t);
extern int mprotect(caddr_t, size_t, int);
extern int msync(caddr_t, size_t, int);
extern int mlock(caddr_t, size_t);
extern int munlock(caddr_t, size_t);
extern int mincore(caddr_t, size_t, char *);
extern int memcntl(caddr_t, size_t, int, caddr_t, int, int);
extern int madvise(caddr_t, size_t, int);
/* transitional large file interface version */
#ifdef  _LARGEFILE64_SOURCE
extern caddr_t mmap64(caddr_t, size_t, int, int, int, off64_t);
#endif
#endif  /* (_POSIX_C_SOURCE > 2)  || defined(_XPG4_2) */

#if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
extern int mlockall(int);
extern int munlockall(void);
#endif

/* mmap failure value */
#define MAP_FAILED      ((void *) -1)

#else   /* __STDC__ */
extern caddr_t mmap();
extern int munmap();
extern int mprotect();
extern int mincore();
extern int memcntl();
extern int msync();
extern int madvise();
extern int mlock();
extern int mlockall();
extern int munlock();
extern int munlockall();
/* transitional large file interface version */
#if     defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
            !defined(__PRAGMA_REDEFINE_EXTNAME))
extern caddr_t mmap64();
#endif  /* _LARGEFILE64_SOURCE... */
#endif  /* __STDC__ */
Comment 9 Dirk Mueller 2005-12-09 13:25:18 UTC
ok, can you try if adding

extern int madvise();

at the beginning of the file fixes it?

Comment 10 Jens Hatlak 2005-12-10 22:58:08 UTC
No:

ksycoca.cpp: In member function 'bool KSycoca::openDatabase(bool)':
ksycoca.cpp:49: error: too many arguments to function 'int madvise()'
ksycoca.cpp:150: error: at this point in file
Comment 11 Dirk Mueller 2006-01-25 11:22:01 UTC
SVN commit 502221 by mueller:

solaris sucks, as usual
CCBUG:114747


 M  +6 -1      ksycoca.cpp   [POSSIBLY UNSAFE: system]


--- branches/KDE/3.5/kdelibs/kdecore/ksycoca.cpp #502220:502221
@@ -42,6 +42,10 @@
 #include <sys/mman.h>
 #endif
 
+#ifdef Q_OS_SOLARIS
+extern int madvise(caddr_t, size_t, int); 
+#endif
+
 #ifndef MAP_FAILED
 #define MAP_FAILED ((void *) -1)
 #endif
@@ -439,7 +443,8 @@
          return;
       _self->d->readError = true;
       if (_self->d->autoRebuild)
-         system("kbuildsycoca"); // Rebuild the damned thing.
+         if(system("kbuildsycoca") < 0) // Rebuild the damned thing.
+	   qWarning("ERROR: Running KSycoca failed.");
    }
 }
 
Comment 12 Dirk Mueller 2006-01-25 11:22:55 UTC
SVN commit 502222 by mueller:

solaris sucks, as usal.
BUG:114747


 M  +6 -1      ksycoca.cpp   [POSSIBLY UNSAFE: system]


--- trunk/KDE/kdelibs/kdecore/ksycoca.cpp #502221:502222
@@ -40,6 +40,10 @@
 #include <sys/mman.h>
 #endif
 
+#ifdef Q_OS_SOLARIS
+extern int madvise(caddr_t, size_t, int); 
+#endif
+
 #ifndef MAP_FAILED
 #define MAP_FAILED ((void *) -1)
 #endif
@@ -443,7 +447,8 @@
          return;
       _self->d->readError = true;
       if (_self->d->autoRebuild)
-         system("kbuildsycoca"); // Rebuild the damned thing.
+         if(system("kbuildsycoca") < 0) // Rebuild the damned thing.
+	   qWarning("ERROR: Running KSycoca failed.");
    }
 }
 
Comment 13 Jens Hatlak 2006-01-26 13:12:32 UTC
Still not fixed, sorry:

ksycoca.cpp: In member function 'bool KSycoca::openDatabase(bool)':
ksycoca.cpp:152: error: invalid conversion from 'void*' to 'char*'
ksycoca.cpp:152: error:   initializing argument 1 of 'int madvise(char*, size_t, int)'

In /usr/include/sys/types.h, caddr_t is defined as char:
typedef char            *caddr_t;       /* ?<core address> type */
Comment 14 Dirk Mueller 2006-01-26 14:39:00 UTC
I committed a workaround..
Comment 15 Jens Hatlak 2006-01-26 15:23:22 UTC
OK, but now I get:

Undefined                       first referenced
 symbol                             in file
madvise(char*, unsigned int, int)   ./.libs/libkdecore.so
ld: fatal: Symbol referencing errors. No output written to .libs/kde-config
collect2: ld returned 1 exit status
Comment 16 Dirk Mueller 2006-01-26 15:54:48 UTC
ok, and this patch?

--- ksycoca.cpp (revision 502540)
+++ ksycoca.cpp (working copy)
@@ -43,7 +43,7 @@
 #endif

 #ifdef Q_OS_SOLARIS
-extern int madvise(caddr_t, size_t, int);
+extern "C" extern int madvise(caddr_t, size_t, int);
 #endif

 #ifndef MAP_FAILED
Comment 17 Jens Hatlak 2006-01-26 16:08:29 UTC
Great, that did it! TUVM
Comment 18 Dirk Mueller 2006-01-30 15:23:03 UTC
ok, closing as fixed. 
Comment 19 Bernd Kuhls 2006-06-01 19:25:21 UTC
this bug is not fixed, see bug #124416
Comment 20 Stephan Kulow 2006-06-01 19:47:51 UTC
please compile between releases. As long as we have no active SVN users using solaris, the situation won't get better ;(

You can also commit right into SVN, if you apply for an account