On 02.09.2026 02:35, Eric Raible wrote:
Here is a simple self-contained example.  It seems to show that tcc_add_symbol 
doesn't work with
_Thread_local, at least on my setup.

Hi, two things...

1) "tcc -run" / JIT libtcc does not support thread local storage
    (error message still missing...)

2) __thread variables may look like normal variables but they are not.

As such, with

    int__thread x2 = 42;
    tcc_add_symbol(s, "x2", &x2);

this 'x2' does not have an address really.  All you can do from C is
to take the address of the current threads instance of 'x2'. But then
again that instance is not a '__thread' object.  It is just a  normal
'int' with 4 bytes somewhere in the memory address space.

Which of course JIT code could still access as 'extern int x2;'
(plus __attribute__((dllimport)) on windows).

That is how I would see it...

-- gr


Thanks - Eric

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to