Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-compilation in Racket/Scheme language

Is it possible to compile for Windows or Mac OSX while working in Linux for Racket programming language (cross-compile)? DrRacket IDE does not provide any such menu item. Raco help command also did not show any such option:

$ raco help make
raco make [ <option> ... ] <file> [<another-file>] ...
 where <option> is one of
  -j <n> : Compile with up to <n> tasks in parallel
  --disable-inline : Disable procedure inlining during compilation
  --disable-constant : Disable enforcement of module constants
  --no-deps : Compile immediate files without updating dependencies
  -p <file>, --prefix <file> : Add elaboration-time prefix file for --no-deps
  --no-prim : Do not assume `scheme' bindings at top level for --no-deps
  -v : Verbose mode
  --vv : Very verbose mode
  --help, -h : Show this help
  -- : Do not treat any remaining argument as a switch (at this level)
 Multiple single-letter switches can be combined after one `-'; for
  example: `-h-' is the same as `-h --'

I suspect it is not possible in Racket. Is it possible for any other Scheme or Lisp language? Thanks for your comments.

like image 944
rnso Avatar asked Sep 17 '17 04:09

rnso


2 Answers

Even though both raco and DrRacket GUI gives the impression that you can make a native executable it is just the racket executable working as a VM bundled with compiled bytecode. Thus you never actually have native code running that you have written in racket.

like image 58
Sylwester Avatar answered Sep 28 '22 13:09

Sylwester


It seems that it's currently possible, but not yet very simple or reliable. According to this mailing list message from Matthew Flatt, dated 2016-01-07:

We've made some progress, although it's not yet as easy as we'd like.

See

http://docs.racket-lang.org/raco/cross-system.html

Suppose you're running on platform X. If you have a Racket installation on X and also a Racket installation for platform Y, then you can use X as described in the docs to run raco exe or raco dist for Y. Probably.

There are two potential obstacles:

  • You need an installation for platform Y.

    If Y is Windows, that's kind of a pain, because racket-lang.org currently only provides an ".exe" installer for Windows. You'd have to install on some Windows machine and then copy over the installation's directory.

    We should probably provide builds for each platform in ".tgz" or ".zip" format, but we haven't set that up, yet.

  • It might not work after all.

    We're using cross-compilation for Windows to build the main Racket distribution, so things are likely to work if Y is Windows. I haven't even tried Y as something like OS X or Linux, though.

like image 23
Pont Avatar answered Sep 28 '22 13:09

Pont