Skip to content

bpo-31171: add `-lpthread' to build multiprocessing for linux platform #13353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

jiahongxujia
Copy link

@jiahongxujia jiahongxujia commented May 16, 2019

While cross compiling on Linux, AC_RUN_IFELSE to check -pthread' is always false, add -lpthread' to linker, it fixed multiprocessing.BoundedSemaphore
of 32-bit python did not work.

Whether corss compiling or not, whether supports `-pthread' or not, the fix
does not have side effect on Linux platform.

Signed-off-by: Hongxu Jia hongxu.jia@windriver.com

https://bugs.python.org/issue31171

While cross compiling on Linux, AC_RUN_IFELSE to check `-pthread' is always
false, add `-lpthread' to linker, it fixed multiprocessing.BoundedSemaphore
of 32-bit python did not work.

Whether corss compiling or not, whether supports `-pthread' or not, the fix
does not have side effect on Linux platform.

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
@@ -1619,7 +1621,11 @@ def detect_multiprocessing(self):
libraries=libs,
include_dirs=["Modules/_multiprocessing"]))

if HOST_PLATFORM.startswith('linux'):
multiprocessing_lib = ['pthread']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xdegaye Does it look right to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also cc @rossburton.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Android, the Python platform name is linux and pthread is not a standalone library but it is included in the libc (named bionic), same as on MacOS X. Therefore -lpthread is not used at the link stage.

IMO it is confusing to have both configure and setup.py handle the setting of -lpthread especially since the configure implementation of pthread variants is already quite involved. It would be better to just fix configure.ac if it is needed.

It is not clear from the comments on issue 31171 if the compiler -pthread option is available. If that option is available then running configure with ac_cv_pthread=yes sets CC="$CC -pthread" and that should fix the problem raised in the issue. Quoted from gcc documentation:

'-pthread'
     Define additional macros required for using the POSIX threads
     library.  You should use this option consistently for both
     compilation and linking.  This option is supported on GNU/Linux
     targets, most other Unix derivatives, and also on x86 Cygwin and
     MinGW targets.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if the cross-compiler does not support the -pthread option then run make with LDFLAGS:

    LDFLAGS=-lpthread make

@kumaraditya303
Copy link
Contributor

setup.py does not exists anymore, if this is still an issue please create a new PR for autoconf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants