lua-users home
lua-l archive

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


Hi I'm having some difficulties building Coco 1.1.5 against Lua 5.1.4 on
an x86_64 Linux machine, using gcc 4.4.1.

Actually, I _am_ able to get it to build and pass all the tests with the
stock Makefile + Coco patch.

But my distribution (ArchLinux) changes the Makefile as follows:


------- start of patch ---------
diff -ur lua-5.1.orig/src/Makefile lua-5.1/src/Makefile
--- lua-5.1.orig/src/Makefile	2006-03-21 11:51:53.000000000 +0100
+++ lua-5.1/src/Makefile	2006-03-21 11:52:09.000000000 +0100
@@ -23,6 +23,7 @@
 PLATS= aix ansi bsd generic linux macosx mingw posix solaris
 
 LUA_A=	liblua.a
+LUA_SO=	liblua.so
 CORE_O=	lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
 	lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o  \
 	lundump.o lvm.o lzio.o
@@ -36,7 +37,7 @@
 LUAC_O=	luac.o print.o
 
 ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
+ALL_T= $(LUA_A) $(LUA_SO) $(LUA_T) $(LUAC_T)
 ALL_A= $(LUA_A)
 
 default: $(PLAT)
@@ -51,6 +52,10 @@
 	$(AR) $@ $?
 	$(RANLIB) $@
 
+$(LUA_SO): $(CORE_O) $(LIB_O)
+	$(CC) -shared -ldl -Wl,-soname,liblua.so -o $@.5.1 $? $(MYLDFLAGS)
+	ln -s $@.5.1 $@
+
 $(LUA_T): $(LUA_O) $(LUA_A)
 	$(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
 
----- end of patch ----

and adds -fPIC to the CFLAGS. This is needed to be able to build
liblua.so on x86_64.

Now, if I build with those changes plus the Coco patch, then compilation is successful _but_
the lua executable I get gives a Segmentation Fault for all of the Coco
tests.

If I disable the building of liblua.so and remove -fPIC from the CFLAGS,
then the lua executable I get passes all the Coco tests.

I didn't set any COCCFLAGS, and building with a new GCC, so I'm guessing Coco is using the gccasm method.

I'm in over my head here. Is it possible to build a Lua shared library
with Coco and x86_64? If so, how should I do it? Do I need to change
some more compilation flags?

Here's the build line my distro uses (this is the version that tries to
build liblua.so):


  make INSTALL_DATA="cp -d" TO_LIB="liblua.a" LUA_SO=liblua.so  INSTALL_TOP=$startdir/pkg/usr INSTALL_MAN=$startdir/pkg/usr/share/man/man1 linux install

and here's the result if I change "make...linux install" to
"make...echo":

> These are the parameters currently set in src/Makefile to build Lua
> 5.1.4:

> PLAT = none
> CC = gcc
> CFLAGS = -march=native -mtune=generic -O2 -pipe -fPIC  
> AR = ar rcu
> RANLIB = ranlib
> RM = rm -f
> MYCFLAGS = 
> MYLDFLAGS = 
> MYLIBS = 

> These are the parameters currently set in Makefile to install Lua 5.1.4:

> PLAT = none
> INSTALL_TOP = /var/cache/build/makepkg-tmp-jim/lua/pkg/usr
> INSTALL_BIN = /var/cache/build/makepkg-tmp-jim/lua/pkg/usr/bin
> INSTALL_INC = /var/cache/build/makepkg-tmp-jim/lua/pkg/usr/include
> INSTALL_LIB = /var/cache/build/makepkg-tmp-jim/lua/pkg/usr/lib
> INSTALL_MAN =
> /var/cache/build/makepkg-tmp-jim/lua/pkg/usr/share/man/man1
> INSTALL_LMOD =
> /var/cache/build/makepkg-tmp-jim/lua/pkg/usr/share/lua/5.1
> INSTALL_CMOD = /var/cache/build/makepkg-tmp-jim/lua/pkg/usr/lib/lua/5.1
> INSTALL_EXEC = install -p -m 0755
> INSTALL_DATA = cp -d


I'd be glad for any help.

-- 
Jim Pryor
jim@jimpryor.net