lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Hisham and people on this list,

I have successfully arm-crosscompiled orbit using the method from Hisham.
But there were a little difference. So I am wring those here as a documentation.

There was two kind of method for me to try to cross compile orbit.
One is a method using luarocks. This is recommended by Hisham.
The other is on github - https://github.com/keplerproject/kepler

Kepler uses LuaRocks as its main deployment option, but can be used without LuaRocks
if needed. The best option for deployment without LuaRocks is to first do a normal
deployment (using LuaRocks) in a separate environment, then copying the modules to
the final environment. This is the recommended solution for embedded scenarios
(doing the LuaRocks-based deployment in your cross-compilation environment).

I firstly tried the former.

  6 variables = {
  7    CC = [[/opt/arm-2007q1/bin/arm-none-linux-gnueabi-gcc]],
  8    LD = [[/opt/arm-2007q1/bin/arm-none-linux-gnueabi-gcc]],
  9    CFLAGS = [[-L/opt/arm-2007q1/lib -I/opt/arm-2007q1/include]],
 10 }

And after I copied all built and installed rocks from host PC to arm device. I had to 
- cross compile lua itself.
- change some lua paths in the lua source files under bin directory, where lua binary exists.

But there was a problem.

When I tried to test installed orbit, lfs.so lpeg.so didn't get loaded properly.
This looked weired.

But trying the later method was a good workaround for this.

luafilesystem, lpeg have slightly different make macro variable definition in their makefiles.
And their makefiles are good to make arm binary file. So overwriting with binaries made the later method works fine.

This is not a question but a record or a documentation for someone who might search the cross compiling orbit and reach here. And for someone who can provide advice to me. Maybe Hisham?

Anyway orbit works in my arm embedded system.
And I can enjoy weekend ^^;

Thank you very much.
Sincerely
Journeyer

----------------------------------------
Journeyer J. Joh
o o s a p r o g r a m m e r
a t
g m a i l  d o t  c o m
----------------------------------------


2013/10/10 Journeyer J. Joh <oosaprogrammer@gmail.com>
Hi Hisham,

Thank you for the detailed information and prompt reply.

I think luarocks is very convenient tool.

Thank you very much.
Sincerely
Journeyer



----------------------------------------
Journeyer J. Joh
o o s a p r o g r a m m e r
a t
g m a i l  d o t  c o m
----------------------------------------


2013/10/9 Hisham <h@hisham.hm>
On 9 October 2013 09:01, Journeyer J. Joh <oosaprogrammer@gmail.com> wrote:
> Hello,
>
> I am now cross-compiling orbit and its dependent rocks.
>
> Cross compiling those rocks usually can be accomplished by 2 teps.
> 1. Changing the install prefix
> 2. Specifying cross compile toolchain
>
> I did step 1. via luarocks configure script as shown below.
>
> ./configure --prefix=/home/gc/rootfs_luarocks
> --rocks-tree=/home/gc/rootfs_orbit
> --with-lua-include=/home/gc/rootfs_orbit/include
> --with-lua-lib=/home/gc/rootfs_orbit/lib
>
> And now I need to find a way to specify cross tool chain into the build
> system.
> When I didn't use luarocks I was able to do this directly on the Makefils or
> config files for each rocks. But Now I use luarocks. When it comes to
> luarocks, most build variables seem to be applied via rockspec file.
>
> So I tried this way below for luasocket rock.
>
>>  20 build = {
>>  21    type = "make",
>>  22    build_variables = {
>>  23       CC = "",
>>  24       CFLAGS = "$(CFLAGS) -DLUASOCKET_DEBUG -I$(LUA_INCDIR)",
>>  25       LDFLAGS = "$(LIBFLAG) -O -fpic",
>>  26       LD = "$(CC)"
>>  27    },
>
>
> Please note I specified CC and LD there.
> But this doesn't produce arm library.
>
> Question #1. How can I specify cross toolchain (macro variables like CC, LD,
> ..)?
> Question #2. Is there any know method to cross compile lua rocks?

I have successfully cross-compiled rocks to ARM with LuaRocks. Instead
of editing the rockspecs themselves, edit your luarocks/config.lua
file and add something like the following:

variables = {
   CC = [[/opt/arm-2007q1/bin/arm-none-linux-gnueabi-gcc]],
   LD = [[/opt/arm-2007q1/bin/arm-none-linux-gnueabi-gcc]],
   CFLAGS = [[-L/opt/arm-2007q1/lib -I/opt/arm-2007q1/include]],
}

Just type luarocks with no arguments to see the "System configuration
file" and "User configuration file" paths in your system shown at the
bottom; you can use either.

You may also need to set the external_deps_dirs so your cross compiler
can find any ARM libraries your rocks need, and rocks_trees to specify
where your ARM rocks should be installed.

external_deps_dirs = { [[/opt/cross/build/usr]] } -- tree where your
ARM libs are
rocks_tree = { [[/opt/cross/build/usr]] } -- tree where your ARM rocks should go

Please let us know in the luarocks mailing list if any rocks don't
cross-compile correctly.

Also, if you want to pack .rock files you may also want to edit
site_config.lua to put the proper value in LUAROCKS_UNAME_M.

> I think I need to use lua JIT compiler natively installed in the system when
> I cross compile lua rocks. But After I cross compiled all rocks, I need to
> cross compile lua JIT compiler also.
>
> Question #3. Am I wrong with this thought?

Yes, you should cross compile rocks running a native Lua and then you
should cross-compile Lua (or LuaJIT) to your system.

-- Hisham