This is on linux on a chromebook: uname -a gives:
Linux penguin 6.6.119-09251-gf81e51484dec #1 SMP PREEMPT Wed, 15 Apr 2026
08:29:49 -0700 aarch64 GNU/Linux
I'm running the latest from mob.
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. With all the recent activity the
_Thread_local I thought this might
be a good time to report this.
Thanks - Eric
#include <stdio.h>#include <stdlib.h>#include "libtcc.h"#pragma
comment(lib, "tcc")
void run(char *decl, void *addr)
{ char prog[1024]; snprintf(prog, sizeof prog - 1, "%s x; %s",
decl, "int get() { return x; }");
TCCState *s = tcc_new(); tcc_set_output_type(s,
TCC_OUTPUT_MEMORY); tcc_set_options(s, "-L/usr/local/lib");
tcc_add_symbol(s, "x", addr);
int (*get)(); if (tcc_compile_string(s, prog) ||
tcc_relocate(s) || !(get = tcc_get_symbol(s, "get"))) {
printf("fail: %s\n", prog); } else { int expected = *(int
*)addr; printf("prog: %s\n%s\n", prog, (get() == expected ?
"OK" : "but something went worng")); }
tcc_delete(s);
}
int x1 = 41;int __thread x2 = 42;
int main(int argc, char *argv[])
{ setbuf(stdout, NULL); int which = (argc > 1 ? atoi(argv[1]) : -1);
switch (which) { case 0: run("int", &x1);
// works fine break; case 1: run("extern int", &x1);
// works fine break; case 2:
run("_Thread_local int", &x2); // libtcc error: 'x' defined
twice break; case 3: run("extern _Thread_local int",
&x2); // segmentation fault break; default:
printf("specify 0-3 on the command line\n"); break; }
}
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel