Patchwork luajit: new package (v2)

login
register
mail settings
Submitter Francois Perrad
Date June 2, 2012, 8:49 a.m.
Message ID <CAB0FRssEYqXNWbALe9HPGOyjkffumkOoDfS_zhj0W1d7F8-7Ow@mail.gmail.com>
Download mbox | patch
Permalink /patch/162404/
State Superseded
Headers show

Comments

Francois Perrad - June 2, 2012, 8:49 a.m.
Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 package/Config.in                     |    3 ++-
 package/luajit/Config.in              |    9 +++++++
 package/luajit/luajit-root-path.patch |   16 ++++++++++++
 package/luajit/luajit.mk              |   44 +++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 package/luajit/Config.in
 create mode 100644 package/luajit/luajit-root-path.patch
 create mode 100644 package/luajit/luajit.mk

+
+$(eval $(call GENTARGETS,package,luajit))
Thomas Petazzoni - July 14, 2012, 10:47 p.m.
Hello,

Le Sat, 2 Jun 2012 10:49:14 +0200,
François Perrad <francois.perrad@gadz.org> a écrit :

> Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
> ---
>  package/Config.in                     |    3 ++-
>  package/luajit/Config.in              |    9 +++++++
>  package/luajit/luajit-root-path.patch |   16 ++++++++++++
>  package/luajit/luajit.mk              |   44 +++++++++++++++++++++++++++++++++
>  4 files changed, 71 insertions(+), 1 deletion(-)

I started integrating this. I made a number of changes (link the luajit
binary dynamically against its shared library, remove the symbolic
thing, addition of the proper 'depends on' for the architectures
that luajit supports, etc.).

However, I've hit a wall with the fact that apparently the luajit build
process requires the host compiler to have the same bitness as the
target architecture. As I was building for ARM on a x86_64 machine,
luajit wasn't happy, and suggested to add -m32 to the host compile
flags. With this, it works.

Unfortunately, it has a number of drawbacks:

 * Requires the host to have multilib libraries available. This is not
   a big problem IMO, as most x86_64 machines will most likely have the
   32 bits libraries installed for one reason or another, and we are
   anyway thinking of using this multilib capability to build Grub when
   the target architecture is x86_64.

 * The major problem is that it means that if your build machine is a 32
   bits machine, then you cannot build luajit for a 64 bits
   architecture (at the moment, the only 64 bits architecture supported
   by luajit is x86_64, so basically, on a i386 build machine, you
   can't build a x86_64 target).

Can you have a look at this and see what's possible to do? I will send
as a reply the current state of the luajit patch that includes my
modifications.

Thanks!

Thomas

Patch

diff --git a/package/Config.in b/package/Config.in
index fb1b08f..fde30b0 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -237,7 +237,8 @@  endmenu
 menu "Interpreter languages and scripting"
 source "package/haserl/Config.in"
 source "package/lua/Config.in"
-if BR2_PACKAGE_LUA
+source "package/luajit/Config.in"
+if BR2_PACKAGE_LUA || BR2_PACKAGE_LUAJIT
 menu "LUA libraries/modules"
 source "package/cgilua/Config.in"
 source "package/copas/Config.in"
diff --git a/package/luajit/Config.in b/package/luajit/Config.in
new file mode 100644
index 0000000..c665b28
--- /dev/null
+++ b/package/luajit/Config.in
@@ -0,0 +1,9 @@ 
+config BR2_PACKAGE_LUAJIT
+	bool "luajit"
+	help
+	  LuaJIT implements the full set of language features defined by Lua 5.1. The
+	  virtual machine (VM) is API- and ABI-compatible to the standard
Lua interpreter
+	  and can be deployed as a drop-in replacement.
+
+	  http://luajit.org/
+
diff --git a/package/luajit/luajit-root-path.patch
b/package/luajit/luajit-root-path.patch
new file mode 100644
index 0000000..2eb037c
--- /dev/null
+++ b/package/luajit/luajit-root-path.patch
@@ -0,0 +1,16 @@ 
+diff -Naur LuaJIT-2.0.0-beta10.orig/src/luaconf.h
LuaJIT-2.0.0-beta10/src/luaconf.h
+--- LuaJIT-2.0.0-beta10.orig/src/luaconf.h	2012-05-30 20:33:27.989333819 +0200
++++ LuaJIT-2.0.0-beta10/src/luaconf.h	2012-05-30 20:46:30.581354777 +0200
+@@ -22,9 +22,9 @@
+ #define LUA_CPATH_DEFAULT \
+   ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
+ #else
+-#define LUA_ROOT	"/usr/local/"
+-#define LUA_LDIR	LUA_ROOT "share/lua/5.1/"
+-#define LUA_CDIR	LUA_ROOT "lib/lua/5.1/"
++#define LUA_ROOT	"/usr/"
++#define LUA_LDIR	LUA_ROOT "share/lua/"
++#define LUA_CDIR	LUA_ROOT "lib/lua/"
+ #ifdef LUA_XROOT
+ #define LUA_JDIR	LUA_XROOT "share/luajit-2.0.0-beta10/"
+ #define LUA_XPATH \
diff --git a/package/luajit/luajit.mk b/package/luajit/luajit.mk
new file mode 100644
index 0000000..b91ddbc
--- /dev/null
+++ b/package/luajit/luajit.mk
@@ -0,0 +1,44 @@ 
+#############################################################
+#
+# luajit
+#
+#############################################################
+
+LUAJIT_VERSION = 2.0.0-beta10
+LUAJIT_SOURCE:=LuaJIT-$(LUAJIT_VERSION).tar.gz
+LUAJIT_SITE = http://luajit.org/download
+LUAJIT_INSTALL_STAGING = YES
+
+define LUAJIT_INSTALL_BETA_FIX_MAKEFILE
+	$(SED) 's/@echo "  $$(SYMLINK) $$(INSTALL_TNAME)
$$(INSTALL_TSYM)"/$$(SYMLINK) $$(INSTALL_TNAME) $$(INSTALL_TSYM)/'
$(@D)/Makefile
+endef
+
+ifeq ($(findstring beta,$(LUAJIT_VERSION)),beta)
+LUAJIT_POST_PATCH_HOOKS += LUAJIT_INSTALL_BETA_FIX_MAKEFILE
+endif
+
+define LUAJIT_NOLARGEFILE_FIX_MAKEFILE
+	$(SED) 's/TARGET_XCFLAGS= -D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE/TARGET_XCFLAGS=/' $(@D)/src/Makefile
+endef
+
+ifneq ($(BR2_LARGEFILE),y)
+LUAJIT_POST_PATCH_HOOKS += LUAJIT_NOLARGEFILE_FIX_MAKEFILE
+endif
+
+define LUAJIT_BUILD_CMDS
+	$(MAKE) PREFIX="/usr" CROSS="$(TARGET_CROSS)" -C $(@D) amalg
+endef
+
+define LUAJIT_INSTALL_STAGING_CMDS
+	$(MAKE) PREFIX="/usr" DESTDIR="$(STAGING_DIR)" -C $(@D) install
+endef
+
+define LUAJIT_INSTALL_TARGET_CMDS
+	$(MAKE) PREFIX="/usr" DESTDIR="$(TARGET_DIR)" -C $(@D) install
+endef
+
+define LUAJIT_CLEAN_CMDS
+	-$(MAKE) -C $(@D) clean
+endef