Grischka last commit breaks some ports

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Grischka last commit breaks some ports

Christian Jullien-3

On OpenBSD:

 

Test: 106_pthread...

106_pthread.c:13: warning: implicit declaration of function 'pthread_condattr_setpshared'

tcc: error: undefined symbol 'pthread_condattr_setpshared'

diff: 106_pthread.output: No such file or directory

gmake[3]: *** [Makefile:122: 106_pthread.test] Error 2

Test: 107_stack_safe...

Test: 108_constructor...

Test: 109_float_struct_calling...

Test: 110_average...

Test: 111_conversion...

Test: 112_backtrace...

Test: 113_btdll...

Segmentation fault (core dumped)

--- 113_btdll.expect    Thu Dec 17 17:28:08 2020

+++ 113_btdll.output    Thu Dec 17 17:28:39 2020

@@ -1,6 +0,0 @@

-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

gmake[3]: *** [Makefile:122: 113_btdll.test] Error 1

Test: 114_bound_signal...

^^^^  wait forever

 

It’s more strange on Windows, when I try to build a 32/64bits version boostrapped from gcc, it builds tcc and two backends.

tcc.exe

i386-win32-tcc.exe

x86_64-win32-tcc.exe

 

./tcc (or –m64) produces an executable using x86_64-win32-tcc.exe

 

But ./tcc –m32 refuses to execute i386-win32-tcc.exe which has an invalid permission. Ls –ls looks good, only clicking on property shows that rights are wrong.

 

tinycc-02f61d5 works like a charm.

 

I’ve not tested your commit on other platforms.


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Grischka last commit breaks some ports

grischka
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?

> Test: 113_btdll...

Seen from the snippet below, tcc does or wants to support
DLL/SO's on OpenBSD:

     #if TARGETOS_OpenBSD ...
             /* add crt end if not memory output */
         if (s1->output_type == TCC_OUTPUT_DLL)
             tcc_add_crt(s1, "crtendS.o");

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

This tests tends to hang on linux too (sometimes),  Might
be an occasion to find out why.

> It's more strange on Windows, when I try to build a 32/64bits version
> boostrapped from gcc, it builds tcc and two backends.

Can be great to do things differently and to love it but for the
other people I would recommend to try out the busybox pack for tcc
on windows here: http://download.savannah.nongnu.org/releases/tinycc/

-- gr

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Grischka last commit breaks some ports

tinycc-devel mailing list
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.
>
>
>> 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 process.

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.

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)))'
See code below.
tcc prints: 388
gcc prints: 392.
If I move the jmpbuf field in the struct TCCState to the end the code works.

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

     Herman



#include <stdio.h>

typedef int __jmp_buf[64] __attribute__((__aligned__ (8)));
typedef struct
{
   unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
} __sigset_t;

struct __jmp_buf_tag
   {
     __jmp_buf __jmpbuf;
     int __mask_was_saved;
     __sigset_t __saved_mask;
   };

int
main(void)
{
    printf ("%d\n", sizeof (struct __jmp_buf_tag));
    return 0;
}



_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Grischka last commit breaks some ports

Christian Jullien-3
Hello,
__aligned__ or alike, when used, is always for good reasons (machine constraints, performances, compatibility...)
So, if not too complex, I vote for __aligned__ support which will improve compatibility  with gcc libs.

M2c.

P.S. After a clean install, win32 mob works again, ignore my previous mail about it. Sorry for the noise. I suspect Cygwin does nasty things sometimes with permissions event with noacl (unclear why 64bit worked?):

# /etc/fstab
#
#    This file is read once by the first process in a Cygwin process tree.
#    To pick up changes, restart all Cygwin processes.  For a description
#    see https://cygwin.com/cygwin-ug-net/using.html#mount-table

# This is default anyway:
none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

C.
-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Herman ten Brugge via Tinycc-devel
Sent: Saturday, December 19, 2020 07:25
To: [hidden email]
Cc: Herman ten Brugge
Subject: Re: [Tinycc-devel] Grischka last commit breaks some ports

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.
>
>
>> 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 process.

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.

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)))'
See code below.
tcc prints: 388
gcc prints: 392.
If I move the jmpbuf field in the struct TCCState to the end the code works.

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

     Herman



#include <stdio.h>

typedef int __jmp_buf[64] __attribute__((__aligned__ (8)));
typedef struct
{
   unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
} __sigset_t;

struct __jmp_buf_tag
   {
     __jmp_buf __jmpbuf;
     int __mask_was_saved;
     __sigset_t __saved_mask;
   };

int
main(void)
{
    printf ("%d\n", sizeof (struct __jmp_buf_tag));
    return 0;
}



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


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Grischka last commit breaks some ports

grischka
In reply to this post by tinycc-devel mailing list
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.

>>> 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
> process.
>
> 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.

> 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
> works.
>
> 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?

-- grischka

>
>     Herman
>
>
>
> #include <stdio.h>
>
> typedef int __jmp_buf[64] __attribute__((__aligned__ (8)));
> typedef struct
> {
>   unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
> } __sigset_t;
>
> struct __jmp_buf_tag
>   {
>     __jmp_buf __jmpbuf;
>     int __mask_was_saved;
>     __sigset_t __saved_mask;
>   };
>
> int

> main(void)
> {
>    printf ("%d\n", sizeof (struct __jmp_buf_tag));
>    return 0;
> }
>


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Grischka last commit breaks some ports

tinycc-devel mailing list
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
>> process.
>>
>> 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
>> works.
>>
>> 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__ 🙁

     Herman


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__
+#endif
  #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))))
  #endif

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

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




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