Merge lp:~peter-pearse/ubuntu/natty/python2.6/prop003 into lp:ubuntu/natty/python2.6

Proposed by Peter Pearse
Status: Work in progress
Proposed branch: lp:~peter-pearse/ubuntu/natty/python2.6/prop003
Merge into: lp:ubuntu/natty/python2.6
Diff against target: 700 lines (+470/-17) (has conflicts)
4 files modified
debian/changelog (+18/-0)
debian/patches/cross.diff (+318/-0)
debian/patches/series.in (+1/-0)
debian/rules (+133/-17)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~peter-pearse/ubuntu/natty/python2.6/prop003
Reviewer Review Type Date Requested Status
Steve Langasek Needs Fixing
Review via email: mp+53601@code.launchpad.net

Description of the change

SUPERSEDES https://code.launchpad.net/~peter-pearse/ubuntu/natty/python2.6/prop002
That branch has been left to preserve the review comments.

setup.py:
- Renamed the variable to indicate it's origin
- Set LDFLAGS & CFLAGS for cross builds empty, rather than setting "sysrooted" values
  Cross toolchain ASSUMED to cope with location the required headers & libraries

debian/rules
- Replaced the arm test as per review comment
- Added -fPIC for static armel builds. Otherwise the module builds fail with
  "relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC"

Makefile.pre.in
- dependencies adjusted as per review comments
- unnecessary, e.g. whitespace, changes removed.

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) wrote :

+# For armel static objects which will be linked into shared modules
+# must be built as PIC
+# Note use of CONFIG_CFLAGS to allow CFLAGS entries to be defined elsewhere
+ifeq ($(DEB_HOST_ARCH),armel)
+ CONFIG_EXTRAS_STATIC = CFLAGS="-fPIC $(CONFIG_CFLAGS)"
+endif

This is new - and rather surprising actually, as armel is not unique in having this requirement. Nor has python2.6 failed to build with the natty native toolchain. Please dig deeper to find out why this is failing.

review: Needs Fixing
Revision history for this message
Steve Langasek (vorlon) wrote :

@@ -200,17 +225,58 @@
                --enable-unicode=ucs4 \
                --with-system-expat

-ifeq ($(DEB_HOST_ARCH), avr32)
+ifeq ($(DEB_HOST_ARCH), arm avr32)
   common_configure_args += --without-ffi
 else
   common_configure_args += --with-system-ffi
 endif

@@ -342,7 +436,7 @@
 ifneq (,$(filter $(DEB_HOST_ARCH), hppa))
   TEST_EXCLUDES += test_fork1 test_multiprocessing test_socketserver test_wait3
 test_wait4 test_gdb
 endif
-ifneq (,$(filter $(DEB_HOST_ARCH), arm avr32))
+ifneq (,$(filter $(DEB_HOST_ARCH), avr32))
   TEST_EXCLUDES += test_ctypes
 endif
 ifneq (,$(filter $(DEB_HOST_ARCH), m68k avr32))

looks like 'arm' got added back in the wrong section.

review: Needs Fixing
Revision history for this message
Peter Pearse (peter-pearse) wrote :

Yes arm was in the wrong place.

The PIC error arises because the packages, as patched, is trying to build the perl dynamic modules against the static library. Altho linking static code into dynamic objects is theoretically allowed, armel static libraries are not guaranteed to be PIC. In this case they aren't so the linking fails.
I need to stop the cross build trying to do this.......

Revision history for this message
Peter Pearse (peter-pearse) wrote :

PIC error - host build skips building the modules during the static build - they are seen as uptodate

Revision history for this message
Peter Pearse (peter-pearse) wrote :

Fix is to use the correct configuration files during installation...
See https://code.launchpad.net/~peter-pearse/ubuntu/natty/python2.6/prop004.

This branch left so comments can be accessed.

68. By Peter Pearse

  * configure.in - Set buggygetaddrinfo for cross builds
  * - Add py_cv_has_zd_printf for cross builds.
  * Makefile.pre.in - Use BUILDPYTHON where applicable for cross builds.
  * setup.py - For cross builds, pass cross toolchain info in python
               environment.
  * debian/rules - Build a build host python for use during a crossbuild
                   Adjust the configuration files & make environment
                   accordingly
  * Modules/Setup.dist - Drop system paths for zlib.

Revision history for this message
Steve Langasek (vorlon) wrote :

On Tue, Mar 29, 2011 at 02:31:29PM -0000, Peter Pearse wrote:
> Fix is to use the correct configuration files during installation...
> See https://code.launchpad.net/~peter-pearse/ubuntu/natty/python2.6/prop004.

This branch is not available.

> This branch left so comments can be accessed.

You can also commit your further changes on top of the existing branch and
push to it, no need to create a separate branch and merge request each time;
that would probably be easier on your side, and it also makes it easier to
see the change history if it's viewable on a single branch.

--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
<email address hidden> <email address hidden>

Revision history for this message
Peter Pearse (peter-pearse) wrote :

