pypa / distutils

distutils as found in cpython

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failing to build c packages on z/OS

pitmanst opened this issue · comments

Hi. Currently, distutils/setuptools does not provide the ability to build C/C++ packages on z/OS Unix System Services, and there's a few changes / additions that are needed to make it work:

  1. On z/OS, to use the functions provided by a shared library you need to specify the side deck file that is created with the shared library. Without this, you'll hit an error declaring all of these functions unresolved. For example, trying to build the PyPI package hello-c-extension will hit the following errors when trying to pip install it:
IEW2456E 9207 SYMBOL PyModule_Create2 UNRESOLVED.  MEMBER COULD NOT BE INCLUDED
         FROM THE DESIGNATED CALL LIBRARY.
IEW2456E 9207 SYMBOL PyLong_FromLong UNRESOLVED.  MEMBER COULD NOT BE INCLUDED
         FROM THE DESIGNATED CALL LIBRARY.
IEW2665S 40FF MODULE *NULL*  IS NON-EXECUTABLE AND WAS NOT SAVED BECAUSE
         STORENX=NEVER.
  1. There's multiple different supported c compilers available on z/OS, but none are installed by default. Along side this, the different compilers accept different flags / different styles of flags. For example:

To specify changing the c standard being used to c99:
IBM z/OS XL C/C++: -qlanglvl=c99
IBM XL C/C++ V2.4.1 for z/OS 2.4 and 2.5: -qlanglvl=c99 or -std=c99
IBM Open XL C/C++ 1.1 for z/OS and IBM C/C++ For Open Enterprise Languages on z/OS 2.0: -std=c99

So the flags for each compiler need to be set depending on which compiler the user is attempting to use.

  1. On z/OS, there's two ways that a user can install Python on their system. The first is through an installer to the predefined/prefixed location. The second method is simply a pax archive, which can be extracted and used at any location. In the former, there's no issue. In the latter, distutils will pick up the expected installation path rather than where it actually is.

I do have a PR which fixes these issues which I'll be creating shortly.