Compiling R (1.3.0) on AIX (4.3) fails (PR#1034)
Thomas J Vogels writes:
Excerpt from email by Kurt Hornik:
On second thought: the comment in tkConfig.sh says # String to pass to linker to pick up the Tk library from its # installed directory. TK_LIB_SPEC='@TK_LIB_SPEC@' so maybe this assumes to be called by ld directly ...
I think you're right with this assumption, but sadly, the current devel release for tcl/tk 8.4a2 is broken--even the maintainers of tcl/tk don't know how they want to handle TK_LIB_SPEC, TK_LIBS and friends! When I tried to compile Tk it failed for 'wish'. I'll check out how to file bug reports against tcl/tk...
[Well getting AIX right is not that easy. Fortunately, R has Tom Vogels to help ...]
What happens if we omit TK_LIB_SPEC from TCLTK_LIBS?
hell breaks loose. TK_LIB_SPEC contains '-bI/some/path/libtk8.3.exp' which is needed badly when linking on AIX.
Argh. After sinking some more time into this ... here's what happens.
Assuming that both tclConfig.sh and tkConfig.sh are found, we do
TCLTL_LIBS="${TCL_LIB_SPEC} ${TK_LIB_SPEC} ${TK_LIBS}"
Using tcl8.4a1 and tk8.4a1 one gets for a shared build on AIX from the
TclTk configure code:
if test "$using_gcc" = "yes" ; then
TCL_BUILD_LIB_SPEC="-Wl,-bI:`pwd`/${TCL_BUILD_EXP_FILE} -L`pwd`"
TCL_LIB_SPEC="-Wl,-bI:${exec_prefix}/lib/${TCL_EXP_FILE} -L`pwd`"
... which is wrong, BTW: TCL_LIB_SPEC should refer to
${exec_prefix}/lib not `pwd` ...
You mean in the `-L' part? Certainly correct ...
else
TCL_BUILD_LIB_SPEC="-bI:`pwd`/${TCL_BUILD_EXP_FILE}"
TCL_LIB_SPEC="-bI:${exec_prefix}/lib/${TCL_EXP_FILE}"
fi
TK_LIB_SPEC="-bI:${exec_prefix}/lib/${TK_EXP_FILE}"
So the TclTk maintainers in their infinite wisdom have caught the gcc
case for tcl but not for tk.
That would explain why Tcl/Tk compiles with Aix's cc but not gcc.
Yep.
I therefore suggest the following.
* Can you try replacing
TCLTK_LIBS="${TCLTK_LIBS} ${TK_LIB_SPEC} ${TK_LIBS}"
in m4/R.m4 by
TCLTK_LIBS="${TCLTK_LIBS} ${wl}${TK_LIB_SPEC} ${TK_LIBS}"
and see if that works? (You will have to configure using
--enable-maintainer-mode to get configure rebuilt. Or, you could
simply edit configure.) By `works' I mean under both gcc and cc.
I changed configure since I don't have autoconf etc. installed. Your solution works when compiling with gcc! I haven't tried cc yet but will do so tomorrow.
Ok, great. My assumption/hope is that this should work ...
* If so, this is the short-term fix we could go for. If not, we may need to infer wl for non-gcc from libtool, which is doable. * It may be useful to report the discrepancy to the TclTk maintainers.
I'll try to compile tcl and tk with gcc and send in reports.
* Provided they fix the problem, we need to think about better strategies. (Something like if wl is not the empty string and TK_LIB_SPEC does not start with it then add it as prefix.) But let us not worry about this now.
Do you really want to go this way? Is AIX the only OS where you can run into this kind of trouble? If so, why not add a compilation of a little test program in configure in case you have os==AIX, that would use the same flags that you'll use in library/src/tcltk.c? If that fails, it's flagged early on and directly points to the tcl/tk installation (and not to R).
I think I want to go this way. Reason: the current situation is a mixture of an R bug and a Tk inconsistency. The R bug is that I had not realized that the LIB_SPECs are meant as flags to ld. The Tk problem is that this is not true. The whole thing is a bit tricky, and it might be interesting to see how e.g. GNOME projects deal with this in their -config scripts. As this is hidden inside libtool could you maybe try compiling libxml2 on your AIX system and see what xml2-config --libs does? Also, what does ./libtool --config | grep ^wl give for configuration with native cc? In general, the portable way would be to have package config scripts use $wl or alike. But that will not do in general: someone could have gcc but a native C++ compiler and $wl might be different between these ... -k -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._