part-cw / lambdanative

LambdaNative is a cross-platform development environment written in Scheme, supporting Android, iOS, BlackBerry 10, OS X, Linux, Windows, OpenBSD, NetBSD, FreeBSD and OpenWrt.
http://www.lambdanative.org
Other
1.4k stars 86 forks source link

gambit 4.9.2 does not compile on linux any more #457

Open zwieblum opened 2 months ago

zwieblum commented 2 months ago

I just tried to rebuild my toolchain and sumbld across this problem: gambitc 4.9.2 does not compile any more with latest gcc. 4gambit 4.7.9 still compiles fine.

The compilation breaks with these lines (and from there on a lot of following errors):

gcc -DLINUX -fcommon -I/home/nik/.cache/lambdanative/linux/include -L/home/nik/.cache/lambdanative/linux/lib -O3 -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -fomit-frame-pointer -fPIC -fno-common -mpc64   -I"../include" -c -o "os_io.o" -I. -DHAVE_CONFIG_H -D___GAMBITDIR="\"/home/nik/.cache/lambdanative/linux\"" -D___GAMBITDIR_USERLIB="\"~/.gambit_userlib\"" -D___SYS_TYPE_CPU="\"x86_64\"" -D___SYS_TYPE_VENDOR="\"unknown\"" -D___SYS_TYPE_OS="\"linux-gnu\"" -D___CONFIGURE_COMMAND="\"./configure '--prefix=/home/nik/.cache/lambdanative/linux' 'CC=gcc -DLINUX -fcommon -I/home/nik/.cache/lambdanative/linux/include -L/home/nik/.cache/lambdanative/linux/lib' 'LDFLAGS=-L/home/nik/.cache/lambdanative/linux/lib' 'CPPFLAGS=-I/home/nik/.cache/lambdanative/linux/include' 'CPP=cpp' 'CXX=g++ -DLINUX -fcommon -I/home/nik/.cache/lambdanative/linux/include -L/home/nik/.cache/lambdanative/linux/lib'"\" -D___OBJ_EXTENSION="\".o\"" -D___EXE_EXTENSION="\"\"" -D___BAT_EXTENSION="\"\"" -D___PRIMAL os_io.c -D___LIBRARY
os_io.c:4649:1: warning: no semicolon at end of struct or union
 4649 | } ___device_tcp_addr;
      | ^
In file included from os_setup.h:8,
                 from os_io.c:14:
os_io.c: In function ‘try_connect’:
os_io.c:4701:35: error: passing argument 2 of ‘connect’ from incompatible pointer type [-Wincompatible-pointer-types]
 4701 |                                   &dev->addr,
      |                                   ^~~~~~~~~~
      |                                   |
      |                                   ___device_tcp_addr * {aka union ___device_tcp_addr_struct *}

gcc version:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 14.2.0-4' --with-bugurl=file:///usr/share/doc/gcc-14/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr --with-gcc-major-version-only --program-suffix=-14 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify --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 --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/reproducible-path/gcc-14-14.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/reproducible-path/gcc-14-14.2.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=3
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.0 (Debian 14.2.0-4)
mgorges commented 2 months ago

Is there an obvious patch in https://github.com/gambit/gambit we can backport? From a quick glance at https://github.com/gambit/gambit/blob/d2c2b46e69da1c5fc6ec8946bdc4e1e94479f961/lib/os_io.c#L4799 where this might be coming from this piece of code hasn't been changed for seven years (commit https://github.com/gambit/gambit/commit/353eec72a43db810e4f9ea957de26a7fe2fca373)

zwieblum commented 2 months ago

Please look again, the error is some lines above:

os_io.c:4649:1: warning: no semicolon at end of struct or union
 4649 | } ___device_tcp_addr;
      | ^

... but I don't have a clue jet :)

zwieblum commented 2 months ago

To clearify: gambit 4.9.2 compiles fine on it's own.

The first bug is introduced in the IPv6 patch from lambdanative: https://github.com/part-cw/lambdanative/blob/5a73d44a59cf34e46637000dfe095d93015ea418/libraries/libgambit/fix_IPv6.patch#L52 it's missing the ; at the end of the line.

But this only solves the first error, others still persist:

In file included from os_setup.h:8,
                 from os_io.c:14:
os_io.c: In function ‘try_connect’:
os_io.c:4701:35: error: passing argument 2 of ‘connect’ from incompatible pointer type [-Wincompatible-pointer-types]
 4701 |                                   &dev->addr,
      |                                   ^~~~~~~~~~
      |                                   |
      |                                   ___device_tcp_addr * {aka union ___device_tcp_addr_struct *}
os.h:1775:32: note: in definition of macro ‘SOCKET_CALL_ERROR’
 1775 | #define SOCKET_CALL_ERROR(s) ((s) < 0)
      |                                ^
In file included from /usr/include/netinet/in.h:23,
                 from /usr/include/netdb.h:27,
                 from os.h:1384:
/usr/include/x86_64-linux-gnu/sys/socket.h:126:52: note: expected ‘const struct sockaddr *’ but argument is of type ‘___device_tcp_addr *’ {aka ‘union ___device_tcp_addr_struct *’}
  126 | extern int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
      |                                                    ^
mgorges commented 2 months ago

I fixed the missing semicolon but don't know about the other piece. @0-8-15 could you please take a look as you introduced the IPv6 patch originally? Thanks!

zwieblum commented 2 months ago

I just removed both libraries/libgambit/fix_IPv6* and gambit 4.9.2 compiles fine again.

Please note: these libraries/libgambit/fix_IPv6* patches also break compiltion of android target (clang14), but later in the process with an error due to not finding a generated gambit_SOMELONGNUMBER.h file.

So with the fix_IOv6 patches removed gambit 4.9.2 compiles and works works as it should.