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

Updated Makefile for better cross-compilation support. #1133

Merged
merged 1 commit into from
May 12, 2023

Conversation

zevv
Copy link
Contributor

@zevv zevv commented May 11, 2023

This PR adds some smoother support for easy cross compilation.

Building janet requires janet_boot to be run on the host at build time; for this some changes were made

  • Added $(RUN) variable to allow a emulator to be specified
  • Added .exe extension to binaries when using MINGW
  • $(UNAME) can now be overridden from the make cmdline

Examples:

Cross compiling for win32 and running under wine:

make  repl  \
   CC=x86_64-w64-mingw32-gcc \
   LD=x86_64-w64-mingw32-gcc \
   UNAME=MINGW \
   RUN=wine

Janet 1.27.0-ad7c3bed mingw/x86/gcc - '(doc)' for help

Cross compiling for aarch64 and running under qemu:

make repl \
        CC=aarch64-none-linux-gnu-gcc \
        LD=aarch64-none-linux-gnu-gcc \
        RUN="qemu-aarch64 -L /tmp/aarch64/"

Janet 1.27.0-ad7c3bed linux/aarch64/gcc - '(doc)' for help

Building janet requires janet_boot to be run on the host at build time;

- $(UNAME) can now be overridden from the make cmdline
- Added $(RUN) variable to allow a emulator to be specified
- Added ".exe" extension to binaries when using MINGW

Examples:

Cross compiling for win32 and running under wine:

```
make test \
       CC=i686-w64-mingw32-gcc \
       LD=i686-w64-mingw32-gcc \
       UNAME=MINGW \
       RUN=wine

Janet 1.27.0-ad7c3bed mingw/x86/gcc - '(doc)' for help
```

Cross compiling for aarch64 and running under qemu:

```
make repl \
        CC=aarch64-none-linux-gnu-gcc \
        LD=aarch64-none-linux-gnu-gcc \
        RUN="qemu-aarch64 -L /tmp/aarch64/"

Janet 1.27.0-ad7c3bed linux/aarch64/gcc - '(doc)' for help
```
@sogaiu
Copy link
Contributor

sogaiu commented May 11, 2023

I got the following near the end of output for trying the MINGW + wine combination:

