classification
Title: cross-compilation support for python build
Type: enhancement Stage: patch review
Components: Cross-Build Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tarek Nosy List: Arfrever, BreamoreBoy, David.Kern, Greg.Hellings, Ray.Donnelly, WhiteTiger, ambrop7, devurandom, doko, eric.araujo, eudoxos, kalev, marqvar, python-dev, rpetrov, tarek, vapier, wrobell
Priority: normal Keywords: needs review, patch

Created on 2008-09-01 21:49 by rpetrov, last changed 2013-02-06 13:27 by doko. This issue is now closed.

Files
File name Uploaded Description Edit
python-trunk-20100516-CROSS.patch rpetrov, 2010-05-16 12:09
python-trunk-20100626-CROSS.patch rpetrov, 2010-06-26 19:43
python-trunk-20100824-CROSS.patch rpetrov, 2010-08-24 11:22
python-2.7-20101112-CROSS.patch rpetrov, 2010-11-12 21:02
python-py3k-20101112-CROSS.patch rpetrov, 2010-11-12 21:03
python-2.7-20110126-CROSS.patch rpetrov, 2011-01-26 21:02
python-py3k-20110126-CROSS.patch rpetrov, 2011-01-26 21:05
python-py3k-20110407-CROSS.patch rpetrov, 2011-04-07 20:26 review
python-py3k-20110520-CROSS.patch rpetrov, 2011-05-19 22:07 review
python-py3k-20110825-CROSS.patch rpetrov, 2011-08-24 21:31 review
python-py3k-20120318-CROSS.patch rpetrov, 2012-03-18 10:13 review
python-py3k-20120318-CROSS-330a2.patch Ray.Donnelly, 2012-05-30 22:15 Patch updated to build against 3.3.0a2
python-py3k-20120607-CROSS.patch rpetrov, 2012-06-06 21:25 version for 3.3.0a4 review
py3k-20121004-CROSS.tgz rpetrov, 2012-10-06 00:13
log ambrop7, 2012-11-05 17:54
Messages (56)
msg72299 - (view) Author: Roumen Petrov (rpetrov) Date: 2008-09-01 21:49
This is minimal patch that add basic cross-compilation possibilities for
python build (configure script).

The patch add macro AC_CANONICAL_HOST.
This macro require files config.guess, config.sub. The patch don't
include them. You may obtain them from GNU automake tarbal.

As result of macro new variable $host ("host triplet":=cpu-verdor-os) is
used to detect so called "host system".

Since this is basic patch, detection of build system in native builds
based on $ac_sys_system and/or $ac_sys_release isn't replaced. This
detection isn't appropriate for cross-compilation environment as contain
values for "build system" and has to be replaces in addition by future
patches.


Also the patch posted in http://bugs.python.org/issue3718 (about
environment variable MACHDEP) isn't required for native builds, but will
help in case of cross-compilation.
msg77241 - (view) Author: Roumen Petrov (rpetrov) Date: 2008-12-07 18:55
The support for *-*mingw* host is enhanced to native msys environment.
This include check for device file /dev/ptmx. The MSYS report that file
exist. As the check is skipped on mingw* host os now cugwin environment
can be used too.

Also check libintl is skipped for mingw as the native build don't use it.
msg98223 - (view) Author: Roumen Petrov (rpetrov) Date: 2010-01-24 13:31
system python has to be at least revision 77704 (trunk)
msg105859 - (view) Author: Roumen Petrov (rpetrov) Date: 2010-05-16 12:09
As part of issue 8510 (update to autoconf2.65) configure script is modernized and most of  updates from patches attached to this issue now are in repository.

Starting from 16 may new patches will include in addition minimal updates of setup.py and Makefile.pre.in (moved from issue 3871) : 
- build modules with system python (from 3871).
- configure ctypes with same arguments as top configure (new)
msg108744 - (view) Author: Roumen Petrov (rpetrov) Date: 2010-06-26 19:43
- consistent platform detection in all methods from setup.py;
- readline libraries detected by configure script are used for setup.py : this could help to detect is more platform independent way if readline is linked with ncurses{w} library;
- ignore "friendly" search library paths : this is useless in case of cross-compilation . Also it is reported that those paths are not so "friendly" even in native builds. Note that with "friendly search library paths" python library search based on file suffix will find libraries system on build system if host system lack them.
msg110685 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-18 20:35
Could someone with knowledge of the Python build systems please comment on this, thanks.
msg114776 - (view) Author: Roumen Petrov (rpetrov) Date: 2010-08-24 11:22
It seems to me I forgot to upload version after updates in Lib/sysconfig.py from issue 7880.
I could not understand what Florent Xicluna (flox). I could not reproduce it. To me update abspath -> realpath is bogus and with reverted update of Lib/sysconfig.py test_sysconfig pass.

This patch is restored previous behaviour and now symlinked system python into cross build tree will behave as before i.e. as expected ;)
msg127140 - (view) Author: Roumen Petrov (rpetrov) Date: 2011-01-26 21:02
fixed patch failure on Parser/pgen.stamp
msg132102 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-03-25 15:26
I see some “fix for issue #NNN is bogus” in your patch: would you open separate bug reports for those?  A diff file is not a very useful way to report bugs or express opinions <wink>.
msg133252 - (view) Author: Roumen Petrov (rpetrov) Date: 2011-04-07 20:26
Uhh after some pseudo multiarch improvements previous patch fail. So new one is uploaded.
Also with this version cross-build won't build pgen$(EXEEXT).
msg136371 - (view) Author: Greg Hellings (Greg.Hellings) Date: 2011-05-20 13:15
Current patch errors with the following message:
gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -L/manual/lib -L/binary/lib -L/manual/lib -L/binary/lib  Parser/acceler.o Parser/grammar1.o Pars
er/listnode.o Parser/node.o Parser/parser.o Parser/bitset.o Parser/metagrammar.o Parser/firstsets.o Parser/grammar.o Parser/pgen.o Objects/obmalloc.o
Python/dynamic_annotations.o Python/mysnprintf.o Python/pyctype.o Parser/tokenizer_pgen.o Parser/printgrammar.o Parser/parsetok_pgen.o Parser/pgenmain
.o -lintl -lpthread  -o Parser/pgen.exe
./Grammar/Grammar ./Include/graminit.h ./Python/graminit.c
./Grammar/Grammar: line 18: single_input:: command not found
./Grammar/Grammar: line 18: simple_stmt: command not found
./Grammar/Grammar: line 18: compound_stmt: command not found
./Grammar/Grammar: line 19: syntax error near unexpected token `NEWLINE'
./Grammar/Grammar: line 19: `file_input: (NEWLINE | stmt)* ENDMARKER'
make: *** [Parser/pgen.stamp] Error 2
msg136772 - (view) Author: Roumen Petrov (rpetrov) Date: 2011-05-24 17:07
Greg, ensure correct configure script first as run commands autoheader and autoconf.
Updates to configure script are not in patch . The patch include updates to source configure.in and autoconf command will update "configure".
msg136885 - (view) Author: wrobell (wrobell) Date: 2011-05-25 18:49
Would it be possible to get list of steps required to test this patch?

1. hg clone
2. copy config.sub and config.guess?
3. autoreconf
4. configure...
5. make

What else?
msg136887 - (view) Author: Roumen Petrov (rpetrov) Date: 2011-05-25 19:42
Usually this is not a question for bug-tracking system . configure .. 
--host=.... will enter into cross-compilation mode. You could find more 
details into respective manual.

Roumen
msg136911 - (view) Author: wrobell (wrobell) Date: 2011-05-25 22:06
well, looking at the first comment, there is required more than simple read of the manual (i.e. missing config.guess/config.sub).

is anything else missing or required?
msg136962 - (view) Author: wrobell (wrobell) Date: 2011-05-26 13:54
as well, by default one experiences

checking for /dev/ptmx... not set
configure: error: set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling


the workaround:

1. create config.site file with the following lines

     ac_cv_file__dev_ptmx=no
     ac_cv_file__dev_ptc=no

2. run configure script as: CONFIG_SITE=config.site ./configure --host...

would be it ok if i add appropriate options for /dev/ptmx and /dev/ptc to this patch so we do not have to play with config.site file?
msg136963 - (view) Author: wrobell (wrobell) Date: 2011-05-26 13:55
next question. when starting compilation i am getting

In file included from Include/Python.h:50,
                 from ./Modules/python.c:3:
Include/pyport.h:257:13: error: #error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG"
make: *** [Modules/python.o] Error 1

how to deal with above?
msg136987 - (view) Author: wrobell (wrobell) Date: 2011-05-26 17:45
looking into configure.in the above fails due to following check

  AC_MSG_CHECKING(for %lld and %llu printf() format support)

the check compiles and tries to _run_ a bit of software to determine lld/llu support.

that of course fails (we are cross compiling). this is similar problem to ptmx/ptc problem (we do not know if host have support for ptmx/ptc).

i wonder if the following would be acceptable

1. if in cross compilation mode, the configure.in could load config-cross.site.
2. the config-cross.site would define variables for ptmx/ptc, long long format and other checks which consist of running code snippets
3. appropriate checks (i.e. ptmx/ptc, lld/llu) would not be run in cross compilation mode. variables from config-cross.site would be used instead.
4. it would be a developer responsibility to set appropriate values for his platform in config-cross.site file.

does above sound like a solution?
msg137001 - (view) Author: Roumen Petrov (rpetrov) Date: 2011-05-26 19:50
At least one is really would like to cross-compile.

worber, the config site has to look like (sample for linux i?86, i.e. intel 32 bit, as host platform)
=================================
ac_cv_little_endian_double=yes
ac_cv_broken_sem_getvalue=no
ac_cv_computed_gotos=yes
ac_cv_buggy_getaddrinfo=no
ac_cv_working_tzset=yes
#next line require fix typo in configure.in
ac_cv_pthread=yes
ac_cv_pthread_system_supported=yes
ac_cv_tanh_preserves_zero_sign=yes

ac_cv_have_long_long_format=yes
ac_cv_file__dev_ptmx=yes
ac_cv_file__dev_ptc=no
=================================

Also with following patch into configure.in
=======================================
diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -1372,7 +1372,7 @@
 # so we need to run a program to see whether it really made the
 # function available.
 AC_MSG_CHECKING(whether $CC accepts -pthread)
-AC_CACHE_VAL(ac_cv_thread,
+AC_CACHE_VAL(ac_cv_pthread,
 [ac_save_cc="$CC"
 CC="$CC -pthread"
 AC_RUN_IFELSE([AC_LANG_SOURCE([[
=======================================
msg142972 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-08-25 16:05
Copy-pasting of a previous comment: I see some “fix for issue #NNN is bogus” in your patch: would you open separate bug reports for those?  A diff file is not a very useful way to report bugs or express opinions <wink>.

Copy-pasting of many previous comments: distutils does not get new features (cross-compilation is a new feature), please focus on packaging.
msg155693 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2012-03-14 00:21
Roumen, do you have a newer patch which applies to the current trunk?
msg155971 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2012-03-15 22:13
some of these changes are now available in trunk, tested with a x86_64-linux-gnu to arm-linux-gnueabihf cross build.

using issue 14324 for configure tests which need fixes, and issue 14327 for the use of uname in the configure script.

please feel free to open separate issues for the changes in the distutils package and the packaging package.
msg155972 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-03-15 22:33
Not for distutils (feature-frozen, see previous messages)
msg155977 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2012-03-16 00:17
issue 14330 handles not using the host python for the build
msg155980 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2012-03-16 00:37
I'm now able to build the interpreter (and run it in qemu on the same machine), but building the extension modules fails. the build is configured as:

CC="arm-linux-gnueabihf-gcc" \
CXX="arm-linux-gnueabihf-g++" \
CFLAGS="-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security" \
LDFLAGS="-Wl,-Bsymbolic-functions -Wl,-z,relro" \
    ../cross/configure \
        --prefix=/usr \
        --enable-ipv6 \
        --with-computed-gotos \
        --enable-loadable-sqlite-extensions \
        --with-dbmliborder=bdb:gdbm \
        --with-system-expat \
        --with-system-ffi \
        --with-fpectl \
        --host=arm-linux-gnueabihf \
        --build=x86_64-linux-gnu

building 'cmath' extension
arm-linux-gnueabihf-gcc -fPIC -Wno-unused-result -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -I. -I/usr/include/arm-linux-gnueabihf -I/usr/local/include -I/usr/include/python3.3m -c cmathmodule.c -o build/temp.linux-x86_64-3.3/cmathmodule.o
arm-linux-gnueabihf-gcc: error: cmathmodule.c: No such file or directory
arm-linux-gnueabihf-gcc: fatal error: no input files
compilation terminated.

the source files are not found (srcdir != builddir), the patch from rpetrov talks about:

+# revert patch from issue 7880 :
+#  - the test case (from issue 7880) works for me
+#  - realpath break cross compilation
+# => so lets use abspath again ;)
+# NOTE "Issue #6612: Fix site and sysconfig to catch os.getcwd() error,
+# eg. if the current directory was deleted." replase all occurrence of
+# realpath with _safe_realpath. Instead to update _safe_realpath to use
+# abspath the cross-compilation revert all!

but I'm running out of time, and won't work on this for the next two weeks.
msg156240 - (view) Author: Roumen Petrov (rpetrov) Date: 2012-03-18 10:44
I cannot test arm build due to issue 12010
msg161972 - (view) Author: Ray Donnelly (Ray.Donnelly) * Date: 2012-05-30 22:36
Hi Roumen,

Many thanks for your patches, I've been using a 2.7.1 version of your patches for Python integration with GDB (pretty-printing) of my own version of the Android NDK for ages now (part of the Necessitas Qt project) and I really appreciate your efforts in this area. I've recently started looking into cross compilation of Python as I want to build everything on Linux and hopefully I can be useful in this effort.

What you said about wchar_t on Android is true on API level <= 8, but fixed for >8. See:

https://groups.google.com/group/android-ndk/browse_thread/thread/e40e3fd241e72d3f?pli=1

To test this:

test.c:
#include <stdlib.h>
char bytes[(signed)sizeof(wchar_t)-4];

compile failure:
arm-linux-androideabi-gcc -I$NDK/platforms/android-8/arch-arm/usr/include/ -S test.c
test.c:2: error: size of array 'bytes' is negative

compile success:
arm-linux-androideabi-gcc -I$NDK/platforms/android-9/arch-arm/usr/include/ -S test.c

I've attached a version of your latest patch re-made against released 3.3.0a2. I've also done the same thing for your MinGW patch at http://bugs.python.org/issue3871

I'll follow up shortly with a patch that addresses some of the remaining issues with cross building for MinGW on Linux (and also the beginnings of Darwin on Linux). It'll be attached to http://bugs.python.org/issue3871 though as it's more specific to MinGW than general cross.
msg162421 - (view) Author: Roumen Petrov (rpetrov) Date: 2012-06-06 21:54
About Android issue with wchar still is applicable. So issue is not exactly as in 12010. Even with changed size  multi-byte functions just return return result like a byte array, i.e. without conversion.  Since python try to validate wide character at some point will be raised exception invalid multi-byte.
Only for test work around could be implement - "fake" conversion functions that just store char into wchar array and to use ascii codec.
Next is that lack of locale support and lack of locale information(structure is without members). 
Another issue is that loader does not resolve indirect dependencies. Many python modules depend from math library but are not linked with it and math functions are resolved later. This does not work on android and those modules must be explicitly linked to math library.
Also posix semaphores must be disabled.

As result python 3k regression tests except those that require locale support or ctype will pass.
msg162464 - (view) Author: Ray Donnelly (Ray.Donnelly) * Date: 2012-06-07 07:51
Re Android

Ah of course. In that case, there's always the NDK built by Dmitry (his latest is v7 AFAIK):

http://www.crystax.net/en/android/ndk
msg164376 - (view) Author: Roundup Robot (python-dev) Date: 2012-06-30 12:33
New changeset 56c574a1819a by doko in branch 'default':
- Issue #3754, refactor sys.platform / get_platform bits, use a
http://hg.python.org/cpython/rev/56c574a1819a
msg164378 - (view) Author: Roundup Robot (python-dev) Date: 2012-06-30 12:44
New changeset af15910d2ffb by doko in branch 'default':
- Issue #3754: Use AC_PATH_TOOL and AC_CHECK_TOOLS instead of
http://hg.python.org/cpython/rev/af15910d2ffb
msg164381 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2012-06-30 13:30
updated the patch in issue #14330.
msg164382 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2012-06-30 13:51
some chunks of the python-py3k-20120607-CROSS.patch patch are now checked in.

I didn't see any issues with the symlinks, and generating the posix vars, so maybe these bits should be dropped from the patch.

remaining issues are:

 - the readline/ncurses configury. maybe this should be done
   in the configure.ac using the host tools, and then provided
   to setup.py by a Makefile macro?

 - why are the Makefile changes for setup.info, pyconfig.h needed?

 - is the _testembed change still needed?

 - does Python/importlib.h really need a rebuild if it's there?
   I think this should just fail, not removed for the cross build.

 - why is the ac_cv_thread vs. ac_cv_pthread change needed?
msg164385 - (view) Author: Roundup Robot (python-dev) Date: 2012-06-30 15:06
New changeset d158b0a78390 by doko in branch 'default':
- Issue #3754: Some unrelated configure.ac cleanups.
http://hg.python.org/cpython/rev/d158b0a78390
msg164395 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2012-06-30 16:26
for the readline ldd check, I'm checking in a patch to use readelf instead of ldd for the cross build.
msg164396 - (view) Author: Roundup Robot (python-dev) Date: 2012-06-30 16:27
New changeset e6e99d449bdc by doko in branch 'default':
- Issue #3754: Use readelf instead of ldd for the cross build readline check
http://hg.python.org/cpython/rev/e6e99d449bdc
msg164402 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2012-06-30 16:48
the ncurses/_flags changes seem to be unrelated. please open a separate issue.
msg164403 - (view) Author: Roundup Robot (python-dev) Date: 2012-06-30 17:29
New changeset 12a56a349af2 by doko in branch 'default':
- Issue #3754: Fix /dev/ptmx, /dev/ptc file checks for cross builds,
http://hg.python.org/cpython/rev/12a56a349af2
msg164409 - (view) Author: Ray Donnelly (Ray.Donnelly) * Date: 2012-06-30 18:42
NCURSES_INTERNALS stuff appears to be redundant:

Mac OS X curses.h, Linux curses.h and Windows PDCurses.h don't reference it, nor does the Python 3.3.0b1 source code. Of course, I haven't checked any other systems.

However: see http://bugs.python.org/issue14598, so maybe for older Linux ncurses and Cygwin it is still needed.

NCURSES_OPAQUE investigation:

Linux ncurses.h:
#ifndef NCURSES_OPAQUE
#define NCURSES_OPAQUE 0
#endif

Mac OS X ncurses.h:
#ifndef NCURSES_OPAQUE
#define NCURSES_OPAQUE 1
#endif

So for OSX we need to be defining it to 0...

but IMHO, these parts are not directly related to cross compilation support so shouldn't be part of this patch.
msg164412 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2012-06-30 18:52
Roumen, I would like to close this issue. Please could you file separate issues for the remaining bits?

 - the thread/pthread configure issue

 - the generation of the Setup / pyconfig.h files?
msg164416 - (view) Author: Roumen Petrov (rpetrov) Date: 2012-06-30 19:23
Matthias  I cannot follow all you questions as I'm on vacation so briefly:
a) ac_cv_thread is type correct one is with'p'
b) ncurses 
NCURSES_INTERNALS reported again in issue 14598
NCURSES_OPAQUE - i don't have time to explain all details but it could be reproduces on linux with version 2.7 
Even on linux to linux build it is required as it could depend from ncurses library version.

c) setup_info is my proposition to pass detection of readline libs from configure to setup.py . Use of readelf is not portable. Why to test again ? If on host platforms shared library is not in elf format  which tool to use ?

d) importlib.h is build now from executable. Probably we could introduce BUILD_CC . Out of scope for now

e) executable that load packages has to be located in builddir to allow "is python build" to be activated and packages from cross-build environment to be loaded.

After 3 weeks I could answer more.
msg166740 - (view) Author: Roumen Petrov (rpetrov) Date: 2012-07-29 10:20
I hope that  following separate issues will address remaining part of this patch:

required:
- 15483: initialise include and library paths in setup.py
- 15484: use _PYTHON_PROJECT_BASE in distutils sysconfig
- TODO: typo in in configure.in - use ac_cv_pthread instead ac_cv_thread
- 15268: skip "curses configure checks fail if only /usr/include/ncursesw/curses.h is installed"

optional:
- 15298: _sysconfigdata is generated in srcdir, not builddir
- 14598: _cursesmodule.c fails with ncurses-5.9 on Linux reported first as 14438 - _cursesmodule build fails on cygwin
and all other that allow python to be build smoothly outside source directory
msg171787 - (view) Author: Václav Šmilauer (eudoxos) * Date: 2012-10-02 11:38
Being a newcomer to this issue, I would like to ask for a brief summary about which parts of the patch are checked in for 3.3.0 and which are still to be applied.

Roumen mentions #15483, #15484, #15268 and the ac_cv_thread in the previous post as mandatory and #15298 and #14598 as optional; can I add those as dependencies of this issue?

python-py3k-20120607-CROSS.patch does not apply to 3.3.0 cleanly, but looking quickly at .rej files suggests that rejected hunks are those which were already merged for 3.3.0 final. Can someone confirm that?
msg172156 - (view) Author: Roumen Petrov (rpetrov) Date: 2012-10-06 00:13
Hi Václav,
uploaded file py3k-20121004-CROSS.tgz contain current status of patch extracted as is from my repository, i.e. on small chunks. I have no idea what is in 3.3.0 .
msg174925 - (view) Author: Ambroz Bizjak (ambrop7) Date: 2012-11-05 17:50
I've applied all patches from py3k-20121004-CROSS.tgz to Python 3.3.0 except 2, 4, and 9 (which didn't apply), but it's not working. After it builds the built in modules, it tries to run the parser generator which was cross-compiled.

make Parser/pgen
make[1]: Entering directory `/root/Python-3.3.0'
armv5tel-softfloat-linux-gnueabi-gcc -c -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -I. -I./Include    -DPy_BUILD_CORE -o Python/dynamic_annotations.o Python/dynamic_annotations.c
armv5tel-softfloat-linux-gnueabi-gcc -c -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -I. -I./Include    -DPy_BUILD_CORE -o Python/mysnprintf.o Python/mysnprintf.c
armv5tel-softfloat-linux-gnueabi-gcc -c -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -I. -I./Include    -DPy_BUILD_CORE -o Python/pyctype.o Python/pyctype.c
armv5tel-softfloat-linux-gnueabi-gcc -c -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -I. -I./Include    -DPy_BUILD_CORE -o Parser/tokenizer_pgen.o Parser/tokenizer_pgen.c
armv5tel-softfloat-linux-gnueabi-gcc -c -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -I. -I./Include    -DPy_BUILD_CORE -o Parser/printgrammar.o Parser/printgrammar.c
armv5tel-softfloat-linux-gnueabi-gcc -c -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -I. -I./Include    -DPy_BUILD_CORE -o Parser/parsetok_pgen.o Parser/parsetok_pgen.c
armv5tel-softfloat-linux-gnueabi-gcc -c -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -I. -I./Include    -DPy_BUILD_CORE -o Parser/pgenmain.o Parser/pgenmain.c
armv5tel-softfloat-linux-gnueabi-gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes   Parser/acceler.o Parser/grammar1.o Parser/listnode.o Parser/node.o Parser/parser.o Parser/bitset.o Parser/metagrammar.o Parser/firstsets.o Parser/grammar.o Parser/pgen.o Objects/obmalloc.o Python/dynamic_annotations.o Python/mysnprintf.o Python/pyctype.o Parser/tokenizer_pgen.o Parser/printgrammar.o Parser/parsetok_pgen.o Parser/pgenmain.o -lpthread -ldl  -lpthread -lutil -o Parser/pgen
make[1]: Leaving directory `/root/Python-3.3.0'
Parser/pgen ./Grammar/Grammar ./Include/graminit.h ./Python/graminit.c
Parser/pgen: Parser/pgen: cannot execute binary file
make: *** [Include/graminit.h] Error 126
msg174926 - (view) Author: Ambroz Bizjak (ambrop7) Date: 2012-11-05 17:54
Forgot to mention: I did run autoreconf after applying the patches. I'm attaching the full output.
msg174928 - (view) Author: Ambroz Bizjak (ambrop7) Date: 2012-11-05 18:45
A minor issue: if only --host= is specified on command line but not --build=, then cross_compiling variable is only defined after AC_PROG_CC is called. However, configure.ac uses it before that (e.g. the part at the top which looks for a python interpreter). Well, more precisely, something in autoconf sets it to cross_compiling=maybe.
msg175009 - (view) Author: Roumen Petrov (rpetrov) Date: 2012-11-06 20:49
HI, Ambroz

Ambroz Bizjak wrote:
> I've applied all patches from py3k-20121004-CROSS.tgz to Python 3.3.0 except 2, 4, and 9 (which didn't apply), but it's not working. After it builds the built in modules, it tries to run the parser generator which was cross-compiled.
3.3.0 was split from head long time before release and I did not spend 
time to check what is actually entered.

About patches :
2: restore graminit.* to source directory
4: restore AST to source directory

After this touch files to avoid timestamp dependencies to launch extra 
build .
You issue was reported and I guess is documented . It is related to 
checkout from repository and to general build process.
I have a shell script to this but in brief script touch in source tree 
following files:
- Include/graminit.h
- Python/graminit.c
- Include/Python-ast.h
- Python/Python-ast.c
- Python/importlib.h

If you decide to build in source tree patch 2 and 4 could be skipped .
Note that listed patches allow user to keep separate builds at same time 
for different platforms. As side effect part of patches could help to 
build with different configuration options.

For one time cross-build users could use following scenario:
1) native configuration, build and installation
2) clean source tree
3) cross build&pack for one platform.
Repeat 2 & 3 for each platform

about 9: pass all top configure arguments to libffi configure to allow 
users to build it properly
It is save to ignore this patch if libffi build is fine for you host 
platform. Otherwise  .... just change setup to use only
...
config_args = sysconfig.get_config_var("CONFIG_ARGS")
...
and replace " ".join(config_args) with config_args in command.

For instance I have build for a platform and with filtered "configure 
arguments" build fail. Instead to patch libffi code I prefer from main 
configure command line to control build of libffi.

Roumen
msg180590 - (view) Author: Roundup Robot (python-dev) Date: 2013-01-25 14:35
New changeset 11a18263ceb7 by doko in branch '2.7':
- Issue #3754: fix typo in pthread AC_CACHE_VAL.
http://hg.python.org/cpython/rev/11a18263ceb7

New changeset e28b30e6eee6 by doko in branch '3.2':
- Issue #3754: fix typo in pthread AC_CACHE_VAL.
http://hg.python.org/cpython/rev/e28b30e6eee6

New changeset 5464a534e7bd by doko in branch '3.3':
- Issue #3754: fix typo in pthread AC_CACHE_VAL.
http://hg.python.org/cpython/rev/5464a534e7bd

New changeset ee48728e3695 by doko in branch 'default':
- Issue #3754: fix typo in pthread AC_CACHE_VAL.
http://hg.python.org/cpython/rev/ee48728e3695
msg180594 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2013-01-25 15:17
about py3k-20121004-CROSS.tgz:

- committed 0001-CROSS-fix-typo-in-thread-AC_CACHE_VAL.patch

- 0002-CROSS-restore-graminit.-to-source-directory.patch
  is this necessary?  Assuming that you have correct time
  stamps, this is something which usually is not built during
  a cross build.

  Can we just have a shell script which touches some files
  so that you can cross-build even from the repository without
  building pgen?

  Do the release managers have such a script which is run
  when building a release?

- 0003-CROSS-restore-importlib-header-to-source-directory-a.patch

  Same as for 0002, using correct timestamps. The EXEEXT is a
  different issue. However I'm not sure what to use, EXEEXT,
  or BUILDEXEEXT.

- 0004-CROSS-restore-AST-to-source-directory.patch

  Same as for 0002. Btw, does this fail with a native out-of-tree
  build too?

- 0005-CROSS-revert-issue13150-i.e.-python-solution-with-_s.patch
  A comment like "The fix for issue #13150 is bogus and break
  everything" might not the best way to convince maintainers ...

  This works for me, and IMO should be dropped, or please explain
  why this doesn't work for you.

- 0006-CROSS-initialise-include-and-library-paths.patch
  Afaics, a similar patch is now applied. Can be dropped.

- 0007-CROSS-set-_PYTHON_PROJECT_BASE-to-current-build-dir.patch
  Applied.

- 0008-CROSS-use-_PYTHON_PROJECT_BASE-in-distutils-sysconfi.patch
  Applied.

- 0009-CROSS-pass-all-top-configure-arguments-to-libffi-con.patch

  Why is it needed to pass all configure args?

