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: Undefined I_* macros of stropts.h when building Python 3.10 on Ubuntu: fail to build the fcntl module
Type: Stage: resolved
Components: Build Versions: Python 3.10
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: andrei.avk, christian.heimes, etale-cohomology, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2021-10-07 11:57 by etale-cohomology, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (7)
msg403396 - (view) Author: Diego Alonso (etale-cohomology) Date: 2021-10-07 11:57
Trying to build Python 3.10 on Ubuntu 20.04. It builds everything but the fcntl module; ie. at the end it says:

Failed to build these modules:
fcntl.

Here are the compilation errors. It's trying to use certain macros that are undefined: I_PUSH, I_POP, I_LOOK, I_FLUSH, I_FLUSHBAND, I_SETSIG, I_GETSIG, I_FIND, I_PEEK, I_SRDOPT, I_GRDOPT, I_NREAD, I_FDINSERT, I_STR, I_SWROPT, I_SENDFD, I_RECVFD, I_LIST, I_ATMARK, I_CKBAND, I_GETBAND, I_CANPUT, I_SETCLTIME, I_LINK, I_UNLINK, I_PLINK, I_PUNLINK

----------------------------------------------------------------
Modules/_xxsubinterpretersmodule.o
In file included from ./Include/Python.h:140,
                 from /home/da/git/Python-3.10.0/Modules/fcntlmodule.c:6:
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c: In function ‘all_ins’:
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:614:33: error: ‘I_PUSH’ undeclared (first use in this function)
  614 |     if (PyModule_AddIntMacro(m, I_PUSH)) return -1;
      |                                 ^~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:614:33: note: each undeclared identifier is reported only once for each function it appears in
  614 |     if (PyModule_AddIntMacro(m, I_PUSH)) return -1;
      |                                 ^~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:615:33: error: ‘I_POP’ undeclared (first use in this function)
  615 |     if (PyModule_AddIntMacro(m, I_POP)) return -1;
      |                                 ^~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:616:33: error: ‘I_LOOK’ undeclared (first use in this function); did you mean ‘F_LOCK’?
  616 |     if (PyModule_AddIntMacro(m, I_LOOK)) return -1;
      |                                 ^~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:617:33: error: ‘I_FLUSH’ undeclared (first use in this function); did you mean ‘CFLUSH’?
  617 |     if (PyModule_AddIntMacro(m, I_FLUSH)) return -1;
      |                                 ^~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:618:33: error: ‘I_FLUSHBAND’ undeclared (first use in this function)
  618 |     if (PyModule_AddIntMacro(m, I_FLUSHBAND)) return -1;
      |                                 ^~~~~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:619:33: error: ‘I_SETSIG’ undeclared (first use in this function); did you mean ‘F_SETSIG’?
  619 |     if (PyModule_AddIntMacro(m, I_SETSIG)) return -1;
      |                                 ^~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:620:33: error: ‘I_GETSIG’ undeclared (first use in this function); did you mean ‘F_GETSIG’?
  620 |     if (PyModule_AddIntMacro(m, I_GETSIG)) return -1;
      |                                 ^~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:621:33: error: ‘I_FIND’ undeclared (first use in this function)
  621 |     if (PyModule_AddIntMacro(m, I_FIND)) return -1;
      |                                 ^~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:622:33: error: ‘I_PEEK’ undeclared (first use in this function)
  622 |     if (PyModule_AddIntMacro(m, I_PEEK)) return -1;
      |                                 ^~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:623:33: error: ‘I_SRDOPT’ undeclared (first use in this function)
  623 |     if (PyModule_AddIntMacro(m, I_SRDOPT)) return -1;
      |                                 ^~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:624:33: error: ‘I_GRDOPT’ undeclared (first use in this function)
  624 |     if (PyModule_AddIntMacro(m, I_GRDOPT)) return -1;
      |                                 ^~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:625:33: error: ‘I_NREAD’ undeclared (first use in this function); did you mean ‘FIONREAD’?
  625 |     if (PyModule_AddIntMacro(m, I_NREAD)) return -1;
      |                                 ^~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:626:33: error: ‘I_FDINSERT’ undeclared (first use in this function)
  626 |     if (PyModule_AddIntMacro(m, I_FDINSERT)) return -1;
      |                                 ^~~~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:627:33: error: ‘I_STR’ undeclared (first use in this function)
  627 |     if (PyModule_AddIntMacro(m, I_STR)) return -1;
      |                                 ^~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:628:33: error: ‘I_SWROPT’ undeclared (first use in this function)
  628 |     if (PyModule_AddIntMacro(m, I_SWROPT)) return -1;
      |                                 ^~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
