Skip to content

Conflicting function declarations for ftell and strtol cause FTBFS with GCC 15 #410

@glaubitz

Description

@glaubitz

The gpt4all package fails to build from source with GCC 15 as it incorrectly declares the functions ftell() and strtol() to have no parameters while the former takes one parameter while the latter takes three:

[   24s] [  7%] Building C object deps/llama.cpp-mainline/ggml/src/kompute/CMakeFiles/xxd.dir/external/bin/xxd.c.o
[   24s] cd /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/build/deps/llama.cpp-mainline/ggml/src/kompute && /usr/bin/cc -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS=1 -DKOMPUTE_OPT_BUILT_IN_VULKAN_HEADER_TAG -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK -DKOMPUTE_OPT_LOG_LEVEL -DKOMPUTE_OPT_USE_BUILT_IN_SPDLOG -DVULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 -I/home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/build -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -O2 -g -DNDEBUG -MD -MT deps/llama.cpp-mainline/ggml/src/kompute/CMakeFiles/xxd.dir/external/bin/xxd.c.o -MF CMakeFiles/xxd.dir/external/bin/xxd.c.o.d -o CMakeFiles/xxd.dir/external/bin/xxd.c.o -c /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:160:17: error: conflicting types for ‘strtol’; have ‘long int(void)’
[   24s]   160 | extern long int strtol();
[   24s]       |                 ^~~~~~
[   24s] In file included from /usr/include/features.h:511,
[   24s]                  from /usr/include/bits/libc-header-start.h:33,
[   24s]                  from /usr/include/stdio.h:28,
[   24s]                  from /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:93:
[   24s] /usr/include/stdlib.h:215:17: note: previous declaration of ‘strtol’ with type ‘long int(const char * restrict,  char ** restrict,  int)’
[   24s]   215 | extern long int __REDIRECT_NTH (strtol, (const char *__restrict __nptr,
[   24s]       |                 ^~~~~~~~~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:161:17: error: conflicting types for ‘ftell’; have ‘long int(void)’
[   24s]   161 | extern long int ftell();
[   24s]       |                 ^~~~~
[   24s] /usr/include/stdio.h:775:17: note: previous declaration of ‘ftell’ with type ‘long int(FILE *)’
[   24s]   775 | extern long int ftell (FILE *__stream) __wur __nonnull ((1));
[   24s]       |                 ^~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c: In function ‘exit_with_usage’:
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:251:1: warning: old-style function definition [-Wold-style-definition]
[   24s]   251 | exit_with_usage(pname)
[   24s]       | ^~~~~~~~~~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c: In function ‘huntype’:
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:287:1: warning: old-style function definition [-Wold-style-definition]
[   24s]   287 | huntype(fpi, fpo, fperr, pname, cols, hextype, base_off)
[   24s]       | ^~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c: In function ‘xxdline’:
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:407:1: warning: old-style function definition [-Wold-style-definition]
[   24s]   407 | xxdline(fp, l, nz)
[   24s]       | ^~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c: In function ‘main’:
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:467:1: warning: old-style function definition [-Wold-style-definition]
[   24s]   467 | main(argc, argv)
[   24s]       | ^~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:518:25: error: too many arguments to function ‘strtol’; expected 0, have 3
[   24s]   518 |             cols = (int)strtol(pp + 2, NULL, 0);
[   24s]       |                         ^~~~~~ ~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:160:17: note: declared here
[   24s]   160 | extern long int strtol();
[   24s]       |                 ^~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:523:27: error: too many arguments to function ‘strtol’; expected 0, have 3
[   24s]   523 |               cols = (int)strtol(argv[2], NULL, 0);
[   24s]       |                           ^~~~~~ ~~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:160:17: note: declared here
[   24s]   160 | extern long int strtol();
[   24s]       |                 ^~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:531:31: error: too many arguments to function ‘strtol’; expected 0, have 3
[   24s]   531 |             octspergrp = (int)strtol(pp + 2, NULL, 0);
[   24s]       |                               ^~~~~~ ~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:160:17: note: declared here
[   24s]   160 | extern long int strtol();
[   24s]       |                 ^~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:536:33: error: too many arguments to function ‘strtol’; expected 0, have 3
[   24s]   536 |               octspergrp = (int)strtol(argv[2], NULL, 0);
[   24s]       |                                 ^~~~~~ ~~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:160:17: note: declared here
[   24s]   160 | extern long int strtol();
[   24s]       |                 ^~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:553:25: error: too many arguments to function ‘strtol’; expected 0, have 3
[   24s]   553 |               seekoff = strtol(pp + 2+relseek+negseek, (char **)NULL, 0);
[   24s]       |                         ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:160:17: note: declared here
[   24s]   160 | extern long int strtol();
[   24s]       |                 ^~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:565:25: error: too many arguments to function ‘strtol’; expected 0, have 3
[   24s]   565 |               seekoff = strtol(argv[2] + relseek+negseek, (char **)NULL, 0);
[   24s]       |                         ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:160:17: note: declared here
[   24s]   160 | extern long int strtol();
[   24s]       |                 ^~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:573:22: error: too many arguments to function ‘strtol’; expected 0, have 3
[   24s]   573 |             length = strtol(pp + 2, (char **)NULL, 0);
[   24s]       |                      ^~~~~~ ~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:160:17: note: declared here
[   24s]   160 | extern long int strtol();
[   24s]       |                 ^~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:578:24: error: too many arguments to function ‘strtol’; expected 0, have 3
[   24s]   578 |               length = strtol(argv[2], (char **)NULL, 0);
[   24s]       |                        ^~~~~~ ~~~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:160:17: note: declared here
[   24s]   160 | extern long int strtol();
[   24s]       |                 ^~~~~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:684:19: error: too many arguments to function ‘ftell’; expected 0, have 1
[   24s]   684 |         seekoff = ftell(fp);
[   24s]       |                   ^~~~~ ~~
[   24s] /home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/deps/llama.cpp-mainline/ggml/src/kompute/external/bin/xxd.c:161:17: note: declared here
[   24s]   161 | extern long int ftell();
[   24s]       |                 ^~~~~
[   24s] make[2]: *** [deps/llama.cpp-mainline/ggml/src/kompute/CMakeFiles/xxd.dir/build.make:82: deps/llama.cpp-mainline/ggml/src/kompute/CMakeFiles/xxd.dir/external/bin/xxd.c.o] Error 1
[   24s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/python-gpt4all-3.9.0-build/gpt4all-3.9.0/gpt4all-backend/build'
[   24s] make[1]: *** [CMakeFiles/Makefile2:516: deps/llama.cpp-mainline/ggml/src/kompute/CMakeFiles/xxd.dir/all] Error 2
[   24s] make[1]: *** Waiting for unfinished jobs....

It would probably best to just delete these declarations and include the corresponding stdlib.h header directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions