[Python-Dev] Why is python linked with c++?
Martin v. Löwis
martin@v.loewis.de
09 Jul 2003 07:40:47 +0200
Neil Schemenauer <nas-python@python.ca> writes:
> The current configure script sets LINKCC to CXX if CXX is set.
No, it also checks if you can link C++ programs with CC, and uses CC
to link if you can:
# LINKCC is the command that links the python executable -- default is $(CC).
# If CXX is set, and if it is needed to link a main function that was
# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
# python might then depend on the C++ runtime
# This is altered for AIX in order to build the export list before
# linking.
AC_SUBST(LINKCC)
AC_MSG_CHECKING(LINKCC)
if test -z "$LINKCC"
then
if test -z "$CXX"; then
LINKCC="\$(PURIFY) \$(CC)"
else
echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
$CXX -c conftest.$ac_ext 2>&5
if $CC -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
&& test -s conftest$ac_exeext && ./conftest$ac_exeext
then
LINKCC="\$(PURIFY) \$(CC)"
else
LINKCC="\$(PURIFY) \$(CXX)"
fi
rm -fr conftest*
fi
case $ac_sys_system in
AIX*)
exp_extra="\"\""
if test $ac_sys_release -ge 5 -o \
$ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
exp_extra="."
fi
LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
dgux*)
LINKCC="LD_RUN_PATH=$libdir $LINKCC";;
Monterey64*)
LINKCC="$LINKCC -L/usr/lib/ia64l64";;
esac
fi
AC_MSG_RESULT($LINKCC)
This change was needed to support various C++ compilers that would
fail to link Modules/ccpython.cc with the C compiler.
Regards,
Martin