GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Python 3.11 is unbuildable with GCC on macOS (error: 'HAVE_MKFIFOAT_RUNTIME' undeclared, error: 'HAVE_MKNODAT_RUNTIME' undeclared) · Issue #104106 · python/cpython

Python 3.11 is unbuildable with GCC on macOS (error: 'HAVE_MKFIFOAT_RUNTIME' undeclared, error: 'HAVE_MKNODAT_RUNTIME' undeclared) #104106

New issue
Copy link
New issue
Copy link
Closed
Closed
Python 3.11 is unbuildable with GCC on macOS (error: 'HAVE_MKFIFOAT_RUNTIME' undeclared, error: 'HAVE_MKNODAT_RUNTIME' undeclared)#104106
Copy link
Labels
OS-macbuildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@biergaizi
biergaizi
opened on May 2, 2023
Issue body actions

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

Linked PRs

  • gh-104106: Add gcc fallback of mkfifoat/mknodat for macOS #104129
  • [3.11] gh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (gh-104129) #104187

Activity

  1. biergaizi
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on May 2, 2023
  2. ned-deily
    added
    OS-mac
    on May 2, 2023
  3. biergaizi
    changed the title [-]Python 3.11 is unbuildable with GCC on macOS (error: 'HAVE_MKNODAT_RUNTIME' undeclared, error: 'HAVE_MKNODAT_RUNTIME' undeclared)[/-] [+]Python 3.11 is unbuildable with GCC on macOS (error: 'HAVE_MKFIFOAT_RUNTIME' undeclared, error: 'HAVE_MKNODAT_RUNTIME' undeclared)[/+] on May 2, 2023
  4. arhadthedev
    added
    buildThe build process and cross-buildThe build process and cross-build
    on May 3, 2023
  5. corona10
    added 2 commits that reference this issue on May 3, 2023

    pythongh-104106: Add gcc fallback of mkfifoat/mknodat for macOS

    4d59c62

    pythongh-104106: Add gcc fallback of mkfifoat/mknodat for macOS

    03032ad
  6. corona10 commented on May 3, 2023

    @corona10
    corona10
    on May 3, 2023
    Member
    More actions

    @biergaizi Can you please check that #104129 solve your issue?

    --- a/Modules/posixmodule.c
    +++ b/Modules/posixmodule.c
    @@ -175,6 +175,14 @@
     #    define HAVE_PWRITEV_RUNTIME (pwritev != NULL)
     #  endif
     
    +#  ifdef HAVE_MKFIFOAT
    +#    define HAVE_MKFIFOAT_RUNTIME (mkfifoat != NULL)
    +#  endif
    +
    +#  ifdef HAVE_MKNODAT
    +#    define HAVE_MKNODAT_RUNTIME (mknodat != NULL)
    +#  endif
    +
     #endif
     
     #ifdef HAVE_FUTIMESAT
  7. biergaizi commented on May 3, 2023

    @biergaizi
    biergaizi
    on May 3, 2023
    Author
    More actions

    No, because this patch contains a typo. #ifdef HAVE_MKNODAT_RUNTIME should be #ifdef HAVE_MKNODAT

  8. corona10
    added a commit that references this issue on May 4, 2023

    pythongh-104106: Add gcc fallback of mkfifoat/mknodat for macOS

    6fc35af
  9. corona10 commented on May 4, 2023

    @corona10
    corona10
    on May 4, 2023
    Member
    More actions

    @biergaizi Thanks, I updated the diff, is the changes solve your issue?

  10. biergaizi commented on May 4, 2023

    @biergaizi
    biergaizi
    on May 4, 2023
    Author
    More actions

    Yes, the revised patch works, posixmodule.c now passes build without failures.

    Reacted by Donghee Na
  11. biergaizi
    added a commit that references this issue on May 5, 2023

    dev-lang/python-3.11.3: fix build on macOS.

    1e5fa9b
  12. corona10
    added 4 commits that reference this issue on May 5, 2023

    gh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (gh-104129)

    e5b8b19

    [3.11] pythongh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (

    40cd6d5

    pythongh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (pyth…

    a2b8d23

    [3.11] gh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (gh-…

    81902d3
  13. corona10 commented on May 5, 2023

    @corona10
    corona10
    on May 5, 2023
    Member
    More actions

    @biergaizi Thank you for the report!

  14. corona10
    closed this as completedon May 5, 2023
  15. carljm
    added a commit that references this issue on May 5, 2023

    Merge branch 'main' into inlinecomp2

    8a78a36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-macbuildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.