From b16084d244418d5421505f09851b5adf5abc35ec Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 25 Sep 2018 14:16:32 +0000 Subject: cmd/go: pass down testing gccgo in TestScript This permits TestScript to work when gccgo is not installed. Previous testing was using a previously installed gccgo, not the newly built one. This revealed that the testing of whether an internal package is permitted was incorrect for standard library packages, since the uninstalled gccgo can see internal packages in the uninstalled libgo. Fix the internal package tests. This permitted removing a couple of gccgo-specific changes in the testsuite. Reviewed-on: https://go-review.googlesource.com/137255 From-SVN: r264570 --- libgo/go/cmd/go/internal/load/pkg.go | 10 ++++++++-- libgo/go/cmd/go/script_test.go | 1 + libgo/go/cmd/go/testdata/script/mod_internal.txt | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'libgo/go') diff --git a/libgo/go/cmd/go/internal/load/pkg.go b/libgo/go/cmd/go/internal/load/pkg.go index 0579fd5..b6c9037 100644 --- a/libgo/go/cmd/go/internal/load/pkg.go +++ b/libgo/go/cmd/go/internal/load/pkg.go @@ -953,8 +953,14 @@ func disallowInternal(srcDir string, importer *Package, importerPath string, p * } // We can't check standard packages with gccgo. - if cfg.BuildContext.Compiler == "gccgo" && p.Standard { - return p + if cfg.BuildContext.Compiler == "gccgo" { + if importer == nil { + if p.Standard { + return p + } + } else if importer.Standard || strings.HasPrefix(importerPath, "cmd/") { + return p + } } // The stack includes p.ImportPath. diff --git a/libgo/go/cmd/go/script_test.go b/libgo/go/cmd/go/script_test.go index 02cb17b..9e958e0 100644 --- a/libgo/go/cmd/go/script_test.go +++ b/libgo/go/cmd/go/script_test.go @@ -78,6 +78,7 @@ var extraEnvKeys = []string{ // For gccgo testing. "GO_TESTING_GOTOOLS", + "GCCGO", "GCCGOTOOLDIR", } diff --git a/libgo/go/cmd/go/testdata/script/mod_internal.txt b/libgo/go/cmd/go/testdata/script/mod_internal.txt index 84e77c6..72706fd 100644 --- a/libgo/go/cmd/go/testdata/script/mod_internal.txt +++ b/libgo/go/cmd/go/testdata/script/mod_internal.txt @@ -16,11 +16,11 @@ stderr 'use of internal package golang.org/x/.* not allowed' # Internal packages in the standard library should not leak into modules. ! go build ./fromstd -[!gccgo] stderr 'use of internal package internal/testenv not allowed' +stderr 'use of internal package internal/testenv not allowed' # Packages found via standard-library vendoring should not leak. ! go build ./fromstdvendor -[!gccgo] stderr 'use of vendored package golang_org/x/net/http/httpguts not allowed' +stderr 'use of vendored package golang_org/x/net/http/httpguts not allowed' env GO111MODULE=off ! go build ./fromstdvendor -- cgit v1.1 From f5ec13f15ddaa6dc61b81d5c14cd8b30df896b40 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 25 Sep 2018 14:31:57 +0000 Subject: internal/bytealg, internal/cpu, internal/poll: portability fixes In internal/bytealg correct a +build tag to never build indexbyte_generic.go for the gofrontend, where we always use indexbyte_native.go. For internal/cpu let the Makefile define CacheLineSize using goarch.sh, rather than trying to enumerate all the possibilities in cpu_ARCH.go files. In internal/poll call the C fcntl function rather than using SYS_FCNTL. Change mksysinfo.sh to ensure that F_GETPIPE_SZ is always defined, and check that in internal/poll. Reviewed-on: https://go-review.googlesource.com/137256 From-SVN: r264572 --- libgo/go/internal/bytealg/indexbyte_generic.go | 2 +- libgo/go/internal/cpu/cpu_arm.go | 7 ------- libgo/go/internal/cpu/cpu_arm64.go | 2 -- libgo/go/internal/cpu/cpu_mips.go | 7 ------- libgo/go/internal/cpu/cpu_mips64.go | 7 ------- libgo/go/internal/cpu/cpu_mips64le.go | 7 ------- libgo/go/internal/cpu/cpu_mipsle.go | 7 ------- libgo/go/internal/cpu/cpu_ppc64x.go | 2 -- libgo/go/internal/cpu/cpu_s390x.go | 2 -- libgo/go/internal/cpu/cpu_wasm.go | 7 ------- libgo/go/internal/cpu/cpu_x86.go | 2 -- libgo/go/internal/poll/splice_linux.go | 9 +++++++-- 12 files changed, 8 insertions(+), 53 deletions(-) delete mode 100644 libgo/go/internal/cpu/cpu_arm.go delete mode 100644 libgo/go/internal/cpu/cpu_mips.go delete mode 100644 libgo/go/internal/cpu/cpu_mips64.go delete mode 100644 libgo/go/internal/cpu/cpu_mips64le.go delete mode 100644 libgo/go/internal/cpu/cpu_mipsle.go delete mode 100644 libgo/go/internal/cpu/cpu_wasm.go (limited to 'libgo/go') diff --git a/libgo/go/internal/bytealg/indexbyte_generic.go b/libgo/go/internal/bytealg/indexbyte_generic.go index 890cd42..6e59fd1 100644 --- a/libgo/go/internal/bytealg/indexbyte_generic.go +++ b/libgo/go/internal/bytealg/indexbyte_generic.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. -// +ignore_for_gccgo +// +build ignore_for_gccgo // +build !386,!amd64,!amd64p32,!s390x,!arm,!arm64,!ppc64,!ppc64le,!mips,!mipsle,!mips64,!mips64le,!wasm package bytealg diff --git a/libgo/go/internal/cpu/cpu_arm.go b/libgo/go/internal/cpu/cpu_arm.go deleted file mode 100644 index 078a6c3..0000000 --- a/libgo/go/internal/cpu/cpu_arm.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 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 cpu - -const CacheLineSize = 32 diff --git a/libgo/go/internal/cpu/cpu_arm64.go b/libgo/go/internal/cpu/cpu_arm64.go index 009f2a2..c4d6b81 100644 --- a/libgo/go/internal/cpu/cpu_arm64.go +++ b/libgo/go/internal/cpu/cpu_arm64.go @@ -4,8 +4,6 @@ package cpu -const CacheLineSize = 64 - // arm64 doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2. // These are initialized by archauxv in runtime/os_linux_arm64.go. // These should not be changed after they are initialized. diff --git a/libgo/go/internal/cpu/cpu_mips.go b/libgo/go/internal/cpu/cpu_mips.go deleted file mode 100644 index 078a6c3..0000000 --- a/libgo/go/internal/cpu/cpu_mips.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 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 cpu - -const CacheLineSize = 32 diff --git a/libgo/go/internal/cpu/cpu_mips64.go b/libgo/go/internal/cpu/cpu_mips64.go deleted file mode 100644 index 078a6c3..0000000 --- a/libgo/go/internal/cpu/cpu_mips64.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 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 cpu - -const CacheLineSize = 32 diff --git a/libgo/go/internal/cpu/cpu_mips64le.go b/libgo/go/internal/cpu/cpu_mips64le.go deleted file mode 100644 index 078a6c3..0000000 --- a/libgo/go/internal/cpu/cpu_mips64le.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 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 cpu - -const CacheLineSize = 32 diff --git a/libgo/go/internal/cpu/cpu_mipsle.go b/libgo/go/internal/cpu/cpu_mipsle.go deleted file mode 100644 index 078a6c3..0000000 --- a/libgo/go/internal/cpu/cpu_mipsle.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 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 cpu - -const CacheLineSize = 32 diff --git a/libgo/go/internal/cpu/cpu_ppc64x.go b/libgo/go/internal/cpu/cpu_ppc64x.go index d3f02ef..5c4bed7 100644 --- a/libgo/go/internal/cpu/cpu_ppc64x.go +++ b/libgo/go/internal/cpu/cpu_ppc64x.go @@ -6,8 +6,6 @@ package cpu -const CacheLineSize = 128 - // ppc64x doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2. // These are initialized by archauxv in runtime/os_linux_ppc64x.go. // These should not be changed after they are initialized. diff --git a/libgo/go/internal/cpu/cpu_s390x.go b/libgo/go/internal/cpu/cpu_s390x.go index 9dedb4c..43fa4ad 100644 --- a/libgo/go/internal/cpu/cpu_s390x.go +++ b/libgo/go/internal/cpu/cpu_s390x.go @@ -4,8 +4,6 @@ package cpu -const CacheLineSize = 256 - // bitIsSet reports whether the bit at index is set. The bit index // is in big endian order, so bit index 0 is the leftmost bit. func bitIsSet(bits []uint64, index uint) bool { diff --git a/libgo/go/internal/cpu/cpu_wasm.go b/libgo/go/internal/cpu/cpu_wasm.go deleted file mode 100644 index 1107a7a..0000000 --- a/libgo/go/internal/cpu/cpu_wasm.go +++ /dev/null @@ -1,7 +0,0 @@ -// 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 cpu - -const CacheLineSize = 64 diff --git a/libgo/go/internal/cpu/cpu_x86.go b/libgo/go/internal/cpu/cpu_x86.go index 7d9d3aa..5f15965 100644 --- a/libgo/go/internal/cpu/cpu_x86.go +++ b/libgo/go/internal/cpu/cpu_x86.go @@ -6,8 +6,6 @@ package cpu -const CacheLineSize = 64 - // cpuid is implemented in cpu_x86.s. func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) diff --git a/libgo/go/internal/poll/splice_linux.go b/libgo/go/internal/poll/splice_linux.go index aa237e5..4265b42 100644 --- a/libgo/go/internal/poll/splice_linux.go +++ b/libgo/go/internal/poll/splice_linux.go @@ -162,10 +162,15 @@ func newTempPipe() (prfd, pwfd int, sc string, err error) { defer atomic.StorePointer(&disableSplice, unsafe.Pointer(p)) // F_GETPIPE_SZ was added in 2.6.35, which does not have the -EAGAIN bug. - if _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fds[0]), syscall.F_GETPIPE_SZ, 0); errno != 0 { + if syscall.F_GETPIPE_SZ == 0 { *p = true destroyTempPipe(fds[0], fds[1]) - return -1, -1, "fcntl", errno + return -1, -1, "fcntl", syscall.EINVAL + } + if _, errno := fcntl(uintptr(fds[0]), syscall.F_GETPIPE_SZ, 0); errno != 0 { + *p = true + destroyTempPipe(fds[0], fds[1]) + return -1, -1, "fcntl", syscall.Errno(errno) } } -- cgit v1.1 From 201054a7f042f5f175605ca64accb2a812b27bfe Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 26 Sep 2018 03:29:07 +0000 Subject: runtime, os: fix the build on Solaris Reviewed-on: https://go-review.googlesource.com/137535 From-SVN: r264593 --- libgo/go/os/executable_solaris.go | 10 +++++--- libgo/go/runtime/os3_solaris.go | 54 +++++++++++++++++++++++++++++++++++++++ libgo/go/runtime/stubs3.go | 1 - 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 libgo/go/runtime/os3_solaris.go (limited to 'libgo/go') diff --git a/libgo/go/os/executable_solaris.go b/libgo/go/os/executable_solaris.go index b145980..a2ad62a 100644 --- a/libgo/go/os/executable_solaris.go +++ b/libgo/go/os/executable_solaris.go @@ -4,14 +4,18 @@ package os -import "syscall" +import ( + "syscall" + _ "unsafe" // for go:linkname +) -var executablePath string // set by sysauxv in ../runtime/os3_solaris.go +// solarisExecutablePath is defined in the runtime package. +func solarisExecutablePath() string var initCwd, initCwdErr = Getwd() func executable() (string, error) { - path := executablePath + path := solarisExecutablePath() if len(path) == 0 { path, err := syscall.Getexecname() if err != nil { diff --git a/libgo/go/runtime/os3_solaris.go b/libgo/go/runtime/os3_solaris.go new file mode 100644 index 0000000..c19f797 --- /dev/null +++ b/libgo/go/runtime/os3_solaris.go @@ -0,0 +1,54 @@ +// Copyright 2011 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 runtime + +import ( + "runtime/internal/sys" + "unsafe" +) + +var executablePath string + +func sysargs(argc int32, argv **byte) { + n := argc + 1 + + // skip over argv, envp to get to auxv + for argv_index(argv, n) != nil { + n++ + } + + // skip NULL separator + n++ + + // now argv+n is auxv + auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize)) + sysauxv(auxv[:]) +} + +const ( + _AT_NULL = 0 // Terminates the vector + _AT_PAGESZ = 6 // Page size in bytes + _AT_SUN_EXECNAME = 2014 // exec() path name +) + +func sysauxv(auxv []uintptr) { + for i := 0; auxv[i] != _AT_NULL; i += 2 { + tag, val := auxv[i], auxv[i+1] + switch tag { + case _AT_PAGESZ: + physPageSize = val + case _AT_SUN_EXECNAME: + executablePath = gostringnocopy((*byte)(unsafe.Pointer(val))) + } + } +} + +//go:linkname solarisExecutablePath os.solarisExecutablePath + +// solarisExecutablePath is called from the os package to fetch the +// saved executable path. +func solarisExecutablePath() string { + return executablePath +} diff --git a/libgo/go/runtime/stubs3.go b/libgo/go/runtime/stubs3.go index 5c0786e..1af693b 100644 --- a/libgo/go/runtime/stubs3.go +++ b/libgo/go/runtime/stubs3.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. // +build !plan9 -// +build !solaris // +build !windows // +build !nacl // +build !freebsd -- cgit v1.1 From dd554b787d0280566e891dba9e19dd718e68d42a Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 26 Sep 2018 15:17:30 +0000 Subject: syscall: don't assume we have a GETEUID system call On Alpha GNU/Linux there is no geteuid system call, there is only getresuid. The raw geteuid system call is only used for testing, so just skip the test if it's not available. Reviewed-on: https://go-review.googlesource.com/137655 From-SVN: r264647 --- libgo/go/syscall/syscall_linux_test.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libgo/go') diff --git a/libgo/go/syscall/syscall_linux_test.go b/libgo/go/syscall/syscall_linux_test.go index 99de6eb..77a822d 100644 --- a/libgo/go/syscall/syscall_linux_test.go +++ b/libgo/go/syscall/syscall_linux_test.go @@ -302,6 +302,10 @@ func TestSyscallNoError(t *testing.T) { t.Skip("skipping root only test") } + if syscall.Sys_GETEUID == 0 { + t.Skip("skipping because there is no geteuid system call") + } + // Copy the test binary to a location that a non-root user can read/execute // after we drop privileges tempDir, err := ioutil.TempDir("", "TestSyscallNoError") -- cgit v1.1 From 44ef03008c75059368245eb3dcd6054bed3f7643 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 1 Oct 2018 20:17:11 +0000 Subject: 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 --- libgo/go/hash/crc32/crc32_amd64p32.go | 2 ++ libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go | 9 +++++++++ libgo/go/runtime/lfstack_32bit.go | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go (limited to 'libgo/go') diff --git a/libgo/go/hash/crc32/crc32_amd64p32.go b/libgo/go/hash/crc32/crc32_amd64p32.go index 1ec44cb4..f61b801 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 0000000..911b608 --- /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 1288c1a..f50c508 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 -- cgit v1.1 From 4913fc07e0b3f1d574dc20f83ec819a26ab4346e Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 2 Oct 2018 15:07:14 +0000 Subject: net: don't fail test if splice fails because pipe2 is missing This reportedly happens on CentOS 5.11. The real code will work fine; this test is assuming that the unexported slice function will handle the splice, but if pipe2 does not work then it doesn't. The relevant code in internal/poll/splice_linux.go says "Falling back to pipe is possible, but prior to 2.6.29 splice returns -EAGAIN instead of 0 when the connection is closed." Reviewed-on: https://go-review.googlesource.com/138838 From-SVN: r264793 --- libgo/go/net/splice_test.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libgo/go') diff --git a/libgo/go/net/splice_test.go b/libgo/go/net/splice_test.go index 44a5c00..40ed19b 100644 --- a/libgo/go/net/splice_test.go +++ b/libgo/go/net/splice_test.go @@ -11,7 +11,9 @@ import ( "fmt" "io" "io/ioutil" + "os" "sync" + "syscall" "testing" ) @@ -225,6 +227,10 @@ func testSpliceReaderAtEOF(t *testing.T) { serverUp.Close() _, err, handled := splice(serverDown.(*TCPConn).fd, serverUp) if !handled { + if serr, ok := err.(*os.SyscallError); ok && serr.Syscall == "pipe2" && serr.Err == syscall.ENOSYS { + t.Skip("pipe2 not supported") + } + t.Errorf("closed connection: got err = %v, handled = %t, want handled = true", err, handled) } lr := &io.LimitedReader{ -- cgit v1.1 From d8ccfadbf2c350adf05729c6fca41a8d3f866bb1 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 2 Oct 2018 16:45:51 +0000 Subject: internal/bytealg: support systems that don't have memmem Reviewed-on: https://go-review.googlesource.com/138839 From-SVN: r264798 --- libgo/go/internal/bytealg/bytealg.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'libgo/go') diff --git a/libgo/go/internal/bytealg/bytealg.c b/libgo/go/internal/bytealg/bytealg.c index 39c060f..988dfaa 100644 --- a/libgo/go/internal/bytealg/bytealg.c +++ b/libgo/go/internal/bytealg/bytealg.c @@ -10,6 +10,33 @@ #include "runtime.h" #include "array.h" +#ifndef HAVE_MEMMEM + +#define memmem goMemmem + +static const void *goMemmem(const void *in, size_t inl, const void *s, size_t sl) { + const char *p; + char first; + const char *stop; + + if (sl == 0) { + return in; + } + if (inl < sl) { + return nil; + } + first = *(const char *)(s); + stop = (const char *)(in) + (inl - sl); + for (p = (const char *)(in); p <= stop; p++) { + if (*p == first && __builtin_memcmp(p + 1, (const char *)(s) + 1, sl - 1) == 0) { + return (const void *)(p); + } + } + return nil; +} + +#endif + intgo Compare(struct __go_open_array, struct __go_open_array) __asm__(GOSYM_PREFIX "internal_bytealg.Compare") __attribute__((no_split_stack)); -- cgit v1.1 From cbba2e1e47b550cebfb63fec85519cb14f2517d4 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 5 Oct 2018 14:21:01 +0000 Subject: runtime: remove checkgoarm function Nothing in libgo calls checkgoarm, and it relies on a variable, goarm, that is not set. Reviewed-on: https://go-review.googlesource.com/c/140057 From-SVN: r264872 --- libgo/go/runtime/os_linux_arm.go | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'libgo/go') diff --git a/libgo/go/runtime/os_linux_arm.go b/libgo/go/runtime/os_linux_arm.go index 42c2839..4b86455 100644 --- a/libgo/go/runtime/os_linux_arm.go +++ b/libgo/go/runtime/os_linux_arm.go @@ -19,25 +19,6 @@ var armArch uint8 = 6 // we default to ARMv6 var hwcap uint32 // set by archauxv var hardDiv bool // set if a hardware divider is available -func checkgoarm() { - // On Android, /proc/self/auxv might be unreadable and hwcap won't - // reflect the CPU capabilities. Assume that every Android arm device - // has the necessary floating point hardware available. - if GOOS == "android" { - return - } - if goarm > 5 && hwcap&_HWCAP_VFP == 0 { - print("runtime: this CPU has no floating point hardware, so it cannot run\n") - print("this GOARM=", goarm, " binary. Recompile using GOARM=5.\n") - exit(1) - } - if goarm > 6 && hwcap&_HWCAP_VFPv3 == 0 { - print("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n") - print("this GOARM=", goarm, " binary. Recompile using GOARM=5 or GOARM=6.\n") - exit(1) - } -} - func archauxv(tag, val uintptr) { switch tag { case _AT_RANDOM: -- cgit v1.1 From 7fc9c2e52f66a2b8aa101ef918829046f8f517e8 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 5 Oct 2018 17:51:57 +0000 Subject: libgo: use inline assembly in favor of call to _xgetbv() Use inline assembly in the implementation of internal_cpu.xgetbv as opposed to a call to the intrinsic _xgetbv(), since non-gcc compilers (e.g. clang) may or may not have support for it. Reviewed-on: https://go-review.googlesource.com/c/140137 From-SVN: r264882 --- libgo/go/internal/cpu/cpu_gccgo.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'libgo/go') diff --git a/libgo/go/internal/cpu/cpu_gccgo.c b/libgo/go/internal/cpu/cpu_gccgo.c index 6625ddc..1d5b492 100644 --- a/libgo/go/internal/cpu/cpu_gccgo.c +++ b/libgo/go/internal/cpu/cpu_gccgo.c @@ -52,12 +52,18 @@ struct xgetbv_ret xgetbv(void) #pragma GCC target("xsave") struct xgetbv_ret xgetbv(void) { - long long r; struct xgetbv_ret ret; - r = _xgetbv(0); - ret.eax = r & 0xffffffff; - ret.edx = r >> 32; + // At some point, use call to _xgetbv() instead: + // + // long long r = _xgetbv(0); + // ret.eax = r & 0xffffffff; + // ret.edx = r >> 32; + // + unsigned int __eax, __edx, __xcr_no = 0; + __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no)); + ret.eax = __eax; + ret.edx = __edx; return ret; } -- cgit v1.1