New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When cross-compiling, don’t try to execute binaries #66815
Comments
I tried |
You're right, this can be avoided (although you will also have to patch the extension module build, which uses the just-built python executable). This problem occurs twice in the build process, once for pgen and once for _freeze_importlib. The problem is that the Makefile rules for the generated files depend on the binary (which is of course not checked in and cannot be touched by "make touch"). Attached patch should fix this. |
Thanks, this patch worked fine. :) I used to build pgen natively first, then make distclean and rebuild until it failed, and then put the native version back here, but this works much better! |
This was removed in c2a53aa27cad, to fix bpo-22359. |
Indeed, that is an issue :( |
I'm looking into this issue because of bpo-23670 (iOS support). Am I correct in assuming that the right fix here is to identify a |
there are two approaches here, one to check in generated files and try to avoid the rebuild, or completely fix the cross build. I think the patch for the parallel build just was a bit over-eager |
Incorrect recursive use of make will be fixed in default, 3.5, 3.4 (?), 2.7 in bpo-22359, reflect the versions correctly here so they're not forgotten. |
So is there somewhere that documents how cross compilation is meant to be done? I tried looking at <https://docs.python.org/2/using/unix.html#building-python\>, <https://hg.python.org/cpython/file/2.7/README\>, and “./configure --help”, but found no hints for cross compilation. If it is just word-of-mouth, would someone mind explaining to me how it is meant to be done? The configure script lists CC as a “C compiler command”. But for cross compilation it sounds like you would need to differentiate host and target compilers. From the errors that have been posted, it sounds like you guys may be setting CC to the target compiler, causing the build to try and use the target compiler to build host programs. |
Similar patch used for 3.5
Additionally required:
-Python/importlib_external.h: $(srcdir)/Lib/importlib/_bootstrap_external.py Programs/_freeze_importlib
+Python/importlib_external.h: $(srcdir)/Lib/importlib/_bootstrap_external.py
+ $(MAKE) Programs/_freeze_importlib
./Programs/_freeze_importlib \
$(srcdir)/Lib/importlib/_bootstrap_external.py Python/importlib_external.h |
In <http://thread.gmane.org/gmane.comp.python.devel/156550/focus=156663\> I suggested adding some makefile settings to manually override the pgen and _frozen_importlib programs. I imagine the changes would look something like cross-override.patch. Can someone who does cross compiling see if it is any use, and/or also indicate what commands or process they use to cross compile? |
So in general: https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/System-Type.html#System-Type and https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Hosts-and-Cross_002dCompilation.html There are three platforms in play: target, host, build. Host is the platform where what you build should run on. Now, the pathological case of building things is the canadian cross - https://en.wikipedia.org/wiki/Cross_compiler#Canadian_Cross Note here that you actually build multiple different entire compilers, - and thats what we need here. We need to build two python's. One, for build, which pgen and _freeze_importlib can depend on. One, for host, which is the output, and can depend on the output of running pgen and _freeze_importlib I don't have examples of Makefile parameterisation to support this offhand, but gcc would be the obvious (if perhaps overwhelming) place to look at it. The key things I'd expect are that:
|
Thanks Robert. Russell also pointed out on python-dev that the patches at bpo-23670 show how he is doing cross compilation, via a new high-level iOS/Makefile file. Here is a cut-down version of the parts that I find relevant: # Build for the native build host # Build for a foreign target host Something I just realized is that the output of pgen is actually committed to the Mercurial repository. It seems that Russell’s cross-compilation was relying on this to avoid rerunning pgen. Same with the output of _freeze_importlib, except Russell is working around that differently. It does not seem right to have files in the repository that are also generated by the normal build process. |
On 14 March 2016 at 01:05, Robert Collins <report@bugs.python.org> wrote:
To be 100% explicit: CPython doesn't need to worry about the third
only then would target matter. |
In bpo-22359, Xavier has posted a patch that looks like a reasonable solution to both cross compiling and allowing parallel make. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: