Files
gentoo/sys-boot/refind/files/refind-0.14.0.2-clang.patch
Viorel Munteanu 797977a54c sys-boot/refind: fix compilation with clang
Compiling with clang works.
Linking with lld produces broken executables (including the drivers).
llvm-objcopy does not support the output format needed by refind.

Try to force ld.bfd and binutils objcopy.  Fail otherwise.

Bug: https://bugs.gentoo.org/732256
Bug: https://bugs.gentoo.org/832018
Bug: https://bugs.gentoo.org/881131
Closes: https://github.com/gentoo/gentoo/pull/32710
Signed-off-by: Viorel Munteanu <ceamac@gentoo.org>
2023-09-14 07:39:01 +03:00

63 lines
1.3 KiB
Diff

Fix compilation with clang.
Clang does not support nested functions (a gcc extension), so move it outside.
Compiling with _FORTIFY_SOURCE and -ffreestanding results in
nanojpeg.c:(.text+0xa28): undefined reference to `__memset_chk'
See also: https://bugs.gentoo.org/881131
--- a/filesystems/crc32c.c
+++ b/filesystems/crc32c.c
@@ -22,25 +22,24 @@
static uint32_t crc32c_table [256];
-static void
-init_crc32c_table (void)
+uint32_t reflect (uint32_t ref, int len)
{
- auto uint32_t reflect (uint32_t ref, int len);
- uint32_t reflect (uint32_t ref, int len)
- {
- uint32_t result = 0;
- int i;
+ uint32_t result = 0;
+ int i;
- for (i = 1; i <= len; i++)
- {
- if (ref & 1)
- result |= 1 << (len - i);
- ref >>= 1;
- }
-
- return result;
+ for (i = 1; i <= len; i++)
+ {
+ if (ref & 1)
+ result |= 1 << (len - i);
+ ref >>= 1;
}
+ return result;
+}
+
+static void
+init_crc32c_table (void)
+{
static int crc32c_table_inited;
if(crc32c_table_inited)
return;
--- a/libeg/nanojpeg.c
+++ b/libeg/nanojpeg.c
@@ -112,6 +112,8 @@
#ifndef _NANOJPEG_H
#define _NANOJPEG_H
+#undef _FORTIFY_SOURCE
+
// Modified: Map libc-style free() and malloc() to their EFI equivalents....
#define free MyFreePool
#define malloc AllocatePool