v icon indicating copy to clipboard operation
v copied to clipboard

Support for ppc/ppc64/s390x/riscv32/riscv64/mips , Closure errors when building V

Open xet7 opened this issue 1 year ago • 43 comments

Describe the bug

Building V at Ubuntu 23.04 s390x Docker container, running on RHEL 8.8 s390x. Same error when building V at Ubuntu and RHEL.

Related to what I'm trying to build at s390x https://github.com/wekan/wekan/wiki/s390x

[linux1@wekanrhel84 v]$ uname -a
Linux wekanrhel84 4.18.0-477.13.1.el8_8.s390x #1 SMP Thu May 18 09:10:47 EDT 2023 s390x s390x s390x GNU/Linux
[linux1@wekanrhel84 v]$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.8 (Ootpa)
[linux1@wekanrhel84 v]$ sudo su
[root@wekanrhel84 v]$ cd
[root@wekanrhel84 ~]# docker run --name ubuntu -h 23.04 -e LANG=C.UTF-8 -it ubuntu:23.04 /bin/bash -l
root@23:/home/ubuntu/repos/v# uname -a
Linux 23.04 4.18.0-477.13.1.el8_8.s390x #1 SMP Thu May 18 09:10:47 EDT 2023 s390x s390x s390x GNU/Linux

root@23:/home/ubuntu/repos/v# make
cd ./vc && git clean -xf && git pull --quiet
cd ./thirdparty/tcc && git clean -xf && git pull --quiet
The executable './thirdparty/tcc/tcc.exe' does not work.
cc  -std=gnu99 -w -o v1.exe ./vc/v.c -lm -lpthread 
./vc/v.c: In function ‘__closure_alloc’:
./vc/v.c:16637:51: error: ‘__closure_thunk’ undeclared (first use in this function); did you mean ‘__closure_alloc’?
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16747:40: note: in expansion of macro ‘_CLOSURE_SIZE’
16747 |         int remaining = _V_page_size / _CLOSURE_SIZE;
      |                                        ^~~~~~~~~~~~~
./vc/v.c:16637:51: note: each undeclared identifier is reported only once for each function it appears in
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16747:40: note: in expansion of macro ‘_CLOSURE_SIZE’
16747 |         int remaining = _V_page_size / _CLOSURE_SIZE;
      |                                        ^~~~~~~~~~~~~
./vc/v.c: In function ‘__closure_init’:
./vc/v.c:16785:30: error: ‘__CLOSURE_GET_DATA_BYTES’ undeclared (first use in this function); did you mean ‘__CLOSURE_GET_DATA’?
16785 |         memcpy(_closure_ptr, __CLOSURE_GET_DATA_BYTES, sizeof(__CLOSURE_GET_DATA_BYTES));
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~
      |                              __CLOSURE_GET_DATA
./vc/v.c:16637:51: error: ‘__closure_thunk’ undeclared (first use in this function); did you mean ‘__closure_init’?
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16788:25: note: in expansion of macro ‘_CLOSURE_SIZE’
16788 |         _closure_ptr += _CLOSURE_SIZE;
      |                         ^~~~~~~~~~~~~
./vc/v.c: In function ‘__closure_create’:
./vc/v.c:16637:51: error: ‘__closure_thunk’ undeclared (first use in this function); did you mean ‘__closure_init’?
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16800:25: note: in expansion of macro ‘_CLOSURE_SIZE’
16800 |         _closure_ptr += _CLOSURE_SIZE;
      |                         ^~~~~~~~~~~~~
make: *** [GNUmakefile:113: all] Error 1

When I try to build TCC from source:

root@23:/home/ubuntu/repos/tinycc# ./configure --prefix=/var/tmp/tcc --crtprefix=/var/tmp/tcc/lib:/usr/lib64:/usr/lib/s390x-linux-gnu --libpaths=/var/tmp/tcc/lib:/usr/lib/s390x-linux-gnu:/usr/lib64:/usr/lib:/lib/s390x-linux-gnu:/lib:/usr/local/lib/s390x-linux-gnu:/usr/local/lib  --debug
Unsupported CPU

Expected Behavior

Building V works.

Current Behavior

Building V did not work, shows closure errors.

Reproduction Steps

SSH to Linux s390x server.

git clone https://github.com/vlang/v

cd v

make

Possible Solution

No response

Additional Information/Context

No response

V version

Newest commit after v0.4, commit 049d6853b70be5adf69fc37d98883efe4c695152 changelog: add a missing link

Environment details (OS name and version, etc.)

Running at IBM LinuxOne Community Cloud, s390x https://github.com/wekan/wekan/wiki/s390x

[linux1@wekanrhel84 v]$ uname -a
Linux wekanrhel84 4.18.0-477.13.1.el8_8.s390x #1 SMP Thu May 18 09:10:47 EDT 2023 s390x s390x s390x GNU/Linux
[linux1@wekanrhel84 v]$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.8 (Ootpa)
[linux1@wekanrhel84 v]$ sudo su
[root@wekanrhel84 v]$ cd
[root@wekanrhel84 ~]# docker run --name ubuntu -h 23.04 -e LANG=C.UTF-8 -it ubuntu:23.04 /bin/bash -l
root@23:/home/ubuntu/repos/v# uname -a
Linux 23.04 4.18.0-477.13.1.el8_8.s390x #1 SMP Thu May 18 09:10:47 EDT 2023 s390x s390x s390x GNU/Linux

xet7 avatar Jul 01 '23 21:07 xet7

Which C compiler do you have, and what version is it?

JalonSolov avatar Jul 01 '23 22:07 JalonSolov

@JalonSolov

Ubuntu 23.04 s390x:

root@23:/# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/s390x-linux-gnu/12/lto-wrapper
Target: s390x-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 12.2.0-17ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=s390x-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch=z13 --with-tune=z16 --enable-s390-excess-float-precision --with-long-double-128 --enable-multilib --enable-checking=release --build=s390x-linux-gnu --host=s390x-linux-gnu --target=s390x-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Ubuntu 12.2.0-17ubuntu1)

RHEL s390x:

[linux1@wekanrhel84 ~]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/s390x-redhat-linux/8/lto-wrapper
Target: s390x-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --disable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --with-long-double-128 --with-arch=z13 --with-tune=z14 --enable-decimal-float --build=s390x-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC)

xet7 avatar Jul 01 '23 22:07 xet7

The Ubuntu version of gcc is fine. The RHEL version is too old... think you need at least v9 of gcc.

Did you clone the latest version of V? It is up to v0.4 as of today.

JalonSolov avatar Jul 01 '23 22:07 JalonSolov

@JalonSolov

Yes. With newest commit on Ubuntu, I get this:

root@23:/home/ubuntu/repos/v# make
cd ./vc && git clean -xf && git pull --quiet
cd ./thirdparty/tcc && git clean -xf && git pull --quiet
The executable './thirdparty/tcc/tcc.exe' does not work.
cc  -std=gnu99 -w -o v1.exe ./vc/v.c -lm -lpthread 
./vc/v.c: In function ‘__closure_alloc’:
./vc/v.c:16637:51: error: ‘__closure_thunk’ undeclared (first use in this function); did you mean ‘__closure_alloc’?
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16747:40: note: in expansion of macro ‘_CLOSURE_SIZE’
16747 |         int remaining = _V_page_size / _CLOSURE_SIZE;
      |                                        ^~~~~~~~~~~~~
./vc/v.c:16637:51: note: each undeclared identifier is reported only once for each function it appears in
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16747:40: note: in expansion of macro ‘_CLOSURE_SIZE’
16747 |         int remaining = _V_page_size / _CLOSURE_SIZE;
      |                                        ^~~~~~~~~~~~~
./vc/v.c: In function ‘__closure_init’:
./vc/v.c:16785:30: error: ‘__CLOSURE_GET_DATA_BYTES’ undeclared (first use in this function); did you mean ‘__CLOSURE_GET_DATA’?
16785 |         memcpy(_closure_ptr, __CLOSURE_GET_DATA_BYTES, sizeof(__CLOSURE_GET_DATA_BYTES));
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~
      |                              __CLOSURE_GET_DATA
./vc/v.c:16637:51: error: ‘__closure_thunk’ undeclared (first use in this function); did you mean ‘__closure_init’?
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16788:25: note: in expansion of macro ‘_CLOSURE_SIZE’
16788 |         _closure_ptr += _CLOSURE_SIZE;
      |                         ^~~~~~~~~~~~~
./vc/v.c: In function ‘__closure_create’:
./vc/v.c:16637:51: error: ‘__closure_thunk’ undeclared (first use in this function); did you mean ‘__closure_init’?
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16800:25: note: in expansion of macro ‘_CLOSURE_SIZE’
16800 |         _closure_ptr += _CLOSURE_SIZE;
      |                         ^~~~~~~~~~~~~
make: *** [GNUmakefile:113: all] Error 1

xet7 avatar Jul 01 '23 22:07 xet7

After make clean I get this:

root@23:/home/ubuntu/repos/v# make clean
rm -rf ./thirdparty/tcc
rm -rf ./thirdparty/legacy
rm -rf ./vc
root@23:/home/ubuntu/repos/v# make
make fresh_vc
make[1]: Entering directory '/home/ubuntu/repos/v'
rm -rf ./vc
git clone --filter=blob:none --quiet https://github.com/vlang/vc ./vc
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), 926.11 KiB | 16.25 MiB/s, done.
Resolving deltas: 100% (1/1), done.
make[1]: Leaving directory '/home/ubuntu/repos/v'
cd ./vc && git clean -xf && git pull --quiet
make fresh_tcc
make[1]: Entering directory '/home/ubuntu/repos/v'
rm -rf ./thirdparty/tcc
Pre-built TCC not available for thirdparty-linux-s390x at https://github.com/vlang/tccbin, will use the system compiler: cc
git clone --filter=blob:none --quiet --branch thirdparty-unknown-unknown https://github.com/vlang/tccbin ./thirdparty/tcc
remote: Enumerating objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 1
Receiving objects: 100% (1/1), 149 bytes | 149.00 KiB/s, done.
make[2]: Entering directory '/home/ubuntu/repos/v'
The executable './thirdparty/tcc/tcc.exe' does not work.
make[2]: Leaving directory '/home/ubuntu/repos/v'
make[1]: Leaving directory '/home/ubuntu/repos/v'
cd ./thirdparty/tcc && git clean -xf && git pull --quiet
The executable './thirdparty/tcc/tcc.exe' does not work.
cc  -std=gnu99 -w -o v1.exe ./vc/v.c -lm -lpthread 
./vc/v.c: In function ‘__closure_alloc’:
./vc/v.c:16637:51: error: ‘__closure_thunk’ undeclared (first use in this function); did you mean ‘__closure_alloc’?
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16747:40: note: in expansion of macro ‘_CLOSURE_SIZE’
16747 |         int remaining = _V_page_size / _CLOSURE_SIZE;
      |                                        ^~~~~~~~~~~~~
./vc/v.c:16637:51: note: each undeclared identifier is reported only once for each function it appears in
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16747:40: note: in expansion of macro ‘_CLOSURE_SIZE’
16747 |         int remaining = _V_page_size / _CLOSURE_SIZE;
      |                                        ^~~~~~~~~~~~~
./vc/v.c: In function ‘__closure_init’:
./vc/v.c:16785:30: error: ‘__CLOSURE_GET_DATA_BYTES’ undeclared (first use in this function); did you mean ‘__CLOSURE_GET_DATA’?
16785 |         memcpy(_closure_ptr, __CLOSURE_GET_DATA_BYTES, sizeof(__CLOSURE_GET_DATA_BYTES));
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~
      |                              __CLOSURE_GET_DATA
./vc/v.c:16637:51: error: ‘__closure_thunk’ undeclared (first use in this function); did you mean ‘__closure_init’?
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16788:25: note: in expansion of macro ‘_CLOSURE_SIZE’
16788 |         _closure_ptr += _CLOSURE_SIZE;
      |                         ^~~~~~~~~~~~~
./vc/v.c: In function ‘__closure_create’:
./vc/v.c:16637:51: error: ‘__closure_thunk’ undeclared (first use in this function); did you mean ‘__closure_init’?
16637 | #define _CLOSURE_SIZE (((2*sizeof(void*) > sizeof(__closure_thunk) ? 2*sizeof(void*) : sizeof(__closure_thunk)) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
      |                                                   ^~~~~~~~~~~~~~~
./vc/v.c:16800:25: note: in expansion of macro ‘_CLOSURE_SIZE’
16800 |         _closure_ptr += _CLOSURE_SIZE;
      |                         ^~~~~~~~~~~~~
make: *** [GNUmakefile:113: all] Error 1

xet7 avatar Jul 01 '23 22:07 xet7

This is newest commit:

commit 049d6853b70be5adf69fc37d98883efe4c695152 (HEAD -> master, origin/master, origin/HEAD)
Author: Alexander Medvednikov
Date:   Sat Jul 1 14:07:51 2023 +0300

    changelog: add a missing link

xet7 avatar Jul 01 '23 22:07 xet7

I just tried the same thing: cloned V into an ubuntu:23.04 image, and ran make, and it worked as expected. However, I have a much newer kernel on my system.

root@23:/tmp/v# make
make fresh_vc
make[1]: Entering directory '/tmp/v'
rm -rf ./vc
git clone --filter=blob:none --quiet https://github.com/vlang/vc ./vc
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), 926.11 KiB | 7.35 MiB/s, done.
Resolving deltas: 100% (1/1), done.
make[1]: Leaving directory '/tmp/v'
cd ./vc && git clean -xf && git pull --quiet
make fresh_tcc
make[1]: Entering directory '/tmp/v'
rm -rf ./thirdparty/tcc
git clone --filter=blob:none --quiet --branch thirdparty-linux-amd64 https://github.com/vlang/tccbin ./thirdparty/tcc
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 25 (delta 0), reused 3 (delta 0), pack-reused 7
Receiving objects: 100% (25/25), 2.07 MiB | 5.25 MiB/s, done.
make[2]: Entering directory '/tmp/v'
make[2]: Leaving directory '/tmp/v'
make[1]: Leaving directory '/tmp/v'
cd ./thirdparty/tcc && git clean -xf && git pull --quiet
cc  -std=gnu99 -w -o v1.exe ./vc/v.c -lm -lpthread 
./v1.exe -no-parallel -o v2.exe  cmd/v
./v2.exe -nocache -o ./v  cmd/v
rm -rf v1.exe v2.exe
Your `tcc` is working. Good - it is much faster at compiling C source code.
V has been successfully built
V 0.4.0 049d685
root@23:/tmp/v# uname -a
Linux 23.04 6.3.5-2-MANJARO #1 SMP PREEMPT_DYNAMIC Sun Jun  4 18:26:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
root@23:/tmp/v# 

JalonSolov avatar Jul 01 '23 22:07 JalonSolov

Hmm, I'll try to create some full VM that could use newer kernel. Building v does work for me on x86_64, but not on s390x with that older kernel.

xet7 avatar Jul 01 '23 22:07 xet7

@JalonSolov

When I run virt-manager KVM VM with Alpine Linux s390x, that has Linux kernel 6.1, I still get closure errors:

v-alpine-s390x

xet7 avatar Jul 01 '23 23:07 xet7

I'm at a loss, then. Someone else will have to chime in.

JalonSolov avatar Jul 02 '23 00:07 JalonSolov

Hmm, maybe that closure is not defined for Linux s390x CPU, at architecture specific code?

https://github.com/vlang/v/blob/master/vlib/v/gen/c/cheaders.v

xet7 avatar Jul 02 '23 00:07 xet7

Also thinking, how to find page size for s390x ?

static int _V_page_size = 0x4000; // 16K

https://github.com/vlang/v/blob/master/vlib/v/gen/c/cheaders.v#L79

xet7 avatar Jul 02 '23 00:07 xet7

$ getconf PAGESIZE
4096

xet7 avatar Jul 02 '23 00:07 xet7

Ah, you're right... closures aren't defined for all CPUs, as they have to have a tiny bit of assembly. We would have to add a chunk for s390 for this to work.

JalonSolov avatar Jul 02 '23 01:07 JalonSolov

@JalonSolov

How can I find what kind of assembly is needed? Does it require compiling C and looking what assembly is created? Or something else?

xet7 avatar Jul 02 '23 01:07 xet7

It was hand-written. Look in vlib/v/gen/c/cheaders.v starting on line 64, at the function c_closure_helpers. Looks like closures are currently supported on x86, x86_64, arm32, arm64, RISC-V 32, and RISC-V 64.

@spaceface777 and/or @spytheman might be able to help further.

JalonSolov avatar Jul 02 '23 01:07 JalonSolov

I do not know is this in any way related to this closure support:

https://gcc.gnu.org/pipermail/java-patches/2002q3/005159.html

xet7 avatar Jul 02 '23 01:07 xet7

same wrong in loongarch64 cpu,can be support for loongarch?

aa@aa-TR41A1:~$ uname -a
Linux aa-TR41A1 5.4.18-58-generic #47-KYLINOS SMP Mon Apr 25 06:02:35 UTC 2022 loongarch64 loongarch64 loongarch64 GNU/Linux

aa@aa-TR41A1:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/loongarch64-linux-gnu/8/lto-wrapper
Target: loongarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6.lnd.vec.20' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,c++,fortran --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=loongarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libsanitizer --disable-libquadmath --disable-libquadmath-support --enable-plugin --with-system-zlib --enable-multiarch --disable-werror --with-arch=loongarch64 --with-abi=lp64 --enable-tls --enable-initfini-array --enable-gnu-indirect-function --disable-host-shared --disable-emultls --with-fix-loongson3-llsc --enable-checking=release --build=loongarch64-linux-gnu --host=loongarch64-linux-gnu --target=loongarch64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Debian 8.3.0-6.lnd.vec.20) 

wenfer avatar Oct 10 '23 07:10 wenfer

Same error on macOS ppc: https://github.com/vlang/v/issues/20507

barracuda156 avatar Jan 12 '24 10:01 barracuda156

It was hand-written. Look in vlib/v/gen/c/cheaders.v starting on line 64, at the function c_closure_helpers. Looks like closures are currently supported on x86, x86_64, arm32, arm64, RISC-V 32, and RISC-V 64.

@spaceface777 and/or @spytheman might be able to help further.

Would be cool if someone adds support here for archs which are missing: PowerPC (ppc / ppc64), s390x, mips.

barracuda156 avatar Jan 12 '24 10:01 barracuda156

@xet7 Somewhat earlier versions somehow worked, despite no support for closures for the arch in question. I have 2023.15 built on macOS PowerPC, while the current version fails exactly like for you.

UPD. Could you try if 0.3.4 works for you? It looks like something was broken in between 0.3.4 and 0.3.5.

barracuda156 avatar Jan 12 '24 10:01 barracuda156

The only way to get this fixed on these extra architectures is for someone else to have access to systems with the same CPUs, or for you to provide login access on yours.

Then, of course, whoever it is will have to understand those systems well enough to add the appropriate code.

JalonSolov avatar Jan 12 '24 13:01 JalonSolov

@JalonSolov Well, I won’t mind giving access to one of my machines, I do not know how to do it, given that there is no static IP and I do not control access point. But there should be some way, of course.

The first thing could be to fix what was broken after 0.3.4, since that version builds perfectly fine with no hacks, despite a lack of arch-specific code.

barracuda156 avatar Jan 12 '24 14:01 barracuda156

How can that even be tested without having access to the machine where it breaks? Either you'll have to create the fix, or someone who knows PowerPC well enough will have to do so.

JalonSolov avatar Jan 12 '24 15:01 JalonSolov

@JalonSolov

One way is to test with Qemu. Here is example how I crosscompiled and tested at many OS/CPU some C89 code. I have tested that those binaries also work at those bare metal architectures that I have available.

https://github.com/xet7/darkesthour

xet7 avatar Jan 12 '24 15:01 xet7

For example, there have been over 1,600 commits since 0.3.4. Which one of those caused the problem?

JalonSolov avatar Jan 12 '24 15:01 JalonSolov

@JalonSolov

Problem is that closure CPU-specific assembler code https://github.com/vlang/v/issues/18737#issuecomment-1616186719

Just a moment, I'll test newest code.

xet7 avatar Jan 12 '24 15:01 xet7

Yes, qemu would be one way to get access to at least some of the arch's mentioned, but then which versions of which OSes? And that still doesn't address needing someone familiar enough with the assembly code for each of those arch's to be able to handle appropriate changes.

JalonSolov avatar Jan 12 '24 15:01 JalonSolov

@JalonSolov

Qemu-user runs Linux binaries for many CPUs, no OS install needed:

https://github.com/xet7/darkesthour/blob/main/Source/menu.sh#L436

Deps are here:

https://github.com/xet7/darkesthour/blob/main/Source/deps.sh#L10

I would think, that that try some of the existing assembler code, what parts also works at other CPUs

xet7 avatar Jan 12 '24 15:01 xet7

@JalonSolov

Problem is that closure CPU-specific assembler code https://github.com/vlang/v/issues/18737#issuecomment-1616186719

Just a moment, I'll test newest code.

@xet7 While that definitely is the problem, vlang 0.3.4 still builds fine. Something got broken to the effect of making the build impossible. (Presumably it was never optimal, but it worked.)

barracuda156 avatar Jan 12 '24 15:01 barracuda156