Re: [Tinycc-devel] Multiple, threaded LibTCC states
Hello, 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. Ciao, Michael.___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] Multiple, threaded LibTCC states
TCC have a semaphore that should protect tcc when used by 2 different threads, and I think at some point it was possible to use tcc with 2 different instances. So if TCC crashes it's a bug. Are you on mob or using the last release Jonathan ? Because the semaphore was introduced after 0.9.27. On Fri, Dec 4, 2020 at 9:16 PM Karl Yerkes wrote: > > Hi Jonathan -- > > I am responding because I've tried to use multiple instances of libtcc in > various threads. i am not a tiny CC developer. > > the short answer is no. libtcc is not designed to be reentrant. there is > global state that messes stuff up sometimes when you try to use multiple > instances simultaneously. > > there have been several attempts to move TCC in the direction of reentrancy, > but (to my knowledge) it has not happened yet. > > personally, i've had luck getting two instances working by linking both > statically and then dynamically in the same program. although, i'm not an > expert and i could just be getting lucky. i'm now working to a "one process > per two TCC instances" scheme. > > for more, search the email archives for reentrant. > > if i'm wrong about any of this, i hope someone with more knowledge will > correct me :) > > -- karl > > On Fri, Dec 4, 2020 at 6:07 AM 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. >> >> Thanks, >> Jonathan >> ___ >> Tinycc-devel mailing list >> Tinycc-devel@nongnu.org >> https://lists.nongnu.org/mailman/listinfo/tinycc-devel > > ___ > Tinycc-devel mailing list > Tinycc-devel@nongnu.org > https://lists.nongnu.org/mailman/listinfo/tinycc-devel ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] Multiple, threaded LibTCC states
Hi Jonathan -- I am responding because I've tried to use multiple instances of libtcc in various threads. i am not a tiny CC developer. the short answer is no. libtcc is not designed to be reentrant. there is global state that messes stuff up sometimes when you try to use multiple instances simultaneously. there have been several attempts to move TCC in the direction of reentrancy, but (to my knowledge) it has not happened yet. personally, i've had luck getting two instances working by linking both statically and then dynamically in the same program. although, i'm not an expert and i could just be getting lucky. i'm now working to a "one process per two TCC instances" scheme. for more, search the email archives for *reentrant*. if i'm wrong about any of this, i hope someone with more knowledge will correct me :) -- karl On Fri, Dec 4, 2020 at 6:07 AM 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. > > Thanks, > Jonathan > ___ > Tinycc-devel mailing list > Tinycc-devel@nongnu.org > https://lists.nongnu.org/mailman/listinfo/tinycc-devel > ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
[Tinycc-devel] Multiple, threaded LibTCC states
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. Thanks, Jonathan ___ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel