Backends¶
The backend is the part of autoplay2c that turns your compiled code into a DLL. There are two of them:
| Backend | Option | Description |
|---|---|---|
| Native | --backend native |
autoplay2c's own code generator and DLL writer. This is the default. |
| C with tcc | --backend c |
Writes the module as C and compiles it with tcc, the Tiny C Compiler. |
Use the native backend. It builds faster, its code runs faster, and it doesn't need anything besides autoplay2c. Both backends make modules that behave the same, since every test runs against both.
The C backend is there as a fallback, in case you ever run into a problem with the native one. If you do, please report it!
Choosing a Backend¶
On the command line, you choose the backend with --backend:
In the application, choose Backend on the Compiler page. In a
project file, it's the Backend setting (native or c).
Finding tcc¶
The C backend needs a tcc toolchain folder, with i386-win32 and x86_64-win32 in it. autoplay2c
looks for it in this order:
- the folder you give with
--tcc(which also selects the C backend), - the folder in the environment variable
A2C_TCC, - a folder named
tccnext toa2c.
The Windows installer puts tcc in that last place, so the C backend works right away. The application's Compiler page shows you where it found tcc, if it did.
Looking Inside¶
You can keep what the compiler made next to the DLL, with --emit or with the options on the
Compiler page:
| Output | What you see |
|---|---|
lua |
The module's Lua source: all your scripts as one module. Projects only. |
c |
The module as C. Made by either backend, but only the C backend compiles it. |
ir |
The compiler's intermediate code, close to the Lua C API calls it makes |
asm |
The native backend's machine code, disassembled, with names for functions, strings and API calls |
These are for the curious, and for reporting problems. You don't need any of them to use your module.
Technical details
- The native backend writes the DLL directly: code, imports, exports, relocations, the version resource and, on x64, the unwind information Windows needs to pass errors through compiled code.
- The same input gives the same DLL, byte for byte, because there's no time stamp in it.
- DLLs are built with ASLR and DEP enabled, and name Windows XP as the oldest Windows they need, as the hosts themselves do.
- tcc is built from pinned sources for both architectures, on every platform autoplay2c runs on.