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: Compiling `timemodule.c` can fail on macOS due to availability warnings
Type: compile error Stage: resolved
Components: Extension Modules, macOS Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Maxime Belanger, benjamin.peterson, miss-islington, ned.deily, ronaldoussoren, vstinner
Priority: normal Keywords: patch

Created on 2018-10-19 06:24 by Maxime Belanger, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 9961 merged maxbelanger, 2018-10-19 06:45
PR 10019 merged miss-islington, 2018-10-21 00:08
PR 10020 merged miss-islington, 2018-10-21 00:08
Messages (4)
msg328030 - (view) Author: Maxime Belanger (Maxime Belanger) Date: 2018-10-19 06:24
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.
msg328183 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2018-10-21 00:07
New changeset 94451182ccd6729c11338926d8a3d11645e86626 by Benjamin Peterson (Max Bélanger) in branch 'master':
closes bpo-35025: Properly guard the `CLOCK_GETTIME` et al macros in timemodule.c. (GH-9961)
https://github.com/python/cpython/commit/94451182ccd6729c11338926d8a3d11645e86626
msg328184 - (view) Author: miss-islington (miss-islington) Date: 2018-10-21 00:30
New changeset beb83d013e0295c987087febf2be78b1da389b15 by Miss Islington (bot) in branch '3.6':
closes bpo-35025: Properly guard the `CLOCK_GETTIME` et al macros in timemodule.c. (GH-9961)
https://github.com/python/cpython/commit/beb83d013e0295c987087febf2be78b1da389b15
msg328185 - (view) Author: miss-islington (miss-islington) Date: 2018-10-21 00:41
New changeset 002aef3f66a9f8da635e20860622f2e539a0b611 by Miss Islington (bot) in branch '3.7':
closes bpo-35025: Properly guard the `CLOCK_GETTIME` et al macros in timemodule.c. (GH-9961)
https://github.com/python/cpython/commit/002aef3f66a9f8da635e20860622f2e539a0b611
History
Date User Action Args
2022-04-11 14:59:07adminsetgithub: 79206
2018-10-21 00:41:45miss-islingtonsetmessages: + msg328185
2018-10-21 00:30:59miss-islingtonsetnosy: + miss-islington
messages: + msg328184
2018-10-21 00:08:44miss-islingtonsetpull_requests: + pull_request9360
2018-10-21 00:08:30miss-islingtonsetpull_requests: + pull_request9359
2018-10-21 00:08:00benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg328183

stage: patch review -> resolved
2018-10-19 06:45:27maxbelangersetkeywords: + patch
stage: patch review
pull_requests: + pull_request9308
2018-10-19 06:36:08serhiy.storchakasetnosy: + vstinner, benjamin.peterson
2018-10-19 06:24:57Maxime Belangercreate