lua-users home
lua-l archive

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


On 3/19/2023 5:29 AM, Roger Leigh wrote:
[snip]
As a result, I've started this project recently: https://gitlab.com/codelibre/lua/lua-cmake

I have tried to do a much more comprehensive job in supporting all of the build options provided by Lua, including:

- Autodetects all supported platforms
- Supports all modes of building shared libraries
- Supports all defines for selecting languages and language behaviours
- Autodetects and supports line editing (Readline or Editline)

To Do: library versioning, exported configuration, installation, packaging, CI testing.

The aim was to pick up where LuaDist left off, working with Lua 5.4.4 and with much of the logic and options being inspired by their work.  It's not quite yet at feature parity, but will catch up quickly once those todo items are completed.

If this is of interest to anyone and you would like to give it a try and provide some feedback, I'd be very grateful.

One issue I have found is that luac can't be linked when building lua as a DLL or shared library:

Windows:

"C:\Program Files\CMake\bin\cmake.exe" --build C:\Users\rleigh\code\lua-cmake\cmake-build-debug-visual-studio-2022-shared --target luac -j 12
[1/2] Linking C shared library src\lua.dll
[2/2] Linking C executable src\luac.exe
FAILED: src/luac.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=src\CMakeFiles\luac.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\mt.exe --manifests  -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1435~1.322\bin\Hostx64\x64\link.exe /nologo src\CMakeFiles\luac.dir\luac.c.obj  /out:src\luac.exe /implib:src\luac.lib /pdb:src\luac.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console  src\lua.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cmd.exe /C "cd /D C:\Users\rleigh\code\lua-cmake\cmake-build-debug-visual-studio-2022-shared\src && C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy Bypass -file E:/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary C:/Users/rleigh/code/lua-cmake/cmake-build-debug-visual-studio-2022-shared/src/luac.exe -installedDir E:/vcpkg/installed/x64-windows/debug/bin -OutVariable out""
LINK Pass 1: command "C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1435~1.322\bin\Hostx64\x64\link.exe /nologo src\CMakeFiles\luac.dir\luac.c.obj /out:src\luac.exe /implib:src\luac.lib /pdb:src\luac.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console src\lua.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:src\CMakeFiles\luac.dir/intermediate.manifest src\CMakeFiles\luac.dir/manifest.res" failed (exit code 1120) with the following output:
luac.c.obj : error LNK2019: unresolved external symbol luaM_free_ referenced in function combine
luac.c.obj : error LNK2019: unresolved external symbol luaG_getfuncline referenced in function PrintCode
luac.c.obj : error LNK2019: unresolved external symbol luaU_dump referenced in function pmain
src\luac.exe : fatal error LNK1120: 3 unresolved externals
ninja: build stopped: subcommand failed.
Unix:

[snip]

I had this too, when building Luac on Windows, with Lua as a DLL.  What
I did was to define LUAI_FUNC to __declspec( dllexport ) or dllimport
as appropriate.

The result is that the DLL will now "export" private functions, but
that's not a concern for me personally.  There are ways to make the
export list /safer/ but I think that's not important now.

Another annoyance is that as of 5.4.4, luaconf.h is not written in a way
that allows people to -DLUAI_FUNC, and -DLUAI_DDEF on the command line,
and luaconf.h must be edited.  That's a minor annoyance, and I currently
plan to write up a patch to fix that, but if someone wants to do it
before me, go ahead.

Now, as I review my own changes, I notice I didn't make LUAI_DDEF
external, but Luac at least works in my private tests, and Lua does
work in all instance I've put it through.

Let me know if you want my specific patch to luaconf.h.


Johann