pythran icon indicating copy to clipboard operation
pythran copied to clipboard

Cross-compilation to target different CPU architectures on Linux?

Open paugier opened this issue 5 years ago • 4 comments

There is nothing on cross-compilation in Pythran documentation. I understand that it is a subject in itself but sometimes, adding -march=native really speedup computations, but then the binary is no longer "generalist".

Would it be possible to compile for different CPU architectures so that the binaries would be both able to run on "old" machines and able to use advanced instructions where they are available?

paugier avatar Oct 17 '19 10:10 paugier

There's support for that through ifunc (see https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Function-Attributes.html) in some compilers, I'm unsure of how easy that would be to wrap into pythran :-)

serge-sans-paille avatar Oct 22 '19 09:10 serge-sans-paille

Better: target_clones attribute :-) https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-target_005fclones-function-attribute

serge-sans-paille avatar Oct 22 '19 12:10 serge-sans-paille

Related question I have:

  • is the .py -> .cpp step guaranteed to be the same independent of hardware/os/etc. target, so you can run it with the native toolchain and use the generated .cpp files in a cross build?
  • Same question for the headers in pythran.get_include() - is there anything in there that's not portable, or is it fine to get the headers from a native package during a cross build?

rgommers avatar Feb 23 '23 14:02 rgommers

So I answered my own questions in gh-2107. For the rest, this is perhaps no longer relevant? I believe the answer is that there's nothing to do in Pythran itself; if you need cross-compilation, use a build system like Meson or CMake that supports that, and use Pythran as a .py->.cpp transpiler only.

rgommers avatar May 12 '23 09:05 rgommers