Compiling 2.5.1 on OpenBSD 4.1

"Martin v. Löwis" martin at v.loewis.de
Mon Jul 30 01:47:14 EDT 2007


> __BSD_VISIBLE is there (it wasn't there before and that's what was causing my original problem).
> dnm at kili:/bu/pkg/Python-2.5.1$ grep _BSD_SOURCE pyconfig.h
> dnm at 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 at 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



More information about the Python-list mailing list