From: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
To: buildroot@buildroot.org
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: [Buildroot] [PATCH 2/2] package/libffi: fix build on OpenRISC
Date: Sat, 17 Aug 2024 14:30:39 +0200 [thread overview]
Message-ID: <20240817123040.841448-2-thomas.petazzoni@bootlin.com> (raw)
In-Reply-To: <20240817123040.841448-1-thomas.petazzoni@bootlin.com>
The build of libffi on OpenRISC is broken with GCC 14.x. This commit
brings two patches, submitted upstream, that address those two build
issues. Both issues always existed in the OpenRISC libffi code base.
Fixes:
http://autobuild.buildroot.net/results/fb95d9a0f8322a58cd266014f3dea4eaa1b483e5/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
...ffi.c-fix-prototype-of-ffi_call_SYSV.patch | 47 +++++++++++++++++
...-ffi.c-fix-incompatible-pointer-type.patch | 50 +++++++++++++++++++
2 files changed, 97 insertions(+)
create mode 100644 package/libffi/0004-src-or1k-ffi.c-fix-prototype-of-ffi_call_SYSV.patch
create mode 100644 package/libffi/0005-src-or1k-ffi.c-fix-incompatible-pointer-type.patch
diff --git a/package/libffi/0004-src-or1k-ffi.c-fix-prototype-of-ffi_call_SYSV.patch b/package/libffi/0004-src-or1k-ffi.c-fix-prototype-of-ffi_call_SYSV.patch
new file mode 100644
index 0000000000..f3a7b29e3b
--- /dev/null
+++ b/package/libffi/0004-src-or1k-ffi.c-fix-prototype-of-ffi_call_SYSV.patch
@@ -0,0 +1,47 @@
+From 4506e943289ed1363f3921bc201d5da76f750229 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+Date: Sat, 17 Aug 2024 12:56:22 +0200
+Subject: [PATCH] src/or1k/ffi.c: fix prototype of ffi_call_SYSV()
+
+The current code base of libffi on OpenRISC (or1k) fails to build with
+GCC 14.x with the following error:
+
+../src/or1k/ffi.c: In function 'ffi_call':
+../src/or1k/ffi.c:167:34: error: passing argument 3 of 'ffi_call_SYSV' from incompatible pointer type [-Wincompatible-pointer-types]
+ 167 | ffi_call_SYSV(size, &ecif, ffi_prep_args, rvalue, fn, cif->flags);
+ | ^~~~~~~~~~~~~
+ | |
+ | void * (*)(char *, extended_cif *)
+../src/or1k/ffi.c:113:27: note: expected 'void * (*)(int *, extended_cif *)' but argument is of type 'void * (*)(char *, extended_cif *)'
+ 113 | void *(*)(int *, extended_cif *),
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This is due to the fact that ffi_prep_args() is in fact defined as:
+
+ void* ffi_prep_args(char *stack, extended_cif *ecif)
+
+so, let's fix the prototype of the function pointer, which anyway gets
+passed to assembly code, so the typing gets lost.
+
+Upstream: https://github.com/libffi/libffi/pull/854
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+---
+ src/or1k/ffi.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/or1k/ffi.c b/src/or1k/ffi.c
+index 9451d4e..157388e 100644
+--- a/src/or1k/ffi.c
++++ b/src/or1k/ffi.c
+@@ -110,7 +110,7 @@ void* ffi_prep_args(char *stack, extended_cif *ecif)
+
+ extern void ffi_call_SYSV(unsigned,
+ extended_cif *,
+- void *(*)(int *, extended_cif *),
++ void *(*)(char *, extended_cif *),
+ unsigned *,
+ void (*fn)(void),
+ unsigned);
+--
+2.46.0
+
diff --git a/package/libffi/0005-src-or1k-ffi.c-fix-incompatible-pointer-type.patch b/package/libffi/0005-src-or1k-ffi.c-fix-incompatible-pointer-type.patch
new file mode 100644
index 0000000000..e1ff003500
--- /dev/null
+++ b/package/libffi/0005-src-or1k-ffi.c-fix-incompatible-pointer-type.patch
@@ -0,0 +1,50 @@
+From ec39b03d891a77552ad7729ff79bf21bf3591842 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+Date: Sat, 17 Aug 2024 13:52:45 +0200
+Subject: [PATCH] src/or1k/ffi.c: fix incompatible pointer type
+
+The current code base of libffi on OpenRISC (or1k) fails to build with
+GCC 14.x with the following error:
+
+../src/or1k/ffi.c: In function 'ffi_closure_SYSV':
+../src/or1k/ffi.c:183:22: error: initialization of 'char *' from incompatible pointer type 'int *' [-Wincompatible-pointer-types]
+ 183 | char *stack_args = sp;
+ | ^~
+
+Indeed:
+
+ register int *sp __asm__ ("r17");
+ [..]
+ char *stack_args = sp;
+
+Adopt the same logic used for:
+
+ char *ptr = (char *) register_args;
+
+which consists in casting to the desired pointer type. Indeed, later
+in the code stack_args is assigned to ptr (so they need to be the same
+pointer type), and some arithmetic is done on ptr, so changing its
+pointer type would change the behavior.
+
+Upstream: https://github.com/libffi/libffi/pull/854
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+---
+ src/or1k/ffi.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/or1k/ffi.c b/src/or1k/ffi.c
+index 157388e..7a6d28c 100644
+--- a/src/or1k/ffi.c
++++ b/src/or1k/ffi.c
+@@ -180,7 +180,7 @@ void ffi_closure_SYSV(unsigned long r3, unsigned long r4, unsigned long r5,
+ register int *r13 __asm__ ("r13");
+
+ ffi_closure* closure = (ffi_closure*) r13;
+- char *stack_args = sp;
++ char *stack_args = (char*) sp;
+
+ /* Lay the register arguments down in a continuous chunk of memory. */
+ unsigned register_args[6] =
+--
+2.46.0
+
--
2.46.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2024-08-17 12:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-17 12:30 [Buildroot] [PATCH 1/2] package/libffi: fix build on ARC Thomas Petazzoni via buildroot
2024-08-17 12:30 ` Thomas Petazzoni via buildroot [this message]
2024-08-18 7:31 ` Yann E. MORIN
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240817123040.841448-2-thomas.petazzoni@bootlin.com \
--to=buildroot@buildroot.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.