- 0010-CROSS-warn-only-if-readelf-is-not-in-host-triplet-fo.patch

  Why is this needed just for readelf? If you do have a cross
  toolchain installed, then this should be available with
  the triplet name, same as for gcc, as, ...

- 0011-CROSS-append-gcc-library-search-paths-instead-to-pre.patch

  Looks ok. Could you mention where this does make a difference,
  or do you just want to keep the search order as defined by
  the compiler?

- 0012-CROSS-avoid-ncursesw-include-path-hack.patch

  This would break cross-building in a multiarch environment.
  Maybe we need a --with-curses-incdir=<> option.

- 0013-CROSS-properly-detect-WINDOW-_flags-for-different-nc.patch
  This should be a separate issue. Not cross specific.

- 0014-CROSS-use-build-directory-as-root-for-regression-tes.patch
  why is this necessary?

- 0015-CROSS-test-tools-has-to-depend-only-from-location-of.patch
  Looks ok, but not cross specific. Could you file a separate issue?

- 0016-CROSS-reload-may-fail-with-operation-on-closed-file-.patch
  Looks like a separate issue.
msg180701 - (view) Author: Roumen Petrov (rpetrov) Date: 2013-01-26 19:16
Matthias Klose wrote:
>
> Matthias Klose added the comment:
> about py3k-20121004-CROSS.tgz:
>    [SNIP]
> - 0002-CROSS-restore-graminit.-to-source-directory.patch
>    [SNIP]
> - 0003-CROSS-restore-importlib-header-to-source-directory-a.patch
>    [SNIP]
> - 0004-CROSS-restore-AST-to-source-directory.patch
>    [SNIP]

All above is related to build out of source tree.
Try to keep a build tree for long time. Synchronize source, for instance 
once in week, and try to rebuild. After updates in those files python 
(native build) crash.
Solutions:
a) restore to source tree as before and only for cross build touch files 
to avoid regeneration.
b) after synchronization copy to build tree but now in all cases.
Note that a) will allow you to build from readonly source tree .

> - 0005-CROSS-revert-issue13150-i.e.-python-solution-with-_s.patch
>    A comment like "The fix for issue #13150 is bogus and break
>    everything" might not the best way to convince maintainers ...
>
>    This works for me, and IMO should be dropped, or please explain
>    why this doesn't work for you.

How old is patch ? Before generated "python solution" to be moved from 
source tree to `cat pybuilddir.txt`. So thanks to all that resolve 
design failure with commit for issue 13150. It seems to me author is not 
able to rewrite => issue 13547,  issue14774,  issue16342(?) .
Now obsolete by issue15298 (10x Trent).

> - 0006-CROSS-initialise-include-and-library-paths.patch
>    Afaics, a similar patch is now applied. Can be dropped.

> [SNIP]
> - 0009-CROSS-pass-all-top-configure-arguments-to-libffi-con.patch
>
>    Why is it needed to pass all configure args?
>
> - 0010-CROSS-warn-only-if-readelf-is-not-in-host-triplet-fo.patch
>
>    Why is this needed just for readelf? If you do have a cross
>    toolchain installed, then this should be available with
>    the triplet name, same as for gcc, as, ...

May be I'm wrong to use cross build for multilib , i.e. with gcc -m32. 
In this case does not exist prefixed readelf.

> - 0011-CROSS-append-gcc-library-search-paths-instead-to-pre.patch
>
>    Looks ok. Could you mention where this does make a difference,
>    or do you just want to keep the search order as defined by
>    the compiler?

issue15485
My multilib compiler list fist paths to 64 libraries the to 32. 64 bit 
is with all dependent libraries and headers but 32-compatible lack some 
(tk/tcl for instance).  As result 32 bit build find all "required" 
dependency,  try to link all modules and fail on missing.
Distutil library search is limited - just search for library name.

> - 0012-CROSS-avoid-ncursesw-include-path-hack.patch
>
>    This would break cross-building in a multiarch environment.
>    Maybe we need a --with-curses-incdir=<> option.

May be (issue15268).

> - 0013-CROSS-properly-detect-WINDOW-_flags-for-different-nc.patch
>    This should be a separate issue. Not cross specific.

issue14598 and issue15484.

> - 0014-CROSS-use-build-directory-as-root-for-regression-tes.patch
>    why is this necessary?

For instance is source tree is readonly . It is important in cross to 
avoid build defects to update source files.
Result is parallel build and test for multiple host.

> - 0015-CROSS-test-tools-has-to-depend-only-from-location-of.patch
>    Looks ok, but not cross specific. Could you file a separate issue?

Unfortunately issue is closed. It was fixed perfectly for about 2 hours. 
I just revert commit.
Same as 14 rule apply.

> - 0016-CROSS-reload-may-fail-with-operation-on-closed-file-.patch
>    Looks like a separate issue.

May be is not same as issue15833 (fixed+closed). May be case is only for 
regression test if  source tree is readonly.

Roumen
msg181180 - (view) Author: Roumen Petrov (rpetrov) Date: 2013-02-02 16:51
I agree that cross-compilation is now usable.
Issues related to build and test outside source tree more or less are permanent but out of cross-compilation scope.
Also parts of patches posted in this issue now are in separate defects or enhancements.
msg181447 - (view) Author: Greg Hellings (Greg.Hellings) Date: 2013-02-05 15:39
I'm trying to cross-compile the latest default out of Mercurial based on the status of this. Currently it fails with the following invocation:

