[New-bugs-announce] [issue31359] `configure` script incorrectly detects symbols as available on Mac w/ Xcode 8+

Maxime Belanger report at bugs.python.org
Tue Sep 5 22:33:46 EDT 2017

New submission from Maxime Belanger:

At Dropbox, we use a custom fork of Python to deploy our Desktop Client onto various platforms, including macOS. We currently use the Mac OS X 10.11 SDK, but are considering updating to the macOS 10.12 SDK, which introduced new low-level functions, such as `getentropy`. Apple uses a series of "availability macros" with new warnings in Clang to consider the case when the `MACOSX_DEPLOYMENT_TARGET` is below the introduction version for a given symbol.

This has caused significant issues for `autoconf`-based projects, as running `configure` mistakes the built version into believing certain symbols are available, when they're not. As a result, deploying a viable build to users on older versions of Mac is rather complicated.

Current "solutions" (in recent versions of Xcode) include:

* Passing `-no_weak_imports` to the linker, which will fail any build using weakly-linked symbols (a pretty big hammer).
* A new compiler warning `-Wunguarded-availability`, which detects uses that contradict the `MACOSX_DEPLOYMENT_TARGET` using some AST tricks.

In our testing, neither had any effect on Python's `configure`, though these solutions worked for some other projects. We've implemented a workaround based on patching `pyconfig.h` after `configure` is complete, but ideally, Python's `configure` should detect `MACOSX_DEPLOYMENT_TARGET` and act accordingly (e.g. if `MACOSX_DEPLOYMENT_TARGET` is below 10.12, `getentropy` should not be considered available).

The following symbols are affected:

New in 10.13 (Python 3 only):
    utimensat       HAVE_UTIMENSAT
    futimens        HAVE_FUTIMENS

New in 10.12:
    getentropy      HAVE_GETENTROPY (Python 2/3)
    clock_gettime   HAVE_CLOCK_GETTIME (Python 2/3)
    clock_settime   HAVE_CLOCK_SETTIME (Python 3)
    clock_getres    HAVE_CLOCK_GETRES (Python 3)

New in 10.10 (Python 3 only):
    fstatat         HAVE_FSTATAT
    faccessat       HAVE_FACCESSAT
    fchmodat        HAVE_FCHMODAT
    fchownat        HAVE_FCHOWNAT
    linkat          HAVE_LINKAT
    fdopendir       HAVE_FDOPENDIR
    mkdirat         HAVE_MKDIRAT
    renameat        HAVE_RENAMEAT
    unlinkat        HAVE_UNLINKAT
    readlinkat      HAVE_READLINKAT
    symlinkat       HAVE_SYMLINKAT
    openat          HAVE_OPENAT

messages: 301432
nosy: Maxime Belanger
priority: normal
severity: normal
status: open
title: `configure` script incorrectly detects symbols as available on Mac w/ Xcode 8+
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list