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

Fails to build with GCC 15 #803

Open
sebastic opened this issue Feb 18, 2025 · 2 comments
Open

Fails to build with GCC 15 #803

sebastic opened this issue Feb 18, 2025 · 2 comments

Comments

@sebastic
Copy link
Contributor

As reported in Debian Bug #1097195:

The package fails to build in a test rebuild on at least amd64 with gcc-15/g++-15, but succeeds to build with gcc-14/g++-14. The severity of this report will be raised before the forky release.

The full build log can be found at:
http://qa-logs.debian.net/2025/02/16/amd64exp/libhdf4_4.3.0-1_unstable_gccexp.log.gz
The last lines of the build log are at the end of this report.

To build with GCC 15, either set CC=gcc-15 CXX=g++-15 explicitly, or install the gcc, g++, gfortran, ... packages from experimental.

apt-get -t=experimental install g++   

GCC 15 now defaults to the C23/C++23 standards, exposing many FTBFS.
Other Common build failures are new warnings resulting in build failures
with -Werror turned on, or new/dropped symbols in Debian symbols files.
For other C/C++ related build failures see the porting guide at
http://gcc.gnu.org/gcc-15/porting_to.html

[...]
../../../../HDF4.3.0/mfhdf/libsrc/nc_priv.h:432:18: note: 'xdr_NC_var' declared here
  432 | HDFLIBAPI bool_t xdr_NC_var(XDR *xdrs, NC_var **vpp);
      |                  ^~~~~~~~~~
../../../../HDF4.3.0/mfhdf/libsrc/array.c:528:25: error: assignment to 'bool_t (*)(void)' {aka 'int (*)(void)'} from incompatible pointer type 'bool_t (*)(XDR *, NC_attr **)' {aka 'int (*)(struct xinfo *, NC_attr **)'} [-Wincompatible-pointer-types]                   
  528 |             xdr_NC_fnct = xdr_NC_attr;
      |                         ^
../../../../HDF4.3.0/mfhdf/libsrc/nc_priv.h:427:18: note: 'xdr_NC_attr' declared here
  427 | HDFLIBAPI bool_t xdr_NC_attr(XDR *xdrs, NC_attr **app);
      |                  ^~~~~~~~~~~
../../../../HDF4.3.0/mfhdf/libsrc/array.c:537:17: error: too many arguments to function 'xdr_NC_fnct'; expected 0, have 2
  537 |         stat = (*xdr_NC_fnct)(xdrs, vp);
      |                ~^~~~~~~~~~~~~ ~~~~
../../../../HDF4.3.0/mfhdf/libsrc/array.c:546:13: error: too many arguments to function 'xdr_NC_fnct'; expected 0, have 3
  546 |     stat = (*xdr_NC_fnct)(xdrs, vp, *countp);
      |            ~^~~~~~~~~~~~~ ~~~~
make[4]: *** [Makefile:648: array.lo] Error 1
make[4]: *** Waiting for unfinished jobs....
../../../../HDF4.3.0/mfhdf/libsrc/cdf.c: In function 'xdr_NC_fill':
../../../../HDF4.3.0/mfhdf/libsrc/cdf.c:2396:25: error: assignment to 'bool_t (*)(void)' {aka 'int (*)(void)'} from incompatible pointer type 'bool_t (*)(XDR *, char **, unsigned int *, unsigned int)' {aka 'int (*)(struct xinfo *, char **, unsigned int *, unsigned int)'} [-Wincompatible-pointer-types]
 2396 |             xdr_NC_fnct = h4_xdr_bytes;
      |                         ^
In file included from ../../../../HDF4.3.0/mfhdf/libsrc/nc_priv.h:31,
                 from ../../../../HDF4.3.0/mfhdf/libsrc/cdf.c:17:
../../../../HDF4.3.0/mfhdf/libsrc/h4_xdr_priv.h:106:18: note: 'h4_xdr_bytes' declared here
  106 | HDFLIBAPI bool_t h4_xdr_bytes(XDR *, char **, unsigned *, unsigned);
      |                  ^~~~~~~~~~~~
../../../../HDF4.3.0/mfhdf/libsrc/cdf.c:2400:25: error: assignment to 'bool_t (*)(void)' {aka 'int (*)(void)'} from incompatible pointer type 'bool_t (*)(XDR *, short int *)' {aka 'int (*)(struct xinfo *, short int *)'} [-Wincompatible-pointer-types]
 2400 |             xdr_NC_fnct = xdr_2shorts;
      |                         ^
