classification
Title: Do not build Programs/_freeze_importlib when cross-compiling
Type: behavior Stage: resolved
Components: Cross-Build Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Alex.Willmer, martin.panter, python-dev, thomas.perl, xdegaye
Priority: normal Keywords: patch

Created on 2016-07-28 11:04 by thomas.perl, last changed 2016-08-04 04:12 by martin.panter. This issue is now closed.

Files
File name Uploaded Description Edit
python-freeze-importlib-cross-compiling.patch thomas.perl, 2016-07-28 11:04 Only build Programs/_freeze_importlib when it is going to be used review
comment-out-regen.patch martin.panter, 2016-07-29 05:54 review
Messages (8)
msg271519 - (view) Author: Thomas Perl (thomas.perl) * Date: 2016-07-28 11:04
Based on http://bugs.python.org/issue27490 and http://bugs.python.org/msg271495, here is a patch that makes sure Programs/_freeze_importlib is only built when not cross-compiling.
msg271606 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-07-29 05:54
Here is another possible option. It is still a bit of a hack, because the configure script inserts comments into the makefile, but this is already done e.g. with @EXPORT_MACOSX_DEPLOYMENT_TARGET@. The advantage is we get to keep the filenames of the dependencies in the makefile, so it should be easier to read and maintain. And we get to eliminate the $(cross_compiling) check as well.

In native compiling mode, everything should be as normal. When cross-compiling, the rules for regenerating files should read like

Python/importlib.h: # $(srcdir)/Lib/importlib/_bootstrap.py Programs/_freeze_importlib
	./Programs/_freeze_importlib \
	    $(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h

Since the Python/importlib.h should already exist, the rule in this form (dependencies commented out) won’t be run, and Make won’t need to build Programs/_freeze_importlib either.
msg271647 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-07-29 20:41
Nice.

FWIW cross-compilation for Android works fine with comment-out-regen.patch.

> In native compiling mode, everything should be as normal. When cross-compiling, the rules for regenerating files should read like
> 
> Python/importlib.h: # $(srcdir)/Lib/importlib/_bootstrap.py Programs/_freeze_importlib
> 	./Programs/_freeze_importlib \
> 	    $(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h

They do read like this.
msg271737 - (view) Author: Thomas Perl (thomas.perl) * Date: 2016-07-31 13:54
+1 on comment-out-regen.patch, makes things much cleaner and removes the shell "if" in the rule body.

Just a small bikeshed issue: Instead of COMMENT_REGEN, maybe call it "CROSS_COMPILE_COMMENT" or "GENERATED_COMMENT" or "COMMENT_IF_CROSS" or somesuch? This way, might be easier to read/understand the makefile rules ("COMMENT_IF_CROSS" -> "a comment character will be inserted here if cross-compiling")?
msg271760 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-08-01 01:32
Thanks for the feedback. I did wonder about the name. Perhaps I will go with GENERATED_COMMENT:

GENERATED_COMMENT='#'

Python/importlib_external.h: @GENERATED_COMMENT@ $(srcdir)/Lib/importlib/_bootstrap_external.py Programs/_freeze_importlib
msg271936 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-08-04 01:56
New changeset bc677cb34889 by Martin Panter in branch '3.5':
Issue #27641: Comment out regeneration rules when cross compiling
https://hg.python.org/cpython/rev/bc677cb34889

New changeset fc034d3607a8 by Martin Panter in branch 'default':
Issue #27641: Merge cross-compiling improvement from 3.5
https://hg.python.org/cpython/rev/fc034d3607a8
msg271942 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-08-04 03:03
New changeset e3757f3e1848 by Martin Panter in branch '2.7':
Issue #27641: Comment out regeneration rules when cross compiling
https://hg.python.org/cpython/rev/e3757f3e1848
msg271947 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-08-04 04:12
_freeze_import is only in Python 3, but I backported my final change because it is more general and also affects pgen.
History
Date User Action Args
2016-08-04 04:12:12martin.pantersetstatus: open -> closed
resolution: fixed
messages: + msg271947

stage: patch review -> resolved
2016-08-04 03:03:46python-devsetmessages: + msg271942
2016-08-04 01:56:08python-devsetnosy: + python-dev
messages: + msg271936
2016-08-01 01:32:33martin.pantersetmessages: + msg271760
2016-07-31 13:54:45thomas.perlsetmessages: + msg271737
2016-07-29 20:41:46xdegayesetmessages: + msg271647
2016-07-29 16:36:34xdegayesetnosy: + xdegaye
2016-07-29 05:54:55martin.pantersetfiles: + comment-out-regen.patch

stage: patch review
messages: + msg271606
versions: + Python 3.5
2016-07-28 11:04:44thomas.perlcreate