Skip to content

Find versioned shared libraries on OpenBSD - #437

Draft
guocn wants to merge 1 commit into
pypa:mainfrom
guocn:fix-openbsd-versioned-library-396
Draft

guocn wants to merge 1 commit into
pypa:mainfrom
guocn:fix-openbsd-versioned-library-396

Conversation

@guocn

@guocn guocn commented Oct 22, 2026 •

Copy link
Copy Markdown

Summary

Fixes #396. Compiler.find_library_file() only probes unversioned shared library names and static archives. OpenBSD normally installs libNAME.so.MAJOR.MINOR without an unversioned symlink, so detection fails when the static archive is absent (the Pillow build scenario in the issue).

For OpenBSD only, probe numeric major/minor shared-library names after the unversioned shared name and before the static archive. Preserve directory priority and choose the largest numeric (major, minor) in each directory. This matches OpenBSD's linker searchLibraryBaseName / findMajMinShlib implementation:
https://github.com/openbsd/src/blob/master/gnu/llvm/lld/ELF/DriverUtils.cpp

Other platforms retain the existing search path. Versioned filenames with malformed suffixes and dangling symlinks are ignored; glob metacharacters in the directory are escaped. The helper performs detection only, not loading or linking.

Tests and limitations

Linux x86_64, CPython 3.13.5, isolated source checkout:

  • Added real-filesystem cases for numeric ordering (3.9 vs 3.10; 9.99 vs 10.0), shared-over-static preference, unversioned preference, directory order (including earlier static vs later shared), malformed names, escaped directory names, missing directory and dangling symlinks, plus Linux unchanged behavior.
  • Before the fix: initial focused matrix 5 failed, 3 passed. Final added matrix on baseline: 6 failed, 5 passed. After: compiler file 18 passed (11 added cases + 7 original).
  • Focused with repository-enabled lint/format/checkdocs/coverage checks: 21 passed before standalone package import setup; direct focused tests remain 18 passed.
  • Full functional suite: 273 passed, 27 skipped, 13 failed. The same 13 existing failures occur on baseline, plus six added regressions before the fix. Failures concern missing host Python development files, Debian egg-info naming, and TestBuildCLib.skipTest; not this search path.
  • Full repository-enabled check run: 600 passed, 27 skipped, 14 failed vs pristine baseline 589 passed, 27 skipped, 14 failed. The 14th is the package check's subprocess importing setuptools under SETUPTOOLS_USE_DISTUTILS=stdlib. That override is needed to test this checkout instead of setuptools' vendored copy. Separate wheel and sdist builds pass without the test-only override.
  • Changed-file Ruff check/format and git diff --check pass.
  • A second CPython 3.11.16 attempt cannot collect seven existing modules because that interpreter omits stdlib test.support; no 3.11 success claimed.

Draft: no native OpenBSD interpreter/linker or Pillow build was available. Platform selection is monkeypatched only within real production-code filesystem tests. Native OpenBSD validation and upstream CI remain outstanding, so no native platform success is claimed. This is a compiler setup lookup, not a parse/request hot path; no performance-neutrality claim is made.

Includes a Towncrier fragment at newsfragments/396.bugfix.rst, following the repository's AGENTS.md / skeleton guidance.

AI assistance

Prepared with AI assistance. Investigation, patch, tests, local checks and this description are AI-assisted. No independent human review is claimed; a separate assistant will inspect the production diff and rerun focused regressions. Draft remains for maintainer/native-platform review.

OpenBSD installs shared libraries as libNAME.so.MAJOR.MINOR without an unversioned symlink. Preserve search-directory precedence and select the highest numeric major/minor pair, matching the OpenBSD linker. Add real-filesystem regression and malformed-name controls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

find_library_file doesn't handle openbsd shared library naming scheme

1 participant