diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-10-05 20:11:24 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-10-05 20:11:24 +0000 |
commit | 504cafd97cd40223dac4beb4a28cb85368cff5b9 (patch) | |
tree | 153fa1d9d2a0ab481ba54a9f2f4ed6e311e2a5bf /libgo/go | |
parent | 5055f108385c076346b3b279788dc0129549b11f (diff) | |
parent | 0d48e8779c6a9ac88f5efd1b4a2d40f43ef75faf (diff) | |
download | gcc-504cafd97cd40223dac4beb4a28cb85368cff5b9.zip gcc-504cafd97cd40223dac4beb4a28cb85368cff5b9.tar.gz gcc-504cafd97cd40223dac4beb4a28cb85368cff5b9.tar.bz2 |
Merge from trunk revision 264887.
From-SVN: r264890
Diffstat (limited to 'libgo/go')
25 files changed, 134 insertions, 80 deletions
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 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/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)); 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_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; } 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_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) } } diff --git a/libgo/go/internal/cpu/cpu_wasm.go b/libgo/go/internal/syscall/unix/getrandom_linux_amd64p32.go index 1107a7a..911b608 100644 --- a/libgo/go/internal/cpu/cpu_wasm.go +++ b/libgo/go/internal/syscall/unix/getrandom_linux_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. -package cpu +package unix -const CacheLineSize = 64 +// Linux getrandom system call number. +// See GetRandom in getrandom_linux.go. +const randomTrap uintptr = 0x40000000 + 318 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{ 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/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 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/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: 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 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") |