From 44ef03008c75059368245eb3dcd6054bed3f7643 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 1 Oct 2018 20:17:11 +0000 Subject: [PATCH] libgo: support x32 as GOARCH=amd64p32 GOOS=linux This is enough to let libgo build when configured using --with-multilib-list=m64,m32,mx32. I don't have an x32-enabled kernel so I haven't tested whether it executes correctly. For https://gcc.gnu.org/PR87470 Reviewed-on: https://go-review.googlesource.com/138817 From-SVN: r264772 --- gcc/go/gofrontend/MERGE | 2 +- libgo/configure | 12 ++++++++++++ libgo/configure.ac | 9 +++++++-- libgo/go/hash/crc32/crc32_amd64p32.go | 2 ++ .../syscall/unix/getrandom_linux_amd64p32.go | 9 +++++++++ libgo/go/runtime/lfstack_32bit.go | 2 +- libgo/goarch.sh | 7 ++++++- 7 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 69dd8b746b7..6ad214689fb 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -013a9e68c9a31f888733d46182d19f9e5d956f27 +2f56d51c6b3104242613c74b02fa6c63a2fe16c5 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/configure b/libgo/configure index 7166f94016b..f7996e115eb 100755 --- a/libgo/configure +++ b/libgo/configure @@ -13685,7 +13685,19 @@ _ACEOF if ac_fn_c_try_compile "$LINENO"; then : GOARCH=386 else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef __ILP32__ +#error x32 +#endif +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : GOARCH=amd64 +else + GOARCH=amd64p32 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; diff --git a/libgo/configure.ac b/libgo/configure.ac index 1c192752ab2..20ce205f2f4 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -252,8 +252,13 @@ changequote([,])dnl #ifdef __x86_64__ #error 64-bit #endif], -[GOARCH=386], -[GOARCH=amd64]) + [GOARCH=386], + AC_COMPILE_IFELSE([ +#ifdef __ILP32__ +#error x32 +#endif], + [GOARCH=amd64], + [GOARCH=amd64p32])) ;; ia64-*-*) GOARCH=ia64 diff --git a/libgo/go/hash/crc32/crc32_amd64p32.go b/libgo/go/hash/crc32/crc32_amd64p32.go index 1ec44cb496a..f61b801b418 100644 --- a/libgo/go/hash/crc32/crc32_amd64p32.go +++ b/libgo/go/hash/crc32/crc32_amd64p32.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build ignore + package crc32 import "internal/cpu" diff --git a/libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go b/libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go new file mode 100644 index 00000000000..911b6089ff3 --- /dev/null +++ b/libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go @@ -0,0 +1,9 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +// Linux getrandom system call number. +// See GetRandom in getrandom_linux.go. +const randomTrap uintptr = 0x40000000 + 318 diff --git a/libgo/go/runtime/lfstack_32bit.go b/libgo/go/runtime/lfstack_32bit.go index 1288c1a2aaa..f50c50895b4 100644 --- a/libgo/go/runtime/lfstack_32bit.go +++ b/libgo/go/runtime/lfstack_32bit.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build 386 arm nacl armbe m68k mips mipsle mips64p32 mips64p32le nios2 ppc s390 sh shbe sparc +// +build 386 amd64p32 arm nacl armbe m68k mips mipsle mips64p32 mips64p32le nios2 ppc s390 sh shbe sparc package runtime diff --git a/libgo/goarch.sh b/libgo/goarch.sh index f5c0a34b1da..f7aef9d7dde 100755 --- a/libgo/goarch.sh +++ b/libgo/goarch.sh @@ -57,10 +57,15 @@ case $goarch in defaultphyspagesize=8192 pcquantum=4 ;; - amd64 | amd64p32) + amd64) family=AMD64 hugepagesize="1 << 21" ;; + amd64p32) + family=AMD64 + hugepagesize="1 << 21" + ptrsize=4 + ;; arm | armbe) family=ARM cachelinesize=32 -- 2.30.2