Cross-compilation in Racket/Scheme language
Asked Answered
H

3

7

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.

Hollands answered 17/9, 2017 at 4:52 Comment(3)
As of this writing (though it might change with the port to Chez Scheme), Racket bytecode is platform-independent, so “cross-compiling” is not terribly meaningful. The same bytecode should work on any platform.Rattly
I meant compilation to native machine code.Hollands
Racket JIT compiles the bytecode to native machine code.Crosscheck
S
2

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.

Simoniac answered 17/9, 2017 at 18:52 Comment(0)
I
2

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.

Irons answered 26/9, 2017 at 8:0 Comment(0)
K
0

Impossible. this question is I want to ask before. Now When I need to compile something in another OS, I use VirtualBox to launch a vm system to compile it.

Kings answered 18/9, 2017 at 6:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.