Bug 281238 - lang/gforth: Fails to build with GCC 14: prim:2157:5: error: implicit declaration of function 'ecvt' [-Wimplicit-function-declaration]
Summary: lang/gforth: Fails to build with GCC 14: prim:2157:5: error: implicit declara...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Alexey Dokuchaev
URL: https://pkg-status.freebsd.org/gohan0...
Keywords:
Depends on:
Blocks: 281091
  Show dependency treegraph
 
Reported: 2024-09-03 13:39 UTC by Lorenzo Salvadore
Modified: 2025-01-08 14:38 UTC (History)
2 users (show)

See Also:


Attachments
gforth poudriere log (57.05 KB, text/plain)
2024-11-15 12:44 UTC, Lorenzo Salvadore
no flags Details
gforth poudriere log (55.77 KB, text/plain)
2024-11-16 08:33 UTC, Lorenzo Salvadore
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lorenzo Salvadore freebsd_committer freebsd_triage 2024-09-03 13:39:35 UTC
Build fails with GCC 14. This blocks GCC_DEFAULT update to GCC 14.

gcc14  -I./../arch/generic -I. -Wall -O2 -pipe  -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc14 -isystem /usr/local/include -fno-strict-aliasing  -DHAVE_CONFIG_H  -DDEFAULTPATH='".:/usr/local/lib/gforth/site-forth:/usr/local/share/gforth/site-forth:/usr/local/lib/gforth/0.7.3:/usr/local/share/gforth/0.7.3"'  -isystem /usr/local/include -fno-gcse -fno-strict-aliasing -fno-crossjumping -fno-reorder-blocks -falign-labels=1 -falign-loops=1 -falign-jumps=1 -fno-defer-pop -fcaller-saves -fno-inline -fno-reorder-blocks -DGFORTH_DEBUGGING -o engine-noll.o -c ./engine.c
In file included from ./engine.c:28:
./forth.h:279:2: warning: #warning flush-icache probably will not work (see manual) [-Wcpp]
  279 | #warning flush-icache probably will not work (see manual)
      |  ^~~~~~~
./forth.h:281:2: warning: #warning no FLUSH_ICACHE, turning off dynamic native code by default [-Wcpp]
  281 | #warning no FLUSH_ICACHE, turning off dynamic native code by default
      |  ^~~~~~~
In file included from ./engine.c:455:
prim: In function 'gforth_engine':
prim:2157:5: error: implicit declaration of function 'ecvt' [-Wimplicit-function-declaration]
prim:2157:4: error: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
gmake[3]: *** [Makefile:169: engine-noll.o] Error 1
gmake[3]: Leaving directory '/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/engine'
gmake[2]: Leaving directory '/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3'
gmake[1]: Leaving directory '/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3'
cp: gforth-noll: No such file or directory
gmake: *** [Makefile:806: gforth] Error 1
*** Error code 1

Full log: https://pkg-status.freebsd.org/gohan04/data/140amd64-default-foo/2024-08-29_19h57m48s/logs/errors/gforth-0.7.3_15.log

Useful link: https://gcc.gnu.org/gcc-14/porting_to.html
Comment 1 Lorenzo Salvadore freebsd_committer freebsd_triage 2024-09-03 13:41:32 UTC
^Triage:

Assign to maintainer
Comment 2 Alexey Dokuchaev freebsd_committer freebsd_triage 2024-09-09 09:11:12 UTC
(In reply to Lorenzo Salvadore from comment #0)
> Build fails with GCC 14. This blocks GCC_DEFAULT update to GCC 14.
Hmm, I'm wondering why this port needs GCC in the first place.  USE_GCC was added in commit ports 7d121368784ad (eleven years ago) without any explanation.  Give me couple of days to either drop the dependency or fix the warning.
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-09-10 05:25:41 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2cab4551df7cf66a0c377f2d53f692f9ddd5f8c9

commit 2cab4551df7cf66a0c377f2d53f692f9ddd5f8c9
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2024-09-10 05:23:20 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2024-09-10 05:23:20 +0000

    lang/gforth: unbreak the build in the -Werror=int-conversion mode

    Missing ecvt() function prototype was causing couple of warnings
    which had become hard errors with recent versions of GCC (14+).
    Getting rid of USE_GCC, while desirable, is not straightforward
    and requires more work.  While here, set the TEST_TARGET which is
    part of the upstream's default ALL_TARGET, but we override that.

    PR:     281238

 lang/gforth/Makefile                         |  2 +-
 lang/gforth/files/patch-engine_forth.h (new) | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
Comment 4 Alexey Dokuchaev freebsd_committer freebsd_triage 2024-09-10 05:29:19 UTC
Please test after commit ports 2cab4551df7c and either provide next error log or close this PR, thanks!
Comment 5 Lorenzo Salvadore freebsd_committer freebsd_triage 2024-11-15 12:44:56 UTC
Created attachment 255192 [details]
gforth poudriere log

I get a new error:

gcc14  -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc14 -L/usr/local/lib/gcc14  engine-fast-ll.o engine-fast2-ll.o main-fast-ll.o io.o signals.o support-ll.o  pow10.o ecvt.o  -lavcall -lffi -lltdl -lm -L/usr/local/lib  -o gforth-fast-ll
gmake[3]: Leaving directory '/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/engine'
gmake[2]: Leaving directory '/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3'
gmake[1]: Leaving directory '/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3'
rm -rf lib/gforth/0.7.3/libcc-named/
for i in libffi.fs fflib.fs cstr.fs unix/socket.fs; do ./gforth -e "s\" `pwd`/lib/gforth/0.7.3/libcc-named/\" libcc-named-dir-v 2! libcc-path clear-path libcc-named-dir libcc-path also-path :noname 2drop s\" /usr/local/lib/gforth/0.7.3/libcc-named/\" ; is replace-rpath" ./$i -e bye; done
/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/lib/gforth/0.7.3/libcc-named/libffi.c: In function 'libffi_LTX_gforth_c_ffi_prep_closure1_aaa_n':
/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/lib/gforth/0.7.3/libcc-named/libffi.c:95:3: warning: 'ffi_prep_closure' is deprecated: use ffi_prep_closure_loc instead [-Wdeprecated-declarations]
   95 |   sp[2]=ffi_prep_closure1((void *)(sp[2]),(void *)(sp[1]),(void *)(sp[0]));
      |   ^~
In file included from /wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/lib/gforth/0.7.3/libcc-named/libffi.c:3:
/usr/local/include/ffi.h:356:1: note: declared here
  356 | ffi_prep_closure (ffi_closure*,
      | ^~~~~~~~~~~~~~~~

file not found
in file included from *OS command line*:-1
libffi.fs:159: open-lib failed
>>>end-c-library<<<
Backtrace:
$D3E2C04990 throw 
$D3E2C40B68 c(abort") 
$D3E2C41418 compile-wrapper-function1 
/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/lib/gforth/0.7.3/libcc-named/fflib.c: In function 'fflib_LTX_gforth_c_alloc_callback1_a_a':
/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/lib/gforth/0.7.3/libcc-named/fflib.c:177:46: error: passing argument 1 of 'alloc_callback' from incompatible pointer type [-Wincompatible-pointer-types]
  177 | #define alloc_callback1(a_ip) alloc_callback(gforth_callback_ffcall, (Xt *)a_ip)
      |                                              ^~~~~~~~~~~~~~~~~~~~~~
      |                                              |
      |                                              void (*)(void ***, void *)
/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/lib/gforth/0.7.3/libcc-named/fflib.c:182:15: note: in expansion of macro 'alloc_callback1'
  182 |   sp[0]=(Cell)alloc_callback1((void *)(sp[0]));
      |               ^~~~~~~~~~~~~~~
In file included from /wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/lib/gforth/0.7.3/libcc-named/fflib.c:3:
/usr/local/include/callback.h:58:35: note: expected 'callback_function_t' {aka 'void (*)(void *, struct vacall_alist *)'} but argument is of type 'void (*)(void ***, void *)'
   58 | extern callback_t alloc_callback (callback_function_t /* ADDRESS */, void* /* DATA */);
      |                                   ^~~~~~~~~~~~~~~~~~~

in file included from *OS command line*:-1
fflib.fs:136: libtool compile failed
>>>end-c-library<<<
Backtrace:
$3AC710804990 throw 
$3AC7108407E8 c(abort") 
$3AC710841418 compile-wrapper-function1 

file not found
in file included from *OS command line*:-1
cstr.fs:23: open-lib failed
>>>end-c-library<<<
Backtrace:
$2DCBEAC04990 throw 
$2DCBEAC40B68 c(abort") 
$2DCBEAC41418 compile-wrapper-function1 

file not found
in file included from *OS command line*:-1
unix/socket.fs:48: open-lib failed
>>>end-c-library<<<
Backtrace:
$2D68D3E04990 throw 
$2D68D3E40B68 c(abort") 
$2D68D3E41418 compile-wrapper-function1 
gmake: *** [Makefile:653: build-libcc-named] Error 1
*** Error code 1

Stop.
make: stopped in /usr/ports/lang/gforth
build of lang/gforth | gforth-0.7.3_15 ended at Fri Nov 15 13:29:45 CET 2024
build time: 00:01:11
!!! build failure encountered !!!



Please see attachment for the full log.

I have tried adding CFLAGS+=-fpermissive as it is working with many other ports: the build completes successfully, however I then get issues with missing files in pkg-plist.
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-11-16 06:09:35 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a62009118b30df00bbe618899ac377b3b408d8f8

commit a62009118b30df00bbe618899ac377b3b408d8f8
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2024-11-16 06:07:52 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2024-11-16 06:07:52 +0000

    lang/gforth: try to fix another warning-becomes-error with GCC 14

    Old gforth_callback_ffcall() signature looks dubious and does not
    match the API of `devel/libffcall' [-Wincompatible-pointer-types]:

      callback.h:58:35: note: expected 'callback_function_t' {aka
     'void (*)(void *, struct vacall_alist *)'} but argument is of
      type 'void (*)(void ***, void *)'

    PR:     281238

 lang/gforth/files/patch-fflib.fs (new) | 11 +++++++++++
 1 file changed, 11 insertions(+)
Comment 7 Alexey Dokuchaev freebsd_committer freebsd_triage 2024-11-16 06:17:29 UTC
(In reply to Lorenzo Salvadore from comment #5)
> I have tried adding CFLAGS+=-fpermissive as it is working with many other
> ports: the build completes successfully,
I don't like this approach as it doesn't fix the problem with the code exposed by the compiler, but shuts it up instead and there's no patch to send upstream.

> however I then get issues with missing files in pkg-plist.
Interesting, this might be an indication of another problem.  I'll try to reproduce it (would be nicer if you'd listed them).
Comment 8 Lorenzo Salvadore freebsd_committer freebsd_triage 2024-11-16 08:33:36 UTC
Created attachment 255211 [details]
gforth poudriere log

Still broken, with the following error (full log attached):

or i in libffi.fs fflib.fs cstr.fs unix/socket.fs; do ./gforth -e "s\" `pwd`/lib/gforth/0.7.3/libcc-named/\" libcc-named-dir-v 2! libcc-path clear-path libcc-named-dir libcc-path also-path :noname 2drop s\" /usr/local/lib/gforth/0.7.3/libcc-named/\" ; is replace-rpath" ./$i -e bye; done
/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/lib/gforth/0.7.3/libcc-named/libffi.c: In function 'libffi_LTX_gforth_c_ffi_prep_closure1_aaa_n':
/wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/lib/gforth/0.7.3/libcc-named/libffi.c:95:3: warning: 'ffi_prep_closure' is deprecated: use ffi_prep_closure_loc instead [-Wdeprecated-declarations]
   95 |   sp[2]=ffi_prep_closure1((void *)(sp[2]),(void *)(sp[1]),(void *)(sp[0]));
      |   ^~
In file included from /wrkdirs/usr/ports/lang/gforth/work/gforth-0.7.3/lib/gforth/0.7.3/libcc-named/libffi.c:3:
/usr/local/include/ffi.h:356:1: note: declared here
  356 | ffi_prep_closure (ffi_closure*,
      | ^~~~~~~~~~~~~~~~

file not found
in file included from *OS command line*:-1
libffi.fs:159: open-lib failed
>>>end-c-library<<<
Backtrace:
$1FF3B4004990 throw 
$1FF3B4040B68 c(abort") 
$1FF3B4041418 compile-wrapper-function1 

file not found
in file included from *OS command line*:-1
fflib.fs:136: open-lib failed
>>>end-c-library<<<
Backtrace:
$356E0BE04990 throw 
$356E0BE40B68 c(abort") 
$356E0BE41418 compile-wrapper-function1 

file not found
in file included from *OS command line*:-1
cstr.fs:23: open-lib failed
>>>end-c-library<<<
Backtrace:
$1A51F0604990 throw 
$1A51F0640B68 c(abort") 
$1A51F0641418 compile-wrapper-function1 

file not found
in file included from *OS command line*:-1
unix/socket.fs:48: open-lib failed
>>>end-c-library<<<
Backtrace:
$15EF3BC04990 throw 
$15EF3BC40B68 c(abort") 
$15EF3BC41418 compile-wrapper-function1 
gmake: *** [Makefile:653: build-libcc-named] Error 1
*** Error code 1

Stop.
make: stopped in /usr/ports/lang/gforth
build of lang/gforth | gforth-0.7.3_15 ended at Sat Nov 16 09:11:43 CET 2024
build time: 00:01:14
!!! build failure encountered !!!



However -fpermissive this time works fine. Of course I agree that a real fix is better, but I believe a workaround such as -fpermissive is fine for a temporary solution or even for unmaintained ports or software unmaintained upstream.

In case it is still useful, those were the issues I had with pkg-plist using -fpermissive, but they are now solved:

====> Running Q/A tests (stage-qa)
====> Checking for pkg-plist issues (check-plist)
===> Parsing plist
===> Checking for items in STAGEDIR missing from pkg-plist
===> Checking for items in pkg-plist which are not in STAGEDIR
Error: Missing: lib/gforth/%%PORTVERSION%%/libcc-named/fflib.a
Error: Missing: lib/gforth/%%PORTVERSION%%/libcc-named/fflib.so
Error: Missing: lib/gforth/%%PORTVERSION%%/libcc-named/fflib.so.0
Error: Missing: lib/gforth/%%PORTVERSION%%/libcc-named/fflib.so.0.0.0
===> Error: Plist issues found.
*** Error code 1

Stop.
make: stopped in /usr/ports/lang/gforth
=>> Error: check-plist failures detected
Comment 9 Alexey Dokuchaev freebsd_committer freebsd_triage 2024-12-02 06:55:06 UTC
(In reply to Lorenzo Salvadore from comment #8)
> Still broken, with the following error (full log attached): [...]
Hmm, now there're no obvious "error:" lines, so I had to build GCC 14 to see what's going on.  It took me a while because non-bootstrapped build is broken (I normally use GCC 8 where disabling the option does not break the port).  I could reproduce the problem and now looking for a proper fix.
Comment 10 commit-hook freebsd_committer freebsd_triage 2024-12-13 11:53:57 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c6132acf5a4df3c177bf89802f380630f2ddd743

commit c6132acf5a4df3c177bf89802f380630f2ddd743
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2024-12-13 11:53:06 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2024-12-13 11:53:06 +0000

    lang/gforth: mend another tricky issue discovered with GCC 14

    When checking whether the linker accepts -export-dynamic flag,
    the configure script tries to build, literally, the following
    short program: ``main(){exit(0);}'', which is not well-formed
    against the modern standards (missing return type and implicit
    function declaration).

    PR:     281238

 lang/gforth/files/patch-configure (new) | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Comment 11 Lorenzo Salvadore freebsd_committer freebsd_triage 2024-12-22 11:23:44 UTC
I have tested it again and it is fixed. I guess we can close this PR now.
Thanks!
Comment 12 Gerald Pfeifer freebsd_committer freebsd_triage 2024-12-24 10:18:56 UTC
Thank you danfe@ for fixing this for real (not just trying to silence
warnings/errors with compiler options)!

I hope you can submit these improvements upstream as well?
Comment 13 Alexey Dokuchaev freebsd_committer freebsd_triage 2025-01-08 14:38:19 UTC
(In reply to Gerald Pfeifer from comment #12)
> Thank you danfe@ for fixing this for real (not just trying to silence
> warnings/errors with compiler options)!
Thank you for your kind words Gerald, and sorry for belated reply.  Happy New Year!  It does sadden me indeed seeing people often not trying to listen to the compiler and urge to shut it up. :(

> I hope you can submit these improvements upstream as well?
It was actually reported* and fixed** back in April 2023, silly me neglected to check this beforehand.  Upstream development is actually rather active, but they haven't made a stable release for a way long time.

*) https://savannah.gnu.org/bugs/?64068
**) https://git.savannah.gnu.org/cgit/gforth.git/commit/?id=88ead2ce