From: Jarkko Hietaniemi Date: Fri, 8 Oct 1999 13:51:34 +0000 (+0000) Subject: The second cut at AIX C++ extension troubles. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c88be79fccb80fda2b9ad01fb180cda4529bca38;p=p5sagit%2Fp5-mst-13.2.git The second cut at AIX C++ extension troubles. p4raw-id: //depot/cfgperl@4318 --- diff --git a/ext/DynaLoader/dl_aix.xs b/ext/DynaLoader/dl_aix.xs index e3a4113..798ed58 100644 --- a/ext/DynaLoader/dl_aix.xs +++ b/ext/DynaLoader/dl_aix.xs @@ -33,10 +33,12 @@ * of load() and unload() from libC and libC_r need to be used, * otherwise statics in the extensions won't get initialized right. * -- Stephanie Beals */ -#ifdef USE_xlC /* The define comes, when it comes, from hints/aix.pl. */ -# define LOAD loadAndInitialize +#ifdef USE_libC /* The define comes, when it comes, from hints/aix.pl. */ +# define LOAD loadAndInit # define UNLOAD terminateAndUnload -# include +# ifdef USE_load_h +# include +# endif #else # define LOAD load # define UNLOAD unload diff --git a/ext/DynaLoader/hints/aix.pl b/ext/DynaLoader/hints/aix.pl index e972bfe..4225979 100644 --- a/ext/DynaLoader/hints/aix.pl +++ b/ext/DynaLoader/hints/aix.pl @@ -1,12 +1,10 @@ # See dl_aix.xs for details. use Config; if ($Config{libs} =~ /-lC/ && -f '/lib/libC.a') { - $self->{CCFLAGS} = $Config{ccflags} . ' -DUSE_xlC'; + $self->{CCFLAGS} = $Config{ccflags} . ' -DUSE_libC'; if (-f '/usr/ibmcxx/include/load.h') { - $self->{CCFLAGS} .= ' -I/usr/ibmcxx/include'; + $self->{CCFLAGS} .= ' -I/usr/ibmcxx/include -DUSE_load_h'; } elsif (-f '/usr/lpp/xlC/include/load.h') { - $self->{CCFLAGS} .= ' -I/usr/lpp/xlC/include'; - } else { - # Hoping that will be found somehow. + $self->{CCFLAGS} .= ' -I/usr/lpp/xlC/include -DUSE_load_h'; } } diff --git a/hints/aix.sh b/hints/aix.sh index a8ae6d5..bd1d859 100644 --- a/hints/aix.sh +++ b/hints/aix.sh @@ -154,29 +154,24 @@ EOM ;; esac - # The libC_r is to be preferred over the libc_r because otherwise - # extensions written in C++ using statics won't be initialized right; - # see ext/DynaLoader/dl_aix.xs. - if test -f /lib/libC_r.a; then - # C_rify libwanted. - set `echo X "$libswanted "| sed -e 's/ C / pthreads C_r /'` - shift - libswanted="$*" - # C_rify lddlflags. - set `echo X "$lddlflags"| sed -e 's/ -lc$/ -lpthreads -lC_r/'` - shift - lddlflags="$*" - else - # The POSIX threads library and the re-entrant libc to libswanted. - set `echo X "$libswanted "| sed -e 's/ c / pthreads c_r /'` - shift - libswanted="$*" - - # The POSIX threads library and the re-entrant libc to lddflags. - set `echo X "$lddlflags"| sed -e 's/ -lc$/ -lpthreads -lc_r/'` - shift - lddlflags="$*" - fi + # c_rify libswanted. + set `echo X "$libswanted "| sed -e 's/ \([cC]\) / \1_r /g'` + shift + libswanted="$*" + # c_rify lddlflags. + set `echo X "$lddlflags "| sed -e 's/ \(-l[cC]\) / \1_r /g'` + shift + lddlflags="$*" + + # Insert pthreads to libswanted, before any libc or libC. + set `echo X "$libswanted "| sed -e 's/ \([cC]\) / pthreads \1 /'` + shift + libswanted="$*" + # Insert pthreads to lddlflags, before any libc or libC. + set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]\) / -lpthreads \1 /'` + shift + lddlflags="$*" + ;; esac EOCBU @@ -205,7 +200,7 @@ EOM # (nothing strange shows up in $ldflags even in hexdump; # so it may be something in the shell, instead?) # Try it out: just uncomment the below line and rerun Configure: -# echo >&4 "AIX $ldflags mystery" ; exit 1 +# echo >&4 "AIX 4.3.1.0 $ldflags mystery" ; exit 1 # Just don't ask me how AIX does it. # Therefore the line re-evaluating ldflags: it seems to bypass # the whatever it was that AIX managed to break. --jhi @@ -230,11 +225,34 @@ $define|true|[yY]*) esac EOCBU -# If the C++ libraries, libC, are available we will prefer them over -# the vanilla libc, because the libC contain loadAndInitialize() and +# If the C++ libraries, libC and libC_r, are available we will prefer them +# over the vanilla libc, because the libC contain loadAndInit() and # terminateAndUnload() which work correctly with C++ statics while libc # load() and unload() do not. See ext/DynaLoader/dl_aix.xs. -# The c_r-to-C_r switch is done by usethreads.cbu. -test -f /lib/libC.a && libswanted=`$echo " $libswanted "|sed -e 's/ c / C /'` +# The C-to-C_r switch is done by usethreads.cbu, if needed. +if test -f /lib/libC.a; then + case "$cc" in + xlC*) + # Cify libswanted for xlC. + set `echo X "$libswanted "| sed -e 's/ c / C /'` + shift + libswanted="$*" + # Cify lddlflags for xlC. + set `echo X "$lddlflags "| sed -e 's/ -lc / -lC /'` + shift + lddlflags="$*" + ;; + *) + # Cify libswanted for non-xlC. + set `echo X "$libswanted "| sed -e 's/ c / c C /'` + shift + libswanted="$*" + # Cify lddlflags for non-xlC. + set `echo X "$lddlflags "| sed -e 's/ -lc / -lc -lC /'` + shift + lddlflags="$*" + ;; + esac +fi # EOF