AmigaLabs / clib4

Clib4 for AmigaOS4
Other
14 stars 7 forks source link

Don't include SDK include in the public include fields of clib4 #165

Closed migthymax closed 2 months ago

migthymax commented 8 months ago

During compiling gdb of binutils, there are a lot of errors regarding redefinition of FLOAT, STATIC, etc. That's coming from the pthread.h include file, including <exec/types.h> and <exec/semaphores.h> These than expose the amigaos SDK internal types, which collides with the types from the clib4, which results in the mention errors.

A quick workaround is to remove the two includes. Than there are four places, which needs to be adopted. The APTR needs to be changed to void*, the other can be commented out.

There are probably other places in clib4 where the exposing of the implementation internals via SDK include should be removed.

3246251196 commented 8 months ago

@migthymax Hey Max, so is it easy to reproduce this by creating a standard main.c and including a few header files?

Thanks.

migthymax commented 8 months ago

@3246251196 I tried to nail it down as much i could.

clib4_pthreads_expose.c:

#include <pthread.h>

typedef int16 LONG;

int main( int argc,char *argv[] )
{
 return 0;
}

Compile it with

ppc-amigaos-gcc -mcrt=clib4 -o text_clib4 clib4_pthreads_expose.c

And it fails with:

clib4_pthreads_expose.c:3:15: error: conflicting types for ‘LONG’; have ‘int16’ {aka ‘short int’}
    3 | typedef int16 LONG;
      |               ^~~~
In file included from /opt/ppc-amigaos/ppc-amigaos/SDK/clib4/include/pthread.h:29,
                 from clib4_pthreads_expose.c:1:
/opt/ppc-amigaos/ppc-amigaos/SDK/include/include_h/exec/types.h:113:17: note: previous declaration of ‘LONG’ with type ‘LONG’ {aka ‘long int’}
  113 | typedef  int32  LONG;
3246251196 commented 8 months ago

@migthymax This is precisely the sort of thing we need all the time. A nice and simple reproducible. Nice work. @afxgroup I can also have a look into it. Is there a known workaround for now?

migthymax commented 7 months ago

I even found includes to SDK header files in the malloc.h header file. They should probably even be removed. Removing them don't seem to have any consequences. The clib4 just compiles fines, at least with the changes from my PR https://github.com/AmigaLabs/clib4/pull/166

afxgroup commented 7 months ago

I've tried to compile openssl3 and now I have an error here:


   50 |     if ((lock = CRYPTO_zalloc(sizeof(pthread_rwlock_t), NULL, 0)) == NULL)```
afxgroup commented 7 months ago

This is fixed for pthread parts now. There are few includes file that has included and should be fixed

3246251196 commented 5 months ago

At least the master branch continues to expose "BOOL" in "pthread.h" which causes issues with some ports.

In file included from /home/rjd/projects/ppc-amigaos-gcc11/ppc-amigaos/SDK/clib4/include/pthread.h:29,
...
/home/rjd/projects/ppc-amigaos-gcc11/ppc-amigaos/SDK/include/include_h/exec/types.h:186:15: note: previous declaration of ‘BOOL’ with type ‘BOOL’ {aka ‘short int’}
afxgroup commented 5 months ago

I've defined BOOL now as typedef short BOOL we have already in the SDK. So no clashes and you should not get any other error. Committed in beta10

afxgroup commented 5 months ago

Sorry, i've read better your comment but i don't understand where you are getting that BOOL. on line 29 in pthread.h there is include <sched.h> and in sched.h there are no BOOL variables. Same in pthread.h. Are you sure you are using beta10?

3246251196 commented 4 months ago

I'll come back to you on this. I do know that the recent change to pthreads header file was a huge success and the removing of dos.h solves a lot of type conflicts.

afxgroup commented 3 months ago

Can we close this? i've moved dos.h file away from include dir. and now no more public includes it is using it. Can you confirm please?

3246251196 commented 2 months ago

@afxgroup I would say: close it.

We can re-open a new issue if we find that the problem is not solved.