$ ../configure --host=i686-w64-mingw32 --build=x86_64-redhat-linux-gnu --target=i686-w64-mingw32 --prefix=/usr/i686-w64-mingw32/sys-root/mingw --exec-prefix=/usr/i686-w64-mingw32/sys-root/mingw --bindir=/usr/i686-w64-mingw32/sys-root/mingw/bin --sbindir=/usr/i686-w64-mingw32/sys-root/mingw/sbin --sysconfdir=/usr/i686-w64-mingw32/sys-root/mingw/etc --datadir=/usr/i686-w64-mingw32/sys-root/mingw/share --includedir=/usr/i686-w64-mingw32/sys-root/mingw/include --libdir=/usr/i686-w64-mingw32/sys-root/mingw/lib --libexecdir=/usr/i686-w64-mingw32/sys-root/mingw/libexec --localstatedir=/usr/i686-w64-mingw32/sys-root/mingw/var --sharedstatedir=/usr/i686-w64-mingw32/sys-root/mingw/com --mandir=/usr/i686-w64-mingw32/sys-root/mingw/share/man --infodir=/usr/i686-w64-mingw32/sys-root/mingw/share/info --enable-ipv6 --enable-shared --with-computed-gotos=yes --with-dbmliborder=gdbm:ndbm:bdb --with-system-expat --with-system-ffi --with-pydebug --with-tsc
checking for hg... found
checking build system type... x86_64-redhat-linux-gnu
checking host system type... i686-w64-mingw32
checking for python interpreter for cross build... python3
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... configure: error: cross build not supported for i686-w64-mingw32
error: Bad exit status from /var/tmp/rpm-tmp.sZjjCl (%build)

This is in a Fedora 18 environment using its included MinGW packages to do the cross compile. I have applied no patches and just did the hg clone this morning from the official repository. Are any of these attached patches still necessary? Is there any documentation about what the process is now for doing the cross-compile build?
msg181449 - (view) Author: Ray Donnelly (Ray.Donnelly) * Date: 2013-02-05 16:04
Yes, patches are still required.

Mainly Roumen's big patch [1] and then a load more too. Matthias Klose has merged a few cross compilation patches.

Here my project with patches for 3.3.0 and an emphasis on cross:
https://github.com/mingwandroid/crucifixion-freedom

...and here's mingwbuilds with the exact same patches (but likely tidier build scripts) without the cross focus:
https://github.com/niXman/mingw-builds/tree/master/patches/Python-3.3.0

Next time there's a release of Python 3, I'll rebase my patches against that.

[1] http://bugs.python.org/issue3871
msg181457 - (view) Author: Greg Hellings (Greg.Hellings) Date: 2013-02-05 16:36
Bummer, the patches in that issue do not apply cleanly to either the 3.3.0 released tarball nor to the 3.3 branch from hg.
msg181520 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2013-02-06 13:27
See http://mail.python.org/pipermail/python-dev/2013-January/123774.html
for the discussion.

Not updating the patches for tip/trunk is the best way to keep them out of the project.
History
Date User Action Args
2013-02-06 13:27:50dokosetmessages: + msg181520
2013-02-05 16:36:02Greg.Hellingssetmessages: + msg181457
2013-02-05 16:04:43Ray.Donnellysetmessages: + msg181449
2013-02-05 15:39:59Greg.Hellingssetmessages: + msg181447
2013-02-02 16:51:13rpetrovsetstatus: open -> closed
resolution: fixed
messages: + msg181180
2013-01-26 19:16:43rpetrovsetmessages: + msg180701
2013-01-25 15:17:06dokosetmessages: + msg180594
2013-01-25 14:35:27python-devsetmessages: + msg180590
2012-11-06 20:49:52rpetrovsetmessages: + msg175009
2012-11-05 18:45:09ambrop7setmessages: + msg174928
2012-11-05 17:54:25ambrop7setfiles: + log

messages: + msg174926
2012-11-05 17:50:55ambrop7setnosy: + ambrop7
messages: + msg174925
2012-10-17 08:46:49devurandomsetnosy: + devurandom
2012-10-06 00:13:06rpetrovsetfiles: + py3k-20121004-CROSS.tgz

messages: + msg172156
2012-10-02 11:38:46eudoxossetnosy: + eudoxos
messages: + msg171787
2012-07-29 10:20:32rpetrovsetmessages: + msg166740
components: + Cross-Build, - Build, Distutils2
2012-06-30 19:23:47rpetrovsetmessages: + msg164416
2012-06-30 18:52:33dokosetmessages: + msg164412
2012-06-30 18:42:50Ray.Donnellysetmessages: + msg164409
2012-06-30 17:29:46python-devsetmessages: + msg164403
2012-06-30 16:48:17dokosetmessages: + msg164402
2012-06-30 16:27:54python-devsetmessages: + msg164396
2012-06-30 16:26:02dokosetmessages: + msg164395
2012-06-30 15:06:38python-devsetmessages: + msg164385
2012-06-30 13:51:23dokosetmessages: + msg164382
2012-06-30 13:30:54dokosetmessages: + msg164381
2012-06-30 12:44:13python-devsetmessages: + msg164378
2012-06-30 12:33:40python-devsetnosy: + python-dev
messages: + msg164376
2012-06-07 07:51:15Ray.Donnellysetmessages: + msg162464
2012-06-06 22:01:14alexissetnosy: - alexis
2012-06-06 21:54:48rpetrovsetmessages: + msg162421
2012-06-06 21:25:39rpetrovsetfiles: + python-py3k-20120607-CROSS.patch
2012-05-30 22:36:44Ray.Donnellysetnosy: + Ray.Donnelly
messages: + msg161972
2012-05-30 22:15:50Ray.Donnellysetfiles: + python-py3k-20120318-CROSS-330a2.patch
2012-03-18 10:44:11rpetrovsetmessages: + msg156240
2012-03-18 10:13:53rpetrovsetfiles: + python-py3k-20120318-CROSS.patch
2012-03-16 00:37:08dokosetmessages: + msg155980
2012-03-16 00:17:35dokosetmessages: + msg155977
2012-03-15 22:41:58vapiersetnosy: + vapier
2012-03-15 22:33:02eric.araujosetmessages: + msg155972
2012-03-15 22:13:44dokosetmessages: + msg155971
2012-03-14 00:21:42dokosetnosy: + doko
messages: + msg155693
2011-11-09 16:44:49marqvarsetnosy: + marqvar
2011-08-25 16:05:42eric.araujosetnosy: + alexis, tarek
messages: + msg142972

