<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Thanks! I'll take a look at building a cross-compiler, since it
worked out for you. I'd been a little afraid to try. (I previously
had a bad experience building ghc as a cross-compiler, but that was
with Android as the target and Mac OS X as the host. The issues I
encountered were mostly when it tried to link ELF binaries with the
Mach-O linker, or vice versa. But with both host and target being
Linux, the linker issues can probably be swept under the rug.)<br>
<br>
The C cross compiler shouldn't be a problem, since OpenWRT's
"buildroot" builds a cross-compiler automatically. (Though if for
any reason that turns out to be a problem, thanks for the tip about
crosstool-ng.) Ideally, I'd love to integrate ghc into OpenWRT's
buildroot so that packages written in Haskell could be built as
easily and in the same way as packages written in C. But I still
have a lot to learn before I attempt that.<br>
<br>
My boot device is an SD card, so space for static binaries shouldn't
be a problem. I already have several gigabytes, which should be
more than enough, and if for some reason I needed more space, I
could swap in a larger SD card, or add more space via USB or mSATA.<br>
<br>
I was aware of Marios Titas's "GHC + musl = easier static linking",
but wasn't really thrilled at the idea of needing an install of
Gentoo-musl to host it. (But I can certainly try that if I have
to.) Or I could just use my OpenWRT box to host the GHC-musl, but
I'm running into issues with getting gcc to run on the target, which
I'm currently following up with the OpenWRT community.<br>
<br>
Thanks for the ideas! I'm sure that one way or another I'll be able
to get it working.<br>
<br>
--Patrick<br>
<br>
<br>
<div class="moz-cite-prefix">On 4/10/16 8:40 AM, Tomas Carnecky
wrote:<br>
</div>
<blockquote
cite="mid:CAPabhsKjsMh667uKvBowr0S6OCbK6rZJgaoVPMrfd9_VOAdRMQ@mail.gmail.com"
type="cite">
<div dir="ltr">I was able to compile Haskell for a mips-linux-musl
target (<a moz-do-not-send="true" href="https://onion.io/omega">https://onion.io/omega</a>).
Most problems were due to the different architecture (MIPS) than
musl. Once you have a C cross-compiler (I used <a
moz-do-not-send="true" href="http://crosstool-ng.org/"><a class="moz-txt-link-freetext" href="http://crosstool-ng.org/">http://crosstool-ng.org/</a></a> to
built the cross-compiler toolchain), compiling GHC as a cross
compiler for that target and then a Haskell application
shouldn't be a problem.
<div><br>
</div>
<div>If you have enough disk space on the target, I would
suggest that you compile your Haskell application into a
static binary.</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Sat, Apr 9, 2016 at 10:47 AM Lana Black
<a class="moz-txt-link-rfc2396E" href="mailto:lanablack@amok.cc"><lanablack@amok.cc></a> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">You will
probably have better luck using ghc with musl.<br>
<br>
Check out this thread: <a moz-do-not-send="true"
href="https://mail.haskell.org/pipermail/haskell-cafe/2015-May/119843.html"
rel="noreferrer" target="_blank">https://mail.haskell.org/pipermail/haskell-cafe/2015-May/119843.html</a><br>
<br>
Original Message <br>
From: Patrick Pelletier<br>
Sent: Saturday, April 9, 2016 7:54 AM<br>
To: haskell-cafe<br>
Subject: [Haskell-cafe] Haskell on OpenWRT<br>
<br>
Has anyone had any success running Haskell programs on
OpenWRT?<br>
<br>
Specifically, I'm running OpenWRT on x86_64, so processor
architecture<br>
shouldn't be an issue. However, by default OpenWRT uses musl
as its C<br>
library, so binaries from a "normal" Linux system wouldn't
be compatible<br>
with OpenWRT.<br>
<br>
I attempted to get around this problem by building an
OpenWRT image with<br>
glibc as the C library. In theory, that ought to solve the
problem. In<br>
practice, my program (a simple hello-world type program,
which runs fine<br>
on Ubuntu) hung, printing nothing, using nearly all of one
core, and was<br>
unkillable by any signal other than SIGKILL. If left alone
to run, it<br>
eventually used all available memory and then died.<br>
<br>
I took a look at ldd, to see if there were any clues there.
On my<br>
Ubuntu 12.04 machine, where I compiled the program (using
ghc 7.4.1), I get:<br>
<br>
ppelletier@patrick64:~/programming/haskell$ ldd contact<br>
linux-vdso.so.1 => (0x00007fff36f50000)<br>
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10<br>
(0x00007f8d49cf8000)<br>
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6<br>
(0x00007f8d49af0000)<br>
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
(0x00007f8d497f3000)<br>
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1
(0x00007f8d495eb000)<br>
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2
(0x00007f8d493e7000)<br>
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
(0x00007f8d49028000)<br>
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0<br>
(0x00007f8d48e0b000)<br>
/lib64/ld-linux-x86-64.so.2 (0x00007f8d49f8d000)<br>
<br>
On my OpenWRT (trunk) box, I get:<br>
<br>
root@OpenWrt:~# ldd /tmp/contact<br>
linux-vdso.so.1 (0x00007ffd2afcc000)<br>
libgmp.so.10 => /usr/lib/libgmp.so.10
(0x00007f27a057a000)<br>
libffi.so.6 => /usr/lib/libffi.so.6 (0x00007f27a0373000)<br>
libm.so.6 => /lib/libm.so.6 (0x00007f27a0080000)<br>
librt.so.1 => /lib/librt.so.1 (0x00007f279fe79000)<br>
libdl.so.2 => /lib/libdl.so.2 (0x00007f279fc76000)<br>
libc.so.6 => /lib/libc.so.6 (0x00007f279f906000)<br>
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f279f6f4000)<br>
libpthread.so.0 => /lib/libpthread.so.0
(0x00007f279f4d9000)<br>
/lib64/ld-linux-x86-64.so.2 (0x00007f27a07dc000)<br>
<br>
This is almost the same, except it has "libgcc_s.so.1",
while on the<br>
Ubuntu box it does not.<br>
<br>
I'd welcome any ideas on how to solve (or at least diagnose)
this<br>
problem. I'd also be interested in any thoughts on the
broader question<br>
of running Haskell programs on OpenWRT.<br>
<br>
Thanks,<br>
<br>
--Patrick<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a moz-do-not-send="true"
href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a moz-do-not-send="true"
href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe"
rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a moz-do-not-send="true"
href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a moz-do-not-send="true"
href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe"
rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</blockquote>
</div>
</div>
</blockquote>
<br>
</body>
</html>