Re: [ANN] CLX - Ahead-of-Time Lua 5.5 Compiler

"David Given" <[email protected]> Sat, 27 Jun 2026 09:29:59 +0200
Newsgroups gmane.comp.lang.lua.general
Message-ID <[email protected]>
Just so you're aware, eons ago I wrote a program which used ucontext-based coroutines, and it was a total disaster. While it worked on *most* platforms, there appear to be some (certain Linux architectures, I recall vaguely) where ucontext interacted very badly with pthreads. From what I remember the platform would do something like ALIGNUP(stackpointer, 10MB) to find the TLS data structure for the running thread. As you might image, when switching to a ucontext stack allocated from the heap, Very Bad Things happened. I eventually had to give up and use threads, with a semaphore to ensure that only one thread was executing at a time. (This was actually pretty helpful, as I could have individual threads enter thread-safe sections for doing certain long-running operations while allowing other threads to execute.)

I do note that C++20 now has a feature which it calls coroutines, except they don't actually appear to be coroutines by any normal definition of the word. Coroutines are apparently now called fibres. Sigh. At least there do appear to be a number of supported fibre libraries.

On another note: are you aware of the Luau strong-typing extension to Lua? It was written by Roblox and is pretty good. I recent migrated my word processor WordGrinder to it and found *so* many bugs. If I could run Luau-annoted Lua though CLX and end up with a native executable, I would be extremely happy.

On Fri, 26 Jun 2026, at 18:01, [email protected] wrote:
> CLX coroutines are stackful.
> 
> Internally they use ucontext (POSIX) or Windows Fibers (Windows), so yielding is implemented as a context switch between execution contexts rather than via longjmp.
> 
> This means local state and call frames remain intact across yields.
> 
> For native C++ modules, yielding follows the same coroutine semantics as Lua: execution can be suspended and resumed without manually preserving state.
> 
> 
> 
> 
> Le 26/06/2026 08:35, 'Sewbacca' via lua-l a écrit :
> 
>> This peaks my interest: How did you implement yielding under the hood? Did you use longjmp or did you employ a different technique? And what does yielding mean for the C++ interface? 
>> 
>> ~ Sewbacca
>> 
>> 
>> -- 
>> 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 [email protected].
>> To view this discussion visit https://groups.google.com/d/msgid/lua-l/1c10d7db-e7bb-4bc0-a39c-f1e83aca1995%40kolabnow.com <https://groups.google.com/d/msgid/lua-l/1c10d7db-e7bb-4bc0-a39c-f1e83aca1995%40kolabnow.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> 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 [email protected].
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/9e9ffe99be701b46cc8eca4e861321de%40luart.org <https://groups.google.com/d/msgid/lua-l/9e9ffe99be701b46cc8eca4e861321de%40luart.org?utm_medium=email&utm_source=footer>.

-- 
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 [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/b9aeb39d-383d-4230-ac94-0aef3a63ef40%40app.fastmail.com.