i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/janet_boot.exe build/core/abstract.boot.o build/core/array.boot.o build/core/asm.boot.o build/core/buffer.boot.o build/core/bytecode.boot.o build/core/capi.boot.o build/core/cfuns.boot.o build/core/compile.boot.o build/core/corelib.boot.o build/core/debug.boot.o build/core/emit.boot.o build/core/ev.boot.o build/core/ffi.boot.o build/core/fiber.boot.o build/core/gc.boot.o build/core/inttypes.boot.o build/core/io.boot.o build/core/marsh.boot.o build/core/math.boot.o build/core/net.boot.o build/core/os.boot.o build/core/parse.boot.o build/core/peg.boot.o build/core/pp.boot.o build/core/regalloc.boot.o build/core/run.boot.o build/core/specials.boot.o build/core/state.boot.o build/core/string.boot.o build/core/strtod.boot.o build/core/struct.boot.o build/core/symcache.boot.o build/core/table.boot.o build/core/tuple.boot.o build/core/util.boot.o build/core/value.boot.o build/core/vector.boot.o build/core/vm.boot.o build/core/wrap.boot.o build/boot/array_test.boot.o build/boot/boot.boot.o build/boot/buffer_test.boot.o build/boot/number_test.boot.o build/boot/system_test.boot.o build/boot/table_test.boot.o -lws2_32 -lpsapi -lwsock32
/usr/bin/i686-w64-mingw32-ld: build/core/abstract.boot.o: in function `janet_os_rwlock_init':
/home/user/src/janet.cross/src/core/abstract.c:126: undefined reference to `InitializeSRWLock'
/usr/bin/i686-w64-mingw32-ld: build/core/abstract.boot.o: in function `janet_os_rwlock_rlock':
/home/user/src/janet.cross/src/core/abstract.c:135: undefined reference to `AcquireSRWLockShared'
/usr/bin/i686-w64-mingw32-ld: build/core/abstract.boot.o: in function `janet_os_rwlock_wlock':
/home/user/src/janet.cross/src/core/abstract.c:139: undefined reference to `AcquireSRWLockExclusive'
/usr/bin/i686-w64-mingw32-ld: build/core/abstract.boot.o: in function `janet_os_rwlock_runlock':
/home/user/src/janet.cross/src/core/abstract.c:143: undefined reference to `ReleaseSRWLockShared'
/usr/bin/i686-w64-mingw32-ld: build/core/abstract.boot.o: in function `janet_os_rwlock_wunlock':
/home/user/src/janet.cross/src/core/abstract.c:147: undefined reference to `ReleaseSRWLockExclusive'
/usr/bin/i686-w64-mingw32-ld: build/core/ev.boot.o: in function `ts_now':
/home/user/src/janet.cross/src/core/ev.c:1430: undefined reference to `GetTickCount64'
/usr/bin/i686-w64-mingw32-ld: build/core/net.boot.o: in function `janet_so_getname':
/home/user/src/janet.cross/src/core/net.c:670: undefined reference to `inet_ntop'
/usr/bin/i686-w64-mingw32-ld: /home/user/src/janet.cross/src/core/net.c:678: undefined reference to `inet_ntop'
collect2: error: ld returned 1 exit status
make: *** [Makefile:171: build/janet_boot.exe] Error 1

I'm trying on an Ubuntu 22.04.2 LTS system and various versions of some things are:

$ wine --version
wine-6.0.3 (Ubuntu 6.0.3~repack-1)
$ i686-w64-mingw32-gcc --version
i686-w64-mingw32-gcc (GCC) 10-win32 20220113
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Any hints as to what I might do to get this working?

@zevv
Copy link
Contributor Author

zevv commented May 11, 2023

Hm, interesting; not much to be found on that error message on the internets, but it might have to do with the gcc version and a magic _WIN32_WINNT define.

I'll see if I can whip up an ubuntu 22 with the same gcc version as you have to reproduce.

@sogaiu
Copy link
Contributor

sogaiu commented May 11, 2023

Below is the full output from the make invocation in case there was something relevant I left out. There were some warnings above what I posted before.

$ make repl CC=i686-w64-mingw32-gcc LD=i686-w64-mingw32-gcc UNAME=MINGW RUN=wine
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/abstract.boot.o -c src/core/abstract.c
src/core/abstract.c: In function ‘janet_os_rwlock_init’:
src/core/abstract.c:126:5: warning: implicit declaration of function ‘InitializeSRWLock’; did you mean ‘InitializeSid’? [-Wimplicit-function-declaration]
  126 |     InitializeSRWLock((PSRWLOCK) rwlock);
      |     ^~~~~~~~~~~~~~~~~
      |     InitializeSid
src/core/abstract.c: In function ‘janet_os_rwlock_rlock’:
src/core/abstract.c:135:5: warning: implicit declaration of function ‘AcquireSRWLockShared’ [-Wimplicit-function-declaration]
  135 |     AcquireSRWLockShared((PSRWLOCK) rwlock);
      |     ^~~~~~~~~~~~~~~~~~~~
src/core/abstract.c: In function ‘janet_os_rwlock_wlock’:
src/core/abstract.c:139:5: warning: implicit declaration of function ‘AcquireSRWLockExclusive’ [-Wimplicit-function-declaration]
  139 |     AcquireSRWLockExclusive((PSRWLOCK) rwlock);
      |     ^~~~~~~~~~~~~~~~~~~~~~~
src/core/abstract.c: In function ‘janet_os_rwlock_runlock’:
src/core/abstract.c:143:5: warning: implicit declaration of function ‘ReleaseSRWLockShared’ [-Wimplicit-function-declaration]
  143 |     ReleaseSRWLockShared((PSRWLOCK) rwlock);
      |     ^~~~~~~~~~~~~~~~~~~~
src/core/abstract.c: In function ‘janet_os_rwlock_wunlock’:
src/core/abstract.c:147:5: warning: implicit declaration of function ‘ReleaseSRWLockExclusive’ [-Wimplicit-function-declaration]
  147 |     ReleaseSRWLockExclusive((PSRWLOCK) rwlock);
      |     ^~~~~~~~~~~~~~~~~~~~~~~
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/array.boot.o -c src/core/array.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/asm.boot.o -c src/core/asm.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/buffer.boot.o -c src/core/buffer.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/bytecode.boot.o -c src/core/bytecode.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/capi.boot.o -c src/core/capi.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/cfuns.boot.o -c src/core/cfuns.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/compile.boot.o -c src/core/compile.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/corelib.boot.o -c src/core/corelib.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/debug.boot.o -c src/core/debug.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/emit.boot.o -c src/core/emit.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/ev.boot.o -c src/core/ev.c
src/core/ev.c: In function ‘janet_stream_marshal’:
src/core/ev.c:425:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  425 |     janet_marshal_int64(ctx, (int64_t)(duph));
      |                              ^
src/core/ev.c: In function ‘janet_stream_unmarshal’:
src/core/ev.c:443:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  443 |     p->methods = (void *) janet_unmarshal_int64(ctx);
      |                  ^
src/core/ev.c:445:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  445 |     p->handle = (JanetHandle) janet_unmarshal_int64(ctx);
      |                 ^
src/core/ev.c: In function ‘ts_now’:
src/core/ev.c:1430:29: warning: implicit declaration of function ‘GetTickCount64’; did you mean ‘GetTickCount’? [-Wimplicit-function-declaration]
 1430 |     return (JanetTimestamp) GetTickCount64();
      |                             ^~~~~~~~~~~~~~
      |                             GetTickCount
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/ffi.boot.o -c src/core/ffi.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/fiber.boot.o -c src/core/fiber.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/gc.boot.o -c src/core/gc.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/inttypes.boot.o -c src/core/inttypes.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/io.boot.o -c src/core/io.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/marsh.boot.o -c src/core/marsh.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/math.boot.o -c src/core/math.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/net.boot.o -c src/core/net.c
src/core/net.c: In function ‘janet_so_getname’:
src/core/net.c:670:18: warning: implicit declaration of function ‘inet_ntop’; did you mean ‘inet_ntoa’? [-Wimplicit-function-declaration]
  670 |             if (!inet_ntop(AF_INET, &(sai->sin_addr), buffer, sizeof(buffer))) {
      |                  ^~~~~~~~~
      |                  inet_ntoa
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/os.boot.o -c src/core/os.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/parse.boot.o -c src/core/parse.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/peg.boot.o -c src/core/peg.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/pp.boot.o -c src/core/pp.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/regalloc.boot.o -c src/core/regalloc.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/run.boot.o -c src/core/run.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/specials.boot.o -c src/core/specials.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/state.boot.o -c src/core/state.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/string.boot.o -c src/core/string.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/strtod.boot.o -c src/core/strtod.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/struct.boot.o -c src/core/struct.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/symcache.boot.o -c src/core/symcache.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/table.boot.o -c src/core/table.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/tuple.boot.o -c src/core/tuple.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/util.boot.o -c src/core/util.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/value.boot.o -c src/core/value.c
src/core/value.c: In function ‘janet_lengthv’:
src/core/value.c:700:36: warning: comparison is always true due to limited range of data type [-Wtype-limits]
  700 |                 if ((uint64_t) len <= (uint64_t) JANET_INTMAX_INT64) {
      |                                    ^~
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/vector.boot.o -c src/core/vector.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/vm.boot.o -c src/core/vm.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/core/wrap.boot.o -c src/core/wrap.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/boot/array_test.boot.o -c src/boot/array_test.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/boot/boot.boot.o -c src/boot/boot.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/boot/buffer_test.boot.o -c src/boot/buffer_test.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/boot/number_test.boot.o -c src/boot/number_test.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/boot/system_test.boot.o -c src/boot/system_test.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/boot/table_test.boot.o -c src/boot/table_test.c
i686-w64-mingw32-gcc -DJANET_BOOTSTRAP -DJANET_BUILD="\"d3bb06cf\"" -O0 -g -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/janet_boot.exe build/core/abstract.boot.o build/core/array.boot.o build/core/asm.boot.o build/core/buffer.boot.o build/core/bytecode.boot.o build/core/capi.boot.o build/core/cfuns.boot.o build/core/compile.boot.o build/core/corelib.boot.o build/core/debug.boot.o build/core/emit.boot.o build/core/ev.boot.o build/core/ffi.boot.o build/core/fiber.boot.o build/core/gc.boot.o build/core/inttypes.boot.o build/core/io.boot.o build/core/marsh.boot.o build/core/math.boot.o build/core/net.boot.o build/core/os.boot.o build/core/parse.boot.o build/core/peg.boot.o build/core/pp.boot.o build/core/regalloc.boot.o build/core/run.boot.o build/core/specials.boot.o build/core/state.boot.o build/core/string.boot.o build/core/strtod.boot.o build/core/struct.boot.o build/core/symcache.boot.o build/core/table.boot.o build/core/tuple.boot.o build/core/util.boot.o build/core/value.boot.o build/core/vector.boot.o build/core/vm.boot.o build/core/wrap.boot.o build/boot/array_test.boot.o build/boot/boot.boot.o build/boot/buffer_test.boot.o build/boot/number_test.boot.o build/boot/system_test.boot.o build/boot/table_test.boot.o -lws2_32 -lpsapi -lwsock32
/usr/bin/i686-w64-mingw32-ld: build/core/abstract.boot.o: in function `janet_os_rwlock_init':
/home/user/src/janet.cross/src/core/abstract.c:126: undefined reference to `InitializeSRWLock'
/usr/bin/i686-w64-mingw32-ld: build/core/abstract.boot.o: in function `janet_os_rwlock_rlock':
/home/user/src/janet.cross/src/core/abstract.c:135: undefined reference to `AcquireSRWLockShared'
/usr/bin/i686-w64-mingw32-ld: build/core/abstract.boot.o: in function `janet_os_rwlock_wlock':
/home/user/src/janet.cross/src/core/abstract.c:139: undefined reference to `AcquireSRWLockExclusive'
/usr/bin/i686-w64-mingw32-ld: build/core/abstract.boot.o: in function `janet_os_rwlock_runlock':
/home/user/src/janet.cross/src/core/abstract.c:143: undefined reference to `ReleaseSRWLockShared'
/usr/bin/i686-w64-mingw32-ld: build/core/abstract.boot.o: in function `janet_os_rwlock_wunlock':
/home/user/src/janet.cross/src/core/abstract.c:147: undefined reference to `ReleaseSRWLockExclusive'
/usr/bin/i686-w64-mingw32-ld: build/core/ev.boot.o: in function `ts_now':
/home/user/src/janet.cross/src/core/ev.c:1430: undefined reference to `GetTickCount64'
/usr/bin/i686-w64-mingw32-ld: build/core/net.boot.o: in function `janet_so_getname':
/home/user/src/janet.cross/src/core/net.c:670: undefined reference to `inet_ntop'
/usr/bin/i686-w64-mingw32-ld: /home/user/src/janet.cross/src/core/net.c:678: undefined reference to `inet_ntop'
collect2: error: ld returned 1 exit status
make: *** [Makefile:171: build/janet_boot.exe] Error 1

