Cross compiling mruby for the Yùn

Hello all,
I am trying to build mruby (new embeddable version of ruby) for linino/Yùn. I installed the Development toolchain as per GitHub - arduino/linino, setup PATH and STAGING_DIR paths and using the mips-openwrt-linux-uclibc-* set of commands for cross-building mruby.

Most the build goes fine and the executable files are created:

$ file build/atheros/bin/mirb 
build/atheros/bin/mirb: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70403, not stripped

But when I copy the executables on the linino I get:

root@ArduinoPB:~# ls 
bin        mirb       mrbc       mruby      test_exec
root@ArduinoPB:~# ./mirb 
-ash: ./mirb: not found

Now, note that mirb is executable, and that test_exec is a simple hello world C program compiled with the same toolchain, which actually do run.

Also, I noticed that during compilation of mruby I got warnings from the linker when it creates the executables:

mips-openwrt-linux-uclibc-ld: warning: cannot find entry symbol __start; defaulting to 0000000000401090

Since __start is actually the entry point of any executable, I suppose that my linking command is missing some standard library. There is the actual link command (I'm linking against libm and libc):

"mips-openwrt-linux-uclibc-ld" -L"/home/rnc/linino/trunk/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/lib" -o "/home/rnc/develop/mruby/build/atheros/bin/mirb" "/home/rnc/develop/mruby/build/atheros/mrbgems/mruby-bin-mirb/tools/mirb/mirb.o" "/home/rnc/develop/mruby/build/atheros/lib/libmruby.a"  -lc -lm 
mips-openwrt-linux-uclibc-ld: warning: cannot find entry symbol __start; defaulting to 00000000004010f0

The question is: what am I missing here? any lib to be added to the ld command?

Once that will be solved, I plan to use mruby in place of python, writing a couple of extension for accessing the Console and the Bridge from within mruby.

Thanks,
-P.

Nevermind, I was using ld for linking the executables, which apparently does not link crt0 by default. By linking executables with gcc solved the problem.

Now I have a basic mruby interpreter running on linino. The self contained executable is statically linked (no dependencies) and weights 2.08Mb, including a rather complete standard library.

I am planing to set up a github repo for a mruby for linino build. It would be nice to know if someone is interested.

-P.

For whom is interested, the repo at Bitbucket under the branch linino can cross-compile and run on the Yùn.
The embedded mruby only consists in three executables (interactive mruby, the interpreter and the byte code compiler), no shared libs. The interpreter also embeds a ruby class named Yun that provides basic interface for using the Arduino Console (on port 6571).

The Downloads page also has a tar ball containing the three precompiled binaries.

Cheers,
-P.

The download here unitn / mruby / Downloads — Bitbucket now also includes support for the Console and the Bridge (analogous to the Python stuff).

Have you ported Bridge to mruby?
Also: what is the advantage of mruby over plain ruby?

Hi Federico,
I ported a quick and dirty version of the Bridge to mruby. It currently has two class methods: Yun::Bridge#put(key, value), Yun::Bridge#get(key), and one module function Yun#reset_mcu(). Bridge methods return hashes (converted from JSON objects).
That's enough for basic applications for now, though I plan too add more.

Main advantage of mruby over ruby is size, which can be crucial on embedded systems. The sole mruby executable weights 2.2Mb and it is completely self contained, including most of the standard library, plus commodities like RegExp, IO, Socket, File, and the Yun module. The mruby-gems, rather than being loaded and parsed runtime, are precompiled into byte code at build time, and directly statically linked into the executable. Once you have a cross-build system is rather easy to build a custom mruby interpreter with a custom set of gems. Furthermore, mruby-gems can easily mix methods implemented in C or mruby in the same class/module.

Finally, mruby C APIs are much more easy than C interfaces for ruby, and I'd say even marginally easier than python and lua interfaces. Which makes really easy to build C executables that embed an mruby interpreter, or to build C extensions to the standard mruby interpreter.

The tarball linked above contains three executables: mirb (the interactive mruby), mruby (the interpreter) and mrbc (the mruby byte code compiler).