Ticket #757 (reopened defect)

Opened 4 years ago

Last modified 3 years ago

conftest.cc:3: error: 'mincore' was not declared in this scope

Reported by: Peter O Owned by: rakshasa
Priority: normal Milestone:
Component: libtorrent Version:
Severity: normal Keywords:
Cc:

Description

On Solaris 10 (or Nexenta Alpha 6) when I attempt to compile libtorrent-0.10.4 I get the following error:

checking signedness of mincore parameter... configure: error: failed, do *not* attempt to use --disable-mincore unless you are running Win32.

config.log says:

configure:22953: checking signedness of mincore parameter
configure:22963: g++ -c -g -O2 -g -DDEBUG -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include conftest.cc >&5
conftest.cc: In function 'void f()':
conftest.cc:3: error: 'mincore' was not declared in this scope
configure:22969: $? = 1
configure: failed program was:
| #include <sys/types.h>
| #include <sys/mman.h>
| void f() { mincore((char*)0, 0, (unsigned char*)0); }
|
configure:23010: g++ -c -g -O2 -g -DDEBUG -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include conftest.cc >&5
conftest.cc: In function 'void f()':
conftest.cc:3: error: 'mincore' was not declared in this scope
configure:23016: $? = 1
configure: failed program was:
| #include <sys/types.h>
| #include <sys/mman.h>
| void f() { mincore((char*)0, 0, (char*)0); }
|
configure:23050: error: failed, do *not* attempt to use --disable-mincore unless you are running Win32.

Attachments

Change History

  Changed 4 years ago by anonymous

What header file is it that defines mincore on Solaris then (man mincore)?

  Changed 4 years ago by Peter O

I don't currently have that manpage (licensing issues with opensolaris) but

$ grep -r mincore /usr/include/
/usr/include/sys/mman.h:extern int mincore(caddr_t, size_t, char *);
/usr/include/sys/mman.h:extern int mincore();
/usr/include/sys/syscall.h:#define      SYS_mincore     114
/usr/include/unistd.h:extern int mincore(caddr_t, size_t, char *);
/usr/include/unistd.h:extern int mincore();

  Changed 4 years ago by Peter O

I was able to find this link to the Solaris 10 mincore manpage:  mincore(2).

I hope this helps.

  Changed 4 years ago by anonymous

Man pages says <sys/types.h>, your grep shows <sys/mman.h> and the test program includes both, that is strange. Maybe it isn't defined in a C++ safe way.

follow-up: ↓ 6   Changed 4 years ago by rakshasa

Check sys/mman.h header to see what #if guards it uses, might be mincore is only available when compiling with certain defines set.

in reply to: ↑ 5   Changed 4 years ago by Peter O

Replying to rakshasa:

Check sys/mman.h header to see what #if guards it uses, might be mincore is only available when compiling with certain defines set.

I posted the file because my coding skills are pretty bad. gotta go to sleep but I will check this again 8 hrs. Thanks for your help.

  Changed 4 years ago by rakshasa

#else /* (_POSIX_C_SOURCE > 2) defined(_XPG4_2) */

Mincore is part of this, so I assume you need to pass some CXXFLAGS when configuring.

  Changed 4 years ago by rakshasa

Deleting the header due to copyright stuff.

  Changed 4 years ago by Peter O

If I add

#include <unistd.h>

to "scripts/common.m4","configure" and "src/data/memory_chunk.cc" in the right places then configure will find mincore, and it will generate a makefile.

When I type "make" I get the following error:

 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I. -I./.. -I../.. -g -O2 -g -DDEBUG -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include -MT memory_chunk.lo -MD -MP -MF .deps/memory_chunk.Tpo -c memory_chunk.cc  -fPIC -DPIC -o .libs/memory_chunk.o
memory_chunk.cc: In member function 'bool torrent::MemoryChunk::advise(uint32_t, uint32_t, int)':
memory_chunk.cc:120: error: 'madvise' was not declared in this scope
make[3]: *** [memory_chunk.lo] Error 1
make[3]: Leaving directory `/export/home/olsenp/sandbox/libtorrent-0.10.4/src/data'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/export/home/olsenp/sandbox/libtorrent-0.10.4/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/export/home/olsenp/sandbox/libtorrent-0.10.4'
make: *** [all] Error 2

I will keep working on this and try to submit a diff when I am done. If anyone has any experience programming on Solaris I can use help. I am trying to convert my server from Linux to Solaris 10. Thanks again.

  Changed 4 years ago by anonymous

It seems we have been trying to fix the same problem. Here's a thread I started on opensolaris-code:

 http://www.opensolaris.org/jive/thread.jspa?threadID=21035&tstart=0

madvise() is simply not in unistd(), so we seem to be back to the fact that even EXTENSIONS does not help (though it did for mincore()).

follow-up: ↓ 14   Changed 4 years ago by peter.schuller@infidyne.com

Ok, I've got it building on Solaris out of pkgsrc now. For reference, these are the patches applied to libtorrent by the pkgsrc package as it appears after my patching. The <time.h> and the "Avoid regenerating within pkgsrc" is pre-existing changes that I include for completeness; the rest are the changes that I needed to make it build.

It does not include chances to common.m4 since it is not used when building out of pkgsrc, but the equivalent change is trivial to apply to that file.

Also, due to the workings of the webinterface and cut'n'paste, whitespace may be screwed below. The patches are simple enough to just apply manually though.

Note that this makes it build; there is some kind of issue that remains during runtime, possibly curses related, that I have not yet investigated. A simple attempt to start rtorrent and immediatley exit fails. Pressing "enter" clears the screen and gets rtorrent seemingly stuck, and truss reports it pollsys():ing.

The pkgsrc PR can be seen here:

 http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=35356

And the patching required to make rtorrent build aswell (sorry not cut'n'pasting the actual patches unless someone asks for it; should be farily straight forward to apply manually even from the patch referenced in the PR):

 http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=35357

--- src/torrent/chunk_manager.cc.orig 2006-10-27 15:48:45.000000000 +0200 +++ src/torrent/chunk_manager.cc @@ -37,6 +37,7 @@

#include "config.h"

#include <sys/types.h>

+#include <sys/time.h>

#include <sys/resource.h>

#include "data/chunk_list.h"

--- configure.orig 2006-10-27 15:52:04.000000000 +0200 +++ configure @@ -22826,6 +22826,9 @@ echo $ECHO_N "checking signedness of min

cat >conftest.$ac_ext <<_ACEOF

#include <sys/types.h>

#include <sys/mman.h>

+#if defined(sun) && defined(SVR4) + #include <unistd.h> +#endif

void f() { mincore((char*)0, 0, (unsigned char*)0); }

_ACEOF

@@ -22873,6 +22876,9 @@ sed 's//| /' conftest.$ac_ext >&5

cat >conftest.$ac_ext <<_ACEOF

#include <sys/types.h>

#include <sys/mman.h>

+#if defined(sun) && defined(SVR4) + #include <unistd.h> +#endif

void f() { mincore((char*)0, 0, (char*)0); }

_ACEOF

@@ -22956,6 +22962,9 @@ echo $ECHO_N "checking signedness of min

cat >conftest.$ac_ext <<_ACEOF

#include <sys/types.h>

#include <sys/mman.h>

+#if defined(sun) && defined(SVR4) + #include <unistd.h> +#endif

void f() { mincore((char*)0, 0, (unsigned char*)0); }

_ACEOF

@@ -23003,6 +23012,9 @@ sed 's//| /' conftest.$ac_ext >&5

cat >conftest.$ac_ext <<_ACEOF

#include <sys/types.h>

#include <sys/mman.h>

+#if defined(sun) && defined(SVR4) + #include <unistd.h> +#endif

void f() { mincore((char*)0, 0, (char*)0); }

_ACEOF

@@ -23704,6 +23716,10 @@ do

_ACEOF cat >>$CONFIG_STATUS <<\_ACEOF

-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)

+ : Avoid regenerating within pkgsrc + exit 0 + : Avoid regenerating within pkgsrc + exit 0

ac_cs_recheck=: ;;

--version | --vers* | -V )

echo "$ac_cs_version"; exit 0 ;;

--- rak/socket_address.h.orig 2006-10-27 15:48:46.000000000 +0200 +++ rak/socket_address.h @@ -62,7 +62,11 @@ class socket_address_inet6;

class socket_address { public:

+#if defined(sun) && defined(SVR4) + static const sa_family_t af_local = AF_UNIX; +#else

static const sa_family_t af_local = AF_LOCAL;

+#endif

static const sa_family_t af_unix = AF_UNIX; // static const sa_family_t af_file = AF_FILE; static const sa_family_t af_inet = AF_INET;

--- src/data/memory_chunk.cc.orig 2006-10-27 15:48:42.000000000 +0200 +++ src/data/memory_chunk.cc @@ -37,6 +37,14 @@

#include "config.h"

#include <unistd.h>

+#if defined(sun) && defined(SVR4) +/* Ugly hack to make this compile on Solaris. See + *  http://www.opensolaris.org/jive/thread.jspa?threadID=21035&tstart=0 + */ +extern "C" { + extern int madvise(caddr_t, size_t, int); +} +#endif

#include <rak/error_number.h>

#include "torrent/exceptions.h"

  Changed 4 years ago by rakshasa

Try svn head, fixed some of the problems i think.

  Changed 4 years ago by rakshasa

  • status changed from new to closed
  • resolution set to worksforme

Since nothing is happening...

in reply to: ↑ 11   Changed 3 years ago by anonymous

Replying to peter.schuller@infidyne.com:

Note that this makes it build; there is some kind of issue that remains during runtime, possibly curses related, that I have not yet investigated. A simple attempt to start rtorrent and immediatley exit fails. Pressing "enter" clears the screen and gets rtorrent seemingly stuck, and truss reports it pollsys():ing.

Peter, I've tracked down the source of the problem you are experiencing with rtorrent pollsys():ing. curses/ncurses defines ERR to be -1. The function InputEvent::event_read in rtorrent/src/input/input_event.cc appears to fire everytime a character is pressed. A loop within InputEvent::event_read then retrieves all characters in the buffer using getch(). When no characters are left in the buffer, getch() returns ERR, causing the loop to end. The problem you have observed, is that the loop never ends. Curses/ncurses defines ERR to be -1, however Solaris has redefined ERR in /usr/include/sys/regset.h to be 13. Even though getch() has returned ERR, the exit condition is never met and the loop spins.

void
InputEvent::event_read() {
  int c;

  while ((c = getch()) != ERR)
    m_slotPressed(c);
}

It is my belief that this naming collision should be primarily resolved by curses/ncurses who both define ERR. Using something like NCURSES_ERR might be the most practical solution. I welcome any comments and ideas on how to resolve this problem in the community. Below is a patch which works around the problem.

diff -ur rtorrent-0.7.4/src/input/input_event.cc rtorrent-0.7.4/src/input/input_event.cc
--- rtorrent-0.7.4.org/src/input/input_event.cc 2007-02-02 06:09:53.000000000 -0500
+++ rtorrent-0.7.4/src/input/input_event.cc     2007-06-22 15:31:25.040189756 -0400
@@ -37,6 +37,7 @@
 #include "config.h"

 #include <ncurses.h>
+#define NCURSES_ERR -1

 #include "input_event.h"

@@ -58,7 +59,7 @@
 InputEvent::event_read() {
   int c;

-  while ((c = getch()) != ERR)
+  while ((c = getch()) != NCURSES_ERR)
     m_slotPressed(c);
 }

  Changed 3 years ago by anonymous

  • status changed from closed to reopened
  • resolution worksforme deleted

Can that last NCURSES_ERR patch be committed? It fixes the issue on solaris.

  Changed 3 years ago by peter@shortbus.org

in response to the close due to inactivity: libtorrent still doesn't build properly from svn head.

the fix for madvise is still needed:

#if defined(sun)   
/* Ugly hack to make this compile on Solaris. See 
 * http://www.opensolaris.org/jive/thread.jspa?threadID=21035&tstart=0 
 */
extern "C" {
    extern int madvise(caddr_t, size_t, int);
}
#endif

the above patch asks for #if defined(sun) && defined(SVR4), but this was too stringent for me.

i'm in the middle of the build, but i hear from others who have successfully built that that NCURSES_ERR package is also still necessary.

though on SXCE nv75 this didn't work for me

  Changed 3 years ago by peter@shortbus.org

ack, sorry, that last line there about SXCE nv75 should be stricken from the record.

Add/Change #757 (conftest.cc:3: error: 'mincore' was not declared in this scope)

Author


E-mail address and user name can be saved in the Preferences.


Action
as reopened
 
Note: See TracTickets for help on using tickets.