foc: fix build errors with gcc 12

Fixes #4833
This commit is contained in:
Christian Prochaska 2023-04-26 02:17:04 +02:00 committed by Christian Helmuth
parent b29db99f1c
commit 920e240f67
7 changed files with 122 additions and 8 deletions

View File

@ -11,10 +11,11 @@ diff --git a/l4/pkg/l4re-core/l4sys/include/kdebug.h b/l4/pkg/l4re-core/l4sys/in
index cfb17464..64ee9900 100644
--- a/l4/pkg/l4re-core/l4sys/include/kdebug.h
+++ b/l4/pkg/l4re-core/l4sys/include/kdebug.h
@@ -133,6 +133,13 @@ __kdebug_op_1(unsigned op, l4_mword_t val) L4_NOTHROW
@@ -133,6 +133,14 @@ __kdebug_op_1(unsigned op, l4_mword_t val) L4_NOTHROW
return res;
}
+__attribute__((optimize("no-tree-loop-distribute-patterns")))
+L4_INLINE unsigned __kdebug_strlen(char const * s)
+{
+ unsigned r = 0;

View File

@ -1,4 +1,4 @@
L4: enable GCC 10
L4: enable GCC 12
diff --git a/l4/mk/Makeconf b/l4/mk/Makeconf
index eb59b51..a7b5955 100644
@ -9,7 +9,7 @@ index eb59b51..a7b5955 100644
L4_STACK_SIZE ?= $(if $(L4_STACK_SIZE_MAIN_THREAD),$(L4_STACK_SIZE_MAIN_THREAD),0x8000)
-CC_WHITELIST-gcc := 4.7 4.8 4.9 5 6 7 8 9
+CC_WHITELIST-gcc := 4.7 4.8 4.9 5 6 7 8 9 10
+CC_WHITELIST-gcc := 4.7 4.8 4.9 5 6 7 8 9 10 11 12
CC_WHITELIST-clang := 3.5 3.6 3.7 3.8 3.9
# This is quite bad: There is no other chance to disable the page-alignedment

View File

@ -1,4 +1,4 @@
FOC: enable GCC 10
FOC: enable GCC 12
diff --git a/src/Makeconf b/src/Makeconf
index de5b656..7660daa 100644
@ -9,7 +9,7 @@ index de5b656..7660daa 100644
-CC_WHITELIST-gcc := 4.7 4.8 4.9 5 6 7 8 9
+CC_WHITELIST-gcc := 4.7 4.8 4.9 5 6 7 8 9 10
+CC_WHITELIST-gcc := 4.7 4.8 4.9 5 6 7 8 9 10 11 12
CC_WHITELIST-clang := 3.6 3.7 3.8 3.9 4.0 5.0 6.0 7.0 8.0 9.0
CC_WHITELIST := $(CC_WHITELIST-$(CC_TYPE))

View File

@ -0,0 +1,94 @@
From 8d55cdc73b07dd56ae59a42bcc11cde82614334a Mon Sep 17 00:00:00 2001
From: Frank Mehnert <frank.mehnert@kernkonzept.com>
Date: Mon, 10 May 2021 00:00:00 +0000
Subject: [PATCH] ia32: add implementation for '__udivmoddi4()'
This function is implicitly required by code in jdb.cpp performing a
64-bit integer division on 32-bit systems. This function is required
by code generated with gcc-11. Code generated with older versions of
gcc was satisfied with the existing implementation for '__udivdi3'.
Also fix cosmetic issues in gcc_lib.c and add Doxygen documentation.
Change-Id: If5b44a9e98429c4fc3eacdd5af8bdaf33c9c2a8f
---
src/lib/libk/gcc_lib.c | 49 +++++++++++++++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 8 deletions(-)
diff --git a/src/lib/libk/gcc_lib.c b/src/lib/libk/gcc_lib.c
index e5626145..b121cb63 100644
--- a/src/lib/libk/gcc_lib.c
+++ b/src/lib/libk/gcc_lib.c
@@ -1,6 +1,8 @@
unsigned long long __umoddi3(unsigned long long, unsigned long long);
unsigned long long __udivdi3(unsigned long long, unsigned long long);
+unsigned long long __udivmoddi4(unsigned long long, unsigned long long,
+ unsigned long long *);
struct llmoddiv_t
{
@@ -31,15 +33,15 @@ static struct llmoddiv_t llmoddiv(unsigned long long div, unsigned long long s)
while (1)
{
if (div >= s)
- {
- div -= s;
- i |= tmp;
- }
+ {
+ div -= s;
+ i |= tmp;
+ }
if (div == 0)
- break;
+ break;
tmp >>= 1;
if (!tmp)
- break;
+ break;
s >>= 1;
}
@@ -47,8 +49,39 @@ static struct llmoddiv_t llmoddiv(unsigned long long div, unsigned long long s)
}
+/**
+ * 64-bit unsigned modulo for 32-bit machines.
+ *
+ * \param div Dividend.
+ * \param s Divisor.
+ * \return div / s.
+ */
unsigned long long __umoddi3(unsigned long long div, unsigned long long s)
-{ return llmoddiv(div,s).mod; }
+{ return llmoddiv(div, s).mod; }
+/**
+ * 64-bit unsigned division for 32-bit machines.
+ *
+ * \param div Dividend.
+ * \param s Divisor.
+ * \return div / s.
+ */
unsigned long long __udivdi3(unsigned long long div, unsigned long long s)
-{ return llmoddiv(div,s).div; }
+{ return llmoddiv(div, s).div; }
+
+/**
+ * 64-bit unsigned division + modulo for 32-bit machines.
+ *
+ * \param n Dividend.
+ * \param d Divisor.
+ * \param[out] r Pointer to the result holding div % s.
+ * \return div / s.
+ */
+unsigned long long __udivmoddi4(unsigned long long div, unsigned long long s,
+ unsigned long long *r)
+{
+ struct llmoddiv_t md = llmoddiv(div, s);
+ if (r)
+ *r = md.mod;
+ return md.div;
+}

View File

@ -0,0 +1,17 @@
Fix reboot loop when built with GCC 12.
diff --git a/src/Makeconf b/src/Makeconf
index bb7ad16c..2fe11226 100644
--- a/src/Makeconf
+++ b/src/Makeconf
@@ -167,8 +167,8 @@ NOOPT_SHARED_FLAGS += $(NOOPT_SHARED_FLAGS-$(CC_TYPE))
# Standard compile flags
ASFLAGS += $(SHARED_FLAGS) -DASSEMBLER
ASFLAGS-clang += -no-integrated-as
-CFLAGS += $(SHARED_FLAGS) -Wbad-function-cast -Wstrict-prototypes
-CXXFLAGS += $(SHARED_FLAGS) -fno-rtti -fno-exceptions
+CFLAGS += $(SHARED_FLAGS) -Wbad-function-cast -Wstrict-prototypes -fno-tree-loop-distribute-patterns
+CXXFLAGS += $(SHARED_FLAGS) -fno-rtti -fno-exceptions -fno-tree-loop-distribute-patterns
OPT_CFLAGS += $(OPT_SHARED_FLAGS)
OPT_CXXFLAGS += $(OPT_SHARED_FLAGS)
NOOPT_CFLAGS += $(NOOPT_SHARED_FLAGS)

View File

@ -1 +1 @@
abe2de76835f33297ca4e4ac687e69bc04f83dc5
00cfb7994fee75bb5aae010a3d2c16a7ffd29ec9

View File

@ -37,11 +37,13 @@ PATCH_OPT(patches/0014-Always-enable-user-mode-access-for-performance-monit.patc
PATCH_OPT(patches/0015-VMX-disable-event-injection-if-requested-by-VMM.patch) := -p3 -d${DIR(foc)}
PATCH_OPT(patches/0016-svm-provide-cr0-to-guest-if-np-enabled.patch) := -p3 -d${DIR(foc)}
PATCH_OPT(patches/0017-svm-avoid-forceful-exit-on-task-switch.patch) := -p3 -d${DIR(foc)}
PATCH_OPT(patches/0018-L4-enable-gcc_10.patch) := -p2 -d${DIR(mk)}
PATCH_OPT(patches/0018-L4-enable-gcc_12.patch) := -p2 -d${DIR(mk)}
PATCH_OPT(patches/0019-Bootstrap-do-not-depend-on-any-libstdcxx-feature.patch) := -p1 -d${DIR(bootstrap)}
PATCH_OPT(patches/0020-Bootstrap-fix-amd64-build-with-binutils-2_32.patch) := -p1 -d${DIR(bootstrap)}
PATCH_OPT(patches/0021-FOC-enable-gcc_10.patch) := -p1 -d${DIR(foc)}
PATCH_OPT(patches/0021-FOC-enable-gcc_12.patch) := -p1 -d${DIR(foc)}
PATCH_OPT(patches/0022-FOC-amd64-split-_syscall_entry-into-code-and-data.patch) := -p1 -d${DIR(foc)}
PATCH_OPT(patches/0023-FOC-arm-link-bootstrap-as-et_rel.patch) := -p1 -d${DIR(foc)}
PATCH_OPT(patches/0024-FOC-ia32-add-implementation-for-__udivmoddi4.patch) := -p1 -d${DIR(foc)}
PATCH_OPT(patches/0025-FOC-no-tree-loop-distribute-patterns.patch) := -p1 -d${DIR(foc)}
$(call check_tool,gawk)