justinethier / cyclone

:cyclone: A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
http://justinethier.github.io/cyclone/
MIT License
823 stars 42 forks source link

Some issues compiling on windows with MSYS2 - CLOCK_MONOTONIC undeclared in time.c 355 #527

Open mdeilman opened 6 months ago

mdeilman commented 6 months ago

Hi there,

first of all thanks for the Windows port :).

I ran into some minor and one issues I cannot resolve:

1) -rdynamic i not accepted with the latest MSYS2 (msys2-x86_64-20240113) (simply removing just works in Makefile,config.msys2) 2) dlfcn.h could not be found (could be resolved by adding pacman -S mingw-w64-x86_64-dlfcn) 3) Is a bit tricky

scheme/time.c:355:23: error: 'CLOCK_MONOTONIC' undeclared (first use in this function) 355 | clock_gettime(CLOCK_MONOTONIC, &now);

I guess it could be a posix issue but adding -D_POSIX_C_SOURCE=199309 doesn't work for me. Any idea ?

If you need more information pls .let me know.

... and thanks in advance.

-- Mario

mdeilman commented 6 months ago

gcc version 13.2.0 on Windows 10 with MSYS2 20240113

mdeilman commented 6 months ago

If I add

-Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -Wno-implicit-function-declaration -D_POSIX_MONOTONIC_CLOCK

(I added the disabled warning just to find the problems faster ;))

and in time.c

ifdef CLOCK_MONOTONIC

        clock_gettime(CLOCK_MONOTONIC, &now);

else

        clock_gettime(CLOCK_REALTIME, &now);

endif

then I got everything compiled but unfortunately ran into another issue

C:/home/sw/msys64/usr/include/sys/errno.h:18: warning: "errno" redefined 18 #define errno (*__errno())
In file included from C:/home/sw/msys64/ucrt64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/stddef.h:1, from C:/home/sw/msys64/usr/include/sys/cdefs.h:47, from C:/home/sw/msys64/usr/include/sys/types.h:21, from C:/home/sw/msys64/usr/local/include/ck_malloc.h:31, from C:/home/sw/msys64/usr/local/include/ck_hs.h:31, from runtime.c:11: C:/home/sw/msys64/ucrt64/include/stddef.h:19: note: this is the location of the previous definition 19 #define errno (*_errno())

In file included from runtime.c:19: C:/home/sw/msys64/usr/include/ctype.h:66:17: error: expected ';', ',' or ')' before numeric constant 66 | #define _X 0100 | ^~~~ make: *** [Makefile:85: libcyclone.a] Error 1

I will continue my investigations

mdeilman commented 6 months ago

Next thing I for the sake of building I commented out

/#define _X 0100/

in ctype .h maybe it is defined somewhere else

and added runtime.c the

  #ifdef CLOCK_MONOTONIC
        clock_gettime(CLOCK_MONOTONIC, &now);
    #else
        clock_gettime(CLOCK_REALTIME, &now);
    #endif

Now I get to the final link step ...

and run into some undefined references :(

---[ Concurrency Kit has installed successfully. 'Makefile.config.msys2' -> 'Makefile.config' cc cyclone.c -O2 -fPIC -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -Wno-implicit-function-declaration -D_POSIX_MONOTONIC_CLOCK -Iinclude -L. -I/usr/local/include -I/usr/include -L/usr/local/lib -c -o cyclone.o cc cyclone.o scheme/base.o scheme/read.o scheme/write.o scheme/case-lambda.o scheme/char.o scheme/complex.o scheme/cxr.o scheme/eval.o scheme/file.o scheme/inexact.o scheme/lazy.o scheme/load.o scheme/process-context.o scheme/repl.o scheme/time.o scheme/cyclone/common.o scheme/cyclone/libraries.o scheme/cyclone/macros.o scheme/cyclone/transforms.o scheme/cyclone/ast.o scheme/cyclone/cps-optimizations.o scheme/cyclone/cgen.o scheme/cyclone/util.o scheme/cyclone/pretty-print.o scheme/cyclone/hashset.o scheme/cyclone/primitives.o libs/cyclone/concurrent.o libs/cyclone/foreign.o libs/cyclone/match.o libs/cyclone/test.o srfi/1.o srfi/2.o srfi/18.o srfi/27.o srfi/28.o srfi/60.o srfi/69.o srfi/106.o srfi/111.o srfi/113.o srfi/117.o srfi/121.o srfi/128.o srfi/132.o srfi/133.o srfi/143.o -pthread -lcyclone -lck -lm -lcyclonebn -ldl -L. -L/usr/local/lib -L/mingw64/lib -o cyclone C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: scheme/base.o:base.c:(.rdata$.refptr._impure_ptr[.ref ptr._impure_ptr]+0x0): undefined reference to _impure_ptr' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x38a9): undefined reference toshutdown' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x3ab1): undefined reference to recv' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x3b6c): undefined reference tosend' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x3c21): undefined reference to __errno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x3c3a): undefined reference toaccept' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x3e54): undefined reference to getaddrinfo' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x3e79): undefined reference tosocket' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x3e93): undefined reference to bind' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x3ea9): undefined reference tofreeaddrinfo' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x3eb5): undefined reference to listen' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x3f63): undefined reference togai_strerror' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x4055): undefined reference to getaddrinfo' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x407f): undefined reference tosocket' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x4097): undefined reference to connect' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x40ad): undefined reference tofreeaddrinfo' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: srfi/106.o:106.c:(.text+0x417b): undefined reference to gai_strerror' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(runtime.o):runtime.c:(.text+0x2d5f): u ndefined reference toerrno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(runtime.o):runtime.c:(.text+0x2d69): u ndefined reference to `errno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(runtime.o):runtime.c:(.text+0x4e75): u ndefined reference to select' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(runtime.o):runtime.c:(.text+0x51c0): u ndefined reference toerrno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(runtime.o):runtime.c:(.text+0xcd53): u ndefined reference to `errno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(runtime.o):runtime.c:(.text+0xcd81): u ndefined reference to __errno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(runtime.o):runtime.c:(.text+0xcd92): u ndefined reference toerrno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x8664-w64-mingw32/bin/ld.exe: ./libcyclone.a(runtime.o):runtime.c:(.rdata$.refptr. ctype_[.refptr.ctype]+0x0): undefined reference to _ctype_' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(mstreams.o):mstreams.c:(.text+0xd3): u ndefined reference toerrno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(mstreams.o):mstreams.c:(.text+0x121): undefined reference to __errno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(mstreams.o):mstreams.c:(.text+0x213): undefined reference toerrno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(mstreams.o):mstreams.c:(.text+0x261): undefined reference to `errno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(mstreams.o):mstreams.c:(.text+0x327): undefined reference to __errno' C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(mstreams.o):mstreams.c:(.text+0x349): more undefined references toerrno' follow C:/home/sw/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libcyclone.a(hashset.o):hashset.c:(.text+0x255): un defined reference to `assert_func'