Add z/OS (s390x-ibm-zos) cross-compilation support - #6314
Open
IgorTodorovskiIBM wants to merge 1 commit into
Open
Add z/OS (s390x-ibm-zos) cross-compilation support#6314IgorTodorovskiIBM wants to merge 1 commit into
IgorTodorovskiIBM wants to merge 1 commit into
Conversation
z/OS uses XPLINK linkage for shared libraries. Extension modules must link libpython explicitly (same reason as AIX), and runtime library discovery uses LIBPATH rather than ELF rpath. Changes: - is_linking_libpython_for_target: add OperatingSystem::Zos so that pyo3-based cdylib crates emit -lpython3.X when targeting z/OS - print_libpython_rpath_link_args: skip -Wl,-rpath for z/OS; callers should set LIBPATH in the runtime environment instead Cross-compilation is driven via PYO3_CONFIG_FILE pointing to a config file generated from the target z/OS Python installation: implementation=CPython version=3.11 shared=true lib_name=python3.11 lib_dir=/usr/lpp/IBM/cyp/v3r11/pyz/lib suppress_build_script_link_lines=false Tested against IBM Open Enterprise Python 3.11 on z/OS 3.1.
Member
|
This seems reasonable, but we can't merge this until there's a target-lexicon release. |
davidhewitt
approved these changes
Aug 9, 2026
davidhewitt
left a comment
Member
There was a problem hiding this comment.
Thanks, please add newsfragments/6314.fixed.md with something like "fix linkage on z/OS" as the content.
We will have to wait until target-lexicon release before merging here as the patch only applies locally not downstream; at that time we can revert the patch, bump the dependency and move forward 👍
chirizxc
reviewed
Aug 9, 2026
| [patch.crates-io] | ||
| # target-lexicon 0.13.5 does not yet include OperatingSystem::Zos; | ||
| # use the main branch until the next release. | ||
| target-lexicon = { git = "https://github.com/bytecodealliance/target-lexicon", branch = "main" } |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add z/OS (
s390x-ibm-zos) support topyo3-build-config.z/OS (IBM Z Operating System) is supported by the Rust compiler as the
s390x-ibm-zostarget. IBM Open Enterprise Python provides Python 3.11/3.12 on z/OS, and pyo3-based extension modules need two build-system fixes to work:Changes
pyo3-build-config/src/impl_.rs— addOperatingSystem::Zostois_linking_libpython_for_target()z/OS uses XPLINK (cross-language platform linkage) for shared libraries. Extension modules (
.sofiles /cdylibcrates) must linklibpython3.xexplicitly, for the same reason AIX does (#4068).pyo3-build-config/src/lib.rs— skip-Wl,-rpathfor z/OS inprint_libpython_rpath_link_args()z/OS uses
LIBPATHfor runtime library discovery rather than ELF-stylerpath. Emitting-Wl,-rpathfor z/OS causes a linker error. The caller setsLIBPATHat runtime instead.Cross-compilation
Cross-compilation from a Linux host is driven via
PYO3_CONFIG_FILE:Testing
Tested by cross-compiling
pydantic-coreandwatchfilesfor z/OS from a Linux LoP machine, withcargo check --target s390x-ibm-zospassing. Full link test pending z/OS server availability.Note on
target-lexiconOperatingSystem::Zosis present intarget-lexiconmain but not yet in the 0.13.x release. This PR includes aCargo.tomlpatch pointing totarget-lexiconmain; oncetarget-lexiconcuts a release withZos, the patch can be removed.