Skip to contentSkip to conversation

package/luajit: build host variant dynamically

PATCH New Romain Naour 2 participants 5 messages Mar 4, 2016 – Mar 26, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/luajit: build host variant dynamically

While building libevas.so for the host-efl with luajit support, the link fail when libluajit is build statically:

/usr/bin/ld: output/host/usr/lib/libluajit-5.1.a(ljamalg.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC output/host/usr/lib/libluajit-5.1.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

Build luajit dynamically in order to build host-efl with luajit support.

Also we need to provide a rpath to HOST_DIR otherwise we hit the rpath sanity check:

***
*** ERROR: package host-luajit installs executables without proper RPATH:
*** output/host/usr/bin/luajit

---
 package/luajit/luajit.mk | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
package/luajit/luajit.mk +4 -1
index d45598e..791ef37 100644
@@ -64,8 +64,11 @@ define LUAJIT_INSTALL_SYMLINK
 endef
 LUAJIT_POST_INSTALL_TARGET_HOOKS += LUAJIT_INSTALL_SYMLINK
 
+# host-efl package needs host-luajit to be linked dynamically.
 define HOST_LUAJIT_BUILD_CMDS
-	$(MAKE) PREFIX="/usr" BUILDMODE=static -C $(@D) amalg
+	$(MAKE) PREFIX="/usr" BUILDMODE=dynamic \
+		TARGET_LDFLAGS="$(HOST_LDFLAGS) -Wl,-rpath,$(HOST_DIR)/usr/lib/" \
+		-C $(@D) amalg
 endef
 
 define HOST_LUAJIT_INSTALL_CMDS
Signature · 1 line
2.5.0
#1 lore raw

PATCH 2/2 package/efl: enable luajit support

The lua-old support is currently broken for Lua 5.2+ due to [1] and it's not yet fixed with efl 1.17.

In order to bump to a newer efl version, we need to enable the luajit support and use it by default.

We need to build Elua for the host to enable luajit support for the target.

[1] https://phab.enlightenment.org/T2728

---
 package/efl/Config.in | 13 ++++++++++---
 package/efl/efl.mk    | 32 ++++++++++++++++++++++++--------
 2 files changed, 34 insertions(+), 11 deletions(-)
package/efl/Config.in +10 -3
index 88e2c36..0851961 100644
@@ -2,8 +2,10 @@ config BR2_PACKAGE_EFL
 	bool "efl"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_PACKAGE_HAS_UDEV # libudev
+	depends on BR2_PACKAGE_HAS_LUAINTERPRETER # luajit or Lua 5.1
 	# https://phab.enlightenment.org/T2728
-	depends on BR2_PACKAGE_LUA_5_1 # needs lua 5.1, broken with 5.2+
+	depends on !BR2_PACKAGE_LUA_5_2 # broken with 5.2+
+	depends on !BR2_PACKAGE_LUA_5_3 # broken with 5.2+
 	depends on BR2_TOOLCHAIN_HAS_THREADS # untested without threads
 	depends on BR2_USE_MMU
 	depends on BR2_USE_WCHAR # use wchar_t
@@ -186,6 +188,11 @@ comment "efl needs udev /dev management and a toolchain w/ C++, dynamic library,
 		|| BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS || !BR2_USE_WCHAR
 	depends on BR2_USE_MMU
 
-comment "efl needs lua 5.1"
-	depends on !BR2_PACKAGE_LUA_5_1
+comment "efl needs a lua interpreter (luajit or lua 5.1)"
+	depends on !BR2_PACKAGE_HAS_LUAINTERPRETER
+	depends on BR2_USE_MMU
+
+comment "efl needs Lua 5.1"
+	depends on BR2_PACKAGE_LUA_5_2 # broken with 5.2+
+	depends on BR2_PACKAGE_LUA_5_3 # broken with 5.2+
 	depends on BR2_USE_MMU
package/efl/efl.mk +24 -8
index 2ea2592..ed6cee6 100644
@@ -19,8 +19,8 @@ EFL_LICENSE_FILES = \
 
 EFL_INSTALL_STAGING = YES
 
-EFL_DEPENDENCIES = host-pkgconf host-efl dbus freetype jpeg lua udev \
-	util-linux zlib
+EFL_DEPENDENCIES = host-pkgconf host-efl host-luainterpreter dbus freetype \
+	jpeg luainterpreter udev util-linux zlib
 
 # Regenerate the autotools:
 #  - to fix an issue in eldbus-codegen: https://phab.enlightenment.org/T2718
@@ -32,16 +32,15 @@ EFL_GETTEXTIZE = YES
 # --disable-sdl: disable sdl2 support.
 # --disable-systemd: disable systemd support.
 # --disable-xinput22: disable X11 XInput v2.2+ support.
-# --enable-lua-old: disable Elua and remove luajit dependency.
 # --with-opengl=none: disable opengl support.
 EFL_CONF_OPTS = \
 	--with-edje-cc=$(HOST_DIR)/usr/bin/edje_cc \
+	--with-elua=$(HOST_DIR)/usr/bin/elua \
 	--with-eolian-gen=$(HOST_DIR)/usr/bin/eolian_gen \
 	--disable-cxx-bindings \
 	--disable-sdl \
 	--disable-systemd \
 	--disable-xinput22 \
-	--enable-lua-old \
 	--with-opengl=none
 
 # Disable untested configuration warning.
@@ -49,6 +48,15 @@ ifeq ($(BR2_PACKAGE_EFL_HAS_RECOMMENDED_CONFIG),)
 EFL_CONF_OPTS += --enable-i-really-know-what-i-am-doing-and-that-this-will-probably-break-things-and-i-will-fix-them-myself-and-send-patches-aba
 endif
 
+# We need to build Elua for the host to enable luajit support for the target.
+# --disable-lua-old: build elua for the target.
+# --enable-lua-old: disable Elua and remove luajit dependency.
+ifeq ($(BR2_PACKAGE_LUAJIT),y)
+EFL_CONF_OPTS += --disable-lua-old
+else
+EFL_CONF_OPTS += --enable-lua-old
+endif
+
 ifeq ($(BR2_PACKAGE_UTIL_LINUX_LIBMOUNT),y)
 EFL_DEPENDENCIES += util-linux
 EFL_CONF_OPTS += --enable-libmount
@@ -227,7 +235,8 @@ $(eval $(autotools-package))
 # * host-freetype: for libevas
 # * host-libglib2: for libecore
 # * host-libjpeg, host-libpng: for libevas image loader
-# * host-lua: disable luajit dependency
+# * host-luainterpreter: host-luajit for Elua tool for the host
+#   or host-lua for lua-old option
 HOST_EFL_DEPENDENCIES = \
 	host-pkgconf \
 	host-dbus \
@@ -235,9 +244,18 @@ HOST_EFL_DEPENDENCIES = \
 	host-libglib2 \
 	host-libjpeg \
 	host-libpng \
-	host-lua \
+	host-luainterpreter \
 	host-zlib
 
+# If luajit is enabled for the target, we need to build Elua for the host.
+# --disable-lua-old: build elua for the host.
+# --enable-lua-old: disable Elua and remove luajit dependency.
+ifeq ($(BR2_PACKAGE_LUAJIT),y)
+HOST_EFL_CONF_OPTS += --disable-lua-old
+else
+HOST_EFL_CONF_OPTS += --enable-lua-old
+endif
+
 # Configure options:
 # --disable-audio, --disable-multisense remove libsndfile dependency.
 # --disable-cxx-bindings: disable C++11 bindings.
@@ -249,7 +267,6 @@ HOST_EFL_DEPENDENCIES = \
 # --disable-physics: remove Bullet dependency.
 # --enable-image-loader-gif=no: disable Gif dependency.
 # --enable-image-loader-tiff=no: disable Tiff dependency.
-# --enable-lua-old: disable Elua and remove luajit dependency.
 # --with-crypto=none: remove dependencies on openssl or gnutls.
 # --with-x11=none: remove dependency on X.org.
 #   Yes I really know what I am doing.
@@ -267,7 +284,6 @@ HOST_EFL_CONF_OPTS += \
 	--enable-image-loader-jpeg=yes \
 	--enable-image-loader-png=yes \
 	--enable-image-loader-tiff=no \
-	--enable-lua-old \
 	--with-crypto=none \
 	--with-glib=yes \
 	--with-opengl=none \
Signature · 1 line
2.5.0
#2 lore raw

PATCH 2/2 package/efl: enable luajit support

Hello,

Quoted 9 lines · Romain Naour

The lua-old support is currently broken for Lua 5.2+ due to [1] and it's not yet fixed with efl 1.17.

In order to bump to a newer efl version, we need to enable the luajit support and use it by default.

We need to build Elua for the host to enable luajit support for the target.

[1] https://phab.enlightenment.org/T2728

I don't really understand the discussion in this bug report, and it seems like you got no feedback. Maybe the explanation was not clear enough as to which cases work / don't work.

In the below, I wonder if it's worth to support Lua 5.1 at all. Supporting Luajit would make the whole thing a lot simpler, no? Do we really care enough to offer the possibility of using Lua instead of Luajit, when recent versions of Lua are in fact not supported?

package/efl/Config.in config BR2_PACKAGE_EFL · line 8

Quoted 13 lines
package/efl/Config.in +3 -1
index 88e2c36..0851961 100644
@@ -2,8 +2,10 @@ config BR2_PACKAGE_EFL
 	bool "efl"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_PACKAGE_HAS_UDEV # libudev
+	depends on BR2_PACKAGE_HAS_LUAINTERPRETER # luajit or Lua 5.1
 	# https://phab.enlightenment.org/T2728
-	depends on BR2_PACKAGE_LUA_5_1 # needs lua 5.1, broken with 5.2+
+	depends on !BR2_PACKAGE_LUA_5_2 # broken with 5.2+
+	depends on !BR2_PACKAGE_LUA_5_3 # broken with 5.2+

I'd prefer:

	depends on BR2_PACKAGE_HAS_LUAINTERPRETER && \
		!BR2_PACKAGE_LUA_5_2 && !BR2_PACKAGE_LUA_5_3
Quoted 7 lines
package/efl/Config.in +0 -0
 	depends on BR2_TOOLCHAIN_HAS_THREADS # untested without threads
 	depends on BR2_USE_MMU
 	depends on BR2_USE_WCHAR # use wchar_t
@@ -186,6 +188,11 @@ comment "efl needs udev /dev management and a toolchain w/ C++, dynamic library,
 		|| BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS || !BR2_USE_WCHAR
 	depends on BR2_USE_MMU
 

package/efl/Config.in comment "efl needs udev /dev management and a toolchain w/ C++, dynamic library, · line 198

Quoted 10 lines
package/efl/Config.in +7 -2
-comment "efl needs lua 5.1"
-	depends on !BR2_PACKAGE_LUA_5_1
+comment "efl needs a lua interpreter (luajit or lua 5.1)"
+	depends on !BR2_PACKAGE_HAS_LUAINTERPRETER
+	depends on BR2_USE_MMU
+
+comment "efl needs Lua 5.1"
+	depends on BR2_PACKAGE_LUA_5_2 # broken with 5.2+
+	depends on BR2_PACKAGE_LUA_5_3 # broken with 5.2+
 	depends on BR2_USE_MMU

I don't think two comments are needed. Only one is enough:

comment "elf needs a lua interpreter (luajit or lua 5.1)"

	depends on BR2_USE_MMU
	depends on !BR2_PACKAGE_HAS_LUAINTERPRETER || \
		BR2_PACKAGE_LUA_5_2 || BR2_PACKAGE_LUA_5_3

package/efl/Config.in

Quoted 8 lines
package/efl/Config.in +8 -0
+# We need to build Elua for the host to enable luajit support for the target.
+# --disable-lua-old: build elua for the target.
+# --enable-lua-old: disable Elua and remove luajit dependency.
+ifeq ($(BR2_PACKAGE_LUAJIT),y)
+EFL_CONF_OPTS += --disable-lua-old
+else
+EFL_CONF_OPTS += --enable-lua-old
+endif

I must say I don't really understand this comment, and why you're adding --disable-lua-old/--enable-lua-old to both the target and host EFL configure options, in both cases depending on BR2_PACKAGE_LUAJIT.

Here, you are saying "We need to build Elua for the host", but the below code is changing the configuration options for the target variant of EFL, which looks weird.

package/efl/Config.in

Quoted 8 lines
package/efl/Config.in +8 -0
+# If luajit is enabled for the target, we need to build Elua for the host.
+# --disable-lua-old: build elua for the host.
+# --enable-lua-old: disable Elua and remove luajit dependency.
+ifeq ($(BR2_PACKAGE_LUAJIT),y)
+HOST_EFL_CONF_OPTS += --disable-lua-old
+else
+HOST_EFL_CONF_OPTS += --enable-lua-old
+endif

Ditto.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH 2/2 package/efl: enable luajit support

Hi Thomas, All,

Le 20/03/2016 22:42, Thomas Petazzoni a ?crit :

Quoted 9 lines

Hello,

Quoted 6 lines · Romain Naour

The lua-old support is currently broken for Lua 5.2+ due to [1] and it's not yet fixed with efl 1.17.

In order to bump to a newer efl version, we need to enable the luajit support and use it by default.

Quoted 7 lines
Quoted 3 lines

We need to build Elua for the host to enable luajit support for the target.

[1] https://phab.enlightenment.org/T2728

I don't really understand the discussion in this bug report, and it seems like you got no feedback. Maybe the explanation was not clear enough as to which cases work / don't work.

Actually, I'm wondering how 6124d0733657e425001ce51f526aea3bb8dc54e7 was tested with Lua 5.2 and Lua 5.3 since it doesn't link with any of them. Also it break the Lua 5.1 support.

Quoted 5 lines

In the below, I wonder if it's worth to support Lua 5.1 at all. Supporting Luajit would make the whole thing a lot simpler, no? Do we really care enough to offer the possibility of using Lua instead of Luajit, when recent versions of Lua are in fact not supported?

Ok, since I have no proper fixes for Lua "old" support, let switch to luajit support only.

Quoted 58 lines
Quoted 6 lines
package/efl/Config.in +0 -0
index 88e2c36..0851961 100644

package/efl/Config.in config BR2_PACKAGE_EFL · line 8

Quoted 8 lines
package/efl/Config.in +3 -1
@@ -2,8 +2,10 @@ config BR2_PACKAGE_EFL
 	bool "efl"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_PACKAGE_HAS_UDEV # libudev
+	depends on BR2_PACKAGE_HAS_LUAINTERPRETER # luajit or Lua 5.1
 	# https://phab.enlightenment.org/T2728
-	depends on BR2_PACKAGE_LUA_5_1 # needs lua 5.1, broken with 5.2+
+	depends on !BR2_PACKAGE_LUA_5_2 # broken with 5.2+
+	depends on !BR2_PACKAGE_LUA_5_3 # broken with 5.2+

I'd prefer:

	depends on BR2_PACKAGE_HAS_LUAINTERPRETER && \
		!BR2_PACKAGE_LUA_5_2 && !BR2_PACKAGE_LUA_5_3
Quoted 7 lines
package/efl/Config.in +0 -0
 	depends on BR2_TOOLCHAIN_HAS_THREADS # untested without threads
 	depends on BR2_USE_MMU
 	depends on BR2_USE_WCHAR # use wchar_t
@@ -186,6 +188,11 @@ comment "efl needs udev /dev management and a toolchain w/ C++, dynamic library,
 		|| BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS || !BR2_USE_WCHAR
 	depends on BR2_USE_MMU
 

package/efl/Config.in comment "efl needs udev /dev management and a toolchain w/ C++, dynamic library, · line 198

Quoted 10 lines
package/efl/Config.in +7 -2
-comment "efl needs lua 5.1"
-	depends on !BR2_PACKAGE_LUA_5_1
+comment "efl needs a lua interpreter (luajit or lua 5.1)"
+	depends on !BR2_PACKAGE_HAS_LUAINTERPRETER
+	depends on BR2_USE_MMU
+
+comment "efl needs Lua 5.1"
+	depends on BR2_PACKAGE_LUA_5_2 # broken with 5.2+
+	depends on BR2_PACKAGE_LUA_5_3 # broken with 5.2+
 	depends on BR2_USE_MMU

I don't think two comments are needed. Only one is enough:

comment "elf needs a lua interpreter (luajit or lua 5.1)"

	depends on BR2_USE_MMU
	depends on !BR2_PACKAGE_HAS_LUAINTERPRETER || \
		BR2_PACKAGE_LUA_5_2 || BR2_PACKAGE_LUA_5_3

package/efl/Config.in

Quoted 8 lines
package/efl/Config.in +8 -0
+# We need to build Elua for the host to enable luajit support for the target.
+# --disable-lua-old: build elua for the target.
+# --enable-lua-old: disable Elua and remove luajit dependency.
+ifeq ($(BR2_PACKAGE_LUAJIT),y)
+EFL_CONF_OPTS += --disable-lua-old
+else
+EFL_CONF_OPTS += --enable-lua-old
+endif

I must say I don't really understand this comment, and why you're adding --disable-lua-old/--enable-lua-old to both the target and host EFL configure options, in both cases depending on BR2_PACKAGE_LUAJIT.

Quoted 3 lines

Here, you are saying "We need to build Elua for the host", but the below code is changing the configuration options for the target variant of EFL, which looks weird.

If we enable luajit support for the target (with --disable-lua-old option), we need to build elua tool for the host. We have to specify the path to elua with --with-elua=$(HOST_DIR)/usr/bin/elua otherwise elua build for the target is used while crosscrompiling. That is why we also need to use --disable-lua-old option for host-efl to build elua for the host.

If the luajit support is disabled, elua is not build at all. So we can remove host-luajit dependency and use --enable-lua-old.

But let use unconditionally luajit support and use --disable-lua-old for host-efl and efl.

Best regards,
Romain

Quoted 14 lines

package/efl/Config.in

Quoted 9 lines
package/efl/Config.in +8 -0
+# If luajit is enabled for the target, we need to build Elua for the host.
+# --disable-lua-old: build elua for the host.
+# --enable-lua-old: disable Elua and remove luajit dependency.
+ifeq ($(BR2_PACKAGE_LUAJIT),y)
+HOST_EFL_CONF_OPTS += --disable-lua-old
+else
+HOST_EFL_CONF_OPTS += --enable-lua-old
+endif

Ditto.

Thomas

#4 lore raw

PATCH 1/2 package/luajit: build host variant dynamically

In reply to Romain Naour

Hello,

package/luajit/luajit.mk define LUAJIT_INSTALL_SYMLINK · line 70

Quoted 5 lines · Romain Naour
package/luajit/luajit.mk +3 -1
+# host-efl package needs host-luajit to be linked dynamically.
 define HOST_LUAJIT_BUILD_CMDS
-	$(MAKE) PREFIX="/usr" BUILDMODE=static -C $(@D) amalg
+	$(MAKE) PREFIX="/usr" BUILDMODE=dynamic \
+		TARGET_LDFLAGS="$(HOST_LDFLAGS) -Wl,-rpath,$(HOST_DIR)/usr/lib/" \

-Wl,-rpath,... is already in HOST_LDFLAGS, so adding it is not necessary. Passing HOST_LDFLAGS is sufficient.

I've fixed that up, adjusted the commit log accordingly, and applied.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com