While `raco exe` in v8.1 very nearly supports cross-builds of Racket
executables[*], it's not easy to pass the right flags and set up the
needed target-platform distributions.

The `raco cross` command provided by the new "raco-cross" package wraps
Racket tools to simplify all of that management. For example,

  raco cross  --target x86_64-linux --vm bc  exe example.rkt

is like running

  raco exe example.rkt

but it cross-builds for x86_64 Linux. That build process involves
downloading a minimal racket tarball for the target platform,
installing "compiler-lib" there, downloading a matching minimal build
of Racket for the host platform, and then running the host Racket in
cross-build mode with installed target distribution --- but, again,
`raco cross` takes care of all that.

Just like using `raco exe` on Linux, the generated executable won't
actually work on other machines until you package it in a distribution
using `raco dist`:

  raco cross  --target x86_64-linux --vm bc  dist example-dist example

Naturally, this second invocation of `raco cross` for the same target
uses the installations prepared by the first `raco cross`, so it's
relatively fast.


I expect that `raco cross` will become more useful after the v8.2
release, which will repair cross-compilation for CS executables and
executables with native libraries (like GUI executables). Meanwhile,
it's possible to use `raco cross` with snapshot builds, but you have to
point it at a snapshot site; see the documentation for more
information.


Because juggling multiple installations and versions is a lot of the
work for cross-compilation, `raco cross` can also be a way to get to a
different version of Racket in minimal form. For example,

  raco cross --version 8.0 racket

starts a Racket v8.0 prompt. (The `racket` command is treated specially
by `raco cross`. All other commands are prefixed by `raco`.)


For more information see

  https://docs.racket-lang.org/raco-cross/index.html


[*] Running a cross-built CS executable fails at the very last step of
    startup, and that's due to an expander bug for handling top-level
    `begin` forms compiled in machine-independent form. We didn't
    detect this problem before, because it wasn't part of Bogdan's use
    case for cross builds, and because cross-compilation was painful
    enough that we didn't actually try other cases.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20210513095436.31b%40sirmail.smtps.cs.utah.edu.

Reply via email to