Greetings,
The Fedora project is rebuilding all packages with a prerelease of GCC
15. This version of GCC changes the default C standard from C17 to
C23. Two C23 changes have been causing a lot of build failures, and
also affect gcl.
First, "bool", "true", and "false" are now keywords of the language;
i.e., "#include <stdbool.h>" has become a no-op. One consequence is
that this code in h/lu.h is now illegal:
#undef bool
typedef int bool;
Since bool is a language keyword, not a preprocessor macro, the #undef
has no effect, and you can't create a typedef for a builtin type, so
that is a compiler error. (There is another such typedef in
bin/dpp.c.)
Second, in C17 and earlier, function declarations of the form "t f();"
mean that f is a function that returns type t and has an unspecified
parameter list. In C23, such a declaration has the same meaning as "t
f(void);"; i.e., it asserts that f takes zero arguments. This leads
to build errors like this:
In file included from ../h/include.h:119,
from typespec.c:29:
../h/../h/protoize.h:64:41: error: conflicting types for
‘clear_compiler_properties’; have ‘union lispunion *(union lispunion
*, union lispunion *)’
64 | /* assignment.c:547:OF */ extern object
clear_compiler_properties (object sym, object code); /* (sym, code)
object sym; object code; */
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../h/include.h:112:
../h/../h/object.h:532:8: note: previous declaration of
‘clear_compiler_properties’ with type ‘union lispunion *(void)’
532 | object clear_compiler_properties();
| ^~~~~~~~~~~~~~~~~~~~~~~~~
I attempted to work around the issue for now by adding -std=gnu17 to
the build flags, but that still fails:
../bin/dpp.c:84:13: error: ‘bool’ cannot be defined via ‘typedef’
84 | typedef int bool;
| ^~~~
../bin/dpp.c:84:13: note: ‘bool’ is a keyword with ‘-std=c23’ onwards
../bin/dpp.c:84:1: warning: useless type name in empty declaration
84 | typedef int bool;
| ^~~~~~~
The problem is that the C compiler is invoked without user CFLAGS in 3
places, each time defaulting to C23 mode. The attached patch, plus
explicitly specifying the C standard as C17 or earlier, works around
the issue.
--
Jerry James
http://www.jamezone.org/
--- gcl-2.6.14/makefile.orig 2023-01-17 11:57:22.238144438 -0700
+++ gcl-2.6.14/makefile 2025-01-21 13:35:13.618595528 -0700
@@ -269,12 +269,12 @@ $(HDIR)new_decl.h:
$(HDIR)mcompdefs.h: $(HDIR)compdefs.h $(HDIR)new_decl.h
cat $< |\
$(AWK) 'BEGIN {print "#include \"include.h\"";print "#include \"cmponly.h\"";print "---"} {a=$$1;gsub("\\.\\.\\.","",a);print "\"#define " $$1 "\" " a}' |\
- $(CC) -E -P -I./$(HDIR) - |\
+ $(CC) $(CFLAGS) -E -P -I./$(HDIR) - |\
$(AWK) '/^\-\-\-$$/ {i=1;next} {if (!i) next} {gsub("\"","");print}' >$@
$(HDIR)cmpinclude.h: $(HDIR)mcompdefs.h $(CMPINCLUDE_FILES) $(HDIR)config.h
cp $< $(@F)
- cat $(CMPINCLUDE_FILES) | $(CC) -E -I./$(HDIR) - | $(AWK) '/^# |^$$|^#pragma/ {next}{print}' >> $(@F)
+ cat $(CMPINCLUDE_FILES) | $(CC) $(CFLAGS) -E -I./$(HDIR) - | $(AWK) '/^# |^$$|^#pragma/ {next}{print}' >> $(@F)
./xbin/move-if-changed mv $(@F) $@
./xbin/move-if-changed cp $@ o/$(@F)
--- gcl-2.6.14/o/makefile.orig 2025-01-21 10:23:02.846520809 -0700
+++ gcl-2.6.14/o/makefile 2025-01-21 13:55:45.962921794 -0700
@@ -70,7 +70,7 @@ boot.h: boot.ini
rm $*.c
$(DPP): ../bin/dpp.c
- ${CC} ${DEFS} -o $@ $<
+ ${CC} ${CFLAGS} ${DEFS} -o $@ $<
new_init.c: ${INI_FILES}
echo '#include "make-init.h"' > $@