This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add some extra content check in configure process for some empty header file who has been deprecated by glibc
Type: compile error Stage:
Components: Build Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Jiachen Yang, Manjusaka, andrei.avk, christian.heimes, etale-cohomology, lilydjwg, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-06-24 15:16 by Manjusaka, last changed 2022-04-11 14:59 by admin.

Messages (6)
msg372254 - (view) Author: Manjusaka (Manjusaka) * Date: 2020-06-24 15:16
Hello everyone

When I try to compile the code from the master branch on my Manjaro, one of the Linux system based on the Arch and based on the glibc-2.31 && gcc-10.1.0 . the compiler show me that the fcntl module has been failed to be compiled

Here's the message 

/home/manjusaka/Documents/project/cpython/Modules/fcntlmodule.c:618:33: error: ‘I_PUSH’ undeclared (first use in this function)
  618 |     if (PyModule_AddIntMacro(m, I_PUSH)) return -1;
      |                                 ^~~~~~
./Include/modsupport.h:146:67: note: in definition of macro ‘PyModule_AddIntMacro’
  146 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/manjusaka/Documents/project/cpython/Modules/fcntlmodule.c:618:33: note: each undeclared identifier is reported only once for each function it appears in
  618 |     if (PyModule_AddIntMacro(m, I_PUSH)) return -1;
      |                                 ^~~~~~
./Include/modsupport.h:146:67: note: in definition of macro ‘PyModule_AddIntMacro’
  146 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/manjusaka/Documents/project/cpython/Modules/fcntlmodule.c:619:33: error: ‘I_POP’ undeclared (first use in this function)
  619 |     if (PyModule_AddIntMacro(m, I_POP)) return -1;
      |                                 ^~~~~
./Include/modsupport.h:146:67: note: in definition of macro ‘PyModule_AddIntMacro’
  146 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/manjusaka/Documents/project/cpython/Modules/fcntlmodule.c:620:33: error: ‘I_LOOK’ undeclared (first use in this function); did you mean ‘F_LOCK’?
  620 |     if (PyModule_AddIntMacro(m, I_LOOK)) return -1;
      |                                 ^~~~~~


I have figured out the reason because the stropts.h has been deprecated since the glic-2.30, but some of the distribution of Linux keep an empty file on the /usr/include, so the configure process will recognize stropts.h is existed and open HAVE_STROPTS_H flag.

So should we add an extra content check in the configure process to avoid the empty file problem?
msg372255 - (view) Author: Manjusaka (Manjusaka) * Date: 2020-06-24 15:17
Here's the reference

https://sourceware.org/legacy-ml/libc-alpha/2019-08/msg00029.html
msg403404 - (view) Author: Diego Alonso (etale-cohomology) Date: 2021-10-07 13:17
Yes, I have the same problem. The empty file is needed to avoid compilation errors in certain builds, but in this case it creates an error...
msg405635 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-11-03 17:54
I think adding this code in the `configure` script may fix it:

as_ac_Header=`$as_echo "ac_cv_header_stropts.h" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "stropts.h" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes" && [ -s stropts.h ]; then :
  cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_stropts.h" | $as_tr_cpp` 1
_ACEOF
fi

here: https://github.com/akulakov/cpython/blob/8f24b7dbcbd83311dad510863d8cb41f0e91b464/configure#L8144

.. but I wasn't able to test it. I have a MacOS system and for me even with a non-empty stropts.h, configure does not pick it up.
msg405637 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-03 18:20
The configure script is auto-generated from configure.ac. Any chance must be applied to configure.ac.

We could replace the AC_CHECK_HEADERS() for stropt.h with a more elaborate AC_COMPILE_IFELSE() block that checks for presence of I_PUSH.

Could you please report the issue to your Linux vendor, too? The empty file seems to break Open Group Unix 98 standard.
msg405639 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-11-03 18:32
Rather of using AC_COMPILE_IFELSE() in configure.ac, would not be easier to use #ifdef in the C file?
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85277
2021-11-03 18:32:16serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg405639
2021-11-03 18:20:26christian.heimessetnosy: + christian.heimes
messages: + msg405637
2021-11-03 17:54:16andrei.avksetnosy: + andrei.avk
messages: + msg405635
2021-10-07 13:17:19etale-cohomologysetnosy: + etale-cohomology
messages: + msg403404
2020-06-24 17:10:08Jiachen Yangsetnosy: + Jiachen Yang
2020-06-24 15:28:19lilydjwgsetnosy: + lilydjwg
2020-06-24 15:18:52Manjusakasettitle: Add some extra content check for some who has been deprecated by glibc -> Add some extra content check in configure process for some empty header file who has been deprecated by glibc
2020-06-24 15:17:18Manjusakasetmessages: + msg372255
2020-06-24 15:16:58Manjusakacreate