aboutsummaryrefslogtreecommitdiff
path: root/libgo/go
AgeCommit message (Collapse)AuthorFilesLines
2017-09-20internal,net,os,runtime,syscall: fixes for AIX following update to go1.9Ian Lance Taylor16-19/+154
Reviewed-on: https://go-review.googlesource.com/64551 From-SVN: r253016
2017-09-20runtime: restore "goroutine in C code" messageIan Lance Taylor2-1/+2
In the 1.9 upgrade I took out the word "goroutine" from a traceback showing a goroutine running in C code, to let TestCgoNumGoroutine pass. However, it turns out that some code is actually checking for that string; for example, https://github.com/grpc/grpc-go/blob/master/test/leakcheck/leakcheck.go#L44 So keep the message the same, and change the test. Reviewed-on: https://go-review.googlesource.com/64850 From-SVN: r252991
2017-09-15syscall: fixes for SolarisIan Lance Taylor3-2/+14
Patch by Rainer Orth. Reviewed-on: https://go-review.googlesource.com/64170 From-SVN: r252866
2017-09-14libgo: update to go1.9Ian Lance Taylor931-20116/+55737
Reviewed-on: https://go-review.googlesource.com/63753 From-SVN: r252767
2017-09-14compiler, runtime: simplify select and channel operationsIan Lance Taylor3-108/+78
In preparation for upgrading libgo to the 1.9 release, this approximately incorporates https://golang.org/cl/37661 and https://golang.org/cl/38351. CL 37661 changed the gc compiler such that the select statement simply returns an integer which is then used as the argument for a switch. Since gccgo already worked that way, this just adjusts the switch code to look like the gc switch code by removing the explicit case index expression and calculating it from the order of calls to selectsend, selectrecv, and selectdefault. CL 38351 simplifies the channel code by not passing the unused channel type descriptor pointer. Reviewed-on: https://go-review.googlesource.com/62730 From-SVN: r252749
2017-09-14compiler, reflect: fix struct field names for embedded aliasesIan Lance Taylor3-93/+89
This adds much of https://golang.org/cl/35731 and https://golang.org/cl/35732 to the gofrontend code. This is a step toward updating libgo to the 1.9 release. The gofrontend already supports type aliases, and this is required for correct support of type aliases when used as embedded fields. The change to expressions.cc is to handle the << 1, used for the newly renamed offsetAnon field, in the constant context used for type descriptor initialization. Reviewed-on: https://go-review.googlesource.com/62710 From-SVN: r252746
2017-08-29net/internal/socktest: build sys_unix.go on AIXIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/59913 From-SVN: r251440
2017-08-29runtime: fix lfstack for 64-bit AIXIan Lance Taylor1-0/+18
Reviewed-on: https://go-review.googlesource.com/57550 From-SVN: r251420
2017-08-18cmd/go: pass -funwind-tables when compiling C codeIan Lance Taylor1-0/+6
Using -funwind-tables is necessary to permit Go code to correctly throw a panic through C code. This hasn't been necessary in the past as -funwind-tables is the default on x86. However, it is not the default for PPC AIX. Reviewed-on: https://go-review.googlesource.com/56650 From-SVN: r251179
2017-08-16runtime: better implementation of netpoll for AIXIan Lance Taylor1-65/+96
Reviewed-on: https://go-review.googlesource.com/54170 From-SVN: r251133
2017-08-09compiler: handle >32bit exponent in LdexpIan Lance Taylor1-2/+7
Libgo's implementation of math.Ldexp declared the libc "ldexp" as taking an 'int' exponent argument, which is not quite right for 64-bit platforms (exp arg is always int32); this could yield incorrect results for exponent values outside the range of Minint32/Maxint32. Fix by upating the type for the libc version of ldexp, and adding guards to screen for out-of-range exponents. Fixes #21323. Reviewed-on: https://go-review.googlesource.com/54250 From-SVN: r250992
2017-07-21syscall: call f?statfs64 on GNU/LinuxIan Lance Taylor1-2/+2
We unconditionally set _FILE_OFFSET_BITS to 64 in configure.ac, so we should unconditionally call the statfs64 and fstatfs64 functions. These functions should be available on all versions of GNU/Linux since 2.6. On 64-bit systems they are aliased to statfs/fstatfs, and on 32-bit systems they use the 64-bit data structures. Fixes golang/go#20922 Reviewed-on: https://go-review.googlesource.com/50635 From-SVN: r250443
2017-07-21runtime: allocate more stack space in CgoCallbackGC testIan Lance Taylor1-1/+3
Allocate enough stack space so that the test will work on a system that does not support split stacks. This test is actually not very meaningful for gccgo at present, but it doesn't hurt to keep running it. Updates golang/go#20931 Reviewed-on: https://go-review.googlesource.com/50630 From-SVN: r250433
2017-07-18re PR go/81451 (missing futex check - libgo/runtime/thread-linux.c:12:0 ↵Ian Lance Taylor1-2/+2
futex.h:13:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘long’) PR go/81451 runtime: inline runtime_osinit We had two identical copies of runtime_osinit. They set runtime_ncpu, a variable that is no longer used. Removing that leaves us with two lines. Inline those two lines in the two places the function was called. This fixes GCC PR 81451. Reviewed-on: https://go-review.googlesource.com/48862 From-SVN: r250326
2017-07-14cmd/go: use gccSupportsFlag for -fsplit-stackIan Lance Taylor1-4/+2
Don't assume that all (or only) 386/amd64 compilers support -fsplit-stack. Reviewed-on: https://go-review.googlesource.com/48592 From-SVN: r250216
2017-07-13re PR go/81393 (Bootstrap failure on s390x-linux while building libgo ↵Ian Lance Taylor2-6/+45
against recent glibc) PR go/81393 syscall: don't use GETREGS/SETREGS on s390 They were removed in recent glibc. Patch by Andreas Krebbel for GCC PR 81393. Reviewed-on: https://go-review.googlesource.com/48231 From-SVN: r250174
2017-06-29cmd/go: fix -buildmode={c-archive,c-shared,pie} for gccgoIan Lance Taylor1-14/+24
The tests are misc/cgo tests that are not currently run but will be run soon. Reviewed-on: https://go-review.googlesource.com/47037 From-SVN: r249794
2017-06-27runtime: adapt memory management to AIX mmapIan Lance Taylor2-1/+11
On AIX: * mmap does not allow to map an already mapped range, * mmap range start at 0x30000000 for 32 bits processes, * mmap range start at 0x70000000_00000000 for 64 bits processes This is adapted from change 37845. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/46772 From-SVN: r249713
2017-06-27syscall: ptrace fixes for s390Ian Lance Taylor2-4/+4
Fixes required now that we #include <linux/ptrace.h> in sysinfo.c. Patch by Andreas Krebbel. Reviewed-on: https://go-review.googlesource.com/46839 From-SVN: r249712
2017-06-26syscall: don't define PtraceRegs for AlphaIan Lance Taylor1-32/+0
It's now defined by mksysinfo.sh. Patch by Uros Bizjak. Reviewed-on: https://go-review.googlesource.com/46712 From-SVN: r249663
2017-06-23runtime: complete defer handling in CgocallBackDoneIan Lance Taylor2-10/+36
When C code calls a Go function, it actually calls a function generated by cgo. That function is written in Go, and, among other things, it calls the real Go function like this: CgocallBack() defer CgocallBackDone() RealGoFunction() The deferred CgocallBackDone function enters syscall mode as we return to C. Typically the C function will then eventually return to Go. However, in the case where the C function is running on a thread created in C, it will not return to Go. For that case we will have allocated an m struct, with an associated g struct, for the duration of the Go code, and when the Go is complete we will return the m and g to a free list. That all works, but we are running in a deferred function, which means that we have been invoked by deferreturn, and deferreturn expects to do a bit of cleanup to record that the defer has been completed. Doing that cleanup while using an m and g that have already been returned to the free list is clearly a bad idea. It was kind of working because deferreturn was holding the g pointer in a local variable, but there were races with some other thread picking up and using the newly freed g. It was also kind of working because of a special check in freedefer; that check is no longer necessary. This patch changes the special case of releasing the m and g to do the defer cleanup in CgocallBackDone itself. This patch also checks for the special case of a panic through CgocallBackDone. In that special case, we don't want to release the m and g. Since we are returning to C code that was not called by Go code, we know that the panic is not going to be caught and we are going to exit the program. So for that special case we keep the m and g structs so that the rest of the panic code can use them. Reviewed-on: https://go-review.googlesource.com/46530 From-SVN: r249611
2017-06-23cmd/go: don't require GOROOT to exist for gccgoIan Lance Taylor1-2/+7
Reviewed-on: https://go-review.googlesource.com/46590 From-SVN: r249609
2017-06-23os: align siginfo argument to waitidIan Lance Taylor1-1/+1
Backport https://golang.org/cl/46511 from gc trunk, as it may fix a bug reported for gccgo running on MIPS (https://groups.google.com/d/msg/golang-dev/sDg-t1_DPw0/-AJmLxgPBQAJ). Reviewed-on: https://go-review.googlesource.com/46571 From-SVN: r249599
2017-06-23runtime: don't crash if no p in kickoffIan Lance Taylor1-0/+18
The kickoff function for g0 can be invoked without a p, for example from mcall(exitsyscall0) in exitsyscall after exitsyscall has cleared the p field. The assignment gp.param = nil will invoke a write barrier. If gp.param is not already nil, this will require a p. Avoid the problem for a specific case that is known to be OK: when the value in gp.param is a *g. Reviewed-on: https://go-review.googlesource.com/46512 From-SVN: r249595
2017-06-23runtime: improve handling of panic during deferred functionIan Lance Taylor2-31/+85
When a panic occurs while processing a deferred function that recovered an earlier panic, we shouldn't report the recovered panic in the panic stack trace. Stop doing so by keeping track of the panic that triggered a defer, marking it as aborted if we see the defer again, and discarding aborted panics when a panic is recovered. This is what the gc runtime does. The test for this is TestRecursivePanic in runtime/crash_test.go. We don't run that test yet, but we will soon. Reviewed-on: https://go-review.googlesource.com/46461 From-SVN: r249590
2017-06-22runtime: uncomment check for gchelper on g0 stackIan Lance Taylor1-4/+3
Now that systemstack changes to the g0 stack, this check passes. Reviewed-on: https://go-review.googlesource.com/46460 From-SVN: r249578
2017-06-22runtime: mark dropm and callees nowritebarrierrecIan Lance Taylor3-0/+7
The CgocallbackDone function calls dropm after it calls entersyscall, which means that dropm must not have any write barriers. Mark it accordingly. Reviewed-on: https://go-review.googlesource.com/46464 From-SVN: r249577
2017-06-22runtime: export getm functionIan Lance Taylor1-0/+3
Use go:linkname to export the getm function. This makes it visible to runtime/testdata/testprogcgo/dropm_stub.go, which uses it as part of the TestEnsureDropM test in runtime/crash_cgo_test.go. That test is not run today, but it will be soon. Reviewed-on: https://go-review.googlesource.com/46462 From-SVN: r249576
2017-06-22runtime: make NumGoroutine wait for system goroutines to registerIan Lance Taylor5-0/+29
In libgo system goroutines register themselves after they start. That means that there is a small race between the goroutine being seen by the scheduler and the scheduler knowing that the goroutine is a system goroutine. That in turn means that runtime.NumGoroutines can overestimate the number of goroutines at times. This patch fixes the overestimate by counting the number of system goroutines waiting to start, and pausing NumGoroutines until those goroutines have all registered. This is kind of a lot of mechanism for this not very important problem, but I couldn't think of a better approach. The test for this is TestNumGoroutine in runtime/proc_test.go. The test is not currently run, but it will be soon. Reviewed-on: https://go-review.googlesource.com/46457 From-SVN: r249565
2017-06-22runtime: don't assume that _ = *s will panic if s is nilIan Lance Taylor2-4/+6
With the gc toolchain apparently var s *string _ = *s is enough to panic with a nil pointer dereference. The gccgo compiler will simply discard the dereference, which I think is a reasonable and acceptable optimization. Change the tests to use an exported variable instead. The tests are not currently run, but they will be with a later patch to gotools. Reviewed-on: https://go-review.googlesource.com/46450 From-SVN: r249562
2017-06-22runtime: change some stack fields to uintptrIan Lance Taylor2-7/+7
Because of how gccgo implements cgo calls, the code in dropm may not have any write barriers. As a step toward implementing that, change the gcstack, gcnextsegment, and gcnextsp fields of the g struct to uintptr, so that assignments to them do not require write barriers. The gcinitialsp field remains unsafe.Pointer, as on 32-bit systems that do not support split stack it points to a heap allocated space used for the goroutine stack. The test for this is runtime tests like TestCgoCallbackGC, which are not run today but will be run with a future gotools patch. Reviewed-on: https://go-review.googlesource.com/46396 From-SVN: r249561
2017-06-22runtime: avoid write barriers when calling deferred functionIan Lance Taylor1-4/+4
Calling a deferred function currently requires changing from a uintptr to the function code to a Go function value. That is done by setting the value of a func local variable using unsafe.Pointer. The local variable will always be on the stack. Adjust the code that sets the local variable to avoid generating a write barrier. A write barrier is never needed here. Also, for deferreturn, we must avoid write barriers entirely when called from a cgo function; that requires more than just this, but this is a start. The test for this is runtime tests that use the go tool; these are not currently run, but they will be in the future. Reviewed-on: https://go-review.googlesource.com/46455 From-SVN: r249559
2017-06-22runtime: rename _defer struct _panic field to panicStackIan Lance Taylor2-10/+10
The gc version of the _defer struct has a _panic field that has a completely different meaning. We are going to want that bring that new meaning into the gofrontend to improve panic reports with nested panic calls. Simplify that by first renaming the existing _panic field. Reviewed-on: https://go-review.googlesource.com/46454 From-SVN: r249558
2017-06-22runtime: adjust tests for gofrontendIan Lance Taylor3-3/+29
- don't run tests that depend on SetCgoTraceback - don't expect a '(' after the function name in a traceback - change the expected name of nested functions in a traceback These tests are not currently run, but they will be soon. Reviewed-on: https://go-review.googlesource.com/46453 From-SVN: r249557
2017-06-22runtime: don't build test files that use SetCgoTraceback for gccgoIan Lance Taylor6-0/+10
The gofrontend doesn't support the runtime.SetCgoTraceback function, which is specifically for handling mixed Go and C tracebacks. Use a build tag to avoid compiling the runtime/testdata/testprogcgo files that refer to SetCgoTraceback. These files are not currently compiled anyhow, but they will be with a future gotools patch. Reviewed-on: https://go-review.googlesource.com/46452 From-SVN: r249556
2017-06-22runtime: build testprogcgo with -pthreadIan Lance Taylor1-0/+3
Building this test with gccgo requires an explicit -pthread option to be passed to the C compiler, so that it links against -lpthread. This test is not built today, but it will be soon with a future patch. Reviewed-on: https://go-review.googlesource.com/46451 From-SVN: r249555
2017-06-22runtime: in traceback, print panic rather than runtime.gopanicIan Lance Taylor1-1/+5
The gc toolchain does the same thing, in gentraceback in runtime/traceback.go. The test for this is TestPanicTraceback in runtime/crash_test.go. We don't yet run that test, but we will in a future change. Reviewed-on: https://go-review.googlesource.com/46397 From-SVN: r249495
2017-06-21debug/elf: handle Alpha relocsIan Lance Taylor1-0/+51
Patch by Uros Bizjak. Reviewed-on: https://go-review.googlesource.com/46391 From-SVN: r249487
2017-06-21Forgot to remove this file in the last libgo commit.Ian Lance Taylor1-11/+0
libgo: remove old MIPS architecture names This removes the old names for the 3 main MIPS ABIs: mipso32, mipsn32 and mipsn64. It also removes the mipso64 ABI which has no equivalent architecture name in go. This ABI has been dead for sometime and I doubt anyone will miss it. Change-Id: I087b243784edf6705fdaf9c32e3233da5e387283 From-SVN: r249485
2017-06-21libgo: remove old MIPS architecture namesIan Lance Taylor10-17/+9
This removes the old names for the 3 main MIPS ABIs: mipso32, mipsn32 and mipsn64. It also removes the mipso64 ABI which has no equivalent architecture name in go. This ABI has been dead for sometime and I doubt anyone will miss it. Reviewed-on: https://go-review.googlesource.com/46154 From-SVN: r249477
2017-06-21cmd/cgo: add mips64p32* to ptrSizeMap and intSizeMapIan Lance Taylor1-42/+46
Reviewed-on: https://go-review.googlesource.com/46152 From-SVN: r249475
2017-06-21internal/syscall/unix: implement randomTrap on mips64p32*Ian Lance Taylor1-1/+1
Rename getrandom_linux_mipsn32.go to use the new architecture name for the n32 ABI and enable building it on mips64p32 and mips64p32le. Reviewed-on: https://go-review.googlesource.com/46151 From-SVN: r249474
2017-06-21libgo, syscall: fix ptrace implementation on MIPSIan Lance Taylor1-20/+0
On MIPS, the correct structure for PtraceRegs is 'struct pt_regs' which is declared in linux/ptrace.h. Previously no PtraceRegs structure was created on MIPS because 'struct user_regs_struct' doesn't exist there. Fallback to using pt_regs when the PtraceRegs structure is generated in mksysinfo.sh, then adjust syscall_linux_mipsx.go to read the program counter from the correct field. In addition, implement PtraceGetRegs and PtraceSetRegs on all 3 ABI variants. syscall_linux_mips64x.go can now be removed since the ptrace code on all 3 ABIs is identical. Reviewed-on: https://go-review.googlesource.com/46150 From-SVN: r249473
2017-06-21libgo, syscall: fix ptrace implementation on MIPSIan Lance Taylor1-3/+17
On MIPS, the correct structure for PtraceRegs is 'struct pt_regs' which is declared in linux/ptrace.h. Previously no PtraceRegs structure was created on MIPS because 'struct user_regs_struct' doesn't exist there. Fallback to using pt_regs when the PtraceRegs structure is generated in mksysinfo.sh, then adjust syscall_linux_mipsx.go to read the program counter from the correct field. In addition, implement PtraceGetRegs and PtraceSetRegs on all 3 ABI variants. syscall_linux_mips64x.go can now be removed since the ptrace code on all 3 ABIs is identical. Reviewed-on: https://go-review.googlesource.com/46150 From-SVN: r249472
2017-06-14cmd/cgo: make _cgo_flags consistent across runsIan Lance Taylor2-3/+26
The go tool will pass -I objdir as one of the flags, where objdir is the temporary build directory. Remove that from _cgo_flags: we don't need it, and it will be different each time. Sort the flags to avoid the unpredictable map iteration order. This matters for gccgo because for a package that uses cgo, the go tool when building for gccgo will store the _cgo_flags file in the archive. That means that we want to generate identical _cgo_flags for every run. The test for this is the cmd/go testsuite, to follow in a future CL. Reviewed-on: https://go-review.googlesource.com/45692 From-SVN: r249199
2017-06-14cmd/go: gccgo: consistent results, fix vendoringIan Lance Taylor1-4/+17
Pass the -fdebug-prefix-map and -gno-record-gcc-switches compiler options to gccgo to generate consistent results. Fix the vendoring code to look for /vendor/, not just /vendor, to avoid being confused by something like vendor/vendor.org. Tested by the cmd/go tests in a followup CL. Reviewed-on: https://go-review.googlesource.com/45695 From-SVN: r249198
2017-06-14cmd/go: skip tests that do not work with gccgoIan Lance Taylor2-1/+34
These tests fail for various reasons, most commonly because gccgo doesn't really have GOROOT, so things like `go build errors` fail. Reviewed-on: https://go-review.googlesource.com/45696 From-SVN: r249197
2017-06-14go/build: use GCCGOTOOLDIR to find gccgo toolsIan Lance Taylor3-1/+7
Add the environment variable GCCGOTOOLDIR to permit overriding the default directory where tools like cgo are found when building with gccgo. This will be used by the cmd/go tests in a future CL. Reviewed-on: https://go-review.googlesource.com/45694 From-SVN: r249196
2017-06-14internal/testenv: support testing gccgoIan Lance Taylor1-3/+14
If GO_TESTING_GOTOOLS is set in the environment, permit tests using gccgo to run the go tool. Like GO_BUILDER_NAME, this should not be set normally. But it is needed when testing the go tool itself, and will be set by the gotools Makefile in a future CL. Reviewed-on: https://go-review.googlesource.com/45693 From-SVN: r249195
2017-06-13runtime: don't always show frames with no function in tracebackIan Lance Taylor1-1/+1
If there is no function name, the traceback is generally uninformative. In earlier versions we did not show such frames. Restore that behavior. These frames can be seen with GOTRACEBACK=system. Reviewed-on: https://go-review.googlesource.com/45431 From-SVN: r249156