Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Jan 2019 22:36:14 +1100
From:      Kubilay Kocak <koobs@FreeBSD.org>
To:        Stefan Metzmacher <metze@samba.org>, python@FreeBSD.org
Subject:   Re: Problem with pyconfig.h in python36 which is already solved for python27
Message-ID:  <da878a4c-e6de-ca4b-c5d2-a5058b6198d7@FreeBSD.org>
In-Reply-To: <e6e7ef63-6c72-ec5c-f6d6-bc1fa5d9b604@samba.org>
References:  <e6e7ef63-6c72-ec5c-f6d6-bc1fa5d9b604@samba.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 26/01/2019 10:07 pm, Stefan Metzmacher via freebsd-python wrote:
> Hi,
> 
> in Samba we recently switched to use python3 by default. But this breaks
> the build on FreeBSD (at least 11.1 and 12.0). In order to be most
> portable, we have a policy in Samba to include <Python.h> as the
> first header when creating python bindings. It means pyconfig.h and
> various system headers are included before our own config.h.
> A detailed way to reproduce this can be found at the end of this mail.
> 
> The problem is that pyconfig.h defines
> _POSIX_C_SOURCE, __BSD_VISIBLE, _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED.
> 
> This seems to be fixed for python27 in this commit:
> https://github.com/freebsd/freebsd-ports/commit/4b17dd9aeb9b28759551f38bf0f6b0edcac88607
> which added lang/python27/files/patch-pr192365.
> 
> Could this be fixed for all python versions?

Hi Stefan,

The commit was added via:

x11-toolkits/py-wxPython30 build fails
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=192365

A similar issue (if not the same), reported upstream here:

https://bugs.python.org/issue17120

I don't see any issues with carrying the same change in other python 
ports, *but* we'd all like to see it resolved permanently upstream.

In order of preference, to progress we'd need:

1) Upstream patches submitted against master, 3.7, 3.6, 2.7 so upstream 
can resolve this completely, commits/merges from which we can backport 
to our python ports.

or

2) Patches against lang/pythonXY ports similar to python27, which may 
not be suitable for upstreaming *as is* (freebsd-specific?)

Along with either of those, create a new bug in Bugzilla to track this 
too, with summary like "lang/python3*: <summary of issue>" adding bug 
192365 to "See Also"

I'm happy to put in the cycles to backport commits from (1) if we can 
get the root of the issue solved upstream.

Thanks for the detailed report.

./koobs



> An alternative fix for this specific problem would be
> defining __STDC_WANT_LIB_EXT1__ in pyconfig.h,
> but I don't know the reason for lang/python27/files/patch-pr192365
> and I guess it's better to have the same fix for all python versions.
> 
> Is this the correct channel to report this problem?
> 
> Thanks in advance!
> metze
> 
> This is a standalone way to reproduce the problem:
> 
> $ cat memset_s.c
> #include <Python.h>
> #include <string.h>
> int main(void)
> {
>          char array[5] = { 1, };
>          memset_s(array, 5, 0, 5);
>          return 0;
> }
> 
> $ gcc -o memset_s.exe memset_s.c -I /usr/local/include/python2.7/
> 
> $ gcc -o memset_s.exe memset_s.c -I /usr/local/include/python3.6m/
> memset_s.c: In function 'main':
> memset_s.c:6:2: warning: implicit declaration of function 'memset_s';
> did you mean 'memset'? [-Wimplicit-function-declaration]
>    memset_s(array, 5, 0, 5);
>    ^~~~~~~~
>    memset
> 
> $ gcc -o memset_s.exe memset_s.c -I ./python3.6m/
> $ diff -Npur /usr/local/include/python3.6m/ ./python3.6m/
> diff -Npur /usr/local/include/python3.6m/pyconfig.h ./python3.6m/pyconfig.h
> --- /usr/local/include/python3.6m/pyconfig.h    2019-01-10
> 02:17:29.000000000 +0100
> +++ ./python3.6m/pyconfig.h     2019-01-25 23:14:09.425842000 +0100
> @@ -1478,7 +1478,7 @@
>   /* #undef _POSIX_1_SOURCE */
> 
>   /* Define to activate features from IEEE Stds 1003.1-2008 */
> -#define _POSIX_C_SOURCE 200809L
> +//#define _POSIX_C_SOURCE 200809L
> 
>   /* Define to 1 if you need to in order for `stat' and other things to
> work. */
>   /* #undef _POSIX_SOURCE */
> @@ -1490,13 +1490,13 @@
>   #define _REENTRANT 1
> 
>   /* Define to the level of X/Open that your system supports */
> -#define _XOPEN_SOURCE 700
> +//#define _XOPEN_SOURCE 700
> 
>   /* Define to activate Unix95-and-earlier features */
> -#define _XOPEN_SOURCE_EXTENDED 1
> +//#define _XOPEN_SOURCE_EXTENDED 1
> 
>   /* Define on FreeBSD to activate all library features */
> -#define __BSD_VISIBLE 1
> +//#define __BSD_VISIBLE 1
> 
>   /* Define to 1 if type `char' is unsigned and you are not using gcc.  */
>   #ifndef __CHAR_UNSIGNED__
> 
> 
> 
> $ gcc -o memset_s.exe memset_s.c -I ./python3.6m.fix2/
> $ diff -Npur /usr/local/include/python3.6m/ ./python3.6m.fix2/
> diff -Npur /usr/local/include/python3.6m/pyconfig.h
> ./python3.6m.fix2/pyconfig.h
> --- /usr/local/include/python3.6m/pyconfig.h    2019-01-10
> 02:17:29.000000000 +0100
> +++ ./python3.6m.fix2/pyconfig.h        2019-01-25 23:43:59.350194000 +0100
> @@ -1498,6 +1498,8 @@
>   /* Define on FreeBSD to activate all library features */
>   #define __BSD_VISIBLE 1
> 
> +#define __STDC_WANT_LIB_EXT1__ 1
> +
>   /* Define to 1 if type `char' is unsigned and you are not using gcc.  */
>   #ifndef __CHAR_UNSIGNED__
>   /* # undef __CHAR_UNSIGNED__ */
> 
> 





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?da878a4c-e6de-ca4b-c5d2-a5058b6198d7>