blob: 4f82a81d4a203ec7b2bb6e21b52608dcda8a9693 [file] [log] [blame]
Guido van Rossumfb842551997-08-06 23:42:07 +00001Subject: AIX - Misc/AIX-NOTES
2From: Vladimir Marangozov <Vladimir.Marangozov@imag.fr>
3To: guido@CNRI.Reston.Va.US (Guido van Rossum)
4Date: Wed, 6 Aug 1997 11:41:00 +0200 (EET)
Guido van Rossum9dc78331996-08-09 14:38:40 +00005
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 seperator,
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
Guido van Rossumfb842551997-08-06 23:42:07 +000057As of AIX version 4, there are two (incompatible) types of pthreads on AIX:
Guido van Rossum9dc78331996-08-09 14:38:40 +000058 a) AIX DCE pthreads (on AIX 3.2.5)
59 b) AIX 4 pthreads (on AIX 4.1 and up)
60Support has been added to Python to handle the distinction.
61
62The cc and gcc compilers do not initialize pthreads properly. The only
63compilers that can initialize pthreads properly are IBM *_r* compilers,
64which use the crt0_r.o module, and which invoke ld with the reentrant
65version of libc (libc_r).
66
67In 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
72For 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
76If the "make" which is used ignores the "CC=cc_r" directive, one could alias
77the cc command to cc_r (for example, in C-shell, perform an "alias cc cc_r").
78
79Vladimir Marangozov (Vladimir.Marangozov@imag.fr) provided this information,
80and he reports that a cc_r build initializes threads properly and that all
81demos on threads run okay with cc_r.
82
83==============================================================================
84 SHARED LIBRARY SUPPORT
85------------------------------------------------------------------------------
86
87AIX shared library support was added to Python in the 1.4 release by Manus
88Hand (mhand@csn.net) and Vladimir Marangozov (Vladimir.Marangozov@imag.fr).
89
Guido van Rossumbed266a1996-10-22 22:08:02 +000090Python modules may now be built as shared libraries on AIX using the normal
Fred Drakecf3bc8c2000-10-26 17:07:40 +000091process of uncommenting the "*shared*" line in Modules/Setup before the
Guido van Rossumfb842551997-08-06 23:42:07 +000092build.
Guido van Rossum9dc78331996-08-09 14:38:40 +000093
94AIX shared libraries require that an "export" and "import" file be provided
95at compile time to list all extern symbols which may be shared between
Guido van Rossumfb842551997-08-06 23:42:07 +000096modules. The "export" file (named python.exp) for the modules and the
97libraries that belong to the Python core is created by the "makexp_aix"
98script before performing the link of the python binary. It lists all global
99symbols (exported during the link) of the modules and the libraries that
100make up the python executable.
Guido van Rossum9dc78331996-08-09 14:38:40 +0000101
102When shared library modules (.so files) are made, a second shell script
103is invoked. This script is named "ld_so_aix" and is also provided with
104the distribution in the Modules subdirectory. This script acts as an "ld"
105wrapper which hides the explicit management of "export" and "import" files;
106it adds the appropriate arguments (in the appropriate order) to the link
107command that creates the shared module. Among other things, it specifies
108that the "python.exp" file is an "import" file for the shared module.
109
Guido van Rossum9dc78331996-08-09 14:38:40 +0000110At the time of this writing, neither the python.exp file nor the makexp_aix
111or ld_so_aix scripts are installed by the make procedure, so you should
112remember to keep these and/or copy them to a different location for
113safekeeping if you wish to use them to add shared extension modules to
114python. However, if the make process has been updated since this writing,
115these files MAY have been installed for you during the make by the
116LIBAINSTALL rule, in which case the need to make safe copies is obviated.
117
118If you wish to add a shared extension module to the language, you would follow
119the steps given in the example below (the example adds the shared extension
120module "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
127For more detailed information on the shared library support, examine the
128contents of the "ld_so_aix" and "makexp_aix" scripts or refer to the AIX
129documentation.
130
Guido van Rossumbed266a1996-10-22 22:08:02 +0000131NOTE: 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
Neal Norwitz6c54ef62003-02-02 17:10:04 +0000140According to Gary Hook from IBM, the format of the export file changed
141in AIX 4.2. For AIX 4.2 and later, a period "." is required on the
142first line after "#!". If python crashes while importing a shared
143library, you can try modifying the LINKCC variable in the Makefile.
144It probably looks like this:
145
146 LINKCC= $(srcdir)/Modules/makexp_aix Modules/python.exp \"\" $(LIBRARY); $(PURIFY) $(CXX)
147
148You should modify the \"\" to be a period:
149
150 LINKCC= $(srcdir)/Modules/makexp_aix Modules/python.exp . $(LIBRARY); $(PURIFY) $(CXX)
151
152Using a period fixed the problem in the snake farm. YMMV.
153After testing with different versions of AIX, a fix should
154be checked in. Hopefully, this fix be incorporated into Python 2.3.
155
Guido van Rossum9dc78331996-08-09 14:38:40 +0000156==============================================================================