[Top][All Lists]

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

Re: [Tinycc-devel] Grischka last commit breaks some ports

From: Herman ten Brugge
Subject: Re: [Tinycc-devel] Grischka last commit breaks some ports
Date: Sat, 19 Dec 2020 12:34:30 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

On 12/19/20 10:40 AM, grischka wrote:
Herman ten Brugge via Tinycc-devel wrote:
On 12/18/20 2:45 PM, grischka wrote:
Christian Jullien wrote:
On OpenBSD:

I noticed some tests were excluded but the reasons were say
not really obvious:

Test: 106_pthread...

From it's name it's testing pthreads. OpenBSD appears to have
pthreads. So what is the deal?
I added a comment that pthread_condattr_setpshared does not exists.

Better than nothing.  Still someone might ask what the heck so
interesting with pthread_condattr_whatnot is this trying to test
at all?  (You know that, and maybe I do, but...)

Anyway, if printf had versyms then I'd just test that instead and
while at it, rename to 106_versym.  I guess it doesn't.
I can rename the testcase if you want to.

Test: 114_bound_signal...
^^^^  wait forever

I think I mailed the reason before.
The problem is in the libc implementation.
- signals should be disabled during pthread_create
- after a fork libc should init the internal i/o mutex for a client

I fixed the pthread_create problem in bcheck.c but this does not work
for bsd because of broken dlsym.
I disabled the fork test on mac. All other libc do this correctly.

Hm, on an alpine musl it does hang, sometimes.  Sometimes it comes
back after a few seconds.  Sometimes almost instantly.
Probably due to fork problem. This looks a lot like the mac problem.
If you attach a debugger when the code hangs you probably see it
waiting on on i/o mutex.

There is also another problem.
The dlltest does not work on arm(32 bits) because the jmp_buf has
different size in tcc and gcc due to '__attribute__((__aligned__ (8)))'

Only the "dlltest with PIC" links to a gcc file.  But wrong size
for TCCState is not good.

See code below.
tcc prints: 388
gcc prints: 392.
If I move the jmpbuf field in the struct TCCState to the end the code

Should we implement the aligned attribute in tcc or should we disable
this test on arm32?

We do have the aligned attribute in tcc and we tried to make it
work. Also, your test does print 392 with tcc on a 32-bit windows:

#define BF_DEBUG

    set field __val offset 0  size 128 align 4
    struct size 128 align 4

    set field __jmpbuf offset 0  size 256 align 8
    set field __mask_was_saved offset 256 size 4  align 4
    set field __saved_mask offset 260 size 128 align 4
    struct size 392 align 8

Why it can be different on arm,  hm...,  maybe __attribute__ was
defined to empty?

The patch below fixes the problem. I will test on all targets before committing it.
This is not the first time that I had a problem with __attribute__ 🙁


diff --git a/tcc.h b/tcc.h
index a9a822e..373076d 100644
--- a/tcc.h
+++ b/tcc.h
@@ -28,6 +28,10 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
+/* gnu headers use to #define __attribute__ to empty for non-gcc compilers */
+#ifdef __TINYC__
+# undef __attribute__
 #include <string.h>
 #include <errno.h>
 #include <math.h>
@@ -108,10 +112,6 @@ extern long double strtold (const char *__nptr, char **__endptr);
 # define PRINTF_LIKE(x,y) __attribute__ ((format (printf, (x), (y))))

-/* gnu headers use to #define __attribute__ to empty for non-gcc compilers */
-#ifdef __TINYC__
-# undef __attribute__

 #ifdef _WIN32
 # define IS_DIRSEP(c) (c == '/' || c == '\\')

reply via email to

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