gcc -pthread -shared -fno-semantic-interposition -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -fprofile-generate build/temp.linux-x86_64-3.10/home/da/git/Python-3.10.0/Modules/_contextvarsmodule.o -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -o build/lib.linux-x86_64-3.10/_contextvars.cpython-310-x86_64-linux-gnu.so
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:633:33: error: ‘I_SENDFD’ undeclared (first use in this function)
  633 |     if (PyModule_AddIntMacro(m, I_SENDFD)) return -1;
      |                                 ^~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:634:33: error: ‘I_RECVFD’ undeclared (first use in this function)
  634 |     if (PyModule_AddIntMacro(m, I_RECVFD)) return -1;
      |                                 ^~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:635:33: error: ‘I_LIST’ undeclared (first use in this function)
  635 |     if (PyModule_AddIntMacro(m, I_LIST)) return -1;
      |                                 ^~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:636:33: error: ‘I_ATMARK’ undeclared (first use in this function)
  636 |     if (PyModule_AddIntMacro(m, I_ATMARK)) return -1;
      |                                 ^~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:637:33: error: ‘I_CKBAND’ undeclared (first use in this function)
  637 |     if (PyModule_AddIntMacro(m, I_CKBAND)) return -1;
      |                                 ^~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:638:33: error: ‘I_GETBAND’ undeclared (first use in this function)
  638 |     if (PyModule_AddIntMacro(m, I_GETBAND)) return -1;
      |                                 ^~~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:639:33: error: ‘I_CANPUT’ undeclared (first use in this function)
  639 |     if (PyModule_AddIntMacro(m, I_CANPUT)) return -1;
      |                                 ^~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:640:33: error: ‘I_SETCLTIME’ undeclared (first use in this function)
  640 |     if (PyModule_AddIntMacro(m, I_SETCLTIME)) return -1;
      |                                 ^~~~~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:644:33: error: ‘I_LINK’ undeclared (first use in this function); did you mean ‘EMLINK’?
  644 |     if (PyModule_AddIntMacro(m, I_LINK)) return -1;
      |                                 ^~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:645:33: error: ‘I_UNLINK’ undeclared (first use in this function)
  645 |     if (PyModule_AddIntMacro(m, I_UNLINK)) return -1;
      |                                 ^~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:646:33: error: ‘I_PLINK’ undeclared (first use in this function)
  646 |     if (PyModule_AddIntMacro(m, I_PLINK)) return -1;
      |                                 ^~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |                                                                   ^
/home/da/git/Python-3.10.0/Modules/fcntlmodule.c:647:33: error: ‘I_PUNLINK’ undeclared (first use in this function)
  647 |     if (PyModule_AddIntMacro(m, I_PUNLINK)) return -1;
      |                                 ^~~~~~~~~
./Include/modsupport.h:154:67: note: in definition of macro ‘PyModule_AddIntMacro’
  154 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
      |
msg403405 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-10-07 13:17
What is the output of the following command?

    ./python -m sysconfig | grep HAVE_STROPTS_H

Also, is there the stropts.h file on your system and where?

    dlocate stropts.h
    locate stropts.h
msg403479 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-10-08 14:22
On my Fedora 34, the HAVE_STROPTS_H macro is not defined in pyconfig.h:

/* Define to 1 if you have the <stropts.h> header file. */
/* #undef HAVE_STROPTS_H */

I confirm that I cannot find this file:

$ find /usr/include/ -name stropts.h
$ find /usr/lib/gcc/x86_64-redhat-linux/11/ -name stropts.h
msg403484 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-10-08 15:57
It is not defined on my Ubuntu 20.04 either. But stropts.h could be installed by some Ubuntu package not installed on my computer, or came from some non-standard source.

On my computer:

$ dlocate stropts.h
manpages-posix-dev: /usr/share/man/man7/stropts.h.7posix.gz
python3-pycparser: /usr/share/python3-pycparser/fake_libc_include/stropts.h
python-pycparser: /usr/share/python-pycparser/fake_libc_include/stropts.h

$ locate stropts.h
/usr/share/man/man7/stropts.h.7posix.gz
/usr/share/python-pycparser/fake_libc_include/stropts.h
/usr/share/python3-pycparser/fake_libc_include/stropts.h
msg403930 - (view) Author: Diego Alonso (etale-cohomology) Date: 2021-10-14 18:36
I had an empty stropts.h lying around somewhere in /usr/* (can't remember where) because some programs don't compile if they don't see that file (even an empty one suffices). But Python doesn't compile if it sees it... So I deleted stropts.h and then ran ./configure again, compiled, and it worked.

The Python build code should be modified to set HAVE_STROPTS_H to 0 on platforms (like Linux) that don't support stropts.h
msg403933 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-10-14 18:53
I'm glad you figured out the problem and fixed your system.

Python uses autoconf (configure) to detect the presence of features. It's a standard approach. Since you had a stropts.h in your include directory, configure declared HAVE_STROPTS_H. The system can't deal with incompatible stropts.h.

We could add more checks and workaround. IMHO it's not worth the effort and time. We assume standard behavior and APIs in lots of places.
msg405634 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-11-03 17:51
Duplicate of #41105 , where two more people ran into this issue.
History
Date User Action Args
2022-04-11 14:59:50adminsetgithub: 89567
2021-11-03 17:51:08andrei.avksetnosy: + andrei.avk
messages: + msg405634
2021-10-14 18:53:17christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg403933

resolution: not a bug
stage: resolved
2021-10-14 18:36:24etale-cohomologysetmessages: + msg403930
2021-10-08 15:57:01serhiy.storchakasetmessages: + msg403484
2021-10-08 14:24:13vstinnersettitle: Undefined I_* macros when building 3.10 on Ubuntu? -> Undefined I_* macros of stropts.h when building Python 3.10 on Ubuntu: fail to build the fcntl module
2021-10-08 14:22:54vstinnersetnosy: + vstinner
messages: + msg403479
2021-10-07 13:17:47serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg403405
2021-10-07 11:57:28etale-cohomologycreate