lua-users home
lua-l archive

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




On Fri, Jan 10, 2020 at 10:01 PM Russell Haley <russ.haley@gmail.com> wrote:
Hi,

I'm taking a shot at building Lua with Clang on Windows and I'm stalled out on modifying the standard Lua makefile. I've tried both the GNU Win32 Make (3.8.1) and Digital Mars Make (It came with DLang). All the below work is with GNU Make.

To modify the Makefile for Windows, I changed CC = clang. Then I've replaced *.o with *.obj in the file and created a new target called clang which looks like this (full modified makefile here: https://pastebin.com/BXGvrPiD)

clang:
$(MAKE) "LUA_A=lua53.dll" "LUA_T=lua.exe" \
"AR=lib" \
"SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
$(MAKE) "LUAC_T=luac.exe" luac.exe 

mingw:
$(MAKE) "LUA_A=lua53.dll" "LUA_T=lua.exe" \
"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
"SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
$(MAKE) "LUAC_T=luac.exe" luac.exe

The above is my attempt to modify the mingw target which I have also included for reference. I've tried the clang target with -shared and -o left in and removed, both with no success. This is the result of my latest attempt with -shared and -o left in: 

C:\Users\russh\lua\lua-5.3.5\src> make clang
make "LUA_A=lua53.dll" "LUA_T=lua.exe" \
        "AR=clang -std=gnu99 -shared -o" \
        "AR=lib -shared -o" \
        "SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
make[1]: Entering directory `C:/Users/russh/lua/lua-5.3.5/src'
lib -shared -o lua53.dll lapi.obj lcode.obj lctype.obj ldebug.obj ldo.obj ldump.obj lfunc.obj lgc.obj llex.obj lmem.obj lobject.obj lopcodes.obj lparser.obj lstate.obj lstring.obj ltable.obj ltm.obj lundump.obj lvm.obj lzio.obj lauxlib.obj lbaselib.obj lbitlib.obj lcorolib.obj ldblib.obj liolib.obj lmathlib.obj loslib.obj lstrlib.obj ltablib.obj lutf8lib.obj loadlib.obj linit.obj
Microsoft (R) Library Manager Version 14.16.27024.1
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : warning LNK4044: unrecognized option '/shared'; ignored
LINK : warning LNK4044: unrecognized option '/o'; ignored
LINK : fatal error LNK1181: cannot open input file 'lua53.dll'
make[1]: *** [lua53.dll] Error 1181
make[1]: Leaving directory `C:/Users/russh/lua/lua-5.3.5/src'
make: *** [clang] Error 2

It seems to me to be missing the compile step and going straight to the link step?

Any input would be appreciated. 

Regards,
Russell

Ugh. I spent hours tonight trying things then finally spend the time to write up that last email and fire it off. Three seconds later I thought of a new path and it turned out to solve the issue. I reverted back to the original makefile and started again. I change CC=clang and set MAKE= make (to fix the spaces in the installed path).

Anyway, Now I'm stuck with an architecture mis-match:

 make clang
make "LUA_A=lua53.dll" "LUA_T=lua.exe" \
        "AR=clang -std=gnu99 -shared -o" "RANLIB=strip --strip-unneeded" \
        "SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
make[1]: Entering directory `C:/Users/russh/lua/lua-5.3.5/src'
clang -std=gnu99 -shared -o lua53.dll lapi.o lcode.o lctype.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 lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o lmathlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o loadlib.o linit.o
libcmt.lib(chkstk.obj) : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
clang: error: linker command failed with exit code 1112 (use -v to see invocation)
make[1]: *** [lua53.dll] Error 1112
make[1]: Leaving directory `C:/Users/russh/lua/lua-5.3.5/src'
make: *** [clang] Error 2
 
Regards,
Russell