@zevv
Copy link
Contributor Author

zevv commented May 11, 2023

Right, I setup a ubuntu 22.04LTC chroot and I can reproduce. According` to https://sourceforge.net/p/mingw/bugs/2314/, this is only supported from MinGW WSL 5.0. 64 bit mingw should be fine though.

This works for me in 22.04LTS:

make  repl  \
   CC=x86_64-w64-mingw32-gcc \
   LD=x86_64-w64-mingw32-gcc \
   UNAME=MINGW \
   RUN=wine

@sogaiu
Copy link
Contributor

sogaiu commented May 11, 2023

That worked fine for me 👍

...
x86_64-w64-mingw32-gcc -Wl,--out-implib,build/janet.lib -O2 -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC -o build/janet.exe build/janet.o build/shell.o -lws2_32 -lpsapi -lwsock32
wine ./build/janet.exe
Janet 1.27.0-d3bb06cf mingw/x64/gcc - '(doc)' for help
repl:1:> (os/which)
[33m:mingw[0m
repl:2:>

Thanks a lot!

@zevv
Copy link
Contributor Author

zevv commented May 11, 2023

Nice; maybe this could also help setting up CI tests for the windows target.

@zevv zevv marked this pull request as ready for review May 11, 2023 13:01
@bakpakin bakpakin merged commit 3b353f1 into janet-lang:master May 12, 2023
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

Successfully merging this pull request may close these issues.

3 participants