[Date Prev][Date Next] [Chronological] [Thread] [Top]

AIX threads


AIX 4.2 sucks even more. In order to use threads, you have to use
cc_r instead of cc. Not cc indicates any error when compiling
and/or linking MT programs, the executables just fail to create
threads with mysterious error codes or even dump core (e.g. on 
calls to pthread_attr_init). There is no flag or something else
to make cc behave like cc_r. And the man pages don't even mention
the existence of cc_r, unless of course you know that this command
exists. Duh!

Trying to compile MT programs are with gcc/egcs made me nearly
biting bits off my keyboard. Fortunately, the AIX FAQ provides a 
recipe for gcc 2.7.x, which is probably also applicable to 
2.8.x and egcs. I have yet to verify this. A question on the
egcs-help list is pending whether there exists a simpler solution.

Unfortunately, Netscape ate my mail (from work) with the references,
so i have to type this from memory: Compile programs normally using
gcc and the _THREAD_SAFE symbol as defined in portable.h, but link
with the command

gcc <flags> -nostartupfiles /usr/lib/crt1_r.o <objfiles> <libs>\
  -lpthreads -lc_r

It is important that crt1_r.o is the first file before any other
object file or library on the command line.
Some other standard libraries have _r versions too, but i can't
remember them right now. I'll go on vacancies tomorrow, you'll
get a complete reference and hopefully a working patch in january.
A quick glance over the autoconf info files didn't tell me where
the information whether gcc is in use is stored, though this is
certainly tested. If you can help me out here...