[coreboot-gerrit] Change in coreboot[master]: buildgcc: Add patch to work around Musl libc issue

Nico Huber (Code Review) gerrit at coreboot.org
Fri Dec 8 20:20:46 CET 2017


Nico Huber has uploaded this change for review. ( https://review.coreboot.org/22786


Change subject: buildgcc: Add patch to work around Musl libc issue
......................................................................

buildgcc: Add patch to work around Musl libc issue

GCC includes `sched.h` after poisoning calloc(). This results in a
build failure with Musl libc. We work around the issue by including
`sched.h` earlier and throw around some void pointers so we only
have to do it in one place.

Change-Id: I1d5462eb9a448147a95dd4ec50361b3f5a28910c
Signed-off-by: Nico Huber <nico.h at gmx.de>
---
A util/crossgcc/patches/gcc-6.3.0_ada-musl_workaround.patch
1 file changed, 107 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/22786/1

diff --git a/util/crossgcc/patches/gcc-6.3.0_ada-musl_workaround.patch b/util/crossgcc/patches/gcc-6.3.0_ada-musl_workaround.patch
new file mode 100644
index 0000000..a500343
--- /dev/null
+++ b/util/crossgcc/patches/gcc-6.3.0_ada-musl_workaround.patch
@@ -0,0 +1,107 @@
+Only in gcc-6.3.0: .unpack_success
+--- gcc-6.3.0.bak/gcc/ada/adaint.c
++++ gcc-6.3.0/gcc/ada/adaint.c
+@@ -103,6 +103,15 @@
+ #define xmalloc(S) malloc (S)
+ #define xrealloc(V,S) realloc (V,S)
+ #else
++#if !defined(__ANDROID__) && defined(__linux__)
++#ifdef __cplusplus
++extern "C" {
++#endif
++#include <sched.h>
++#ifdef __cplusplus
++}
++#endif
++#endif
+ #include "config.h"
+ #include "system.h"
+ #include "version.h"
+@@ -3096,7 +3105,7 @@
+ 
+ /* Dynamic cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count)
+ {
+   return CPU_ALLOC (count);
+@@ -3109,19 +3118,19 @@
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   CPU_FREE (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count, cpu_set_t *set)
++__gnat_cpu_zero (size_t count, void *set)
+ {
+   CPU_ZERO_S (count, set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+@@ -3132,10 +3141,10 @@
+ 
+ /* Static cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
+ {
+-  return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
++  return xmalloc (sizeof (cpu_set_t));
+ }
+ 
+ size_t
+@@ -3145,19 +3154,19 @@
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   free (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   CPU_ZERO (set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+--- gcc-6.3.0.bak/gcc/ada/adaint.h
++++ gcc-6.3.0/gcc/ada/adaint.h
+@@ -287,13 +287,11 @@
+ 
+ /* Routines for interface to required CPU set primitives */
+ 
+-#include <sched.h>
+-
+-extern cpu_set_t *__gnat_cpu_alloc                 (size_t);
++extern void *__gnat_cpu_alloc                 (size_t);
+ extern size_t __gnat_cpu_alloc_size                (size_t);
+-extern void   __gnat_cpu_free                  (cpu_set_t *);
+-extern void   __gnat_cpu_zero                      (size_t, cpu_set_t *);
+-extern void   __gnat_cpu_set                       (int, size_t, cpu_set_t *);
++extern void   __gnat_cpu_free                  (void *);
++extern void   __gnat_cpu_zero                      (size_t, void *);
++extern void   __gnat_cpu_set                       (int, size_t, void *);
+ #endif
+ 
+ #if defined (_WIN32)

-- 
To view, visit https://review.coreboot.org/22786
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d5462eb9a448147a95dd4ec50361b3f5a28910c
Gerrit-Change-Number: 22786
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h at gmx.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171208/cef44de5/attachment.html>


More information about the coreboot-gerrit mailing list