Compiling 2.5.1 on OpenBSD 4.1

N

nazgul

Hi all,

In my prev post, I indicated I was using 2.5.1 on one box and 2.5p3 on the
OpenBSD box. I'm trying to build 2.5.1 on OpenBSD and I get this:

Modules/posixmodule.c:5701: error: `lstat' undeclared (first use in this
function)

I browsed the source and don't understand why I'm getting it. I'm not a
configure expert, but I did figure out that pyconfig.h has these set:

#define HAVE_LSTAT 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TYPES_H 1

and that posixmodule.c includes sys/stat.h, sys/types.h (per the lstat
manpage) as well as declaring lstat outright.

I'm stumped. Any suggestions? ./configure was run with no options.

TIA,
nazgul
 
?

=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=

I'm stumped. Any suggestions?

You will have to find the true declaration of lstat - reading
man pages or checking that everything "looks right" won't help.

So where is lstat declared? Is it declared at all, and if so,
is that declaration conditional perhaps?

Produce a preprocessor output (posixmodule.i), by adding
-fsave-temps to the compiler line compiling posixmodule.c
(copy the line from the make output into a shell, and add
this command line); then inspect that output to see whether
lstat has been declared.

Regards,
Martin
 
N

nazgul

=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= said:
You will have to find the true declaration of lstat - reading
man pages or checking that everything "looks right" won't help.

So where is lstat declared? Is it declared at all, and if so,
is that declaration conditional perhaps?

Produce a preprocessor output (posixmodule.i), by adding
-fsave-temps to the compiler line compiling posixmodule.c
(copy the line from the make output into a shell, and add
this command line); then inspect that output to see whether
lstat has been declared.

Regards,
Martin

Thanks Martin. Did I mention this was OpenBSD 4.1 in the original post? Here's the patch:

--- configure.~1~ Mon Mar 12 06:50:51 2007
+++ configure Sun Jul 29 11:47:27 2007
@@ -1553,7 +1553,7 @@
# On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
# even though select is a POSIX function. Reported by J. Ribbens.
# Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
- OpenBSD/2.* | OpenBSD/3.[0123456789] | OpenBSD/4.[0])
+ OpenBSD/2.* | OpenBSD/3.[0123456789] | OpenBSD/4.[01])
define_xopen_source=no;;
# Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
# _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
 
?

=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=

Thanks Martin. Did I mention this was OpenBSD 4.1 in the original post? Here's the patch:

It may work, but I don't like it. Can you please try this one instead,
and report whether it works?

Thanks,
Martin

Index: configure
===================================================================
--- configure (Revision 56599)
+++ configure (Arbeitskopie)
@@ -1388,6 +1388,14 @@
_ACEOF


+# OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
+# also defined. This can be overridden by defining _BSD_SOURCE
+
+cat >>confdefs.h <<\_ACEOF
+#define _BSD_SOURCE 1
+_ACEOF
+
+
# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
 
N

nazgul

It may work, but I don't like it. Can you please try this one instead,
and report whether it works?

Different error:

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -c ./Modules/posixmodule.c -o Modules/posixmodule.o
In file included from Include/Python.h:57,
from Modules/posixmodule.c:30:
Include/pyport.h:520: warning: `struct winsize' declared inside parameter list
Include/pyport.h:520: warning: its scope is only this definition or declaration, which is probably not what you want
Include/pyport.h:521: warning: `struct winsize' declared inside parameter list
Modules/posixmodule.c: In function `_pystat_fromstructstat':
Modules/posixmodule.c:1306: error: structure has no member named `st_atimespec'
Modules/posixmodule.c:1307: error: structure has no member named `st_mtimespec'
Modules/posixmodule.c:1308: error: structure has no member named `st_ctimespec'
Modules/posixmodule.c: In function `posix_chroot':
Modules/posixmodule.c:1735: error: `chroot' undeclared (first use in this function)
Modules/posixmodule.c:1735: error: (Each undeclared identifier is reported only once
Modules/posixmodule.c:1735: error: for each function it appears in.)
Modules/posixmodule.c: In function `posix_setgroups':
Modules/posixmodule.c:5506: warning: implicit declaration of function `setgroups'
Modules/posixmodule.c: In function `posix_wait3':
Modules/posixmodule.c:5590: warning: implicit declaration of function `wait3'
Modules/posixmodule.c: In function `posix_wait4':
Modules/posixmodule.c:5614: warning: implicit declaration of function `wait4'
Modules/posixmodule.c: In function `posix_lstat':
Modules/posixmodule.c:5701: error: `lstat' undeclared (first use in this function)
Modules/posixmodule.c: In function `posix_major':
Modules/posixmodule.c:6337: warning: implicit declaration of function `major'
Modules/posixmodule.c: In function `posix_minor':
Modules/posixmodule.c:6350: warning: implicit declaration of function `minor'
Modules/posixmodule.c: In function `posix_makedev':
Modules/posixmodule.c:6363: warning: implicit declaration of function `makedev'
Modules/posixmodule.c: In function `posix_getloadavg':
Modules/posixmodule.c:7955: warning: implicit declaration of function `getloadavg'
*** Error code 1

Stop in /bu/pkg/Python-2.5.1 (line 1111 of Makefile).

__BSD_VISIBLE is there (it wasn't there before and that's what was causing my original problem).
dnm@kili:/bu/pkg/Python-2.5.1$ grep _BSD_SOURCE pyconfig.h
dnm@kili:/bu/pkg/Python-2.5.1$ grep _BSD_VISIBLE pyconfig.h
#define __BSD_VISIBLE 1

I don't understand what's causing the problem, though:

/usr/include/unistd.h:
#if __XPG_VISIBLE >= 500
ssize_t pread(int, void *, size_t, off_t);
ssize_t pwrite(int, const void *, size_t, off_t);
int ttyname_r(int, char *, size_t)
__attribute__((__bounded__(__string__,2,3)));
#endif

#if __BSD_VISIBLE || __XPG_VISIBLE <= 500
/* Interfaces withdrawn by X/Open Issue 5 Version 0 */
void *brk(void *);
int chroot(const char *);
int getdtablesize(void);
int getpagesize(void);
char *getpass(const char *);
void *sbrk(int);
#endif

#if __POSIX_VISIBLE >= 200112 || __XPG_VISIBLE >= 420
int lockf(int, int, off_t);
#endif
---

posixmodule.i:
ssize_t pread(int, void *, size_t, off_t);
ssize_t pwrite(int, const void *, size_t, off_t);
int ttyname_r(int, char *, size_t)
__attribute__((__bounded__(__string__,2,3)));
# 188 "/usr/include/unistd.h" 3 4
int lockf(int, int, off_t);
---

Plus, I get lots of warnings that I didn't get using my patch. Sample:

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -c ./Modules/threadmodule.c -o Modules/threadmodule.o
In file included from Include/Python.h:57,
from Modules/threadmodule.c:5:
Include/pyport.h:520: warning: `struct winsize' declared inside parameter list
Include/pyport.h:520: warning: its scope is only this definition or declaration, which is probably not what you want
Include/pyport.h:521: warning: `struct winsize' declared inside parameter list

Here are the differences between the pyconfig.h with my patch and with yours:

dnm@kili:/bu/pkg/Python-2.5.1$ diff pyconfig.h pyconfig.h.martin
93c93
< #define HAVE_CURSES_RESIZETERM 1
---
/* #undef HAVE_CURSES_RESIZETERM */
647c647
< #define HAVE_TERM_H 1
---
/* #undef HAVE_TERM_H */
744c744
< #define MVWDELCH_IS_EXPRESSION 1
---
/* #undef MVWDELCH_IS_EXPRESSION */
863c863
< #define WINDOW_HAS_FLAGS 1
---
/* #undef WINDOW_HAS_FLAGS */
932c932
< /* #undef _POSIX_C_SOURCE */
---
#define _POSIX_C_SOURCE 200112L
941c941
< /* #undef _XOPEN_SOURCE */
---
#define _XOPEN_SOURCE 600
944c944
< /* #undef _XOPEN_SOURCE_EXTENDED */
---
#define _XOPEN_SOURCE_EXTENDED 1

Thanks,
dnm
 
?

=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=

__BSD_VISIBLE is there (it wasn't there before and that's what was causing my original problem).
dnm@kili:/bu/pkg/Python-2.5.1$ grep _BSD_SOURCE pyconfig.h
dnm@kili:/bu/pkg/Python-2.5.1$ grep _BSD_VISIBLE pyconfig.h
#define __BSD_VISIBLE 1

It being in pyconfig.h is irrelevant - it was there before; my proposed
patch hasn't changed that. The problem is that sys/cdefs.h defines
__BSD_VISIBLE to 0 under certain circumstances; I was hoping that
my patch would change these circumstances.

I don't have OpenBSD available, so I have to do all my research over
the web. I would really appreciate if this problem could be solved
"for good". In the past, it was always difficult that the *BSDs would
hide interfaces if I say that my program uses XOPEN/Unix. Python
uses a "POSIX+" approach: use POSIX interfaces where available;
use platform-specific ones elsewhere.

It seems that OpenBSD (now) also supports such an approach, with
the _BSD_SOURCE define. So I would much appreciate some help in
making it so that Python actually gets access to these interfaces;
then, from OpenBSD 4.1 on, no additional system-specific changes
would have to be made.
posixmodule.i:
ssize_t pread(int, void *, size_t, off_t);
ssize_t pwrite(int, const void *, size_t, off_t);
int ttyname_r(int, char *, size_t)
__attribute__((__bounded__(__string__,2,3)));
# 188 "/usr/include/unistd.h" 3 4
int lockf(int, int, off_t);
---

In some versions of gcc, there is a mechanism to also record
the #define's and #undefines in the preprocessor output
(e.g. -dD). If such a mechanism is available in the OpenBSD
gcc, please use it to see what gets defined (and undefined)
in what order.

If that fails, sprinkle

#ifndef __BSD_VISIBLE
#error broken
#endif

throughout the files, e.g. between #include directives, and
(if you can) into the system headers themselves.
Plus, I get lots of warnings that I didn't get using my patch. Sample:

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -c ./Modules/threadmodule.c -o Modules/threadmodule.o
In file included from Include/Python.h:57,
from Modules/threadmodule.c:5:
Include/pyport.h:520: warning: `struct winsize' declared inside parameter list
Include/pyport.h:520: warning: its scope is only this definition or declaration, which is probably not what you want
Include/pyport.h:521: warning: `struct winsize' declared inside parameter list

This should be the same problem: struct winsize is conditional.
Here are the differences between the pyconfig.h with my patch and with yours:

dnm@kili:/bu/pkg/Python-2.5.1$ diff pyconfig.h pyconfig.h.martin

I see. The macros _BSD_SOURCE didn't actually get defined.
Please try the revised patch below.

Regards,
Martin

Index: configure
===================================================================
--- configure (Revision 56599)
+++ configure (Arbeitskopie)
@@ -1388,6 +1388,14 @@
_ACEOF


+# OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
+# also defined. This can be overridden by defining _BSD_SOURCE
+
+cat >>confdefs.h <<\_ACEOF
+#define _BSD_SOURCE 1
+_ACEOF
+
+
# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.

Index: pyconfig.h.in
===================================================================
--- pyconfig.h.in (Revision 56599)
+++ pyconfig.h.in (Arbeitskopie)
@@ -909,6 +909,9 @@
# undef _ALL_SOURCE
#endif

+/* Define on OpenBSD to activate all library features */
+#undef _BSD_SOURCE
+
/* Define on Irix to enable u_int */
#undef _BSD_TYPES
 
N

nazgul

I don't have OpenBSD available, so I have to do all my research over
the web. I would really appreciate if this problem could be solved
"for good". In the past, it was always difficult that the *BSDs would
hide interfaces if I say that my program uses XOPEN/Unix. Python
uses a "POSIX+" approach: use POSIX interfaces where available;
use platform-specific ones elsewhere.

I'll be happy to test anything you want WRT OpenBSD. I have one here and I
don't think it's going anywhere.
I see. The macros _BSD_SOURCE didn't actually get defined.
Please try the revised patch below.

This looks to have fixed it. Build was succesful. Thanks!

dnm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top