Greetings,

It would appear that tcc doesn't support .symver assembler directive.
FreeBSD uses it for the __sym_compat macro invocation for an old qsort
interface:

#if defined(__generic) || defined(__cplusplus)
void __qsort_r_compat(void *, size_t, size_t, void *,
            int (*)(void *, const void *, const void *));
__sym_compat(qsort_r, __qsort_r_compat, FBSD_1.0);
#endif

Where __sym_compat is defined in cdefs.h:
#define __sym_compat(sym,impl,verid)    \
        __asm__(".symver " #impl ", " #sym "@" #verid)

I get this error when building tcc:
/usr/include/stdlib.h:353: error: unknown opcode '.symver'
(which corresponds to the line the above appears at).

If I have this code in cdefs.h:

#ifdef __TINYC__
#define __sym_compat(a,b,c)
#else
/* The above define */
#endif

That solves the problem. Since I have a FreeBSD commit access, I can easily
fix this. In fact, I'm going through FreeBSD's cdefs.h trying to clean
things up. I'd like to not break tcc, but it looks like it's starting out
broken and I'd like to fix that as part of this... The above hack is the
'obvious' fix, but I thought I'd ask here to see if the wisdom of this
crowd exceeds my quick and dirty somewhat ugly hack.

Running the tests, btw, shows things are close, but not quite right. Two
tests are failing:
Test: 108_constructor...
--- 108_constructor.expect 2023-11-24 23:18:30.255708000 -0700
+++ 108_constructor.output 2023-11-25 08:12:48.572593000 -0700
@@ -1,3 +1 @@
-constructor
 main
-destructor

and

Test: 126_bound_global...
--- 126_bound_global.expect 2023-11-24 23:18:30.259390000 -0700
+++ 126_bound_global.output 2023-11-25 08:12:49.954458000 -0700
@@ -1,2 +0,0 @@
-126_bound_global.c:11: at main: BCHECK: ........ is outside of the region
-126_bound_global.c:11: at main: RUNTIME ERROR: invalid memory access
gmake[2]: *** [Makefile:136: 126_bound_global.test] Error 1

The former likely needs a tweak since FreeBSD's ctor/dtor stuff was redone
in the last few years. The bound global isn't detecting bounds. Not sure
why.

There's also a pseudo failure where the output isn't nested like it should
be:
Test: 113_btdll...
--- 113_btdll.expect 2023-11-24 23:18:30.256779000 -0700
+++ 113_btdll.output 2023-11-25 08:12:48.701184000 -0700
@@ -1,6 +1,3 @@
-113_btdll.c:12: at f_1: hello from f_1() / 113_btdll.c:12
-113_btdll.c:37: by main
-113_btdll.c:20: at f_2: hello from f_2() / 113_btdll.c:20
-113_btdll.c:38: by main
-113_btdll.c:31: at f_main: hello from f_main() / 113_btdll.c:31
-113_btdll.c:39: by main
+hello from f_1() / 113_btdll.c:12
+hello from f_2() / 113_btdll.c:20
+hello from f_main() / 113_btdll.c:31

Warner
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to