GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-21536: On Cygwin, C extensions must be linked with libpython by embray · Pull Request #13549 · python/cpython

Conversation

@embray

@embray embray commented May 24, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

It is also possible to link against a library or executable with a
statically linked libpython, but not both with the same DLL. In fact
building a statically linked python is currently broken on Cygwin
for other (related) reasons.

The same problem applies to other POSIX-like layers over Windows
(MinGW, MSYS) but Python's build system does not seem to attempt
to support those platforms at the moment.

Follow-up to #12946

https://bugs.python.org/issue21536

@vstinner

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@embray
bpo-21536: On Cygwin, C extensions must be linked with libpython in
effceb0
general.

It is also possible to link against a library or executable with a
statically linked libpython, but not both with the same DLL.  In fact
building a statically linked python is currently broken on Cygwin
for other (related) reasons.

The same problem applies to other POSIX-like layers over Windows
(MinGW, MSYS) but Python's build system does not seem to attempt
to support those platforms at the moment.
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label May 24, 2019
@bedevere-bot bedevere-bot added the awaiting review label May 24, 2019
embray
embray commented May 24, 2019
View reviewed changes
Comment thread Lib/distutils/command/build_ext.py
if get_config_var('ANDROID_API_LEVEL') != 0:
link_libpython = True
elif get_config_var('MACHDEP') == 'cygwin':
link_libpython = True

@embray embray May 24, 2019

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Here I just mostly "unwrapped" the single if condition above into multiple explicit branches, which I think makes the logic clearer, especially with more cases added on...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner vstinner added the skip news label May 24, 2019
@vstinner
vstinner merged commit c994c8f into python:master May 24, 2019
@bedevere-bot bedevere-bot removed the awaiting review label May 24, 2019
@vstinner

vstinner commented May 24, 2019

Copy link
Copy Markdown
Member

LGTM.I merged your PR, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@embray

embray commented May 24, 2019

Copy link
Copy Markdown
Contributor Author

Thank you, though perhaps it was too quick! There is a bug in my logic in configure.ac.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented May 24, 2019

Copy link
Copy Markdown
Member

Thank you, though perhaps it was too quick! There is a bug in my logic in configure.ac.

Ah? I didn't notice. Write a second PR in that case ;-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

embray
embray commented May 24, 2019
View reviewed changes
Comment thread configure
# On Android and Cygwin the shared libraries must be linked with libpython.

if test -z "$ANDROID_API_LEVEL"; then
if test -z "$ANDROID_API_LEVEL" -o "$MACHDEP" != "cygwin"; then

@embray embray May 24, 2019

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This should be -a not -o technically, but it would probably be even clearer if the test weren't negated, and were instead

if test -n "$ANDROID_API_LEVEL" -o "$MACHDEP" = "cygwin";

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner May 24, 2019

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

"even clearer if the test weren't negated" yeah, please invert the test conditions to avoid double negation ;-)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@embray embray May 24, 2019

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Glad we're on the same page. It's the double-negation that tripped me up in the first place, and probably you too.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner May 24, 2019

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

probably you too.

yes

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner

vstinner commented May 24, 2019

Copy link
Copy Markdown
Member

Hum, is if test -z "$ANDROID_API_LEVEL" -o "$MACHDEP" != "cygwin"; then the issue?

I'm not comfortable with double negation :-) Maybe write:

if test -n "$ANDROID_API_LEVEL" -o "$MACHDEP" = "cygwin"; then
   LIBPYTHON=...
else
  LIBPYTHON=
fi
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@embray embray mentioned this pull request May 24, 2019
bpo-21536: Follow-up to #13549 #13552
Merged
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
@embray @DinoV
bpo-21536: On Cygwin, C extensions must be linked with libpython (pyt…
8789997
…honGH-13549)

It is also possible to link against a library or executable with a
statically linked libpython, but not both with the same DLL.  In fact
building a statically linked python is currently broken on Cygwin
for other (related) reasons.

The same problem applies to other POSIX-like layers over Windows
(MinGW, MSYS) but Python's build system does not seem to attempt
to support those platforms at the moment.
@pitrou pitrou mentioned this pull request Sep 2, 2022
extension built with a shared python cannot be loaded with a static python #65735
Closed
eli-schwartz
eli-schwartz reviewed Dec 20, 2022
View reviewed changes
Comment thread Lib/distutils/command/build_ext.py
Comment on lines +720 to +725
# remain RTLD_LOCAL and so the shared libraries must be linked with
# libpython when python is built with a shared python library (issue
# bpo-21536).
# On Cygwin (and if required, other POSIX-like platforms based on
# Windows like MinGW) it is simply necessary that all symbols in
# shared libraries are resolved at link time.

@eli-schwartz eli-schwartz Dec 20, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@embray trying to better understand this change...

On Android, before this PR, it is technically possible to refrain from linking to libpython if and only if python itself is configured as a static build.

This Cygwin change applies here also within if get_config_var('Py_ENABLE_SHARED'): -- does Cygwin only need libpython in shared builds, like Cygwin, or all the time, like MSVC?

The commit message glosses over it by pointing out that static Cygwin builds are broken anyway. I am simply curious what the most correct approach is (when implementing similar logic outside of distutils).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner left review comments
+1 more reviewer
@eli-schwartz eli-schwartz eli-schwartz left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@embray @vstinner @eli-schwartz @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.