compiler, libgo: don't pad sparc64-linux epollevent

Change the compiler to not add zero padding because of zero-sized
fields named "_", since those can't be referenced anyhow.

Change the sparc-linux64 epollevent struct to name the alignment
field "_", to avoid zero padding.

Fixes https://gcc.gnu.org/PR103847

Change-Id: I591b3b798a24141e3d0e1ccf6ff0f7f0570af9d4
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/374914
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Ian Lance Taylor 2021-12-29 15:08:32 -08:00
Родитель 3e9f4ee166
Коммит d3be41f0a1
2 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -6454,9 +6454,18 @@ get_backend_struct_fields(Gogo* gogo, Struct_type* type, bool use_placeholder,
? p->type()->get_backend_placeholder(gogo)
: p->type()->get_backend(gogo));
(*bfields)[i].location = p->location();
lastsize = gogo->backend()->type_size((*bfields)[i].btype);
if (lastsize != 0)
saw_nonzero = true;
int64_t size = gogo->backend()->type_size((*bfields)[i].btype);
if (size != 0)
saw_nonzero = true;
if (size > 0 || !Gogo::is_sink_name(p->field_name()))
lastsize = size;
else
{
// There is an unreferenceable field of zero size. This
// doesn't affect whether we may need zero padding, so leave
// lastsize unchanged.
}
}
go_assert(i == fields->size());
if (saw_nonzero && lastsize == 0 && !type->is_results_struct())

Просмотреть файл

@ -98,7 +98,7 @@ if grep '^const _epoll_data_offset ' ${OUT} >/dev/null 2>&1; then
echo 'type epollevent struct { events uint32; data [8]byte }' >> ${OUT}
elif test "$val" = "8"; then
if test "$GOARCH" = "sparc64" -a "$GOOS" = "linux"; then
echo 'type epollevent struct { events uint32; pad [4]byte; data [8]byte; _align [0]int64 }' >> ${OUT}
echo 'type epollevent struct { events uint32; pad [4]byte; data [8]byte; _ [0]int64 }' >> ${OUT}
else
echo 'type epollevent struct { events uint32; pad [4]byte; data [8]byte }' >> ${OUT}
fi