| 1 | Subject: AIX - Misc/AIX-NOTES | 
|---|
| 2 | From: Vladimir Marangozov <Vladimir.Marangozov@imag.fr> | 
|---|
| 3 | To: guido@CNRI.Reston.Va.US (Guido van Rossum) | 
|---|
| 4 | Date: Wed, 6 Aug 1997 11:41:00 +0200 (EET) | 
|---|
| 5 |  | 
|---|
| 6 | ============================================================================== | 
|---|
| 7 | COMPILER INFORMATION | 
|---|
| 8 | ------------------------------------------------------------------------------ | 
|---|
| 9 |  | 
|---|
| 10 | (1) A problem has been reported with "make test" failing because of "weird | 
|---|
| 11 | indentation."  Searching the comp.lang.python newsgroup reveals several | 
|---|
| 12 | threads on this subject, and it seems to be a compiler bug in an old | 
|---|
| 13 | version of the AIX CC compiler.  However, the compiler/OS combination | 
|---|
| 14 | which has this problem is not identified.  In preparation for the 1.4 | 
|---|
| 15 | release, Vladimir Marangozov (Vladimir.Marangozov@imag.fr) and Manus Hand | 
|---|
| 16 | (mhand@csn.net) reported no such troubles for the following compilers and | 
|---|
| 17 | operating system versions: | 
|---|
| 18 | AIX C compiler version 3.1.2 on AIX 4.1.3 and AIX 4.1.4 | 
|---|
| 19 | AIX C compiler version 1.3.0 on AIX 3.2.5 | 
|---|
| 20 | If you have this problem, please report the compiler/OS version. | 
|---|
| 21 |  | 
|---|
| 22 | (2) Stefan Esser (se@MI.Uni-Koeln.DE), in work done to compile Python | 
|---|
| 23 | 1.0.0 on AIX 3.2.4, reports that AIX compilers don't like the LANG | 
|---|
| 24 | environment varaiable set to European locales.  This makes the compiler | 
|---|
| 25 | generate floating point constants using "," as the decimal separator, | 
|---|
| 26 | which the assembler doesn't understand (or perhaps it is the other way | 
|---|
| 27 | around, with the assembler expecting, but not getting "," in float | 
|---|
| 28 | numbers).  "LANG=C; export LANG" solves the problem, as does | 
|---|
| 29 | "LANG=C $(MAKE) ..." in the master Makefile. | 
|---|
| 30 |  | 
|---|
| 31 | (3) The cc (or xlc) compiler considers "Python/ceval.c" too complex to | 
|---|
| 32 | optimize, except when invoked with "-qmaxmem=4000" | 
|---|
| 33 |  | 
|---|
| 34 | (4) Some problems (due to _AIX not being #defined) when python 1.0.0 was | 
|---|
| 35 | compiled using 'gcc -ansi' were reported by Stefan Esser, but were not | 
|---|
| 36 | investigated. | 
|---|
| 37 |  | 
|---|
| 38 | (5) The cc compiler has internal variables named "__abs" and "__div".  These | 
|---|
| 39 | names are reserved and may not be used as program variables in compiled | 
|---|
| 40 | source.  (As an anecdote in support of this, the implementation of | 
|---|
| 41 | Python/operator.c had this problem in the 1.4 beta releases, and the | 
|---|
| 42 | solution was to re#define some core-source variables having these names, | 
|---|
| 43 | to give these python variables different names if the build is being done | 
|---|
| 44 | on AIX.) | 
|---|
| 45 |  | 
|---|
| 46 | (6) As mentioned in the README, builds done immediately after previous builds | 
|---|
| 47 | (without "make clean" or "make clobber") sometimes fail for mysterious | 
|---|
| 48 | reasons.  There are some unpredictable results when the configuration | 
|---|
| 49 | is changed (that is, if you "configure" with different parameters) or if | 
|---|
| 50 | intermediate changes are made to some files.  Performing "make clean" or | 
|---|
| 51 | "make clobber" resolves the problems. | 
|---|
| 52 |  | 
|---|
| 53 | ============================================================================== | 
|---|
| 54 | THREAD SUPPORT | 
|---|
| 55 | ------------------------------------------------------------------------------ | 
|---|
| 56 |  | 
|---|
| 57 | As of AIX version 4, there are two (incompatible) types of pthreads on AIX: | 
|---|
| 58 | a)  AIX DCE pthreads (on AIX 3.2.5) | 
|---|
| 59 | b)  AIX 4 pthreads (on AIX 4.1 and up) | 
|---|
| 60 | Support has been added to Python to handle the distinction. | 
|---|
| 61 |  | 
|---|
| 62 | The cc and gcc compilers do not initialize pthreads properly. The only | 
|---|
| 63 | compilers that can initialize pthreads properly are IBM *_r* compilers, | 
|---|
| 64 | which use the crt0_r.o module, and which invoke ld with the reentrant | 
|---|
| 65 | version of libc (libc_r). | 
|---|
| 66 |  | 
|---|
| 67 | In order to enable thread support, follow these steps: | 
|---|
| 68 | 1.  Uncomment the thread module in Modules/Setup | 
|---|
| 69 | 2.  configure --without-gcc --with-thread ... | 
|---|
| 70 | 3.  make CC="cc_r" OPT="-O -qmaxmem=4000" | 
|---|
| 71 |  | 
|---|
| 72 | For example, to make with both threads and readline, use: | 
|---|
| 73 | ./configure --without-gcc --with-thread --with-readline=/usr/local/lib | 
|---|
| 74 | make CC=cc_r OPT="-O2 -qmaxmem=4000" | 
|---|
| 75 |  | 
|---|
| 76 | If the "make" which is used ignores the "CC=cc_r" directive, one could alias | 
|---|
| 77 | the cc command to cc_r (for example, in C-shell, perform an "alias cc cc_r"). | 
|---|
| 78 |  | 
|---|
| 79 | Vladimir Marangozov (Vladimir.Marangozov@imag.fr) provided this information, | 
|---|
| 80 | and he reports that a cc_r build initializes threads properly and that all | 
|---|
| 81 | demos on threads run okay with cc_r. | 
|---|
| 82 |  | 
|---|
| 83 | ============================================================================== | 
|---|
| 84 | SHARED LIBRARY SUPPORT | 
|---|
| 85 | ------------------------------------------------------------------------------ | 
|---|
| 86 |  | 
|---|
| 87 | AIX shared library support was added to Python in the 1.4 release by Manus | 
|---|
| 88 | Hand (mhand@csn.net) and Vladimir Marangozov (Vladimir.Marangozov@imag.fr). | 
|---|
| 89 |  | 
|---|
| 90 | Python modules may now be built as shared libraries on AIX using the normal | 
|---|
| 91 | process of uncommenting the "*shared*" line in Modules/Setup before the | 
|---|
| 92 | build. | 
|---|
| 93 |  | 
|---|
| 94 | AIX shared libraries require that an "export" and "import" file be provided | 
|---|
| 95 | at compile time to list all extern symbols which may be shared between | 
|---|
| 96 | modules.  The "export" file (named python.exp) for the modules and the | 
|---|
| 97 | libraries that belong to the Python core is created by the "makexp_aix" | 
|---|
| 98 | script before performing the link of the python binary. It lists all global | 
|---|
| 99 | symbols (exported during the link) of the modules and the libraries that | 
|---|
| 100 | make up the python executable. | 
|---|
| 101 |  | 
|---|
| 102 | When shared library modules (.so files) are made, a second shell script | 
|---|
| 103 | is invoked.  This script is named "ld_so_aix" and is also provided with | 
|---|
| 104 | the distribution in the Modules subdirectory.  This script acts as an "ld" | 
|---|
| 105 | wrapper which hides the explicit management of "export" and "import" files; | 
|---|
| 106 | it adds the appropriate arguments (in the appropriate order) to the link | 
|---|
| 107 | command that creates the shared module.  Among other things, it specifies | 
|---|
| 108 | that the "python.exp" file is an "import" file for the shared module. | 
|---|
| 109 |  | 
|---|
| 110 | At the time of this writing, neither the python.exp file nor the makexp_aix | 
|---|
| 111 | or ld_so_aix scripts are installed by the make procedure, so you should | 
|---|
| 112 | remember to keep these and/or copy them to a different location for | 
|---|
| 113 | safekeeping if you wish to use them to add shared extension modules to | 
|---|
| 114 | python.  However, if the make process has been updated since this writing, | 
|---|
| 115 | these files MAY have been installed for you during the make by the | 
|---|
| 116 | LIBAINSTALL rule, in which case the need to make safe copies is obviated. | 
|---|
| 117 |  | 
|---|
| 118 | If you wish to add a shared extension module to the language, you would follow | 
|---|
| 119 | the steps given in the example below (the example adds the shared extension | 
|---|
| 120 | module "spam" to python): | 
|---|
| 121 | 1.  Make sure that "ld_so_aix" and "makexp_aix" are in your path. | 
|---|
| 122 | 2.  The "python.exp" file should be in the current directory. | 
|---|
| 123 | 3.  Issue the following commands or include them in your Makefile: | 
|---|
| 124 | cc -c spammodule.c | 
|---|
| 125 | ld_so_aix cc spammodule.o -o spammodule.so | 
|---|
| 126 |  | 
|---|
| 127 | For more detailed information on the shared library support, examine the | 
|---|
| 128 | contents of the "ld_so_aix" and "makexp_aix" scripts or refer to the AIX | 
|---|
| 129 | documentation. | 
|---|
| 130 |  | 
|---|
| 131 | NOTE:  If the extension module is written in C++ and contains templates, | 
|---|
| 132 | an alternative to "ld_so_aix" is the /usr/lpp/xlC/bin/makeC++SharedLib | 
|---|
| 133 | script.  Chris Myers (myers@TC.Cornell.EDU) reports that ld_so_aix | 
|---|
| 134 | works well for some C++ (including the C++ that is generated | 
|---|
| 135 | automatically by the Python SWIG package [SWIG can be found at | 
|---|
| 136 | http://www.cs.utah.edu/~beazley/SWIG/swig.html]).  However, it is not | 
|---|
| 137 | known whether makeC++SharedLib can be used as a complete substitute | 
|---|
| 138 | for ld_so_aix. | 
|---|
| 139 |  | 
|---|
| 140 | According to Gary Hook from IBM, the format of the export file changed | 
|---|
| 141 | in AIX 4.2.  For AIX 4.2 and later, a period "." is required on the | 
|---|
| 142 | first line after "#!".  If python crashes while importing a shared | 
|---|
| 143 | library, you can try modifying the LINKCC variable in the Makefile. | 
|---|
| 144 | It probably looks like this: | 
|---|
| 145 |  | 
|---|
| 146 | LINKCC=     $(srcdir)/Modules/makexp_aix Modules/python.exp \"\" $(LIBRARY); $(PURIFY) $(CXX) | 
|---|
| 147 |  | 
|---|
| 148 | You should modify the \"\" to be a period: | 
|---|
| 149 |  | 
|---|
| 150 | LINKCC=     $(srcdir)/Modules/makexp_aix Modules/python.exp . $(LIBRARY); $(PURIFY) $(CXX) | 
|---|
| 151 |  | 
|---|
| 152 | Using a period fixed the problem in the snake farm.  YMMV. | 
|---|
| 153 | This fix has been incorporated into Python 2.3. | 
|---|
| 154 |  | 
|---|
| 155 | ============================================================================== | 
|---|