Cross compilation: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: PE32/64 note, sp)
Line 6: Line 6:
A simple format directive in the source allows for easy cross-compilation to any other supported system, for
A simple format directive in the source allows for easy cross-compilation to any other supported system, for
instance the Linux binaries of Phix are always compiled on Windows by throwing the following at "p -c -norun p32.exu"
instance the Linux binaries of Phix are always compiled on Windows by throwing the following at "p -c -norun p32.exu"
(with a similar p64.exu for 64bit):
(with a similar p64.exu for 64bit, and the formats PE32 and PE64 for the reverse trick):
<!--<lang Phix>(phixonline)-->
<!--<lang Phix>(phixonline)-->
<span style="color: #000000;">format</span> <span style="color: #000000;">ELF32</span>
<span style="color: #000000;">format</span> <span style="color: #000000;">ELF32</span>
Line 12: Line 12:
<!--</lang>-->
<!--</lang>-->
The platform() and machine_bits() builtins can be explictly used as runtime tests to vary code by platform.
The platform() and machine_bits() builtins can be explictly used as runtime tests to vary code by platform.
The compiler tries hard to avoid omitting unnecessary binary, which is likely to be more successful when those routines are used as plainly as possible, without any and/or parts to the conditional. Likewise #ilASM{} aka inline assembly can contain guards
The compiler tries hard to avoid emitting unnecessary binary, which is likely to be more successful when those routines are used as plainly as possible, without any and/or parts to the conditional. Likewise #ilASM{} aka inline assembly can contain guards
such as [32] to emit (only) the relevant code for different target architectures, see
such as [32] to emit (only) the relevant code for different target architectures, see
[[Conditional_structures#ilASM]] and [[Pragmatic_directives#Phix]] for more details and examples.
[[Conditional_structures#ilASM]] and [[Pragmatic_directives#Phix]] for more details and examples.