Hello Hisham,
I checked my compilation again.
Previously I said using luarocks to cross compile rocks(packages) is not convenient or problematic.
Because determining what macro variables is difficult and moreover even it can easily conflicted with different rocks.
But with my tonight's test, I found I am wrong!
I tried to cross compile luafilesystem and lpeg with luarocks.
Firstly, for luafilesystem :
I set /home/gc/rootfs_orbit/etc/luarocks/config-5.1.lua as shown below.
1 rocks_trees = {
2 home..[[/.luarocks]],
3 [[/home/gc/rootfs_orbit]]
4 }
5
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 = [[-v -L/opt/arm-2007q1/lib -I/opt/arm-2007q1/include -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic]],
10 }
and cross compiled with
luarocks install luafilesystem-1.6.2-1.rockspec
And the result was correct cross compiled arm binary!
Previously I wasn't.
The difference stems from the CFLAGS settings difference between I used previously and now.
Previously I didn't specify "-O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic"
This time I looked the Makefile(config) of luafilesystem and found correct build options and set it to luafilesystem. And I tried to compile only luafilesystem with luarocks.
And after I got the correct lfs.so I tried for lpeg.so. And also I was able to get the correct arm binary.
For lpeg I looked into it's makefile. And found correct build options and put it into the file, /home/gc/rootfs_orbit/etc/luarocks/config-5.1.lua.
It was :
1 rocks_trees = {
2 home..[[/.luarocks]],
3 [[/home/gc/rootfs_orbit]]
4 }
5
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 = [[-v -L/opt/arm-2007q1/lib -I/opt/arm-2007q1/include -shared -fPIC -O2]],
10 }
This time also the CFLAGS are searched and placed from the lpeg makefile.
Previously, I thought /home/gc/rootfs_orbit/etc/luarocks/config-5.1.lua has to be used for all rocks in a shared-manner. With this manner I didn't try to search correct build options for each library. But this is wrong.
Crosscompile has to be done for particular rocks for each. One must write /home/gc/rootfs_orbit/etc/luarocks/config-5.1.lua for only one rock. It cannot be shared for any two different rocks, which has c or cpp source file to be compiled by toolchain.
/home/gc/rootfs_orbit/etc/luarocks/config-5.1.lua can be shared pure lua rocks but not c or cpp rocks.
This is tonight's result of my experiment.
Maybe Hisham, this is what you wanted me to achieve to night.
Thank you very much.
I am sorry for the wrong record of mine in the past few days.
I hope people don't get confused by my posting.
Thank you Hisham and people on this list.
Good night!
Journeyer