Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Jan 2019 12:07:55 +0100
From:      Stefan Metzmacher <metze@samba.org>
To:        python@FreeBSD.org
Subject:   Problem with pyconfig.h in python36 which is already solved for python27
Message-ID:  <e6e7ef63-6c72-ec5c-f6d6-bc1fa5d9b604@samba.org>

next in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--yX6iusQnJug2FhSBIoLjNCLQpIgGfWa4y
Content-Type: multipart/mixed; boundary="mjCfEcWlcFYUBVqlQt54PUqiKeB8nGWRL";
 protected-headers="v1"
From: Stefan Metzmacher <metze@samba.org>
To: python@FreeBSD.org
Message-ID: <e6e7ef63-6c72-ec5c-f6d6-bc1fa5d9b604@samba.org>
Subject: Problem with pyconfig.h in python36 which is already solved for
 python27

--mjCfEcWlcFYUBVqlQt54PUqiKeB8nGWRL
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

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/4b17dd9aeb9b28759551f38bf=
0f6b0edcac88607
which added lang/python27/files/patch-pr192365.

Could this be fixed for all python versions?

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] =3D { 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=
=2Eh
--- /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
=2E/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 +01=
00
@@ -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__ */



--mjCfEcWlcFYUBVqlQt54PUqiKeB8nGWRL--

--yX6iusQnJug2FhSBIoLjNCLQpIgGfWa4y
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEfFbGo3YXpfgryIw9DbX1YShpvVYFAlxMP48ACgkQDbX1YShp
vVYVyg//VtEMMFX2bhClTkvyF0rpi8n/Q5HMF5HUZDPdqPo3WJIJd4aHMAw1BQ42
EFMWdcAGzlkXsqIhQiPpVGBQF9kgwEhtsOkEKdbjf515tuyIduvS7SPLOue3FTKj
7tGA+VLMZhaIRiKeS8uDpYt9mJcZUJa97RIYS4+cg68CDOVwOLKC3emnZa2yFwHR
iXHPUU6HgBsifYxM+xJ3QWR7FFe6QehzVDugox/vamP+DHQeaQSruRtLRP7tEZhA
JuMjAj+Fr0WB5ygOIif/qW6YEczSfi3CaNEZNMLCbFr6ZgAxP68rbXL5zD4UGAUt
M1pfmAfphsxU9C/BVOmHlhVUU2mOZXmyZqlUNoHWCh5Eh53IUSCRdhfsOSAo0HRo
1tHjLn8W2d8jtkbjbhoHZkJMVkVT5BteqqB9gwPgFAwtI+jgSRdyy8aZSbpE8+yk
2jyqgiWq4s3QKqvZ6Itk1Lgriy1iNcgSrsl2vXC+aCuo8gFAFlq5pSjZ66GLJ/6l
gd78gqFr3UGehpYfN7QD6AFZeY0BMglVj6hEHIqeDM/sz/qAj6b1boc9E1IuCzPq
/c7RsOS99VS66RUNr69jGi8sQdF+cdLn0l/afzSUC+wDwvzfP0KKeCyF8L2b/iRB
F46tbqKuk9w07QyyHDofnZ7dj5W4LhUpV98AylPp/BkDh488xqc=
=EJAj
-----END PGP SIGNATURE-----

--yX6iusQnJug2FhSBIoLjNCLQpIgGfWa4y--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e6e7ef63-6c72-ec5c-f6d6-bc1fa5d9b604>