There now

Pushed before I read your note re pushing on the same branch.

However my bzr knowledge wouldn't be good enough anyway - doko had

changed the lp:ubuntu/python2.6.....

Presumably I could have just merged his changes in, but it was easier to rebase

Peter

> -----Original Message-----
> From: <email address hidden> [mailto:<email address hidden>] On
> Behalf Of Steve Langasek
> Sent: 29 March 2011 19:49
> To: Peter Pearse
> Subject: Re: [Merge]
> lp:~peter-pearse/ubuntu/natty/python2.6/prop003 into
> lp:ubuntu/python2.6
>
> On Tue, Mar 29, 2011 at 02:31:29PM -0000, Peter Pearse wrote:
> > Fix is to use the correct configuration files during installation...
> > See
> https://code.launchpad.net/~peter-pearse/ubuntu/natty/python2.
> 6/prop004.
>
> This branch is not available.
>
> > This branch left so comments can be accessed.
>
> You can also commit your further changes on top of the
> existing branch and push to it, no need to create a separate
> branch and merge request each time; that would probably be
> easier on your side, and it also makes it easier to see the
> change history if it's viewable on a single branch.
>
> --
> Steve Langasek Give me a lever long enough
> and a Free OS
> Debian Developer to set it on, and I can
> move the world.
> Ubuntu Developer
> http://www.debian.org/
> <email address hidden>
> <email address hidden>
>
> https://code.launchpad.net/~peter-pearse/ubuntu/natty/python2.
> 6/prop003/+merge/53601
> You are the owner of lp:~peter-pearse/ubuntu/natty/python2.6/prop003.
>
>

-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Unmerged revisions

68. By Peter Pearse

  * configure.in - Set buggygetaddrinfo for cross builds
  * - Add py_cv_has_zd_printf for cross builds.
  * Makefile.pre.in - Use BUILDPYTHON where applicable for cross builds.
  * setup.py - For cross builds, pass cross toolchain info in python
               environment.
  * debian/rules - Build a build host python for use during a crossbuild
                   Adjust the configuration files & make environment
                   accordingly
  * Modules/Setup.dist - Drop system paths for zlib.

67. By Peter Pearse

configure.in - Set buggygetaddrinfo for cross builds
             - Add py_cv_has_zd_printf for cross builds
