By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

Compiling 2.5.1 on OpenBSD 4.1

P: n/a
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
Jul 29 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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
Jul 29 '07 #2

P: n/a
=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= <ma****@v.loewis.dewrote in news:46**************@v.loewis.de:
>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
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
Jul 29 '07 #3

P: n/a
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.
Jul 29 '07 #4

P: n/a
=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= <ma****@v.loewis.dewrote
in news:46**************@v.loewis.de:
>
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
Jul 29 '07 #5

P: n/a
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
Jul 31 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.