I am happy to announce that atspkg
now has experimental support for
cross-compiling! I will give a short illustration of how this works using my own
project, polyglot.
First, get a copy of the project:
git clone https://github.com/vmchale/polyglot.git
cd polyglot
Install a cross compiler for C (here, we are using Debian, but you can install a cross-compiler another way):
sudo apt install gcc-arm-linux-gnueabihf
Then, install atspkg
:
curl -sSl https://raw.githubusercontent.com/vmchale/atspkg/master/bash/install.sh | bash -s
And invoke it:
atspkg build --target=arm-linux-gnueabihf
It's worth noting that doing this by hand is difficult - it requires us
to cross-compile the ATS standard library as well as the garbage collector and its dependencies. The ATS
libraries are unfortunately difficult to cross-compile; I won't claim that it is
impossible to do so using the provided makefiles, but it was difficult enough that
I simply replaced the make
build steps with atspkg
. I included the
atspkg.dhall
for the standard library below as it is a nice example of
configuration using Dhall.
{- Dhall prelude imports -}
let map = http://hackage.haskell.org/package/dhall/src/Prelude/List/map
in
let concat = http://hackage.haskell.org/package/dhall/src/Prelude/List/concat
in
{- ATSPackage parts -}
let prelude = http://hackage.haskell.org/package/ats-pkg/src/dhall/atspkg-prelude.dhall
in
{- Helper functions -}
let mapDir =
λ(rec : {dir : Text, xs : List Text }) →
map Text Text
(λ(x : Text) → "${rec.dir}/DATS/${x}.dats")
rec.xs
in
let mapPre =
λ(xs : List Text) →
mapDir { dir = "prelude", xs = xs }
in
let mapC =
λ(xs : List Text) →
mapDir { dir = "libats/libc", xs = xs }
in
let mapML =
λ(xs : List Text) →
mapDir { dir = "libats/ML", xs = xs }
in
let atslib =
λ(compilerVersion : List Natural) →
λ(libVersion : List Natural) →
prelude.default ⫽
{ libraries =
[
prelude.staticLib ⫽
{ libTarget = "target/libatslib.a"
, name = "atslib"
, src =
concat Text
[ mapPre [ "bool", "integer", "basics", "pointer", "integer_long", "integer_short", "integer_size", "char", "float", "string", "strptr", "integer_ptr", "integer_fixed", "filebas" ]
, mapC [ "math", "float", "errno", "fcntl", "dirent", "stdio", "stdlib", "string", "strings", "time", "unistd" ]
, mapML [ "list0", "option0", "array0", "matrix0", "string", "strarr", "gvalue", "dynarray", "hashtblref", "filebas", "filebas_dirent" ]
]
, includes = ([] : List Text)
}
]
, cflags = [ "-fPIC" ]
, compiler = compilerVersion
}
in
atslib [0,3,11] [0,3,11]