Bug#853223: gcc-6: Please update gccgo-m68k.diff with additional changes
Source: gcc-6
Version: 6.3.0-5
Severity: normal
Tags: patch
User: debian-68k@lists.debian.org
Usertags: m68k
Forwarded: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79281
Hi!
While the first gccgo patch for m68k (gccgo-m68k.diff) already made the Go
compiler partially work, there is still an additional change required which
is enforcing alignment for the structs "Lock" and "Note" in libgo/runtime/
runtime.h:
--- a/src/libgo/runtime/runtime.h.orig 2016-02-12 23:10:09.000000000 +0100
+++ b/src/libgo/runtime/runtime.h 2017-01-30 18:30:14.188171787 +0100
@@ -154,14 +154,14 @@
// Futex-based impl treats it as uint32 key,
// while sema-based impl as M* waitm.
// Used to be a union, but unions break precise GC.
- uintptr key;
+ uintptr key __attribute__((aligned(4)));
};
struct Note
{
// Futex-based impl treats it as uint32 key,
// while sema-based impl as M* waitm.
// Used to be a union, but unions break precise GC.
- uintptr key;
+ uintptr key __attribute__((aligned(4)));
};
struct String
{
This is a change proposed by upstream [1] and verified by me to fix an issue with
goroutines causing crashes on m68k [2]. Since this part is implemented differently
in gcc-7, we need to pick a different fix there but I haven't received any proposal
from upstream for that yet.
Attaching the updated gccgo patch for m68k with the changes proposed by upstream.
Thanks,
Adrian
> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79281#c4
> [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79281
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer - glaubitz@debian.org
`. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
--- a/src/gcc/go/gofrontend/types.cc.orig 2016-02-03 07:54:41.000000000 +0100
+++ b/src/gcc/go/gofrontend/types.cc 2017-01-20 17:54:46.460409688 +0100
@@ -2175,11 +2175,25 @@
is_common = true;
}
+ // The current garbage collector requires that the GC symbol be
+ // aligned to at least a four byte boundary. See the use of PRECISE
+ // and LOOP in libgo/runtime/mgc0.c.
+ int64_t align;
+ if (!sym_init->type()->backend_type_align(gogo, &align))
+ go_assert(saw_errors());
+ if (align < 4)
+ align = 4;
+ else
+ {
+ // Use default alignment.
+ align = 0;
+ }
+
// Since we are building the GC symbol in this package, we must create the
// variable before converting the initializer to its backend representation
// because the initializer may refer to the GC symbol for this type.
this->gc_symbol_var_ =
- gogo->backend()->implicit_variable(sym_name, sym_btype, false, true, is_common, 0);
+ gogo->backend()->implicit_variable(sym_name, sym_btype, false, true, is_common, align);
if (phash != NULL)
*phash = this->gc_symbol_var_;
--- a/src/libgo/runtime/go-unsafe-pointer.c.orig 2015-10-29 19:14:50.000000000 +0100
+++ b/src/libgo/runtime/go-unsafe-pointer.c 2017-01-20 17:57:12.227392567 +0100
@@ -36,7 +36,8 @@
sizeof REFLECTION - 1
};
-const uintptr unsafe_Pointer_gc[] = {sizeof(void*), GC_APTR, 0, GC_END};
+const uintptr unsafe_Pointer_gc[] __attribute__((aligned(4))) =
+ {sizeof(void*), GC_APTR, 0, GC_END};
const struct __go_type_descriptor unsafe_Pointer =
{
--- a/src/libgo/runtime/parfor.c.orig 2015-10-31 01:59:47.000000000 +0100
+++ b/src/libgo/runtime/parfor.c 2017-01-20 17:58:47.154729980 +0100
@@ -10,7 +10,7 @@
struct ParForThread
{
// the thread's iteration space [32lsb, 32msb)
- uint64 pos;
+ uint64 pos __attribute__((aligned(8)));
// stats
uint64 nsteal;
uint64 nstealcnt;
--- a/src/libgo/runtime/runtime.h.orig 2016-02-12 23:10:09.000000000 +0100
+++ b/src/libgo/runtime/runtime.h 2017-01-21 00:58:07.386595035 +0100
@@ -431,7 +431,7 @@
// otherwise parfor may return while other threads are still working
ParForThread *thr; // array of thread descriptors
// stats
- uint64 nsteal;
+ uint64 nsteal __attribute__((aligned(8))); // force alignment for m68k
uint64 nstealcnt;
uint64 nprocyield;
uint64 nosyield;
--- a/src/libgo/runtime/runtime.h.orig 2016-02-12 23:10:09.000000000 +0100
+++ b/src/libgo/runtime/runtime.h 2017-01-30 18:30:14.188171787 +0100
@@ -154,14 +154,14 @@
// Futex-based impl treats it as uint32 key,
// while sema-based impl as M* waitm.
// Used to be a union, but unions break precise GC.
- uintptr key;
+ uintptr key __attribute__((aligned(4)));
};
struct Note
{
// Futex-based impl treats it as uint32 key,
// while sema-based impl as M* waitm.
// Used to be a union, but unions break precise GC.
- uintptr key;
+ uintptr key __attribute__((aligned(4)));
};
struct String
{
Reply to: