pythran
pythran copied to clipboard
Cross-compilation to target different CPU architectures on Linux?
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?
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 :-)
Better: target_clones attribute :-) https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-target_005fclones-function-attribute
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?
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.