New submission from Maxime Belanger <m...@dropbox.com>:

We build Python on macOS with `-Werror=unguarded-availability` and 
`-mmacosx-version-min=<xx>` to ensure `libpython` is binary-compatible with 
earlier versions of macOS. 

This can create problems when building some modules, including `timemodule.c`, 
which was recently altered to fix bpo-28081. The initial fix is inappropriate, 
because attempting to reference `CLOCK_REALTIME` et al when 
`HAVE_CLOCK_GETTIME` is unset (in our case, due to being too "new"), results in 
a compiler error:

```
./Modules/timemodule.c:1368:29: error: '_CLOCK_REALTIME' is only available on 
macOS 10.12 or newer
      [-Werror,-Wunguarded-availability]
    PyModule_AddIntMacro(m, CLOCK_REALTIME);
                            ^~~~~~~~~~~~~~
/usr/include/time.h:154:24: note: expanded from macro 'CLOCK_REALTIME'
#define CLOCK_REALTIME _CLOCK_REALTIME
                       ^~~~~~~~~~~~~~~
./Include/modsupport.h:78:67: note: expanded from macro 'PyModule_AddIntMacro'
#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
```

A more correct patch (I'm attaching ours) is to only add the macros to the 
module if at least one of the three functions is defined. This should continue 
to work for the author of the original issue as well as fix our problem.

----------
components: Extension Modules, macOS
messages: 328030
nosy: Maxime Belanger, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: Compiling `timemodule.c` can fail on macOS due to availability warnings
type: compile error
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to