[cfe-dev] Building Lua with Clang on Windows 10

Russell Haley via cfe-dev cfe-dev at lists.llvm.org
Sat Jan 11 13:34:33 PST 2020


Forwarding a conversation where I forgot to CC the mailing list...

On Sat, Jan 11, 2020 at 10:59 AM Zachary Turner <zturner at roblox.com> wrote:

> Sure, go ahead.
>
> You might need to build llvm from source to get strip and ranlib, I’m not
> sure what’s in the install package
>
To the Bat Cave!

>
> On Sat, Jan 11, 2020 at 10:21 AM Russell Haley <russ.haley at gmail.com>
> wrote:
>
>>
>>
>> On Sat, Jan 11, 2020 at 7:48 AM Zachary Turner <zturner at roblox.com>
>> wrote:
>>
>>> llvm has versions of both of those.  llvm-strip and llvm-ranlib
>>>
>> Hmmm... I have a new installation of LLVM (done last night) and it
>> doesn't seem to include llvm-strip?
>>
>> I just realized both our conversations went private (e.g. not on the
>> mailing list anymore). That's my fault, the lua mailing list does an
>> automatic reply all and I forget when using other mailing lists. If your
>> comfortable with that, I'll take the opportunity to ask you about your
>> awesome job (I checked you on linkedin), otherwise I'll reply all.
>>
>> Cheers,
>> Russ
>>
>>>
>>> On Fri, Jan 10, 2020 at 11:28 PM Russell Haley <russ.haley at gmail.com>
>>> wrote:
>>>
>>>>
>>>>
>>>> On Fri, Jan 10, 2020 at 10:45 PM Zachary Turner <zturner at roblox.com>
>>>> wrote:
>>>>
>>>>> If you’re trying to build a 32-bit lua, pass -m32 for all clang
>>>>> invocations.  If you’re trying to build a 64-bit lua, pass -m64 instead.
>>>>> That should hopefully fix it.
>>>>>
>>>>> Also, cross posting between Lia and clang mailing lists... This is a
>>>>> new one :)
>>>>>
>>>>
>>>> Yes, it's a bit cheeky isn't it? I checked the installation date for
>>>> clang I've been wringing my hands about this issue for three years
>>>> apparently. Capre diem and all that.
>>>>
>>>> So close!  Is there a microsoft/llvm equivalent to "strip" or ranlib?
>>>>
>>>> clang -std=c99 -m32 -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
>>>>    Creating library lua53.lib and object lua53.exp
>>>> strip --strip-unneeded lua53.dll
>>>> process_begin: CreateProcess(NULL, strip --strip-unneeded lua53.dll,
>>>> ...) failed.
>>>> make (e=2): The system cannot find the file specified.
>>>> make[1]: *** [lua53.dll] Error 2
>>>> make[1]: Leaving directory `C:/Users/russh/lua/lua-5.3.5/src'
>>>> make: *** [clang] Error 2
>>>>
>>>> (Also, thank you!)
>>>> Russ
>>>>
>>>>>
>>>>> On Fri, Jan 10, 2020 at 10:22 PM Russell Haley via cfe-dev <
>>>>> cfe-dev at lists.llvm.org> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Jan 10, 2020 at 10:01 PM Russell Haley <russ.haley at 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
>>>>>> _______________________________________________
>>>>>> cfe-dev mailing list
>>>>>> cfe-dev at lists.llvm.org
>>>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>>>>
>>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200111/41bf51c7/attachment-0001.html>


More information about the cfe-dev mailing list