Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,7 @@ clean: pycremoval
-rm -f Lib/lib2to3/*Grammar*.pickle
-rm -f Programs/_testembed Programs/_freeze_importlib
-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
-rm -rf build/run_ifelse_cvs
-rm -f Include/pydtrace_probes.h
-rm -f profile-gen-stamp

Expand Down
10 changes: 10 additions & 0 deletions Misc/NEWS.d/next/Build/2019-03-19-10-35-38.bpo-36361.WINBB9.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
When cross-compiling and the ``CONFIG_SITE`` environment variable is unset
or empty, ``configure`` copies the executables, results of the build of the
AC_RUN_IFELSE test programs in configure.ac, to the ``build/run_ifelse_cvs``
directory. The ``Misc/build_config_site.sh`` script may be run then to
create a config.site file when invoked with one of the parameters as a path
to a shell script that transfers an executable to the platform, target of
the cross-compilation, and runs it on this platform. A second run of
'configure' with the CONFIG_SITE environment variable set to the
**absolute** path of this config.site file allows configuring the Python
build with the correct cache values for this platform.
114 changes: 114 additions & 0 deletions Misc/build_config_site.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#! /bin/sh
#
# Build a config.site file using the executables created in the
# 'build/run_ifelse_cvs' directory by configure when cross-compiling.
#
# The first parameter must be a shell script that takes an executable file
# pathname as its only parameter. The script uploads the executable and runs it
# on the host machine, target of the cross-compilation.
#
# The config.site file is a shell script that sets the correct cache values
# for the cross-compilation. It must be used in a second run of configure
# where the environment variable 'CONFIG_SITE' is set to the config.site
# **absolute pathname** (autoconf manual, section 15.8 Setting Site Defaults).

usage ()
{
test -n "$1" && { echo $1; echo; } 1>&2

echo "usage: $pgm push_exec targetdir config_site

push_exec Path of the shell script used for uploading the executable on
the machine, target of the cross-compilation, and that exits with
the exit status of running this executable on this machine.

targetdir Directory (possibly out of source) where python is being
cross compiled. The executables and their actions generated by
configure are located in sub-directories of the
build/run_ifelse_cvs sub-directory of 'targetdir'.

config_site Path of the config.site file generated by $pgm.
" 1>&2
exit 2
}

# List directory content sorted by modification time, oldest first.
list_dir_mtime()
{
local list=""
for arg in `ls -t $1`
do
list="$arg $list"
done
echo "$list"
}

# Initialize variables.
pgm=${0##*/}
test "$#" != 3 && usage
test ! -f $1 && usage "error: file '$1' does not exist"
push_exec=$1
build_dir=$2/build/run_ifelse_cvs
test ! -d $build_dir && usage "error: directory '$build_dir' does not exist"
config_site=$3

# First write the list of cache values to config.site.
cv_list=`echo "$(ls $build_dir)" | sed -n -e 's/^\(.*\)$/# \1/p'`
cat << EOF > $config_site
# This script has been generated by $pgm from the following
# list of cache values handled by AC_RUN_IFELSE macros as found
# in configure.ac:
#
$cv_list
#
# The list may be used to verify that this config.site file has not become
# stale in the case of addition of new cache values in configure.ac.
#
# The script sets the following cache values that have been found different
# from the pessimistic default values set by AC_RUN_IFELSE, after running the
# executable on the target machine:

EOF

# The tests for the cache variables are run in the same chronological order
# as those run by configure.
ac_cv_pthread_is_default=no
for cv in `list_dir_mtime $build_dir`; do
echo -n "$cv... "

# Do not run the tests for the cache variables that are not tested
# by configure when the ac_cv_pthread_is_default value as been found
# as 'yes'.
if test $ac_cv_pthread_is_default = yes; then
case $cv in
ac_cv_kpthread|ac_cv_kthread|ac_cv_pthread)
echo "no change, ac_cv_pthread_is_default=$ac_cv_pthread_is_default"
continue;;
esac
fi

# Run the test.
result=FALSE
if test -f $build_dir/$cv/a.out && \
`/bin/sh $push_exec $build_dir/$cv/a.out`; then
result=TRUE
fi

# Add the cache value to config.site if the test result is different from
# the content of ACTION-IF-CROSS-COMPILING.
if cmp -s $build_dir/$cv/$result $build_dir/$cv/CROSS-COMPILING; then
echo "no change"
else
# Check that the result can be run as a script before adding
# it to config.site.
if `/usr/bin/env -i /bin/sh $build_dir/$cv/$result`; then
echo "using ACTION-IF-$result"
cat $build_dir/$cv/$result >> $config_site
if test $cv = ac_cv_pthread_is_default -a $result = TRUE; then
ac_cv_pthread_is_default=yes
fi
else
echo "error: invalid shell statements in ACTION-IF-$result" 1>&2
fi
fi
done
1 change: 1 addition & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,4 @@ AS_VAR_IF([$1], [""], [$5], [$4])dnl

m4_include([m4/ax_c_float_words_bigendian.m4])
m4_include([m4/ax_check_openssl.m4])
m4_include([m4/ac_run_ifelse.m4])
Loading