../../../../HDF4.3.0/mfhdf/libsrc/cdf.c:2354:1: note: 'xdr_2shorts' declared here
 2354 | xdr_2shorts(XDR *xdrs, short *sp)
      | ^~~~~~~~~~~
../../../../HDF4.3.0/mfhdf/libsrc/cdf.c:2404:25: error: assignment to 'bool_t (*)(void)' {aka 'int (*)(void)'} from incompatible pointer type 'bool_t (*)(XDR *, int *)' {aka 'int (*)(struct xinfo *, int *)'} [-Wincompatible-pointer-types]
 2404 |             xdr_NC_fnct = h4_xdr_int;
      |                         ^
../../../../HDF4.3.0/mfhdf/libsrc/h4_xdr_priv.h:103:18: note: 'h4_xdr_int' declared here
  103 | HDFLIBAPI bool_t h4_xdr_int(XDR *, int *);
      |                  ^~~~~~~~~~
../../../../HDF4.3.0/mfhdf/libsrc/cdf.c:2408:25: error: assignment to 'bool_t (*)(void)' {aka 'int (*)(void)'} from incompatible pointer type 'bool_t (*)(XDR *, float *)' {aka 'int (*)(struct xinfo *, float *)'} [-Wincompatible-pointer-types]
 2408 |             xdr_NC_fnct = h4_xdr_float;
      |                         ^
../../../../HDF4.3.0/mfhdf/libsrc/h4_xdr_priv.h:109:18: note: 'h4_xdr_float' declared here
  109 | HDFLIBAPI bool_t h4_xdr_float(XDR *, float *);
      |                  ^~~~~~~~~~~~
../../../../HDF4.3.0/mfhdf/libsrc/cdf.c:2412:25: error: assignment to 'bool_t (*)(void)' {aka 'int (*)(void)'} from incompatible pointer type 'bool_t (*)(XDR *, double *)' {aka 'int (*)(struct xinfo *, double *)'} [-Wincompatible-pointer-types]
 2412 |             xdr_NC_fnct = h4_xdr_double;
      |                         ^
../../../../HDF4.3.0/mfhdf/libsrc/h4_xdr_priv.h:110:18: note: 'h4_xdr_double' declared here
  110 | HDFLIBAPI bool_t h4_xdr_double(XDR *, double *);
      |                  ^~~~~~~~~~~~~
../../../../HDF4.3.0/mfhdf/libsrc/cdf.c:2421:17: error: too many arguments to function 'xdr_NC_fnct'; expected 0, have 2
 2421 |         stat = (*xdr_NC_fnct)(xdrs, fillp);
      |                ~^~~~~~~~~~~~~ ~~~~
make[4]: *** [Makefile:648: cdf.lo] Error 1
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../../HDF4.3.0/mfhdf/libsrc -I../../hdf/src -I../../../../HDF4.3.0/hdf/src -I../../../../HDF4.3.0/mfhdf/libsrc -DHDF -D_POSIX_C_SOURCE=200809L -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -DNDEBUG -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/libhdf4-4.3.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -c ../../../../HDF4.3.0/mfhdf/libsrc/iarray.c -o iarray.o >/dev/null 2>&1
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../../HDF4.3.0/mfhdf/libsrc -I../../hdf/src -I../../../../HDF4.3.0/hdf/src -I../../../../HDF4.3.0/mfhdf/libsrc -DHDF -D_POSIX_C_SOURCE=200809L -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -DNDEBUG -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/libhdf4-4.3.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -c ../../../../HDF4.3.0/mfhdf/libsrc/error.c -o error.o >/dev/null 2>&1
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../../HDF4.3.0/mfhdf/libsrc -I../../hdf/src -I../../../../HDF4.3.0/hdf/src -I../../../../HDF4.3.0/mfhdf/libsrc -DHDF -D_POSIX_C_SOURCE=200809L -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -DNDEBUG -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/libhdf4-4.3.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -c ../../../../HDF4.3.0/mfhdf/libsrc/attr.c -o attr.o >/dev/null 2>&1
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../../HDF4.3.0/mfhdf/libsrc -I../../hdf/src -I../../../../HDF4.3.0/hdf/src -I../../../../HDF4.3.0/mfhdf/libsrc -DHDF -D_POSIX_C_SOURCE=200809L -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -DNDEBUG -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/libhdf4-4.3.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -c ../../../../HDF4.3.0/mfhdf/libsrc/dim.c -o dim.o >/dev/null 2>&1
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../../HDF4.3.0/mfhdf/libsrc -I../../hdf/src -I../../../../HDF4.3.0/hdf/src -I../../../../HDF4.3.0/mfhdf/libsrc -DHDF -D_POSIX_C_SOURCE=200809L -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -DNDEBUG -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/libhdf4-4.3.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -c ../../../../HDF4.3.0/mfhdf/libsrc/file.c -o file.o >/dev/null 2>&1
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../../HDF4.3.0/mfhdf/libsrc -I../../hdf/src -I../../../../HDF4.3.0/hdf/src -I../../../../HDF4.3.0/mfhdf/libsrc -DHDF -D_POSIX_C_SOURCE=200809L -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -DNDEBUG -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/libhdf4-4.3.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/ -c ../../../../HDF4.3.0/mfhdf/libsrc/hdfsds.c -o hdfsds.o >/dev/null 2>&1
make[4]: Leaving directory '/build/reproducible-path/libhdf4-4.3.0/debian/build-hdf4/mfhdf/libsrc'
make[3]: *** [Makefile:490: all-recursive] Error 1
make[3]: Leaving directory '/build/reproducible-path/libhdf4-4.3.0/debian/build-hdf4/mfhdf'
make[2]: *** [Makefile:582: all-recursive] Error 1
make[2]: Leaving directory '/build/reproducible-path/libhdf4-4.3.0/debian/build-hdf4'
dh_auto_build: error: cd debian/build-hdf4 && make -j8 F77=gfortran CC=gcc CXX=g\+\+ "CFLAGS=-g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/libhdf4-4.3.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include/tirpc/" "LDFLAGS=-Wl,-z,relro -Wl,-z,now -ltirpc" "LIBS=-ljpeg -lz -lm" returned exit code 2
make[1]: *** [debian/rules:106: override_dh_auto_build] Error 25
make[1]: Leaving directory '/build/reproducible-path/libhdf4-4.3.0'
make: *** [debian/rules:54: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2

From Porting to GCC 15 > Function declarations without parameters:

The meaning of function declarations of the form rettype identifier (); such as char *strstr (); changed in C23.

In C17 and earlier, such function declarators specified no information about the number or types of the parameters of the function (C17 6.7.6.3), requiring users to know the correct number of arguments, with each passed argument going through default argument promotion.

In C23 such declarations mean (void) i.e. a function taking no arguments, which can lead to build failures on code that relied on the earlier meaning, such as in this example:

#include <signal.h>

void test()
{
  void (*handler)();
  handler = signal(SIGQUIT, SIG_IGN);
}
<source>: In function 'test':
<source>:6:11: error: assignment to 'void (*)(void)' from incompatible pointer type '__sighandler_t' {aka 'void (*)(int)'} [-Wincompatible-pointer-types]
    6 |   handler = signal(SIGQUIT, SIG_IGN);
      |           ^
In file included from <source>:1:
/usr/include/signal.h:72:16: note: '__sighandler_t' declared here
   72 | typedef void (*__sighandler_t) (int);
      |                ^~~~~~~~~~~~~~

Code such as the above relying on a non-zero number of parameters (such as a single int) can be fixed for C23 by adding the correct parameters to the function declarator, such as via:

  void (*handler)(int);

In other cases the code is simply missing a #include of the correct header, such as with:

  void *malloc();

These can be fixed by including the correct header and removing the non-prototype declaration.

Alternatively you can use -std= to select an earlier version of the C standard.

@hyoklee
Copy link
Member

hyoklee commented Feb 19, 2025

@sebastic , thank you for testing HDF4 well in advance with gcc-15 and autotools!

FYI, CMake build of the master branch seems fine:

https://my.cdash.org/viewTest.php?onlypassed&buildid=2826506

Can Debian packaging team try CMake for HDF4 package?

@sebastic
Copy link
Contributor Author

Can Debian packaging team try CMake for HDF4 package?

Not really. Our build is heavily patched to build variants with and without netcdf compatibility, requiring us to completely rewrite our packaging for the switch to CMake.

That's only worthwhile if we can get rid of the -alt variant, but most reverse dependencies in Debian use that variant not the regular one. We could make the -alt variant the only one built when switching to CMake, but the amount of work required to change the packaging to use CMake is still hard to find the motivation for.

I see that on master functions like h4_xdr_double have been renamed to use the hdf prefix instead of h4, I suspect source changes related to those are more likely to have made a difference with your GCC 15 build than CMake.

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

2 participants