Makefile.pre.in - Use BUILDPYTHON where applicable for cross builds
setup.py - For cross builds, pass cross toolchain info in python environment
debian/rules - Build a build host python for use during a crossbuild.
             - Adjust the configuration files & make environment accordingly.
             - Compile static armel objects with -fPIC

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-03-25 17:45:24 +0000
3+++ debian/changelog 2011-03-29 15:11:04 +0000
4@@ -1,9 +1,27 @@
5+<<<<<<< TREE
6 python2.6 (2.6.6-6ubuntu7) natty; urgency=low
7
8 * Search libraries in multiarch directories too. LP: #738213.
9
10 -- Matthias Klose <doko@timbuktu> Fri, 25 Mar 2011 17:45:24 +0100
11
12+=======
13+python2.6 (2.6.6-6ubuntu7) natty; urgency=low
14+
15+ * configure.in - Set buggygetaddrinfo for cross builds
16+ * - Add py_cv_has_zd_printf for cross builds.
17+ * Makefile.pre.in - Use BUILDPYTHON where applicable for cross builds.
18+ * setup.py - For cross builds, pass cross toolchain info in python
19+ environment.
20+ * debian/rules - Build a build host python for use during a crossbuild
21+ Adjust the configuration files & make environment
22+ accordingly
23+ * - Compile static armel objects with -fPIC.
24+ * Modules/Setup.dist - Drop system paths for zlib.
25+
26+ -- Peter Pearse <peter.pearse@linaro.org> Tue, 29 Mar 2011 15:03:05 +0000
27+
28+>>>>>>> MERGE-SOURCE
29 python2.6 (2.6.6-6ubuntu6) natty; urgency=low
30
31 * Disable the profiled build on ppc64.
32
33=== added file 'debian/patches/cross.diff'
34--- debian/patches/cross.diff 1970-01-01 00:00:00 +0000
35+++ debian/patches/cross.diff 2011-03-29 15:11:04 +0000
36@@ -0,0 +1,318 @@
37+Index: python2.6/configure.in
38+===================================================================
39+--- python2.6.orig/configure.in 2011-03-29 14:45:33.000000000 +0000
40++++ python2.6/configure.in 2011-03-29 14:45:33.000000000 +0000
41+@@ -3018,8 +3018,8 @@
42+ buggygetaddrinfo=no,
43+ AC_MSG_RESULT(buggy)
44+ buggygetaddrinfo=yes,
45+-AC_MSG_RESULT(buggy)
46+-buggygetaddrinfo=yes)], [
47++AC_MSG_RESULT(cross)
48++buggygetaddrinfo=no)], [
49+ AC_MSG_RESULT(no)
50+ buggygetaddrinfo=yes
51+ ])
52+@@ -3873,7 +3873,7 @@
53+ AC_MSG_RESULT(no)
54+ fi
55+
56+-AC_MSG_CHECKING(for %zd printf() format support)
57++AC_CACHE_CHECK([for %zd printf() format support], [py_cv_has_zd_printf], [dnl
58+ AC_TRY_RUN([#include <stdio.h>
59+ #include <stddef.h>
60+ #include <string.h>
61+@@ -3907,10 +3907,13 @@
62+ return 1;
63+
64+ return 0;
65+-}],
66+-[AC_MSG_RESULT(yes)
67+- AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
68+- AC_MSG_RESULT(no))
69++}], [py_cv_has_zd_printf="yes"],
70++ [py_cv_has_zd_printf="no"],
71++ [py_cv_has_zd_printf="cross -- assuming yes"]
72++)])
73++if test "$py_cv_has_zd_printf" != "no" ; then
74++ AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])
75++fi
76+
77+ AC_CHECK_TYPE(socklen_t,,
78+ AC_DEFINE(socklen_t,int,
79+Index: python2.6/Makefile.pre.in
80+===================================================================
81+--- python2.6.orig/Makefile.pre.in 2011-03-29 14:45:33.000000000 +0000
82++++ python2.6/Makefile.pre.in 2011-03-29 14:45:53.000000000 +0000
83+@@ -207,6 +207,8 @@
84+ ##########################################################################
85+ # Parser
86+ PGEN= Parser/pgen$(EXE)
87++# Allow override for cross build
88++BUILDPGEN= $(PGEN)
89+
90+ POBJS= \
91+ Parser/acceler.o \
92+@@ -354,7 +356,7 @@
93+
94+ # Default target
95+ all: build_all
96+-build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
97++build_all: $(BUILDPYTHON) $(PYTHON) oldsharedmods sharedmods gdbhooks
98+
99+ # Compile a binary with gcc profile guided optimization.
100+ profile-opt:
101+@@ -371,7 +373,7 @@
102+ build_all_generate_profile:
103+ $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov"
104+
105+-run_profile_task:
106++run_profile_task: $(BUILDPYTHON) $(PYTHON)
107+ -./$(BUILDPYTHON) $(PROFILE_TASK)
108+
109+ build_all_use_profile:
110+@@ -386,17 +388,17 @@
111+
112+
113+ # Build the interpreter
114+-$(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY)
115++$(PYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY)
116+ $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
117+ Modules/python.o \
118+- $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
119++ $(LDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
120+
121+-platform: $(BUILDPYTHON)
122++platform: $(BUILDPYTHON) $(PYTHON)
123+ $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
124+
125+
126+ # Build the shared modules
127+-sharedmods: $(BUILDPYTHON)
128++sharedmods: $(BUILDPYTHON) $(PYTHON)
129+ @case $$MAKEFLAGS in \
130+ *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(LDFLAGS)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
131+ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(LDFLAGS)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
132+@@ -434,10 +436,10 @@
133+ #
134+ # Distributors are likely to want to install this somewhere else e.g. relative
135+ # to the stripped DWARF data for the shared library.
136+-gdbhooks: $(BUILDPYTHON)-gdb.py
137++gdbhooks: $(PYTHON)-gdb.py
138+
139+-$(BUILDPYTHON)-gdb.py: Tools/gdb/libpython.py
140+- $(INSTALL_SCRIPT) $< $(BUILDPYTHON)-gdb.py
141++$(PYTHON)-gdb.py: Tools/gdb/libpython.py
142++ $(INSTALL_SCRIPT) $< $(PYTHON)-gdb.py
143+
144+ # This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
145+ # minimal framework (not including the Lib directory and such) in the current
146+@@ -529,9 +531,9 @@
147+ $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
148+
149+
150+-$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
151++$(GRAMMAR_H) $(GRAMMAR_C): $(BUILDPGEN) $(PGEN) $(GRAMMAR_INPUT)
152+ -@$(INSTALL) -d Include
153+- -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
154++ -$(BUILDPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
155+
156+ $(PGEN): $(PGENOBJS)
157+ $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
158+@@ -780,7 +782,7 @@
159+
160+ # Install the interpreter with $(VERSION) affixed
161+ # This goes into $(exec_prefix)
162+-altbininstall: $(BUILDPYTHON)
163++altbininstall: $(BUILDPYTHON) $(PYTHON)
164+ @for i in $(BINDIR) $(LIBDIR); \
165+ do \
166+ if test ! -d $(DESTDIR)$$i; then \
167+@@ -789,7 +791,7 @@
168+ else true; \
169+ fi; \
170+ done
171+- $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
172++ $(INSTALL_PROGRAM) $(PYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
173+ if test -f $(LDLIBRARY); then \
174+ if test -n "$(DLLLIBRARY)" ; then \
175+ $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
176+@@ -1014,7 +1016,7 @@
177+
178+ # Install the dynamically loadable modules
179+ # This goes into $(exec_prefix)
180+-sharedinstall:
181++sharedinstall: $(BUILDPYTHON)
182+ $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
183+ --prefix=$(prefix) \
184+ --install-scripts=$(BINDIR) \
185+@@ -1039,7 +1041,7 @@
186+
187+ frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib
188+
189+-frameworkinstallstructure: $(LDLIBRARY)
190++frameworkinstallstructure: $(BUILDPYTHON) $(LDLIBRARY)
191+ @if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
192+ echo Not configured with --enable-framework; \
193+ exit 1; \
194+@@ -1094,7 +1096,7 @@
195+ cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
196+
197+ # This installs a few of the useful scripts in Tools/scripts
198+-scriptsinstall:
199++scriptsinstall: $(BUILDPYTHON)
200+ SRCDIR=$(srcdir) $(RUNSHARED) \
201+ ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
202+ --prefix=$(prefix) \
203+@@ -1110,14 +1112,14 @@
204+ config.status: $(srcdir)/configure
205+ $(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
206+
207+-.PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
208++.PRECIOUS: config.status $(PYTHON) Makefile Makefile.pre
209+
210+ # Some make's put the object file in the current directory
211+ .c.o:
212+ $(CC) -c $(PY_CFLAGS) -o $@ $<
213+
214+ # Run reindent on the library
215+-reindent:
216++reindent: $(BUILDPYTHON)
217+ ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
218+
219+ # Rerun configure with the same options as it was run last time,
220+@@ -1162,7 +1164,7 @@
221+ find . -name '*.gc??' -exec rm -f {} ';'
222+
223+ clobber: clean profile-removal
224+- -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
225++ -rm -f $(PYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
226+ tags TAGS \
227+ config.cache config.log pyconfig.h Modules/config.c
228+ -rm -rf build platform
229+@@ -1215,7 +1217,7 @@
230+ -o -print
231+
232+ # Perform some verification checks on any modified files.
233+-patchcheck:
234++patchcheck: $(BUILDPYTHON)
235+ $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
236+
237+ # Dependencies
238+Index: python2.6/Modules/Setup.dist
239+===================================================================
240+--- python2.6.orig/Modules/Setup.dist 2011-03-29 14:45:33.000000000 +0000
241++++ python2.6/Modules/Setup.dist 2011-03-29 14:45:33.000000000 +0000
242+@@ -458,7 +458,9 @@
243+ # Andrew Kuchling's zlib module.
244+ # This require zlib 1.1.3 (or later).
245+ # See http://www.gzip.org/zlib/
246+-#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
247++# Well behaved toolchains should not require -L$(exec_prefix)/lib or -I$(prefix)/include
248++# - using them breaks cross builds
249++#zlib zlibmodule.c -lz
250+
251+ # Interface to the Expat XML parser
252+ #
253+Index: python2.6/setup.py
254+===================================================================
255+--- python2.6.orig/setup.py 2011-03-29 14:45:33.000000000 +0000
256++++ python2.6/setup.py 2011-03-29 14:45:33.000000000 +0000
257+@@ -235,6 +235,32 @@
258+ # When you run "make CC=altcc" or something similar, you really want
259+ # those environment variables passed into the setup.py phase. Here's
260+ # a small set of useful ones.
261++
262++ # Change the environment for cross compiling
263++ # - may want to use environment variables for settings?
264++ if os.environ.get('CROSS_COMPILE'):
265++ host_gnu_type=os.environ.get('CROSS_COMPILE')
266++ os.environ["CC"] = host_gnu_type + '-gcc'
267++ os.environ["CXX"] = host_gnu_type + '-g++'
268++ os.environ["LDSHARED"] = host_gnu_type + '-gcc -shared'
269++ os.environ["CPP"] = host_gnu_type + '-cpp'
270++ # Ensure system directories not used
271++ # - because python determines what packages are installed by
272++ # searching it's include paths for their headers
273++ # [ wrongly in my opinion
274++ # - should attempt to compile & link test programs
275++ # or ask pkgconfig ]
276++ # we add in the current cross install locations here.
277++ # Should multiarch implementation result in only one
278++ # location for architecture independent headers this mechanism
279++ # will need reconsideration.
280++ os.environ["LDFLAGS"] = '-L/usr/' + host_gnu_type + '/lib'
281++ os.environ["CFLAGS"] = '-I/usr/' + host_gnu_type + '/include'
282++ # Use -D markers to detect if/where used
283++ os.environ["CPPFLAGS"] = '-DCPPFLAGS'
284++ os.environ["BASECFLAGS"] = '-DBASECFLAGS'
285++ os.environ["OPT"] = '-DOPT'
286++
287+ compiler = os.environ.get('CC')
288+ args = {}
289+ # unfortunately, distutils doesn't let us provide separate C and C++
290+@@ -313,6 +339,13 @@
291+ self.announce('WARNING: skipping import check for Cygwin-based "%s"'
292+ % ext.name)
293+ return
294++
295++ # Cant import cross built modules
296++ if os.environ.get('CROSS_COMPILE'):
297++ self.announce('WARNING: skipping import check for %s, cross built for %s'
298++ % (ext.name, os.environ.get('CROSS_COMPILE')))
299++ return
300++
301+ ext_filename = os.path.join(
302+ self.build_lib,
303+ self.get_ext_filename(self.get_ext_fullname(ext.name)))
304+@@ -394,12 +427,14 @@
305+ for directory in reversed(options.dirs):
306+ add_dir_to_list(dir_list, directory)
307+
308+- if os.path.normpath(sys.prefix) != '/usr':
309+- add_dir_to_list(self.compiler.library_dirs,
310++ # Don't add the system path for cross builds
311++ # - ASSUME toolchain will search correct multiarch paths
312++ if os.environ.get('CROSS_COMPILE') is None:
313++ if os.path.normpath(sys.prefix) != '/usr':
314++ add_dir_to_list(self.compiler.library_dirs,
315+ sysconfig.get_config_var("LIBDIR"))
316+- add_dir_to_list(self.compiler.include_dirs,
317++ add_dir_to_list(self.compiler.include_dirs,
318+ sysconfig.get_config_var("INCLUDEDIR"))
319+-
320+ try:
321+ have_unicode = unicode
322+ except NameError:
323+@@ -412,7 +447,18 @@
324+ '/lib64', '/usr/lib64',
325+ '/lib', '/usr/lib',
326+ ]
327+- inc_dirs = self.compiler.include_dirs + ['/usr/include']
328++
329++ inc_dirs = self.compiler.include_dirs
330++ # Don't add the system path for cross builds
331++ # - need "sysrooted paths" until location of headers
332++ # in multiarch clarified (and implemented)
333++ if os.environ.get('CROSS_COMPILE') is None:
334++ inc_dirs = inc_dirs + ['/usr/include']
335++ else:
336++ host_gnu_type = os.environ.get('CROSS_COMPILE')
337++ inc_dirs = inc_dirs + ['/usr/' + host_gnu_type + '/include']
338++ lib_dirs = inc_dirs + ['/usr/' + host_gnu_type + '/lib']
339++
340+ gnu_triplet = os.popen('dpkg-architecture -qDEB_HOST_GNU_TYPE').readline()[:-1]
341+ inc_dirs.append(os.path.join('/usr/include', gnu_triplet))
342+ exts = []
343+@@ -1840,6 +1886,11 @@
344+ mkpath(ffi_builddir)
345+ config_args = []
346+
347++ if os.environ.get('CROSS_COMPILE'):
348++ host_gnu_type = os.environ.get('CROSS_COMPILE')
349++ print "Configuring _ctypes module for cross building %s" % (host_gnu_type)
350++ config_args = [ '--host ' + host_gnu_type]
351++
352+ # Pass empty CFLAGS because we'll just append the resulting
353+ # CFLAGS to Python's; -g or -O2 is to be avoided.
354+ cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
355
356=== modified file 'debian/patches/series.in'
357--- debian/patches/series.in 2010-10-12 12:53:47 +0000
358+++ debian/patches/series.in 2011-03-29 15:11:04 +0000
359@@ -60,3 +60,4 @@
360 link-system-expat.diff
361 plat-gnukfreebsd.diff
362 issue7356.diff
363+cross.diff
364
365=== modified file 'debian/rules'
366--- debian/rules 2011-02-23 23:41:57 +0000
367+++ debian/rules 2011-03-29 15:11:04 +0000
368@@ -10,6 +10,8 @@
369
370 DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
371 DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
372+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
373+DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
374
375 changelog_values := $(shell dpkg-parsechangelog \
376 | awk '/^(Version|Source):/ {print $$2}')
377@@ -25,6 +27,10 @@
378 ifneq (,$(findstring nobench, $(DEB_BUILD_OPTIONS)))
379 WITHOUT_BENCH := yes
380 endif
381+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
382+ WITHOUT_BENCH := yes
383+ WITHOUT_CHECK := yes
384+endif
385 ifeq ($(on_buildd),yes)
386 ifneq (,$(findstring $(DEB_HOST_ARCH), hppa mips mipsel s390))
387 WITHOUT_CHECK := yes
388@@ -92,7 +98,17 @@
389 endif
390 with_fpectl = yes
391
392-CC = gcc
393+ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
394+ CC = gcc
395+ CROSS =
396+else
397+ CC = $(DEB_HOST_GNU_TYPE)-gcc
398+ # Note that make runs the binaries as ./$(app),
399+ # - so they must not be absolutely pathed
400+ CROSS = BUILDPYTHON=../build-cross/python \
401+ BUILDPGEN=../build-cross/Parser/pgen \
402+ CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)
403+endif
404
405 # on alpha, use -O2 only, use -mieee
406 ifeq ($(DEB_HOST_ARCH),alpha)
407@@ -102,8 +118,17 @@
408 ifeq ($(DEB_HOST_ARCH),m68k)
409 OPTSETTINGS = OPT="-fwrapv -g -O2 -Wall -Wstrict-prototypes"
410 endif
411+# For armel static objects which will be linked into shared modules
412+# must be built as PIC
413+# Note use of CONFIG_CFLAGS to allow CFLAGS entries to be defined elsewhere
414+ifeq ($(DEB_HOST_ARCH),armel)
415+# CONFIG_EXTRAS_STATIC = CFLAGS="-fPIC $(CONFIG_CFLAGS)"
416+endif
417
418 PWD := $(shell pwd)
419+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
420+ buildd_cross := $(CURDIR)/build-cross
421+endif
422 buildd_static := $(CURDIR)/build-static
423 buildd_shared := $(CURDIR)/build-shared
424 buildd_debug := $(CURDIR)/build-debug
425@@ -138,7 +163,7 @@
426 d_dbg := debian/$(p_dbg)
427
428 # profiled build fails on amd64, lpia, sparc
429-ifneq (,$(filter $(DEB_HOST_ARCH), alpha amd64 armel hppa i386 ia64 lpia mips mipsel powerpc ppc64 s390 sparc64 hurd-i386 kfreebsd-i386 kfreebsd-amd64))
430+ifneq (,$(filter $(DEB_HOST_ARCH), alpha amd64 armel hppa i386 ia64 lpia mips mipsel powerpc s390 sparc64 hurd-i386 kfreebsd-i386 kfreebsd-amd64))
431 make_build_target =
432 else
433 make_build_target = profile-opt
434@@ -167,30 +192,30 @@
435
436 stamps/stamp-build-static: stamps/stamp-configure-static
437 dh_testdir
438- $(MAKE) $(NJOBS) -C $(buildd_static) \
439+ $(MAKE) $(NJOBS) -C $(buildd_static) $(CROSS) \
440 PROFILE_TASK='$(PROFILE_TASK)' $(make_build_target)
441 touch stamps/stamp-build-static
442
443 stamps/stamp-build-shared: stamps/stamp-configure-shared
444 dh_testdir
445- $(MAKE) $(NJOBS) -C $(buildd_shared)
446+ $(MAKE) $(NJOBS) -C $(buildd_shared) $(CROSS)
447 # : # build the shared library
448-# $(MAKE) $(NJOBS) -C $(buildd_shared) \
449+# $(MAKE) $(NJOBS) -C $(buildd_shared) $(CROSS) \
450 # libpython$(VER).so
451 : # build a static library with PIC objects
452- $(MAKE) $(NJOBS) -C $(buildd_shared) \
453+ $(MAKE) $(NJOBS) -C $(buildd_shared) $(CROSS) \
454 LIBRARY=libpython$(VER)-pic.a libpython$(VER)-pic.a
455 touch stamps/stamp-build-shared
456
457 stamps/stamp-build-debug: stamps/stamp-configure-debug
458 dh_testdir
459- $(MAKE) $(NJOBS) -C $(buildd_debug)
460+ $(MAKE) $(NJOBS) -C $(buildd_debug) $(CROSS)
461 touch stamps/stamp-build-debug
462
463 stamps/stamp-build-shared-debug: stamps/stamp-configure-shared-debug
464 dh_testdir
465 : # build the shared debug library
466- $(MAKE) $(NJOBS) -C $(buildd_shdebug) \
467+ $(MAKE) $(NJOBS) -C $(buildd_shdebug) $(CROSS) \
468 libpython$(VER)_d.so
469 touch stamps/stamp-build-shared-debug
470
471@@ -206,11 +231,53 @@
472 common_configure_args += --with-system-ffi
473 endif
474
475+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
476+ common_configure_args += \
477+ --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE)
478+endif
479+
480 ifeq ($(with_fpectl),yes)
481 common_configure_args += \
482 --with-fpectl
483 endif
484
485+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
486+
487+# Build build host binary for use during the build
488+# - various files will be accessed from the build-cross
489+# directory and must be copied in after variants are configured.
490+stamps/stamp-configure-cross: stamps/stamp-patch
491+ rm -rf $(buildd_cross)
492+ mkdir -p $(buildd_cross)
493+ cd $(buildd_cross) && \
494+ CC=gcc CONFIG_SITE= $(OPTSETTINGS) \
495+ ../configure --build $(DEB_BUILD_GNU_TYPE) $(CONFIG_EXTRAS_STATIC)
496+ egrep \
497+ "^#($$(awk '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in | tr '\012' '|')XX)" \
498+ Modules/Setup.dist \
499+ | sed -e 's/^#//' -e 's/-Wl,-Bdynamic//;s/-Wl,-Bstatic//' \
500+ >> $(buildd_cross)/Modules/Setup.local
501+ cd $(buildd_cross) && \
502+ ../Modules/makesetup -c ../Modules/config.c.in -s Modules \
503+ Modules/Setup.config Modules/Setup.local Modules/Setup
504+ mv $(buildd_cross)/config.c $(buildd_cross)/Modules/
505+ @echo "Each build should use it's own pyconfig.h & Makefile variables"
506+ cp $(buildd_cross)/pyconfig.h $(buildd_cross)/pyconfig.h.cross
507+ cp $(buildd_cross)/Makefile $(buildd_cross)/Makefile.cross
508+ touch stamps/stamp-configure-cross
509+
510+stamps/stamp-build-cross: stamps/stamp-configure-cross
511+ dh_testdir
512+ $(MAKE) $(NJOBS) -C $(buildd_cross) python Parser/pgen
513+ touch stamps/stamp-build-cross
514+
515+stamps/stamp-configure-shared: stamps/stamp-build-cross
516+stamps/stamp-configure-static: stamps/stamp-build-cross
517+stamps/stamp-configure-debug: stamps/stamp-build-cross
518+stamps/stamp-configure-shared-debug: stamps/stamp-build-cross
519+
520+endif
521+
522 stamps/stamp-configure-shared: stamps/stamp-patch
523 rm -rf $(buildd_shared)
524 mkdir -p $(buildd_shared)
525@@ -229,6 +296,12 @@
526 Modules/Setup.config Modules/Setup.local Modules/Setup
527 mv $(buildd_shared)/config.c $(buildd_shared)/Modules/
528
529+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
530+ @echo "Build python should use the new pyconfig.h & Makefile "
531+ cp $(buildd_shared)/pyconfig.h $(buildd_cross)/pyconfig.h
532+ cp $(buildd_shared)/Makefile $(buildd_cross)/Makefile
533+endif
534+
535 touch stamps/stamp-configure-shared
536
537 stamps/stamp-configure-static: stamps/stamp-patch
538@@ -237,7 +310,7 @@
539 cd $(buildd_static) && \
540 CC="$(CC)" $(OPTSETTINGS) \
541 ../configure \
542- $(common_configure_args)
543+ $(common_configure_args) $(CONFIG_EXTRAS_STATIC)
544 egrep \
545 "^#($$(awk '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in | tr '\012' '|')XX)" \
546 Modules/Setup.dist | sed 's/^#//' \
547@@ -245,7 +318,6 @@
548 cd $(buildd_static) && \
549 ../Modules/makesetup -c ../Modules/config.c.in -s Modules \
550 Modules/Setup.config Modules/Setup.local Modules/Setup
551-
552 : # apply workaround for missing os.fsync
553 sed 's/HAVE_SYNC/HAVE_FSYNC/g' $(buildd_static)/pyconfig.h \
554 > $(buildd_static)/pyconfig.h.new
555@@ -253,6 +325,12 @@
556 mv -f $(buildd_static)/pyconfig.h.new $(buildd_static)/pyconfig.h
557 mv $(buildd_static)/config.c $(buildd_static)/Modules/
558
559+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
560+ @echo "Build python should use the new pyconfig.h"
561+ cp $(buildd_static)/pyconfig.h $(buildd_cross)/pyconfig.h
562+ cp $(buildd_static)/Makefile $(buildd_cross)/Makefile
563+endif
564+
565 touch stamps/stamp-configure-static
566
567 stamps/stamp-configure-debug: stamps/stamp-patch
568@@ -278,6 +356,12 @@
569 touch -r $(buildd_debug)/pyconfig.h $(buildd_debug)/pyconfig.h.new
570 mv -f $(buildd_debug)/pyconfig.h.new $(buildd_debug)/pyconfig.h
571
572+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
573+ @echo "Build python should use the new pyconfig.h"
574+ cp $(buildd_debug)/pyconfig.h $(buildd_cross)/pyconfig.h
575+ cp $(buildd_debug)/Makefile $(buildd_cross)/Makefile
576+endif
577+
578 touch stamps/stamp-configure-debug
579
580 stamps/stamp-configure-shared-debug: stamps/stamp-patch
581@@ -305,9 +389,16 @@
582 touch -r $(buildd_shdebug)/pyconfig.h $(buildd_shdebug)/pyconfig.h.new
583 mv -f $(buildd_shdebug)/pyconfig.h.new $(buildd_shdebug)/pyconfig.h
584
585+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
586+ @echo "Build python should use the new pyconfig.h"
587+ cp $(buildd_shdebug)/pyconfig.h $(buildd_cross)/pyconfig.h
588+ cp $(buildd_shdebug)/Makefile $(buildd_cross)/Makefile
589+endif
590+
591 touch stamps/stamp-configure-shared-debug
592
593 stamps/stamp-mincheck: stamps/stamp-build-static debian/PVER-minimal.README.Debian.in
594+ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
595 for m in $(MIN_MODS) $(MIN_PACKAGES) $(MIN_EXTS) $(MIN_BUILTINS); do \
596 echo "import $$m"; \
597 done > $(buildd_static)/minmods.py
598@@ -321,6 +412,9 @@
599 else true; fi
600 cd $(buildd_static) && ./python ../debian/mincheck.py \
601 minmods.py mindeps.txt
602+else
603+ @echo "No mincheck for cross build"
604+endif
605 touch stamps/stamp-mincheck
606
607 TEST_RESOURCES = all
608@@ -412,6 +506,7 @@
609 touch stamps/stamp-check
610
611 stamps/stamp-pystone:
612+ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
613 @echo "BEGIN pystone static"
614 cd $(buildd_static) && ./python ../Lib/test/pystone.py
615 cd $(buildd_static) && ./python ../Lib/test/pystone.py
616@@ -426,6 +521,9 @@
617 cd $(buildd_debug) && ./python ../Lib/test/pystone.py
618 cd $(buildd_debug) && ./python ../Lib/test/pystone.py
619 @echo "END pystone debug"
620+else
621+ @echo "No pystone for cross build"
622+endif
623 touch stamps/stamp-pystone
624
625 #ifeq (,$(filter $(DEB_HOST_ARCH), arm armel avr32 hppa mips mipsel m68k))
626@@ -487,7 +585,7 @@
627
628 stamps/stamp-doc-html:
629 dh_testdir
630- $(MAKE) -C Doc html
631+ $(MAKE) -C Doc html $(CROSS)
632 touch stamps/stamp-doc-html
633
634 build-doc: stamps/stamp-patch stamps/stamp-build-doc
635@@ -518,14 +616,17 @@
636 clean: control-file
637 dh_testdir
638 dh_testroot
639- $(MAKE) -f debian/rules unpatch
640+ $(MAKE) -f debian/rules unpatch $(CROSS)
641 rm -rf stamps .pc
642 rm -f debian/test_results
643
644- $(MAKE) -C Doc clean
645- sed 's/^@/#/' Makefile.pre.in | $(MAKE) -f - srcdir=. distclean
646+ $(MAKE) -C Doc clean $(CROSS)
647+ sed 's/^@/#/' Makefile.pre.in | $(MAKE) -f - srcdir=. distclean $(CROSS)
648 rm -rf Lib/test/db_home
649 rm -rf $(buildd_static) $(buildd_shared) $(buildd_debug) $(buildd_shdebug)
650+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
651+ rm -rf $(buildd_cross)
652+endif
653 find -name '*.py[co]' | xargs -r rm -f
654 rm -f Lib/lib2to3/*.pickle
655 rm -rf locales
656@@ -568,9 +669,19 @@
657 : # their packages' directories.
658 install -d $(d)/usr
659 ifeq ($(with_interp),static)
660- $(MAKE) -C $(buildd_static) install prefix=$(CURDIR)/$(d)/usr
661+ ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
662+ @echo "Build python should use the new pyconfig.h"
663+ cp $(buildd_static)/pyconfig.h $(buildd_cross)/pyconfig.h
664+ cp $(buildd_static)/Makefile $(buildd_cross)/Makefile
665+ endif
666+ $(MAKE) -C $(buildd_static) install prefix=$(CURDIR)/$(d)/usr $(CROSS)
667 else
668- $(MAKE) -C $(buildd_shared) install prefix=$(CURDIR)/$(d)/usr
669+ ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
670+ @echo "Build python should use the new pyconfig.h"
671+ cp $(buildd_shared)/pyconfig.h $(buildd_cross)/pyconfig.h
672+ cp $(buildd_shared)/Makefile $(buildd_cross)/Makefile
673+ endif
674+ $(MAKE) -C $(buildd_shared) install prefix=$(CURDIR)/$(d)/usr $(CROSS)
675 endif
676 -find $(d)/usr/lib/python$(VER) -name '*_failed*.so'
677 find $(d)/usr/lib/python$(VER) -name '*_failed*.so' | xargs -r rm -f
678@@ -806,8 +917,13 @@
679
680 : # generate binfmt file
681 mkdir -p $(d_min)/usr/share/binfmts
682+ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
683 $(buildd_static)/python debian/mkbinfmt.py $(PVER) \
684 > $(d_min)/usr/share/binfmts/$(PVER)
685+else
686+ $(buildd_cross)/python debian/mkbinfmt.py $(PVER) \
687+ > $(d_min)/usr/share/binfmts/$(PVER)
688+endif
689
690 : # desktop entry
691 mkdir -p $(d_base)/usr/share/applications
692@@ -823,7 +939,7 @@
693
694 : # install debug package
695 rm -rf $(d)-dbg
696- $(MAKE) -C $(buildd_debug) install DESTDIR=$(CURDIR)/$(d)-dbg
697+ $(MAKE) -C $(buildd_debug) install DESTDIR=$(CURDIR)/$(d)-dbg $(CROSS)
698 dh_installdirs -p$(p_dbg) \
699 usr/bin \
700 usr/share/man/man1 \

Subscribers

People subscribed via source and target branches

to all changes: