lua-users home
lua-l archive

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


On 09.11.2011 09:51, Benoit Germain wrote:
2011/11/7 Taj Khattra<>:

try moving -lpthread to the end of the command line
    cc -shared lanes.o threading.o tools.o keeper.o -lpthread -o


MinGW compilation remains happy if I change the makefile as follows:

lua51-$(MODULE)$(_SO): $(OBJ)
-	$(CC) $(LIBFLAG) $(LIBS) $^ $(LUA_LIBS) -o $@
+	$(CC) $(LIBFLAG) $^ $(LIBS) $(LUA_LIBS) -o $@

Tell me if Ubuntu 11.10 is happy with this change too, so that I can commit it.

LuaLanes builds on Ubuntu 11.10 with this fix. But note that in general linking with libpthread is not enough to compile multithreaded programs, and it is not equivalent to the -pthread compiler flag[1], which on Linux also sets -D_REENTRANT (which is required by POSIX for all multithreaded code). But I guess it only makes a difference if you compile Lua and all your C extensions yourself, since I doubt that this flag is used in most makefiles by default. Lanes itself currently does not use any feature that depends on _REENTRANT in Ubuntu 11.10. So let's hope for the best.
Btw, there is also a -mthread gcc option for MinGW ...


While you are at it, there are still two warnings which break the build if -Werror is set:
lanes.c: In function ‘LG_set_debug_threadname’:
lanes.c:1361:14: warning: variable ‘threadName’ set but not used [-Wunused-but-set-variable]
tools.c: In function ‘populate_func_lookup_table_recur’:
tools.c:291:17: warning: variable ‘fqnString’ set but not used [-Wunused-but-set-variable]

... and two more if using -Wextra:lanes.c:
In function ‘LG_wakeup_conv’:
lanes.c:2206:12: warning: missing initializer [-Wmissing-field-initializers]
lanes.c:2206:12: warning: (near initialization for ‘t.tm_gmtoff’) [-Wmissing-field-initializers]
threading.c: In function ‘THREAD_WAIT’:
threading.c:666:33: warning: unused parameter ‘ref’ [-Wunused-parameter]

The glibc memory corruption is gone, but now I get an assertion failure on 'make test' (not always on the first test, but I don't get far):
lua5.1: lanes.c:1018: selfdestruct_remove: Assertion `found' failed.
Aborted (core dumped)