Skip to content

Is it possible to support cosmopolitan? #18

@duke13137

Description

@duke13137

Hi, thank you for the very neat library bringing C one step closer to Go :-)

Have you look into supporting cosmopolitan?

Looking at https://justine.lol/cosmopolitan/functions.html, cosmopolitan covers most of POSIX.

I changed one line in neco.c trying to compile one example.

-#elif defined(__EMSCRIPTEN__) || defined(_WIN32)
+#elif defined(__EMSCRIPTEN__) || defined(_WIN32) || defined(__COSMOCC__)

It seems only dladdr and _Unwind_Backtrace are missing to support llco

$ cosmocc -I../ ../neco.c channels.c -o channel
../neco.c: In function ‘llco_getsymbol’:
../neco.c:1352:20: warning: implicit declaration of function ‘dladdr’ [-Wimplicit-function-declaration]
 1352 |     if (sym->ip && dladdr(sym->ip, (void*)&dlinfo)) {
      |                    ^~~~~~
../neco.c: At top level:
../neco.c:3902:18: warning: not sure if modding const structs is good

 3902 | static const int ALLOWED_SIGNALS[] = {
      |                  ^~~~~~~~~~~~~~~
../neco.c:3912:18: warning: not sure if modding const structs is good

 3912 | static const int TRAPPED_SIGNALS[] = {
      |                  ^~~~~~~~~~~~~~~
cc1: note: rewrote 2 switch statements
cc1: note: modified 3 initializations
/opt/cosmocc/bin/../libexec/gcc/x86_64-linux-cosmo/12.3.0/ld.bfd: /tmp/fatcosmocc.6206z09eh66x1.o: in function `llco_getsymbol':
neco.c:(.text+0x7f9): undefined reference to `dladdr'
/opt/cosmocc/bin/../libexec/gcc/x86_64-linux-cosmo/12.3.0/ld.bfd: /tmp/fatcosmocc.6206z09eh66x1.o: in function `llco_unwind':
neco.c:(.text+0xa5e): undefined reference to `_Unwind_Backtrace'
/opt/cosmocc/bin/../libexec/gcc/x86_64-linux-cosmo/12.3.0/ld.bfd: /tmp/fatcosmocc.6206z09eh66x1.o: in function `is_main_thread':
neco.c:(.text+0x7683): undefined reference to `pthread_main_np'
collect2: error: ld returned 1 exit status

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions