linux-on-ibm-z / docs

A collection of instructions and tutorials to help you get your favorite software up and running on Linux on z
147 stars 58 forks source link

error compiling wrk on zLinux #32

Open gongsu832 opened 4 years ago

gongsu832 commented 4 years ago

Install LuaJIT from git://github.com/linux-on-ibm-z/LuaJIT.git using branch v2.1 into /usr/local.

Clone wrk from https://github.com/wg/wrk then modify Makefile as:

diff --git a/Makefile b/Makefile
index 0325481..403691b 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ CFLAGS  += -I$(ODIR)/include
 LDFLAGS += -L$(ODIR)/lib

 ifneq ($(WITH_LUAJIT),)
-       CFLAGS  += -I$(WITH_LUAJIT)/include
+       CFLAGS  += -I$(WITH_LUAJIT)/include/luajit-2.1
        LDFLAGS += -L$(WITH_LUAJIT)/lib
 else
        CFLAGS  += -I$(ODIR)/include/luajit-2.1

Compiling wrk with

WITH_LUAJIT=/usr/local make

results in the following error:

LUAJIT src/wrk.lua
luajit: /usr/local/share/luajit-2.1.0-beta3/jit/bcsave.lua:214: bad argument #1 to 'bswap' (number expected, got nil)
LINK wrk
clang: error: no such file or directory: 'obj/bytecode.o'
make: *** [Makefile:56: wrk] Error 1
cwsolee commented 4 years ago

Are u following our instruction(https://github.com/linux-on-ibm-z/docs/wiki/Building-LuaJIT) here to build luajit and has problem? Your issue seems to be talking about building another package.

mundaym commented 4 years ago

It looks like bcsave.lua is part of the JIT package. We haven't ported the JIT compiler to s390x (we only did the virtual machine).

It looks like the Makefile is trying to save the bytecode generated by luajit directly into an object file but the code for doing that in bcsave.lua doesn't support s390x. For example there is no s390x case in this line:

f16(({ x86=3, x64=62, arm=40, arm64=183, arm64be=183, ppc=20, mips=8, mipsel=8 })[ctx.arch])

You might be able to get it to work by adding code to handle s390x to bcsave.lua. I'm not sure if it will be enough though, we might need full JIT support for this application.

gongsu832 commented 4 years ago

@mundaym Thanks Mike. Indeed it sounds like the s390x port is missing some features (JIT in this case). Hacking bcsave.lua might get wrk to work but that requires lua language knowledge which I certainly don't possess. I imagine porting JIT would be a non-trivial undertaking. Is there any plan to do so in the (hopefully not so distant) future?

cwsolee commented 4 years ago

We don't have plan to port JIT because the effort is too huge. We might re-consider if there is a solid business case to do so. Email me to talk further.