Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mdeilman opened this issue Feb 21, 2024 · 3 comments

Comments

@mdeilman
Copy link

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
Copy link
Author

gcc version 13.2.0 on Windows 10 with MSYS2 20240113

@mdeilman
Copy link
Author

mdeilman commented Feb 21, 2024

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
Copy link
Author

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 to shutdown'
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 to send'
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 to accept'
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 to socket'
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 to freeaddrinfo'
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 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: 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 to socket'
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 to freeaddrinfo'
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 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+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 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+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 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:(.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 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+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 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+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 to __errno' 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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant