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: warning: this use of "defined" may not be portable (Mac OS)
Type: compile error Stage:
Components: macOS Versions: Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: clem.wang, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2020-03-13 23:09 by clem.wang, last changed 2022-04-11 14:59 by admin.

Messages (4)
msg364125 - (view) Author: Clem Wang (clem.wang) Date: 2020-03-13 23:09
pyenv install 3.8.2
results in:

BUILD FAILED (OS X 10.15.3 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/jy/10md97xn3mz_x_b42l1r2r8c0000gp/T/python-build.20200313154805.37448
Results logged to /var/folders/jy/10md97xn3mz_x_b42l1r2r8c0000gp/T/python-build.20200313154805.37448.log

Last 10 log lines:
  331 | #if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h:331:6: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h:540:6: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]
  540 | #if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h:540:6: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]
cc1: some warnings being treated as errors
make: *** [Objects/floatobject.o] Error 1
make: *** Waiting for unfinished jobs....


The real problem is on line 199 of
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h

/* <rdar://problem/25944576> */
#define _PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT \
	defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREAD_EPOCH) || (SWIFT_SDK_OVERLAY_PTHREAD_EPOCH < 1))


I'm not sure if this is a problem for Apple to fix or whether the Python build needs to be more tolerant of warnings.
msg364255 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-03-15 19:53
What version of macOS are you on? And which compiler do you use?
msg364267 - (view) Author: Clem Wang (clem.wang) Date: 2020-03-15 23:14
Oops: forgot version numbers....

MacOS Catalina (10.15.13 19D76)
2.6 Ghz 6-Code Intel i7
32 GB RAM

Homebrew 2.2.10
Homebrew/homebrew-core (git revision 58c0; last commit 2020-03-13)
Homebrew/homebrew-cask (git revision ab52c7; last commit 2020-03-14)

Not sure which compiler is being used, but I have these installed:

gcc --version
gcc (MacPorts gcc9 9.2.0_1) 9.2.0

(3.8-env) C02ZD5VVLVDQ:3.8-env clem.wang$ clang --version
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
msg381950 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-11-27 14:12
This is incompatibility between upstream clang and Apple's headers. The same warning is not present when using Xcode's compiler.

As a workaround this warning can be disabled when including pthread.h, something like:

```
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexpansion-to-defined"
#endif

#include <pthread.h>

#ifdef __clang__
#pragma clang diagnostic pop
#endif
```

I won't create a PR for this because I don't have homebrew on my systems.

Alternatively build with "-Wno-expansion-to-defined" in CFLAGS.
History
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84142
2020-11-27 14:12:38ronaldoussorensetmessages: + msg381950
2020-03-15 23:14:40clem.wangsetmessages: + msg364267
2020-03-15 19:53:24ronaldoussorensetmessages: + msg364255
2020-03-13 23:09:18clem.wangcreate