--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lua-l/aa3dce3a-7c11-401c-95d0-611a8385552en%40googlegroups.com.
Not exactly.
Clx compiles Lua source code to native code (via C++) and produces a standalone executable without the Lua VM: the generated program executes true native (and fast) compiled code, similarly to C, C++ or Rust.
The Lua VM is only optionally embedded when dynamic code execution (load(), loadfile(), dofile()) is required.
SamirIn this case, the Lua function is translated into a C++ lambda, which is then compiled by Clang/GCC/MSVC into machine code.
For example, the Lua f(g()) / g(f()) calls become clx::call_direct() calls. Arguments are passed through LValue arrays (args[]), while multiple return values are represented by clx::MultiValue.
So the pipeline is essentially:
Lua source → generated C++ → C++ compiler → machine code
This is essentially the same model used by other compiled languages: the source is transformed into an intermediate representation (here C++ code) and ultimately compiled to native machine code.
The result is a true standalone native and fast executable, without requiring lua55.dll, liblua5.5.so, or any embedded Lua 5.5 VM.
Samir
Yes, the Lua-to-C++ transpiler is entirely part of clx itself; it has its own parser, optimizer and code generator.
Many projects use bytecode IR (LLVM, MIR,...). I used a similar approach in an earlier project, but the resulting dependencies were too large for my goal of producing very small executables.
So I chose C++ as the IR and let Clang/GCC/MSVC handle the final native compilation.
Samir
--
There is only the compiled executable, called clx.
You can see the emitted cpp file using the --cpp flag.
Hi Rodion,
Thanks for the question.
The goal of clx is mainly to provide a modern compilation path for Lua 5.5, producing small standalone native executables. I wouldn't consider it a direct replacement for LuaJIT, since the target (Lua 5.1) and approaches are quite different (LuaJIT still uses an interpreter and dépends on lua51 Dynamic library).
And yes, you're correct: when using dynamically loaded code, it runs through the optional embedded Lua 5.5 VM, so its performance is that of the interpreter (minus the bridge overhead). The main application code remains compiled native code and interfaces with dynamic code seamlessly.
Regards,
Samir
To view this discussion visit https://groups.google.com/d/msgid/lua-l/CAL2n1txE45GT9UNKBAZ3ZGuveFMgdA9OejnHH3Y19M8tBuqibQ%40mail.gmail.com.
Hi Martin,
Thanks for trying clx, and I'm sorry you've run into this issue.
To avoid cluttering the mailing list, could you please open an issue on GitHub and include your CPU model (or the output of lscpu) along with any other details about your system?
I'll investigate it there.
Samir
Thank you Sergio !
I will fix the benchmark typo and create a new issue template for documentation errors.
Samir