assignee: tarek
components: + Distutils2
2011-08-24 21:31:25rpetrovsetfiles: + python-py3k-20110825-CROSS.patch
2011-08-18 09:40:20kalevsetnosy: + kalev
2011-05-26 19:50:19rpetrovsetmessages: + msg137001
2011-05-26 17:45:50wrobellsetmessages: + msg136987
2011-05-26 13:55:58wrobellsetmessages: + msg136963
2011-05-26 13:54:38wrobellsetmessages: + msg136962
2011-05-25 22:17:52victorpolucenosetnosy: - victorpoluceno
2011-05-25 22:06:43wrobellsetmessages: + msg136911
2011-05-25 19:42:23rpetrovsetmessages: + msg136887
2011-05-25 18:49:53wrobellsetmessages: + msg136885
2011-05-24 17:07:25rpetrovsetmessages: + msg136772
2011-05-20 15:11:51eric.araujolinkissue3871 dependencies
2011-05-20 13:15:26Greg.Hellingssetmessages: + msg136371
2011-05-20 10:08:25wrobellsetnosy: + wrobell
2011-05-20 05:40:33Greg.Hellingssetnosy: + Greg.Hellings
2011-05-19 22:07:23rpetrovsetfiles: + python-py3k-20110520-CROSS.patch
2011-05-17 01:58:38WhiteTigersetnosy: + WhiteTiger
2011-05-07 01:34:17David.Kernsetnosy: + David.Kern
2011-04-07 20:26:47rpetrovsetfiles: + python-py3k-20110407-CROSS.patch

messages: + msg133252
2011-03-25 15:26:43eric.araujosetmessages: + msg132102
2011-03-25 15:25:27eric.araujosetnosy: + eric.araujo

versions: + Python 3.3, - Python 3.2
2011-01-26 21:05:26rpetrovsetfiles: + python-py3k-20110126-CROSS.patch
nosy: rpetrov, Arfrever, victorpoluceno, BreamoreBoy
2011-01-26 21:02:37rpetrovsetfiles: + python-2.7-20110126-CROSS.patch
nosy: rpetrov, Arfrever, victorpoluceno, BreamoreBoy
messages: + msg127140
2010-11-12 21:03:57rpetrovsetfiles: + python-py3k-20101112-CROSS.patch
2010-11-12 21:02:45rpetrovsetfiles: + python-2.7-20101112-CROSS.patch
2010-08-24 14:50:19Arfreversetnosy: + Arfrever
2010-08-24 11:22:23rpetrovsetfiles: + python-trunk-20100824-CROSS.patch

messages: + msg114776
2010-07-18 20:37:47BreamoreBoysetversions: + Python 3.2, - Python 2.7
2010-07-18 20:35:55BreamoreBoysetnosy: + BreamoreBoy
messages: + msg110685
2010-06-26 19:43:30rpetrovsetfiles: + python-trunk-20100626-CROSS.patch

messages: + msg108744
2010-05-16 12:11:23rpetrovsetfiles: - python-trunk-20100124-CROSS.patch
2010-05-16 12:11:15rpetrovsetfiles: - python-trunk-20100103-CROSS.patch
2010-05-16 12:11:10rpetrovsetfiles: - python-trunk-20091206-CROSS.patch
2010-05-16 12:11:03rpetrovsetfiles: - python-trunk-20091129-CROSS.patch
2010-05-16 12:10:55rpetrovsetfiles: - python-trunk-20091104-CROSS.patch
2010-05-16 12:10:47rpetrovsetfiles: - python-trunk-20090722-CROSS.patch
2010-05-16 12:10:00rpetrovsetfiles: + python-trunk-20100516-CROSS.patch

messages: + msg105859
title: minimal cross-compilation support for configure -> cross-compilation support for python build
2010-01-24 16:12:56brian.curtinsetpriority: normal
keywords: + needs review
stage: patch review
2010-01-24 13:31:09rpetrovsetfiles: + python-trunk-20100124-CROSS.patch

messages: + msg98223
2010-01-03 11:24:42rpetrovsetfiles: + python-trunk-20100103-CROSS.patch
versions: + Python 2.7
2009-12-06 16:37:44rpetrovsetfiles: + python-trunk-20091206-CROSS.patch
2009-11-29 17:43:41rpetrovsetfiles: + python-trunk-20091129-CROSS.patch
2009-11-04 22:04:31rpetrovsetfiles: + python-trunk-20091104-CROSS.patch
2009-07-22 20:08:53rpetrovsetnosy: rpetrov, victorpoluceno
type: enhancement
components: + Build
2009-07-22 20:08:29rpetrovsetfiles: - python-trunk-20090612-CROSS.patch
2009-07-22 20:08:22rpetrovsetfiles: - python-trunk-20090415-CROSS.patch
2009-07-22 20:08:12rpetrovsetfiles: - python-trunk.patch-CROSS-20090110
2009-07-22 20:07:34rpetrovsetfiles: + python-trunk-20090722-CROSS.patch
2009-06-12 19:40:50rpetrovsetfiles: + python-trunk-20090612-CROSS.patch
2009-04-17 16:36:57victorpolucenosetnosy: + victorpoluceno
2009-04-15 20:42:10rpetrovsetfiles: - python-trunk-CROSS.patch
2009-04-15 20:41:54rpetrovsetfiles: - python-trunk-CROSS.patch
2009-04-15 20:41:46rpetrovsetfiles: + python-trunk-20090415-CROSS.patch
2009-01-10 18:41:04rpetrovsetfiles: + python-trunk.patch-CROSS-20090110
2008-12-07 18:55:52rpetrovsetfiles: + python-trunk-CROSS.patch
messages: + msg77241
2008-09-30 17:54:09rpetrovsetfiles: - python-trunk-CROSS.patch
2008-09-30 17:53:55rpetrovsetfiles: + python-trunk-CROSS.patch
2008-09-01 21:49:18rpetrovcreate