Description
Bug report
Due to missing fallback macro definitions in Modules/posixmodule.c
(source) for HAVE_MKFIFOAT_RUNTIME
and HAVE_MKNODAT_RUNTIME
, Python 3.11 cannot be built with GCC on macOS, due to the following failures:
./Modules/posixmodule.c: In function 'parse_posix_spawn_flags':
./Modules/posixmodule.c:186:64: warning: comparison between pointer and integer
186 | (posix_spawn != NULL && setsid != NULL)
| ^~
./Modules/posixmodule.c:6026:13: note: in expansion of macro 'HAVE_POSIX_SPAWN_SETSID_RUNTIME'
6026 | if (HAVE_POSIX_SPAWN_SETSID_RUNTIME) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Modules/posixmodule.c: In function 'os_mkfifo_impl':
./Modules/posixmodule.c:10690:17: error: 'HAVE_MKFIFOAT_RUNTIME' undeclared (first use in this function); did you mean 'HAVE_MKDIRAT_RUNTIME'?
10690 | if (HAVE_MKFIFOAT_RUNTIME) {
| ^~~~~~~~~~~~~~~~~~~~~
| HAVE_MKDIRAT_RUNTIME
./Modules/posixmodule.c:10690:17: note: each undeclared identifier is reported only once for each function it appears in
./Modules/posixmodule.c: In function 'os_mknod_impl':
./Modules/posixmodule.c:10759:17: error: 'HAVE_MKNODAT_RUNTIME' undeclared (first use in this function); did you mean 'HAVE_MKDIRAT_RUNTIME'?
10759 | if (HAVE_MKNODAT_RUNTIME) {
| ^~~~~~~~~~~~~~~~~~~~
| HAVE_MKDIRAT_RUNTIME
./Modules/posixmodule.c: In function 'probe_mkfifoat':
arm64-apple-darwin22-gcc -Wsign-compare -DNDEBUG -O2 -pipe -fwrapv -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I. -I./Include -I/Users/gentoo/gentoo/tmp/usr/include/ncursesw -DPy_BUILD_CORE_BUILTIN -c ./Modules/_codecsmodule.c -o Modules/_codecsmodule.o
./Modules/posixmodule.c:15647:23: error: 'HAVE_MKFIFOAT_RUNTIME' undeclared (first use in this function); did you mean 'HAVE_MKDIRAT_RUNTIME'?
15647 | PROBE(probe_mkfifoat, HAVE_MKFIFOAT_RUNTIME)
| ^~~~~~~~~~~~~~~~~~~~~
./Modules/posixmodule.c:15611:11: note: in definition of macro 'PROBE'
15611 | if (test) { \
| ^~~~
./Modules/posixmodule.c: In function 'probe_mknodat':
./Modules/posixmodule.c:15651:22: error: 'HAVE_MKNODAT_RUNTIME' undeclared (first use in this function); did you mean 'HAVE_MKDIRAT_RUNTIME'?
15651 | PROBE(probe_mknodat, HAVE_MKNODAT_RUNTIME)
| ^~~~~~~~~~~~~~~~~~~~
./Modules/posixmodule.c:15611:11: note: in definition of macro 'PROBE'
15611 | if (test) { \
| ^~~~
make: *** [Makefile:2695: Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....
In Modules/posixmodule.c
, Python conditionally defines a series of macros that indicate whether a system call is supported based on #ifdef
checks. By default, the clang specific __builtin_available()
compiler built-in function is used to check them. But if __builtin_available()
is unavailable, a fallback is also provided.
For example, for HAVE_FSTATAT_RUNTIME
, we have:
#ifdef HAVE_BUILTIN_AVAILABLE
# define HAVE_FSTATAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
// [...]
#else /* Xcode 8 or earlier */
/* __builtin_available is not present in these compilers, but
* some of the symbols might be weak linked (10.10 SDK or later
* deploying on 10.9.
*
* Fall back to the older style of availability checking for
* symbols introduced in macOS 10.10.
*/
# ifdef HAVE_FSTATAT
# define HAVE_FSTATAT_RUNTIME (fstatat != NULL)
# endif
#endif
The fallback is important because it's not only used to support older Xcode or macOS, but it also provides fallback when GCC is used. The function __builtin_available()
is clang-only and does not exist in GCC. In the past, this was handled by the else
portion of the ifdef
, so it worked on GCC as well. Unfortunately, when HAVE_MKFIFOAT_RUNTIME
and HAVE_MKDIRAT_RUNTIME
have been added to the code, a fallback was never provided, thus, compiling Python 3.11 with GCC now fails due to undeclared macros.
Your environment
- CPython versions tested on: Python 3.11.3
- Operating system and architecture: macOS 13.2.1
- GCC 12.2.0