[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1091027: syslinux: FTBFS: debug.c:91:5: error: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]



Hello,

There were a couple more build failures with GCC-14, I'm attaching a patch
that takes care of them.


The first diff is from https://lists.debian.org/debian-cd/2024/10/msg00000.html
from the linked Ubuntu patch:
https://git.launchpad.net/ubuntu/+source/syslinux/commit/?h=applied/ubuntu/noble&id=4828eee42000655782c9e1ccaa5d56333dd3d44f

This disables FCF protection on i386, which is appropriate since it's
only supported on i686 and later:
https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html


The second diff adds #include <stdio.h> to com32/lib/syslinux/debug.c,
which fixes the implicit declaration issue.


The third diff adds #include <setjmp.h> to efi/main.c, and fixes
the incorrect invocations of longjmp() and setjmp() where the functions
were passed a pointer to jmp_buf, but the value should be passed instead.

This has to be double-checked.  I've looked at other instances of these
functions in the com32 codebase, and they use the value of jmp_buf,
not a pointer to the value.


And the last, fourth diff, adds a type cast in com32/chain/chain.c
from (addr_t *) to (size_t *).  I think that assuming that these two
will have the same size is a reasonable assumption to make


When combined with the following patch to fix the build failure
with gnu-efi >= 3.0.16, I'm able to build the package again on unstable:
https://lore.kernel.org/all/20240228181411.10174-1-ju.o@free.fr/T/

Best Regards,
Marek
Description: GCC-14 compatibility patch

* Disable FCF protection on i386, where it's not supported. 
* Add missing include to resolve implicit printf() function declaration.
* Add missing header file for long jumps in efi/main.c, fix invocations.
* Type-cast addr_t pointer to size_t, assumes that their size is the same.

Author: Marek Benc <benc.marek.elektro98@proton.me>
Bug-Debian: https://bugs.debian.org/1091027
Last-Update: 2025-04-11

--- syslinux-6.04~git20190206.bf6db5b4+dfsg1.orig/mk/embedded.mk
+++ syslinux-6.04~git20190206.bf6db5b4+dfsg1/mk/embedded.mk
@@ -24,6 +24,7 @@ GCCOPT :=
 ifeq ($(ARCH),i386)
 	GCCOPT := $(call gcc_ok,-m32)
 	GCCOPT += $(call gcc_ok,-march=i386)
+	GCCOPT    += $(call gcc_ok,-fcf-protection=none,)
 	GCCOPT    += $(call gcc_ok,-mpreferred-stack-boundary=2,)
 	GCCOPT    += $(call gcc_ok,-mincoming-stack-boundary=2,)
 endif

--- syslinux-6.04~git20190206.bf6db5b4+dfsg1.orig/com32/lib/syslinux/debug.c
+++ syslinux-6.04~git20190206.bf6db5b4+dfsg1/com32/lib/syslinux/debug.c
@@ -1,4 +1,5 @@
 #include <linux/list.h>
+#include <stdio.h>
 #include <string.h>
 #include <stdbool.h>

--- syslinux-6.04~git20190206.bf6db5b4+dfsg1.orig/efi/main.c
+++ syslinux-6.04~git20190206.bf6db5b4+dfsg1/efi/main.c
@@ -6,6 +6,7 @@
 #include <core.h>
 #include <fs.h>
 #include <com32.h>
+#include <setjmp.h>
 #include <syslinux/memscan.h>
 #include <syslinux/firmware.h>
 #include <syslinux/linux.h>
@@ -184,7 +185,7 @@
      * Inform the firmware that we failed to execute correctly, which
      * will trigger the next entry in the EFI Boot Manager list.
      */
-    longjmp(&load_error_buf, 1);
+    longjmp(load_error_buf, 1);
 }
 
 void bios_timer_cleanup(void)
@@ -1382,7 +1383,7 @@
 		status = uefi_call_wrapper(in->ReadKeyStroke, 2, in, &key);
 	} while (status == EFI_SUCCESS);
 
-	if (!setjmp(&load_error_buf))
+	if (!setjmp(load_error_buf))
 		load_env32(NULL);
 
 	/* load_env32() failed.. cancel timer and bailout */

--- syslinux-6.04~git20190206.bf6db5b4+dfsg1.orig/com32/chain/chain.c
+++ syslinux-6.04~git20190206.bf6db5b4+dfsg1/com32/chain/chain.c
@@ -514,7 +514,7 @@
     if (opt.file) {
 	fdat.base = (opt.fseg << 4) + opt.foff;
 
-	if (loadfile(opt.file, &fdat.data, &fdat.size)) {
+	if (loadfile(opt.file, &fdat.data, (size_t *)&fdat.size)) {
 	    error("Couldn't read the boot file.");
 	    goto bail;
 	}

Reply to: