[Top][All Lists]

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

Re: [Tinycc-devel] Multiple, threaded LibTCC states

From: Michael Matz
Subject: Re: [Tinycc-devel] Multiple, threaded LibTCC states
Date: Sun, 6 Dec 2020 00:40:35 +0100 (CET)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)


On Thu, 3 Dec 2020, Jonathan Levi wrote:

I am using LibTCC to compile runtime defined functions for a rendering layer
of a project of mine.  I compile many of these functions in parallel. 
LibTCC is crashing with exit code -11, at what appears to be when execution
is passed to LibTCC on multiple threads, at the same time.  It happens when
I try to compile multiple functions at the same time, or compile a function
at the same time as calling another already compiled function.  (Although
calling multiple functions at the same time does not appear to exit.)

Should LibTCC work in multiple threads?  I wonder whether I am just missing
a dependency.

It's quite possible that there are still bugs with that, but in general it should work. There's actually a testcase that compiles tcc with itself 20 times with 20 threads, so that makes sure it normally works.

One thing to keep in mind: each thread must use a different top-level TCCState, i.e. tcc_new result, you can't share that one between threads (or at least can't use the same TCCState concurrently). There is a little shared global state in TCC, but all accesses to that one are (supposed to be) protected by appropriate mutexes (fairly coaerse grained).

You also want to use the mob branch of tcc, not the 0.9.27 release. And you may want to have a look at tests/libtcc_test_mt.c to see if you're using libtcc like that testcase does.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]