Patchwork lua: fix compilation with Blackfin FLAT

login
register
mail settings
Submitter Francois Perrad
Date Jan. 22, 2014, 11:13 a.m.
Message ID <1390389214-9768-1-git-send-email-francois.perrad@gadz.org>
Download mbox | patch
Permalink /patch/313208/
State Superseded, archived
Headers show

Comments

Francois Perrad - Jan. 22, 2014, 11:13 a.m.
the dlfcn interface is not available with flat memory model

see http://autobuild.buildroot.net/results/b41/b4146bf821d59f694546f6e3a341394cc8fa43ce/

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 package/lua/lua.mk |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Peter Korsgaard - Jan. 22, 2014, 9:05 p.m.
>>>>> "Francois" == Francois Perrad <fperrad@gmail.com> writes:

 > the dlfcn interface is not available with flat memory model
 > see http://autobuild.buildroot.net/results/b41/b4146bf821d59f694546f6e3a341394cc8fa43ce/

 > Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
 > ---
 >  package/lua/lua.mk |   12 ++++++++----
 >  1 file changed, 8 insertions(+), 4 deletions(-)

 > diff --git a/package/lua/lua.mk b/package/lua/lua.mk
 > index 2c867f6..b263070 100644
 > --- a/package/lua/lua.mk
 > +++ b/package/lua/lua.mk
 > @@ -15,7 +15,6 @@ LUA_LICENSE = MIT
 >  LUA_LICENSE_FILES = COPYRIGHT
 
 >  LUA_CFLAGS = -Wall -fPIC
 > -LUA_MYLIBS += -ldl
 
 >  ifeq ($(BR2_PACKAGE_LUA_5_2),y)
 >  LUA_CFLAGS += -DLUA_COMPAT_ALL
 > @@ -24,17 +23,22 @@ LUA_CFLAGS += -D_FILE_OFFSET_BITS=32
 >  endif
 >  endif
 
 > +ifneq ($(BR2_BINFMT_FLAT),y)
 > +	LUA_CFLAGS += -DLUA_USE_DLOPEN
 > +	LUA_MYLIBS += -ldl
 > +endif

But BINFMT_FLAT imply BR2_PREFER_STATIC_LIB. I guess we should do this
whenever BR2_PREFER_STATIC_LIB is enabled, right?
Francois Perrad - Jan. 23, 2014, 9:33 a.m.
2014/1/22 Peter Korsgaard <jacmet@uclibc.org>:
>>>>>> "Francois" == Francois Perrad <fperrad@gmail.com> writes:
>
>  > the dlfcn interface is not available with flat memory model
>  > see http://autobuild.buildroot.net/results/b41/b4146bf821d59f694546f6e3a341394cc8fa43ce/
>
>  > Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
>  > ---
>  >  package/lua/lua.mk |   12 ++++++++----
>  >  1 file changed, 8 insertions(+), 4 deletions(-)
>
>  > diff --git a/package/lua/lua.mk b/package/lua/lua.mk
>  > index 2c867f6..b263070 100644
>  > --- a/package/lua/lua.mk
>  > +++ b/package/lua/lua.mk
>  > @@ -15,7 +15,6 @@ LUA_LICENSE = MIT
>  >  LUA_LICENSE_FILES = COPYRIGHT
>
>  >  LUA_CFLAGS = -Wall -fPIC
>  > -LUA_MYLIBS += -ldl
>
>  >  ifeq ($(BR2_PACKAGE_LUA_5_2),y)
>  >  LUA_CFLAGS += -DLUA_COMPAT_ALL
>  > @@ -24,17 +23,22 @@ LUA_CFLAGS += -D_FILE_OFFSET_BITS=32
>  >  endif
>  >  endif
>
>  > +ifneq ($(BR2_BINFMT_FLAT),y)
>  > +    LUA_CFLAGS += -DLUA_USE_DLOPEN
>  > +    LUA_MYLIBS += -ldl
>  > +endif
>
> But BINFMT_FLAT imply BR2_PREFER_STATIC_LIB. I guess we should do this
> whenever BR2_PREFER_STATIC_LIB is enabled, right?

No, the condition BR2_PREFER_STATIC_LIB is too large.
The tarball Lua contains no Configure script, my patch behaves like
the detection of the presence of the functions dlopen/dlclose/dlsym in
a Configure script.
The purpose of BR2_PREFER_STATIC_LIB as described in its help message
is very different.

François

>
> --
> Bye, Peter Korsgaard
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Peter Korsgaard - Jan. 23, 2014, 11:33 a.m.
>>>>> "François" == François Perrad <francois.perrad@gadz.org> writes:

Hi,

 >> But BINFMT_FLAT imply BR2_PREFER_STATIC_LIB. I guess we should do this
 >> whenever BR2_PREFER_STATIC_LIB is enabled, right?

 > No, the condition BR2_PREFER_STATIC_LIB is too large.
 > The tarball Lua contains no Configure script, my patch behaves like
 > the detection of the presence of the functions dlopen/dlclose/dlsym in
 > a Configure script.
 > The purpose of BR2_PREFER_STATIC_LIB as described in its help message
 > is very different.

Well, I wouldn't call it "very different". The idea is to not use shared
libraries when PREFER_STATIC_LIB is enabled, so also not
dlopen/dlclose/dlsym.

What you perhaps mean is that there is a difference between
architectures (or variants) where we select BR2_PREFER_STATIC_LIB
because they cannot support shared libraries (and hence have no
dlopen/dlclose/dlsym), and other situations where the USER just desides
that they don't want shared libraries, even if the architecture could
support it.
Francois Perrad - Jan. 23, 2014, 12:59 p.m.
2014/1/23 Peter Korsgaard <jacmet@uclibc.org>:
>>>>>> "François" == François Perrad <francois.perrad@gadz.org> writes:
>
> Hi,
>
>  >> But BINFMT_FLAT imply BR2_PREFER_STATIC_LIB. I guess we should do this
>  >> whenever BR2_PREFER_STATIC_LIB is enabled, right?
>
>  > No, the condition BR2_PREFER_STATIC_LIB is too large.
>  > The tarball Lua contains no Configure script, my patch behaves like
>  > the detection of the presence of the functions dlopen/dlclose/dlsym in
>  > a Configure script.
>  > The purpose of BR2_PREFER_STATIC_LIB as described in its help message
>  > is very different.
>
> Well, I wouldn't call it "very different". The idea is to not use shared
> libraries when PREFER_STATIC_LIB is enabled, so also not
> dlopen/dlclose/dlsym.
>
> What you perhaps mean is that there is a difference between
> architectures (or variants) where we select BR2_PREFER_STATIC_LIB
> because they cannot support shared libraries (and hence have no
> dlopen/dlclose/dlsym), and other situations where the USER just desides
> that they don't want shared libraries, even if the architecture could
> support it.

Yes, BR2_PREFER_STATIC_LIB is mostly a user choice, when
BR2_BINFMT_FLAT is an architecture limitation.

François

>
> --
> Bye, Peter Korsgaard
Peter Korsgaard - Jan. 23, 2014, 1:56 p.m.
>>>>> "François" == François Perrad <francois.perrad@gadz.org> writes:

Hi,

 >> What you perhaps mean is that there is a difference between
 >> architectures (or variants) where we select BR2_PREFER_STATIC_LIB
 >> because they cannot support shared libraries (and hence have no
 >> dlopen/dlclose/dlsym), and other situations where the USER just desides
 >> that they don't want shared libraries, even if the architecture could
 >> support it.

 > Yes, BR2_PREFER_STATIC_LIB is mostly a user choice, when
 > BR2_BINFMT_FLAT is an architecture limitation.

But why should lua care? If buildroot is configured to use static
libraries, then that's what it should do.

Patch

diff --git a/package/lua/lua.mk b/package/lua/lua.mk
index 2c867f6..b263070 100644
--- a/package/lua/lua.mk
+++ b/package/lua/lua.mk
@@ -15,7 +15,6 @@  LUA_LICENSE = MIT
 LUA_LICENSE_FILES = COPYRIGHT
 
 LUA_CFLAGS = -Wall -fPIC
-LUA_MYLIBS += -ldl
 
 ifeq ($(BR2_PACKAGE_LUA_5_2),y)
 LUA_CFLAGS += -DLUA_COMPAT_ALL
@@ -24,17 +23,22 @@  LUA_CFLAGS += -D_FILE_OFFSET_BITS=32
 endif
 endif
 
+ifneq ($(BR2_BINFMT_FLAT),y)
+	LUA_CFLAGS += -DLUA_USE_DLOPEN
+	LUA_MYLIBS += -ldl
+endif
+
 ifeq ($(BR2_PACKAGE_LUA_INTERPRETER_READLINE),y)
 	LUA_DEPENDENCIES = readline ncurses
 	LUA_MYLIBS += -lreadline -lhistory -lncurses
-	LUA_CFLAGS += -DLUA_USE_POSIX -DLUA_USE_DLOPEN -DLUA_USE_READLINE
+	LUA_CFLAGS += -DLUA_USE_POSIX -DLUA_USE_READLINE
 else
 ifeq ($(BR2_PACKAGE_LUA_INTERPRETER_LINENOISE),y)
 	LUA_DEPENDENCIES = linenoise
 	LUA_MYLIBS += -llinenoise
-	LUA_CFLAGS += -DLUA_USE_POSIX -DLUA_USE_DLOPEN -DLUA_USE_LINENOISE
+	LUA_CFLAGS += -DLUA_USE_POSIX -DLUA_USE_LINENOISE
 else
-	LUA_CFLAGS += -DLUA_USE_POSIX -DLUA_USE_DLOPEN
+	LUA_CFLAGS += -DLUA_USE_POSIX
 endif
 endif