lua-users home
lua-l archive

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


Am 15.04.2014 20:25 schröbte Dirk Laurie:
2014-04-15 20:18 GMT+02:00 Roberto Ierusalimschy <roberto@inf.puc-rio.br>:
The `lpeg.so` made for Lua 5.2 by `luarocks install lpeg` under Ubuntu 12.04
is loaded without error by Lua 5.3.

However, the result of running it is not as expected in the case
of position matches.

[...]

If instead I build lpeg from source, obtained by `luarocks download lpeg`
and `luarocks unpack lpeg`, changing LUADIR to the
5.3.0-work2 directory, and doing `luarocks --local make`,
the same thing happens.

If instead of `luarocks --local make` I just say `make`,
after `make clean` of course, the same thing happens.

I have been using LPeg with Lua 5.3 for some time, and I did not have
any of these problems. Your example runs just fine here. As you
are having the same results as when you ran Lua 5.3 with LPeg for 5.2
(where those wrong results were expected), it seems that somehow
your compilation of LPeg is still using the 5.2 header files.


The result seems to be the concatenation of an address and
the correct value 4. That address has the same relationship
to the address of _G as shown above: last 3 hex digits 008
where G has last 3 hex digits 3c0.

This seems a mismatch between the lua_Integer seen by Lua and the one
seen by LPeg. (LPeg pushes a result with 4 bytes where Lua expects an
argument with 8.) Another indication that LPeg is not seeing the correct
header files.


This is what appears on my screen:
…/lpeg-0.12$ make
make lpeg.so "DLLFLAGS = -shared -fPIC"
make[1]: Entering directory `/tmp/lpeg/lpeg-0.12-1/lpeg-0.12'
gcc -Wall -Wextra -pedantic -Waggregate-return -Wcast-align
-Wcast-qual -Wdisabled-optimization -Wpointer-arith -Wshadow
-Wsign-compare -Wundef -Wwrite-strings -Wbad-function-cast
-Wdeclaration-after-statement -Wmissing-prototypes -Wnested-externs
-Wstrict-prototypes  -O2 -ansi
-I/mnt/archive/Downloads/lua/lua-5.3.0-work2 -fPIC   -c -o lpvm.o
lpvm.c
gcc -Wall -Wextra -pedantic -Waggregate-return -Wcast-align
-Wcast-qual -Wdisabled-optimization -Wpointer-arith -Wshadow
-Wsign-compare -Wundef -Wwrite-strings -Wbad-function-cast
-Wdeclaration-after-statement -Wmissing-prototypes -Wnested-externs
-Wstrict-prototypes  -O2 -ansi
-I/mnt/archive/Downloads/lua/lua-5.3.0-work2 -fPIC   -c -o lpcap.o
lpcap.c
gcc -Wall -Wextra -pedantic -Waggregate-return -Wcast-align
-Wcast-qual -Wdisabled-optimization -Wpointer-arith -Wshadow
-Wsign-compare -Wundef -Wwrite-strings -Wbad-function-cast
-Wdeclaration-after-statement -Wmissing-prototypes -Wnested-externs
-Wstrict-prototypes  -O2 -ansi
-I/mnt/archive/Downloads/lua/lua-5.3.0-work2 -fPIC   -c -o lptree.o
lptree.c
gcc -Wall -Wextra -pedantic -Waggregate-return -Wcast-align
-Wcast-qual -Wdisabled-optimization -Wpointer-arith -Wshadow
-Wsign-compare -Wundef -Wwrite-strings -Wbad-function-cast
-Wdeclaration-after-statement -Wmissing-prototypes -Wnested-externs
-Wstrict-prototypes  -O2 -ansi
-I/mnt/archive/Downloads/lua/lua-5.3.0-work2 -fPIC   -c -o lpcode.o
lpcode.c
gcc -Wall -Wextra -pedantic -Waggregate-return -Wcast-align
-Wcast-qual -Wdisabled-optimization -Wpointer-arith -Wshadow
-Wsign-compare -Wundef -Wwrite-strings -Wbad-function-cast
-Wdeclaration-after-statement -Wmissing-prototypes -Wnested-externs
-Wstrict-prototypes  -O2 -ansi
-I/mnt/archive/Downloads/lua/lua-5.3.0-work2 -fPIC   -c -o lpprint.o
lpprint.c
env gcc -shared -fPIC lpvm.o lpcap.o lptree.o lpcode.o lpprint.o -o lpeg.so
make[1]: Leaving directory `/tmp/lpeg/lpeg-0.12-1/lpeg-0.12'



FWIW, I successfully built LPeg 0.12 for Lua 5.3work2 on Ubuntu Linux using the LPeg source tarball. The provided test script ran ok, valgrind reported no abnormalities. I also do suspect that the above output is not from compiling for Lua 5.3 because I had to replace `-ansi` with `-std=c99` to avoid a _lot_ of warnings about the use of `long long` which I don't see above despite `-ansi`, `-pedantic`, and `-Wall`. (I also had to manually enable the 5.2 compatibility macros in `lptypes.h`, as well as change LUALIB, obviously.)

HTH,
Philipp