Commit Graph

996 Commits

Author SHA1 Message Date
Ian Lance Taylor a2a7ea4834 runtime: rename siginfo to _siginfo_t
Since the name siginfo winds up in runtime.inc, this avoids a name
    collision on systems that define "struct siginfo" in the system header
    files.
    
    Reviewed-on: https://go-review.googlesource.com/35239

From-SVN: r244484
2017-01-16 01:21:42 +00:00
Ian Lance Taylor 58a3a26bbd libgo: correct golang_org Makefile variables not used on all systems
Patch by Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/35238

From-SVN: r244483
2017-01-16 01:05:10 +00:00
Ian Lance Taylor c2047754c3 libgo: update to Go 1.8 release candidate 1
Compiler changes:
      * Change map assignment to use mapassign and assign value directly.
      * Change string iteration to use decoderune, faster for ASCII strings.
      * Change makeslice to take int, and use makeslice64 for larger values.
      * Add new noverflow field to hmap struct used for maps.
    
    Unresolved problems, to be fixed later:
      * Commented out test in go/types/sizes_test.go that doesn't compile.
      * Commented out reflect.TestStructOf test for padding after zero-sized field.
    
    Reviewed-on: https://go-review.googlesource.com/35231

gotools/:
	Updates for Go 1.8rc1.
	* Makefile.am (go_cmd_go_files): Add bug.go.
	(s-zdefaultcc): Write defaultPkgConfig.
	* Makefile.in: Rebuild.

From-SVN: r244456
2017-01-14 00:05:42 +00:00
Ian Lance Taylor 6fcb740ac4 runtime: copy more scheduler code from Go 1.7 runtime
I looked at a diff of proc.go between Go 1.7 and gccgo, and copied
    over all the easy stuff.
    
    Reviewed-on: https://go-review.googlesource.com/35090

From-SVN: r244291
2017-01-10 21:09:00 +00:00
Ian Lance Taylor 0c22e4415f compiler, runtime: drop size arguments to hash/equal functions
Drop the size arguments for the hash/equal functions stored in type
    descriptors.  Types know what size they are.  To make this work,
    generate hash/equal functions for types that can use an identity
    comparison but are not a standard size and alignment.
    
    Drop the multiplications by 33 in the generated hash code and the
    reflect package hash code.  They are not necessary since we started
    passing a seed value around, as the seed includes the hash of the
    earlier values.
    
    Copy the algorithms for standard types from the Go 1.7 runtime,
    replacing the C functions.
    
    Reviewed-on: https://go-review.googlesource.com/34983

From-SVN: r244256
2017-01-10 03:59:20 +00:00
Ian Lance Taylor 2193ad7fbf runtime: copy more of scheduler from Go 1.7 runtime
This started by moving procresize from C to Go so that we can pass the
    right type to the memory allocator when allocating a p, which forced
    the gomaxprocs variable to move from C to Go, and everything else
    followed from that.
    
    Reviewed-on: https://go-review.googlesource.com/34916

From-SVN: r244236
2017-01-09 19:37:19 +00:00
Ian Lance Taylor 12e917fff2 runtime: actually remove go-alloc.h
Accidentally omitted from the commit of CL 34797 (SVN revision 244036).

From-SVN: r244166
2017-01-06 16:06:42 +00:00
Ian Lance Taylor 08934aed39 re PR go/78978 (runtime/pprof FAILs on Solaris 2/x86)
PR go/78978
    libgo: build with -Wa,-nH if possible on Solaris
    
    By default the Solaris assembler records the required hardware
    capability in the object file.  This means that the AES hashing code
    breaks on systems that do not support AES, even though the code uses a
    runtime check to only actually invoke the AES instructions on systems
    that support it.  An earlier fix for the problem only fixed the shared
    library, not the static libgo.a.  Fix the problem for real by using an
    assembler option to not record the hardware capability.
    
    For GCC PR 78978.
    
    Patch by Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/34910

From-SVN: r244165
2017-01-06 16:04:01 +00:00
Ian Lance Taylor 0f2a6e84c6 runtime: remove __go_alloc and __go_free
Move allocg and handling of allgs slice from C to Go.
    
    Reviewed-on: https://go-review.googlesource.com/34797

From-SVN: r244036
2017-01-03 22:58:48 +00:00
Ian Lance Taylor b379f8d81f re PR go/78789 (Error: no such instruction: `aesenc %xmm0,%xmm2' when compiling libgo/runtime/aeshash.c)
PR go/78789
    runtime: don't build aeshash.c if the assembler doesn't support it
    
    This is for CentOS 5, whose assembler does not know the aesinc
    instruction.
    
    Fixes GCC PR 78789.
    
    Patch by Uros Bizjak.
    
    Reviewed-on: https://go-review.googlesource.com/34796

From-SVN: r244031
2017-01-03 20:41:54 +00:00
Ian Lance Taylor 0d3dd8fb65 runtime: copy cgo support from Go 1.7 runtime
Remove support for _cgo_allocate.  It was removed from the gc
    toolchain in Go 1.5, so it is unlikely that anybody is trying to use it.
    
    Reviewed-on: https://go-review.googlesource.com/34557

From-SVN: r243805
2016-12-19 18:00:35 +00:00
Ian Lance Taylor c3c54e0f07 libgo: fixes for Solaris build
Don't put m[0-4] in runtime.inc.
    
    Pass -mclear-hwcap to the linker if supported.
    
    From Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/34331

From-SVN: r243619
2016-12-13 18:03:45 +00:00
Ian Lance Taylor 560bcfdcfd runtime: mark non-x86 aeshashbody parameters as unused
Avoids warnings during the build.
    
    Reviewed-on: https://go-review.googlesource.com/34142

From-SVN: r243459
2016-12-08 20:43:19 +00:00
Ian Lance Taylor 453060a906 runtime: copy memory hash code from Go 1.7
Rewrite the AES hashing code from gc assembler to C code using
    intrinsics.  The resulting code generates the same hash code for the
    same input as the gc code--that doesn't matter as such, but testing it
    ensures that the C code does something useful.
    
    Also change mips64pe32le to mips64p32le in configure script--noticed
    during CL review.
    
    Reviewed-on: https://go-review.googlesource.com/34022

From-SVN: r243445
2016-12-08 16:37:54 +00:00
Ian Lance Taylor b2264b0964 runtime: allocate _panic struct on heap
The gc library allocates a _panic struct on the stack. This does not
    work for gccgo, because when a deferred function recovers the panic we
    unwind the stack up to that point so that returning from the function
    will work correctly.
    
    Allocating on the stack fine if the panic is not recovered, and it
    works fine if the panic is recovered by a function that
    returns. However, it fails if the panic is recovered by a function
    that itself panics, and if that second panic is then recovered by a
    function higher up on the stack. When we unwind the stack to that
    second panic, the g will wind up pointing at a panic farther down on
    the stack. Even then everything will often work fine, except when the
    deferred function catching the second panic makes a bunch of calls
    that use stack space before returning. In that case the code can
    overwrite the panic struct, which will then cause disaster when we
    remove the struct from the linked list, as the link field will be
    garbage. This case is rare enough that all the x86 tests were passing,
    but there was a failure on ppc64le.
    
    Before https://golang.org/cl/33414 we allocated the panic struct on
    the heap, so go back to doing that again.
    
    Fixes golang/go#18228.
    
    Reviewed-on: https://go-review.googlesource.com/34027

From-SVN: r243444
2016-12-08 15:54:30 +00:00
Ian Lance Taylor 776a8a927e runtime: remove some unused variables/declarations from runtime.h
Small patch from Eric Botcazou.
    
    Reviewed-on: https://go-review.googlesource.com/34029

From-SVN: r243424
2016-12-08 00:38:03 +00:00
Ian Lance Taylor 6e7f1be7ae runtime: set isarchive in initsig
The library initialization code in go-libmain.c sets the C variable
    runtime_isarchive but failed to set the Go variable runtime.isarchive.
    We don't currently have a way to let C code access an unexported Go
    variable, but fortunately the only time the Go function initsig is
    called with an argument of true is exactly where we want to set
    isarchive.  So let initsig do it.
    
    Reviewed-on: https://go-review.googlesource.com/33753

From-SVN: r243094
2016-12-01 05:47:58 +00:00
Ian Lance Taylor 24f1d7f80e runtime: print C functions in traceback
Since gccgo can trace back through C code as easily as Go code, we
    should print C functions in the traceback.
    
    This worked before https://golang.org/cl/31230 for a dumb reason.  The
    default value for runtime.traceback_cache was, and is, 2 << 2, meaning
    to print all functions.  The old C code for runtime_parsedebugvars
    would return immediately and do nothing if the environment variable
    GODEBUG was not set (if GODEBUG was set it would later call
    setTraceback.  The new Go code for runtime.parsedebugvars does not
    return immediately if GODEBUG is not set, and always calls
    setTraceback.  Either way, if GOTRACEBACK is not set, setTraceback
    would set traceback_cache to 1 << 2, meaning to only print non-runtime
    functions and having the effect of not printing plain C functions.
    
    Keep the current handling of GODEBUG/GOTRACEBACK, which matches the gc
    library, but add an extra check to print C functions by default.
    
    Reviewed-on: https://go-review.googlesource.com/33717

From-SVN: r243083
2016-11-30 20:28:28 +00:00
Ian Lance Taylor fbe9724cc3 runtime: fixes for -buildmode=c-archive
With -buildmode=c-archive, initsig is called before the memory
    allocator has been initialized.  The code was doing a memory
    allocation because of the call to funcPC(sigtramp).  When escape
    analysis is fully implemented, that call should not allocate.  For
    now, finesse the issue by calling a C function to get the C function
    pointer value of sigtramp.
    
    When returning from a call from C to a Go function, a deferred
    function is run to go back to syscall mode.  When the call occurs on a
    non-Go thread, that call sets g to nil, making it impossible to add
    the _defer struct back to the pool.  Just drop it and let the garbage
    collector clean it up.
    
    Reviewed-on: https://go-review.googlesource.com/33675

From-SVN: r242992
2016-11-30 02:09:24 +00:00
Ian Lance Taylor 7239bf746a re PR go/77910 (go: open zversion.go: no such file or directory)
PR go/77910
    cmd/go: don't check standard packages when using gccgo
    
    This copies https://golang.org/cl/33295 to libgo.
    
    This fixes GCC PR 77910.
    
    Reviewed-on: https://go-review.googlesource.com/33471

From-SVN: r242724
2016-11-22 21:04:27 +00:00
Ian Lance Taylor 9d1e3afb54 runtime: rewrite panic/defer code from C to Go
The actual stack unwind code is still in C, but the rest of the code,
    notably all the memory allocation, is now in Go.  The names are changed
    to the names used in the Go 1.7 runtime, but the code is necessarily
    somewhat different.
    
    The __go_makefunc_can_recover function is dropped, as the uses of it
    were removed in https://golang.org/cl/198770044.
    
    Reviewed-on: https://go-review.googlesource.com/33414

From-SVN: r242715
2016-11-22 17:58:04 +00:00
Ian Lance Taylor 092dd2bc33 runtime: move schedt type and sched var from C to Go
This doesn't change any actual code, it just starts using the Go
    definition of the schedt type and the sched variable rather than the C
    definitions.
    
    The schedt type is tweaked slightly for gccgo.  We aren't going to
    release goroutine stacks, so we don't need separate gfreeStack and
    gfreeNostack lists.  We only have one size of defer function, so we
    don't need a list of 5 different pools.
    
    Reviewed-on: https://go-review.googlesource.com/33364

From-SVN: r242600
2016-11-18 17:48:29 +00:00
Ian Lance Taylor d6255159e8 runtime: don't call __go_alloc/__go_free in environment functions
Reviewed-on: https://go-review.googlesource.com/33363

From-SVN: r242594
2016-11-18 16:03:13 +00:00
Ian Lance Taylor d519aeda8b libgo: remove old/regexp and old/template
They were removed from the master Go library in 2012
    (https://golang.org/cl/5979046) but somehow that was not reflected here.
    
    Reviewed-on: https://go-review.googlesource.com/33391

From-SVN: r242592
2016-11-18 14:51:13 +00:00
Ian Lance Taylor 9bd0f0bc6b Correct gcc/go/gofrontend/lex.cc and libgo/aclocal.m4 to the versions in the gofrontend repo...
Correct gcc/go/gofrontend/lex.cc and libgo/aclocal.m4 to the versions
in the gofrontend repo, which is supposed to be the master copy.

Remove a few files in libgo that somehow were not deleted in the past.

From-SVN: r242583
2016-11-18 04:15:46 +00:00
Ian Lance Taylor 54f0deb00f Update libgo/configure to restore it to the master version.
Update a few binary files that were changed in the master gc repo,
copied into the gofrontend repo, but not correctly copied into the GCC
repo.  The changes are all minor and do not affect any actual tests.
Two instances of "http" changed to "https", and two timestamps were
zeroed out.

From-SVN: r242582
2016-11-18 04:05:10 +00:00
Ian Lance Taylor 5302cd0250 runtime, reflect: rewrite Go to FFI type conversion in Go
As we move toward the Go 1.7 garbage collector, it's essential that all
    allocation of values that can contain Go pointers be done using the
    correct type descriptor.  That is simplest if we do all such allocation
    in Go code.  This rewrites the code that converts from a Go type to a
    libffi CIF into Go.
    
    Reviewed-on: https://go-review.googlesource.com/33353

From-SVN: r242578
2016-11-18 00:15:38 +00:00
Ian Lance Taylor 350767bf22 runtime: replace runtime1.goc with Go and C code
A step toward eliminating goc2c.
    
    Drop the exported parfor code; it was needed for tests in the past, but
    no longer is. The Go 1.7 runtime no longer uses parfor.
    
    Reviewed-on: https://go-review.googlesource.com/33324

From-SVN: r242509
2016-11-16 18:33:11 +00:00
Matthias Klose 84c1b9d3d4 config-ml.in: Remove references to GCJ.
<toplevel>

2016-11-15  Matthias Klose  <doko@ubuntu.com>

	* config-ml.in: Remove references to GCJ.
	* configure.ac: Likewise.
	* configure: Regenerate.

config/

2016-11-15  Matthias Klose  <doko@ubuntu.com>

	multi.m4: Don't set GCJ.

gcc/

2016-11-15  Matthias Klose  <doko@ubuntu.com>

	* doc/install.texi: Remove references to gcj/libjava.
	* doc/invoke.texi: Likewise.

*/ (where necessary)

2016-11-15  Matthias Klose  <doko@ubuntu.com>

	* configure: Regenerate.

From-SVN: r242433
2016-11-15 16:34:02 +00:00
Ian Lance Taylor 7b9f5ceef1 runtime: don't crash if signal handler info argument is nil
Apparently on Solaris 10 a SA_SIGINFO signal handler can be invoked with
    a nil info argument.  I would not have believed it but I've now seen it
    happen, and the sigaction man page actually says "If the second argument
    is not equal to NULL, it points to a siginfo_t structure...."  So, if
    that happens, don't crash.
    
    Also fix another case where we want to make sure that &T{} does not
    allocate.
    
    Reviewed-on: https://go-review.googlesource.com/33150

From-SVN: r242403
2016-11-14 23:16:04 +00:00
Ian Lance Taylor 0f366729b9 libgo: fix GOARCH_INT64ALIGN for several targets
From Andreas Schwab.
    
    Reviewed-on: https://go-review.googlesource.com/33130

From-SVN: r242072
2016-11-11 14:52:35 +00:00
Ian Lance Taylor 980f9a0a4b runtime: copy signal code from Go 1.7 runtime
Add a little shell script to auto-generate runtime.sigtable from the
    known signal names.
    
    Force the main package to always import the runtime package.  Otherwise
    some runtime package global variables may never be initialized.
    
    Set the syscallsp and syscallpc fields of g when entering a syscall, so
    that the runtime package knows when a g is executing a syscall.
    
    Fix runtime.funcPC to avoid dead store elimination of the interface
    value when the function is inlined.
    
    Reviewed-on: https://go-review.googlesource.com/33025

From-SVN: r242060
2016-11-10 22:53:23 +00:00
Ian Lance Taylor 655a835566 re PR go/78172 (gen-sysinfo.go vs AIX cred.h)
PR go/78172.
    libgo: avoid confusion in upcase_fields in mksysinfo.sh
    
    The mksysinfo.sh script could get confused when there were multiple
    types starting with the same name.  I believe this is the underlying
    cause of GCC PR 78172.
    
    Also redirect a grep to /dev/null to avoid extraneous messages during
    the build.
    
    Reviewed-on: https://go-review.googlesource.com/32821

From-SVN: r241868
2016-11-05 00:21:33 +00:00
Ian Lance Taylor 307dde6fcc libgo: fix GOARCH_PHYSPAGESIZE for ia64
From Andreas Schwab.
    
    Reviewed-on: https://go-review.googlesource.com/32537

From-SVN: r241757
2016-11-01 21:45:32 +00:00
Ian Lance Taylor 69907c4ad5 runtime: recreate function called by cgo -gccgo
When using cgo -gccgo calls to C.GoString, C.GoStringN, and C.GoBytes
    are turned into calls to __go_byte_array_to_string and
    __go_string_to_byte_array.  Those functions were removed when the string
    code was copied from Go 1.7, but we still need them for cgo.  While cgo
    should be updated, old versions will exist for some time.
    
    Reviewed-on: https://go-review.googlesource.com/32474

From-SVN: r241743
2016-11-01 14:07:43 +00:00
Ian Lance Taylor f94a3edc6e libgo: only rebuild package if dependent .gox has changed
Use mvifdiff and stamp files to track whether a .gox file has changed.
    When package A depends on package B, and we rebuild package B, only
    rebuild package A if package B's .gox file changes.  This is safe
    because when package A imports package B it only reads package B's .gox
    file.  This means that changes that do not affect export information
    will not cause dependent packages to be recompiled.
    
    Reviewed-on: https://go-review.googlesource.com/32476

From-SVN: r241742
2016-11-01 13:54:21 +00:00
Ian Lance Taylor 380f39b91b libgo: minor Makefile improvements
Suggested by Ralph Corderoy.
    
    Reviewed-on: https://go-review.googlesource.com/32414

From-SVN: r241741
2016-11-01 13:50:03 +00:00
Ian Lance Taylor 48e21b40b5 libgo: eliminate a lot of duplication in Makefile.am
I read through the GNU make manual.  I knew there had to be a way to do it.
    
    Remove the special netgo library.  The essential feature--using the Go
    DNS resolver--is now available by setting GODEBUG=netdns=go.
    
    Reviewed-on: https://go-review.googlesource.com/32333

From-SVN: r241687
2016-10-30 16:45:34 +00:00
Ian Lance Taylor 94f56408db compiler, runtime: copy slice code from Go 1.7 runtime
Change the compiler handle append as the gc compiler does: call a
    function to grow the slice, but otherwise assign the new elements
    directly to the final slice.
    
    For the current gccgo memory allocator the slice code has to call
    runtime_newarray, not mallocgc directly, so that the allocator sets the
    TypeInfo_Array bit in the type pointer.
    
    Rename the static function cnew to runtime_docnew, so that the stack
    trace ignores it when ignoring runtime functions.  This was needed to
    fix the runtime/pprof tests on 386.
    
    Reviewed-on: https://go-review.googlesource.com/32218

From-SVN: r241667
2016-10-28 22:34:47 +00:00
Ian Lance Taylor a5742b0158 re PR go/78144 (FAIL: time on systems with tzdata2016g installed)
PR go/78144
    libgo: incorporate fix for timezone test
    
    This brings over the test-only fix for issue 17276 into gccgo/libgo
    (with tzdata-2016g there is a new zone abbreviation).  This is a
    copy of https://golang.org/cl/29995.
    
    Reviewed-on: https://go-review.googlesource.com/32182

From-SVN: r241661
2016-10-28 20:21:52 +00:00
Ian Lance Taylor 0dfeae289c re PR go/78143 (bootstrap broken in libgo on powerpc-linux-gnu)
PR go/78143
    runtime: build lfstack_32bit.go on ppc
    
    Missed a build tag.  This is GCC PR 78143.
    
    Reviewed-on: https://go-review.googlesource.com/32295

From-SVN: r241659
2016-10-28 18:57:36 +00:00
Ian Lance Taylor eae2ada503 libgo: redirect grep output in mkrsysinfo.sh to /dev/null
I noticed a stray useless output line when building libgo.
    
    Reviewed-on: https://go-review.googlesource.com/32294

From-SVN: r241655
2016-10-28 17:55:13 +00:00
Ian Lance Taylor 15ca61bc74 libgo: keep c0 and c1 out of runtime.inc
The constants named c0 and c1 turn up as macros in runtime.inc.  This
    reportedly breaks building on Solaris 11, where there is a system struct
    that has a field named c1.  The constants aren't needed by the runtime C
    code, so avoid the problem by grepping them out.
    
    Reviewed-on: https://go-review.googlesource.com/31730

From-SVN: r241432
2016-10-21 21:01:04 +00:00
Ian Lance Taylor 6156a05a25 libgo: leave Int64Align as 8 on 32-bit SPARC
Verified by testing on SPARC Solaris.
    
    Reviewed-on: https://go-review.googlesource.com/31675

From-SVN: r241430
2016-10-21 20:44:46 +00:00
Ian Lance Taylor e597e0533d runtime: copy lfstack code from Go 1.7 runtime
Note that lfstack_64bit.go was modified for Solaris support in a
    different, and better, way than the superseded lfstack.goc code.
    
    Reviewed-on: https://go-review.googlesource.com/31673

From-SVN: r241427
2016-10-21 20:07:06 +00:00
Ian Lance Taylor 6b752cfac4 runtime: rewrite interface code into Go
I started to copy the Go 1.7 interface code, but the gc and gccgo
    representations of interfaces are too different.  So instead I rewrote
    the gccgo interface code from C to Go.  The code is largely the same as
    it was, but the names are more like those used in the gc runtime.
    
    I also copied over the string comparison functions, and tweaked the
    compiler to use eqstring when comparing strings for equality.
    
    Reviewed-on: https://go-review.googlesource.com/31591

From-SVN: r241384
2016-10-20 18:51:35 +00:00
Ian Lance Taylor 29849c91e4 runtime, syscall: force EPOLLET to be positive
The C definition is 1U << 31.  Reportedly on some systems GCC's
    -fgo-dump-spec can print this as -2147483648.
    
    Reviewed-on: https://go-review.googlesource.com/31448

From-SVN: r241347
2016-10-19 16:53:13 +00:00
Ian Lance Taylor 812ba636c7 runtime: copy netpoll code from Go 1.7 runtime
Reviewed-on: https://go-review.googlesource.com/31325

From-SVN: r241307
2016-10-18 14:38:29 +00:00
Ian Lance Taylor 421a8ed412 runtime: scan caller-saved registers for non-split-stack
While testing a patch on Solaris, which does not support split-stack, I
    ran across a bug in the handling of caller-saved registers for the
    garbage collector.  For non-split-stack systems, runtime_mcall is
    responsible for saving all caller-saved registers on the stack so that
    the GC stack scan will see them.  It does this by calling
    __builtin_unwind_init and setting the g's gcnextsp field to point to the
    current stack.  The garbage collector then scans the stack from gcnextsp
    to the top of stack.
    
    Unfortunately, the code was setting gcnextsp to point to runtime_mcall's
    argument, which meant that even though runtime_mcall was careful to
    store all caller-saved registers on the stack, the GC never saw them.
    This is, of course, only a problem if a value lives only in a
    caller-saved register, and not anywhere else on the stack or heap.  And
    it is only a problem if that caller-saved register manages to make it
    all the way down to runtime_mcall without being saved by any function on
    the way.  This is moderately unlikely but it turns out that the recent
    changes to keep values on the stack when compiling the runtime package
    caused it to happen for the local variable `s` in `notifyListWait` in
    runtime/sema.go.  That function calls goparkunlock which is simple
    enough to not require all registers, and itself calls runtime_mcall.  So
    it was possible for `s` to be released by the GC before the goroutine
    returned from goparkunlock, which eventually caused a dangling pointer
    to be passed to releaseSudog.
    
    This is not a problem on split-stack systems, which use
    __splitstack_get_context, which saves a stack pointer low enough on the
    stack to scan the registers saved by runtime_mcall.
    
    Reviewed-on: https://go-review.googlesource.com/31323

From-SVN: r241304
2016-10-18 13:29:37 +00:00
Ian Lance Taylor 8cce07d1dd runtime: copy rdebug code from Go 1.7 runtime
While we're at it, update the runtime/debug package, and start running
    its testsuite by default.  I'm not sure why runtime/debug was not
    previously updated to 1.7.  Doing that led me to fix some minor aspects
    of runtime.Stack and the C function runtime/debug.readGCStats.
    
    Reviewed-on: https://go-review.googlesource.com/31251

From-SVN: r241261
2016-10-17 16:54:25 +00:00
Ian Lance Taylor 35d9424444 runtime: copy runtime package time code from Go 1.7
Fix handling of function values for -fgo-c-header to generate FuncVal*,
    not simply FuncVal.
    
    While we're here change runtime.nanotime to use clock_gettime with
    CLOCK_MONOTONIC, rather than gettimeofday.  This is what the gc library
    does.  It provides nanosecond precision and a monotonic clock.
    
    Reviewed-on: https://go-review.googlesource.com/31232

From-SVN: r241197
2016-10-15 00:29:06 +00:00
Ian Lance Taylor 1f0be9ee86 runtime: copy mprof code from Go 1.7 runtime
Also create a gccgo version of some of the traceback code in
    traceback_gccgo.go, replacing some code currently in C.
    
    This required modifying the compiler so that when compiling the runtime
    package a slice expression does not cause a local array variable to
    escape to the heap.
    
    Reviewed-on: https://go-review.googlesource.com/31230

From-SVN: r241189
2016-10-14 22:51:46 +00:00
Ian Lance Taylor db2fb304fe runtime: just do file/line lookup in C, move Func to Go
In order to port stack backtraces to Go, we need the ability to look up
    file/line information for PC values without allocating memory.  This
    patch moves the handling of Func from C code to Go code, and simplifies
    the C code to just look up function/file/line/entry information for a PC.
    
    Reviewed-on: https://go-review.googlesource.com/31150

From-SVN: r241172
2016-10-14 17:20:40 +00:00
Ian Lance Taylor d2c4425e86 debug/elf: add sparc64 relocations
This is a backport of https://go-review.googlesource.com/30870.
    
    Reviewed-on: https://go-review.googlesource.com/30916

From-SVN: r241171
2016-10-14 17:16:55 +00:00
Ian Lance Taylor 238fc3441c runtime: copy cpuprof code from Go 1.7 runtime
This replaces runtime/cpuprof.goc with go/runtime/cpuprof.go and adjusts
    the supporting code in runtime/proc.c.
    
    This adds another case where the compiler needs to avoid heap allocation
    in the runtime package: when evaluating a method expression into a
    closure.  Implementing this required moving the relevant code from
    do_get_backend to do_flatten, so that I could easily add a temporary
    variable.  Doing that let me get rid of Bound_method_expression::do_lower.
    
    Reviewed-on: https://go-review.googlesource.com/31050

From-SVN: r241163
2016-10-14 13:36:35 +00:00
Ian Lance Taylor 58f7dab40d runtime: copy mstats code from Go 1.7 runtime
This replaces mem.go and the C runtime_ReadMemStats function with the Go
    1.7 mstats.go.
    
    The GCStats code is commented out for now.  The corresponding gccgo code
    is in runtime/mgc0.c.
    
    The variables memstats and worldsema are shared between the Go code and
    the C code, but are not exported.  To make this work, add temporary
    accessor functions acquireWorldsema, releaseWorldsema, getMstats (the
    latter known as mstats in the C code).
    
    Check the preemptoff field of m when allocating and when considering
    whether to start a GC.  This works with the new stopTheWorld and
    startTheWorld functions in Go, which are essentially the Go 1.7
    versions.
    
    Change the compiler to stack allocate closures when compiling the
    runtime package.  Within the runtime packages closures do not escape.
    This is similar to what the gc compiler does, except that the gc
    compiler, when compiling the runtime package, gives an error if escape
    analysis shows that a closure does escape.  I added this here because
    the Go version of ReadMemStats calls systemstack with a closure, and
    having that allocate memory was causing some tests that measure memory
    allocations to fail.
    
    Reviewed-on: https://go-review.googlesource.com/30972

From-SVN: r241124
2016-10-13 15:24:50 +00:00
Ian Lance Taylor 80b489ebba syscall: don't use pt_regs in clone_linux.c
It's unnecessary and it reportedly breaks the build on arm64 GNU/Linux.
    
    Reviewed-on: https://go-review.googlesource.com/30978

From-SVN: r241084
2016-10-13 04:19:57 +00:00
Ian Lance Taylor 1ad16c5284 compiler, runtime: copy string code from Go 1.7
Add compiler support for turning concatenating strings into a call to
    a runtime function that takes the appropriate number of arguments.
    
    Rename some local variables in mgc0.c to avoid macros that the new
    rune.go causes to appear in runtime.inc.
    
    Reviewed-on: https://go-review.googlesource.com/30827

From-SVN: r241074
2016-10-12 18:17:52 +00:00
Ian Lance Taylor fa8e596366 syscall: mark rawClone as no_split_stack
Reviewed-on: https://go-review.googlesource.com/30955

From-SVN: r241072
2016-10-12 17:42:49 +00:00
Ian Lance Taylor 543f217b7a runtime: copy Go 1.7 runtime semaphore code
This triggered a check in releaseSudog that g.param not nil, because
    libgo uses the param field when starting a goroutine.  Fixed by clearing
    g->param in kickoff in proc.c.
    
    Reviewed-on: https://go-review.googlesource.com/30951

From-SVN: r241067
2016-10-12 15:38:56 +00:00
Ian Lance Taylor c8dc49fb03 syscall, internal/syscall/unix: Fix getrandom, clone on sparc64
Since sparc is a valid architecture, the name of
    getrandom_linux_sparc.go means that it will be ignored on sparc64,
    even though it's whitelisted with a +build line.
    
    On SPARC, clone has a unique return value convention which requires
    some inline assembly to convert it to the normal convention.
    
    Reviewed-on: https://go-review.googlesource.com/30873

From-SVN: r241051
2016-10-12 14:28:05 +00:00
Ian Lance Taylor 207f844e6e configure: redirect -fsplit-stack compilation to dev/null
Avoid an error message in the middle of the configure output.
    
    Patch by Eric Botcazou.
    
    Reviewed-on: https://go-review.googlesource.com/30813

From-SVN: r240993
2016-10-11 13:13:17 +00:00
Ian Lance Taylor abe08b7d90 Accidentally failed to commit these earlier, as part of:
Update the compiler to use the new names.  Add calls to printlock and
    printunlock around print statements.  Move expression evaluation before
    the call to printlock.  Update g's writebuf field to a slice, and adjust
    C code accordingly.

    Reviewed-on: https://go-review.googlesource.com/30717

From-SVN: r240958
2016-10-11 00:08:35 +00:00
Ian Lance Taylor 65180edc56 runtime: copy print/println support from Go 1.7
Update the compiler to use the new names.  Add calls to printlock and
    printunlock around print statements.  Move expression evaluation before
    the call to printlock.  Update g's writebuf field to a slice, and adjust
    C code accordingly.
    
    Reviewed-on: https://go-review.googlesource.com/30717

From-SVN: r240956
2016-10-10 23:13:39 +00:00
Ian Lance Taylor 5d8c099ede runtime: copy channel code from Go 1.7 runtime
Change the compiler to use the new routines. Drop the separation of
    small and large values when sending on a channel. Allocate the select
    struct on the stack. Remove the old C implementation of channels. Adjust
    the garbage collector for the new data structure.
    
    Bring in part of the tracing code, enough for the channel code to call.
    
    Bump the permitted number of allocations in one of the tests in
    context_test.go. The difference is that now receiving from a channel
    allocates a sudog, which the C code used to simply put on the
    stack. This will be somewhat better when we port proc.go.
    
    Reviewed-on: https://go-review.googlesource.com/30714

From-SVN: r240941
2016-10-10 16:52:09 +00:00
Ian Lance Taylor 95ccd17c61 re PR go/77809 ("_LITTLE_ENDIAN" redefined)
PR go/77809

    libgo: strip most C macros from runtime.inc
    
    The Go runtime package is picking up C macros from runtime_sysinfo.go
    and then re-exporting them to runtime.inc.  This can cause name
    conflicts.  Change the Makefile so that we only put the macros we need
    into runtime.inc.  These are the constants that are actually defined by
    Go code, not runtime_sysinfo.go.  There are only a few, so we can
    pattern match.
    
    This is an additional hack on runtime.inc.  The long term goal is to
    convert the runtime package to Go and eliminate runtime.inc entirely, so
    a few hacks seem acceptable.
    
    Fixes GCC PR 77809.

    Reviewed-on: https://go-review.googlesource.com/30167

From-SVN: r240724
2016-10-03 18:39:54 +00:00
Ian Lance Taylor c0401cf78c runtime: copy internal locking code from Go 1.7 runtime
Remove the old locking code written in C.
    
    Add a shell script mkrsysinfo.sh to generate the runtime_sysinfo.go
    file, so that we can get Go copies of the system time structures and
    other types.
    
    Tweak the compiler so that when compiling the runtime package the
    address operator does not cause local variables to escape.  When the gc
    compiler compiles the runtime, an escaping local variable is treated as
    an error.  We should implement that, instead of this change, when escape
    analysis is turned on.
    
    Tweak the compiler so that the generated C header does not include names
    that start with an underscore followed by a non-upper-case letter,
    except for the special cases of _defer and _panic.  Otherwise we
    translate C types to Go in runtime_sysinfo.go and then generate those Go
    types back as C types in runtime.inc, which is useless and painful for
    the C code.
    
    Change entersyscall and friends to take a dummy argument, as the gc
    versions do, to simplify calls from the shared code.
    
    Reviewed-on: https://go-review.googlesource.com/30079

From-SVN: r240657
2016-09-30 13:45:08 +00:00
Ian Lance Taylor 6748787813 runtime: copy runtime.go and runtime1.go from Go 1.7
Also copy over cputicks.go, env_posix.go, vdso_none.go, stubs2.go, and a
    part of os_linux.go.  Remove the corresponding functions from the C code
    in libgo/go/runtime.  Add some transitional support functions to
    stubs.go.  This converts several minor functions from C to Go.
    
    Reviewed-on: https://go-review.googlesource.com/29962

From-SVN: r240609
2016-09-29 00:56:44 +00:00
Ian Lance Taylor 58920998e3 libgo: fix for runtime/check failure with "-O0 -g"
Tweak the makefile rules for the runtime/check test to
    insure that the runtime package is compiled with
    "-fgo-compiling-runtime". This resolves a test failure
    (unsat on runtime.getcallerpc) when in a build directory where the
    compiler flags have been configured to disable optimization.
    
    Reviewed-on: https://go-review.googlesource.com/30010

From-SVN: r240588
2016-09-28 18:02:40 +00:00
Ian Lance Taylor 14cda8a1cf libgo: separate mksysinfo inputs into separate Makefile targets
This is a step toward a version of mksysinfo that generates information
    for the runtime package.  This will be used to generate the
    runtime_sysinfo.go file, which is currently directly generated by a
    Makefile target.
    
    Reviewed-on: https://go-review.googlesource.com/29683

From-SVN: r240560
2016-09-27 21:32:50 +00:00
Ian Lance Taylor 6465652c87 internal/syscall/unix: add getrandom syscall for MIPS and SPARC
Reviewed-on: https://go-review.googlesource.com/29678

From-SVN: r240457
2016-09-23 21:00:43 +00:00
Ian Lance Taylor 4a2bb7fcb0 compiler, runtime: replace hashmap code with Go 1.7 hashmap
This change removes the gccgo-specific hashmap code and replaces it with
    the hashmap code from the Go 1.7 runtime.  The Go 1.7 hashmap code is
    more efficient, does a better job on details like when to update a key,
    and provides some support against denial-of-service attacks.
    
    The compiler is changed to call the new hashmap functions instead of the
    old ones.
    
    The compiler now tracks which types are reflexive and which require
    updating when used as a map key, and records the information in map type
    descriptors.
    
    Map_index_expression is simplified.  The special case for a map index on
    the right hand side of a tuple expression has been unnecessary for some
    time, and is removed.  The support for specially marking a map index as
    an lvalue is removed, in favor of lowering an assignment to a map index
    into a function call.  The long-obsolete support for a map index of a
    pointer to a map is removed.
    
    The __go_new_map_big function (known to the compiler as
    Runtime::MAKEMAPBIG) is no longer needed, as the new runtime.makemap
    function takes an int64 hint argument.
    
    The old map descriptor type and supporting expression is removed.
    
    The compiler was still supporting the long-obsolete syntax `m[k] = 0,
    false` to delete a value from a map.  That is now removed, requiring a
    change to one of the gccgo-specific tests.
    
    The builtin len function applied to a map or channel p is now compiled
    as `p == nil ? 0 : *(*int)(p)`.  The __go_chan_len function (known to
    the compiler as Runtime::CHAN_LEN) is removed.
    
    Support for a shared zero value for maps to large value types is
    introduced, along the lines of the gc compiler.  The zero value is
    handled as a common variable.
    
    The hash function is changed to take a seed argument, changing the
    runtime hash functions and the compiler-generated hash functions.
    Unlike the gc compiler, both the hash and equal functions continue to
    take the type length.
    
    Types that can not be compared now store nil for the hash and equal
    functions, rather than pointing to functions that throw.  Interface hash
    and comparison functions now check explicitly for nil.  This matches the
    gc compiler and permits a simple implementation for ismapkey.
    
    The compiler is changed to permit marking struct and array types as
    incomparable, meaning that they have no hash or equal function.  We use
    this for thunk types, removing the existing special code to avoid
    generating hash/equal functions for them.
    
    The C runtime code adds memclr, memequal, and memmove functions.
    
    The hashmap code uses go:linkname comments to make the functions
    visible, as otherwise the compiler would discard them.
    
    The hashmap code comments out the unused reference to the address of the
    first parameter in the race code, as otherwise the compiler thinks that
    the parameter escapes and copies it onto the heap.  This is probably not
    needed when we enable escape analysis.
    
    Several runtime map tests that ere previously skipped for gccgo are now
    run.
    
    The Go runtime picks up type kind information and stubs.  The type kind
    information causes the generated runtime header file to define some
    constants, including `empty`, and the C code is adjusted accordingly.
    
    A Go-callable version of runtime.throw, that takes a Go string, is
    added to be called from the hashmap code.
    
    Reviewed-on: https://go-review.googlesource.com/29447

	* go.go-torture/execute/map-1.go: Replace old map deletion syntax
	with call to builtin delete function.

From-SVN: r240334
2016-09-21 20:58:51 +00:00
Ian Lance Taylor 321f72a231 syscall: build export_unix_test.go on solaris
Patch from Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/29436

From-SVN: r240285
2016-09-20 18:26:55 +00:00
Ian Lance Taylor b276eda4b4 re PR go/77642 (GO Bootstrap fail starting with r239872 splitstack signature does not match)
PR go/77642

    runtime: pass correct type to __splitstack_find
    
    The code was passing uintptr* to a function that expected size_t*.
    
    Based on patch by Andreas Krebbel.
    
    Fixes GCC PR 77642.
    
    Reviewed-on: https://go-review.googlesource.com/29433

From-SVN: r240275
2016-09-20 16:48:19 +00:00
Ian Lance Taylor f6c7d678f8 libgo: fix typo in configure.ac (PCQUANTUm -> PCQUANTUM)
Reviewed-on: https://go-review.googlesource.com/29154

From-SVN: r240146
2016-09-14 20:52:51 +00:00
Ian Lance Taylor a846424359 runtime/internal/sys: new package, API copied from Go 1.7
Copy over the Go 1.7 runtime/internal/sys package, but instead of having
    separate files for each GOARCH and GOOS value, set the values in
    configure.ac and write them out in Makefile.am.  Setting the values in
    configure.ac should make it easier to add new processors.
    
    Remove the automake GOARCH conditionals, which are no longer used.
    Leave the GOOS conditionals for now, as they are used for the C runtime
    package.
    
    Reviewed-on: https://go-review.googlesource.com/29018

From-SVN: r240083
2016-09-11 13:23:27 +00:00
Ian Lance Taylor af4b8a5233 libgo: update to Go 1.7.1 release
Reviewed-on: https://go-review.googlesource.com/29012

From-SVN: r240071
2016-09-10 13:14:00 +00:00
Ian Lance Taylor 337fa50b7b runtime/internal/atomic: new package, API copied from Go 1.7
Copy over the Go 1.7 runtime/internal/atomic package, but implement the
    functions in C using __atomic functions rather than using the
    processor-specific assembler code.
    
    Reviewed-on: https://go-review.googlesource.com/29010

From-SVN: r240070
2016-09-10 12:21:59 +00:00
Ian Lance Taylor ac376b15df runtime: use alignof to check alignment of ucontext_t
Use alignof rather than assuming a 16 byte alignment.
    
    Reviewed-on: https://go-review.googlesource.com/28913

From-SVN: r240047
2016-09-09 16:39:44 +00:00
Ian Lance Taylor a9ca0a9d02 runtime: remove remaining use of MAKECONTEXT_STACK_TOP macro
The definition and most uses of MAKECONTEXT_STACK_TOP were removed in
    https://golang.org/cl/88660043, which removed support for Solaris 8/9.
    One use of MAKECONTEXT_STACK_TOP was accidentally left in the source
    code.  Remove it now.
    
    Reviewed-on: https://go-review.googlesource.com/28911

From-SVN: r240045
2016-09-09 14:00:43 +00:00
Ian Lance Taylor 6f02c13813 runtime: align ucontext_t argument to 16 byte boundary
Some systems, such as ia64 and PPC, require that a ucontext_t pointer
    passed to getcontext and friends be aligned to a 16-byte boundary.
    Currently the ucontext_t fields in the g structure are defined in Go,
    and Go has no way to ensure a 16-byte alignment for a struct field.
    The fields are currently represented by an array of unsafe.Pointer.
    Enforce the alignment by making the array larger, and picking an offset
    into the array that is 16-byte aligned.
    
    Reviewed-on: https://go-review.googlesource.com/28910

From-SVN: r240044
2016-09-09 13:31:49 +00:00
Ian Lance Taylor fc4eaccf10 runtime: make gsignal stack at least SIGSTKSZ bytes
The default stack size for the gsignal goroutine, 32K, is not enough on
    ia64.  Make sure that the stack size is at least SIGSTKSZ.
    
    Reviewed-on: https://go-review.googlesource.com/28224

From-SVN: r239894
2016-08-31 13:59:03 +00:00
Ian Lance Taylor 75791bab05 runtime: use -fgo-c-header to build C header file
Use the new -fgo-c-header option to build a header file for the Go
    runtime code in libgo/go/runtime, and use the new header file in the C
    runtime code in libgo/runtime.  This will ensure that the Go code and C
    code share the same data structures as we convert the runtime from C to
    Go.
    
    The new file libgo/go/runtime/runtime2.go is copied from the Go 1.7
    release, and then edited to remove unnecessary data structures and
    modify others for use with libgo.
    
    The new file libgo/go/runtime/mcache.go is an initial version of the
    same files in the Go 1.7 release, and will be replaced by the Go 1.7
    file when we convert to the new memory allocator.
    
    The new file libgo/go/runtime/type.go describes the gccgo version of the
    reflection data structures, and replaces the Go 1.7 runtime file which
    describes the gc version of those structures.
    
    Using the new header file means changing a number of struct fields to
    use Go naming conventions (that is, no underscores) and to rename
    constants to have a leading underscore so that they are not exported
    from the Go package.  These names were updated in the C code.
    
    The C code was also changed to drop the thread-local variable m, as was
    done some time ago in the gc sources.  Now the m field is always
    accessed using g->m, where g is the single remaining thread-local
    variable.  This in turn required some adjustments to set g->m correctly
    in all cases.
    
    Also pass the new -fgo-compiling-runtime option when compiling the
    runtime package, although that option doesn't do anything yet.
    
    Reviewed-on: https://go-review.googlesource.com/28051

From-SVN: r239872
2016-08-30 21:07:47 +00:00
Ian Lance Taylor 87155d4f6c cmd/go: ignore errors from go/build for standard packages
The go/build package does not know that gccgo's standard packages don't
    have source, and will report an error saying that it can not find them.
    Work around that in the cmd/go sources, since the go/build sources don't
    currently have a list of standard packages.
    
    This should get a real fix in the master sources, somehow.
    
    Fixes golang/go#16701.
    
    Reviewed-on: https://go-review.googlesource.com/27052

From-SVN: r239486
2016-08-15 18:05:24 +00:00
Ian Lance Taylor 82b709f9c4 libgo: don't unset in shell script
Reportedly ksh fails to unset a variable that was not previously set.
    Change match.sh and gotest to not unset LANG, but instead set LANG=C.
    Also don't combine exporting and setting variable in a single statement.
    
    Reviewed-on: https://go-review.googlesource.com/26999

From-SVN: r239443
2016-08-13 02:52:42 +00:00
Ian Lance Taylor 237673d052 crypto/aes, hash/crc32: ignore s390x specific files for now
These files are used to select s390x assembler support in the gc
    toolchain.  We don't currently have that support, as it is written in
    the cmd/asm syntax rather than gas syntax.  Mark the files to be ignored
    for now, falling back to the default implementations.
    
    Patch by Andreas Krebbel.
    
    Reviewed-on: https://go-review.googlesource.com/26994

From-SVN: r239442
2016-08-13 00:19:56 +00:00
Ian Lance Taylor 7159824eb3 syscall: remove exec_solaris_test.go
It is testing functionality that gccgo does not need and does not
    support.
    
    Reviewed-on: https://go-review.googlesource.com/26992

From-SVN: r239438
2016-08-13 00:14:19 +00:00
Ian Lance Taylor 3d0fa95d5c os: fix build tags for dir_regfile.go
We want to build dir_regfile.go if not GNU/linux, and not solaris/386,
    and not solaris/sparc.  The latter two conditions were incorrect.  To
    write ! solaris/386 we have to write !solaris !386.  I forgot De
    Morgan's Law.
    
    Reviewed-on: https://go-review.googlesource.com/26870

From-SVN: r239393
2016-08-11 21:36:13 +00:00
Ian Lance Taylor bbc824cd56 mksysinfo.sh: always define CLONE_NEWNET
CLONE_NEWNET is needed to compile the syscall tests on GNU/Linux.
    The symbol is not defined in the CentOS 5.11 header files.
    
    Patch from Uros Bizjak.
    
    Reviewed-on: https://go-review.googlesource.com/26630

From-SVN: r239296
2016-08-09 16:38:23 +00:00
Ian Lance Taylor 0717bdbfbd text/template: reduce maxExecDepth for gccgo further
We already lowered the limit of recursive template invocations from
    100,000 to 10,000, but the tests still fail occasionally on
    x86_64-pc-linux-gnu when using GNU ld (so that split stacks are not
    fully functional).  Reduce the limit further, to 1000, enough so that
    the test passes consistently.
    
    Permitting 1000 recursive template invocations still seems capacious
    enough for real world use.
    
    Reviewed-on: https://go-review.googlesource.com/25590

From-SVN: r239261
2016-08-08 22:55:29 +00:00
Ian Lance Taylor b123572d81 libgo: don't have .lo depend on .lo.dep
Having each .lo depend on the corresponding .lo.dep caused too many
    rebuilds, because the .lo.dep files are rebuilt when Makefile changes.
    Instead, if the .lo.dep file changes, remove the .lo file.
    
    Reviewed-on: https://go-review.googlesource.com/25588

From-SVN: r239258
2016-08-08 21:23:57 +00:00
Ian Lance Taylor 9a7b016159 testsuite: fix gotest for absolute srcdir
The recent changes to Makefile.am mean that if you configure with an
    absolute path as srcdir then gotest will be invoked with absolute paths
    for the files.  That case never worked.  This patch fixes it.
    
    Reviewed-on: https://go-review.googlesource.com/25587

From-SVN: r239256
2016-08-08 20:34:05 +00:00
Ian Lance Taylor f432d1282d re PR go/72814 (reflect FAILs on 32-bit Solaris/SPARC: SIGILL)
PR go/72814

    runtime: treat zero-sized result value as void
    
    Change the FFI interface to treat a call to a function that returns a
    zero-sized result as a call to a function that returns void.
    
    This is part of the fix for https://gcc.gnu.org/PR72814.  On 32-bit
    SPARC systems, a call to a function that returns a non-zero-sized struct
    is followed by an unimp instruction that describes the size of the
    struct.  The function returns to the address after the unimp
    instruction.  The libffi library can not represent a zero-sized struct,
    so we wind up treating it as a 1-byte struct.  Thus in that case libffi
    calls the function with an unimp instruction, but the function does not
    adjust the return address.  The result is that the program attempts to
    execute the unimp instruction, causing a crash.
    
    This is part of a change that fixes the crash by treating all functions
    that return zero bytes as functions that return void.
    
    Reviewed-on: https://go-review.googlesource.com/25585

	* go-gcc.cc (Gcc_backend::function_type): If the return type is
	zero bytes, treat the function as returning void.
	(return_statement): If the return type is zero bytes, don't
	actually return any values.

From-SVN: r239252
2016-08-08 19:53:44 +00:00
Ian Lance Taylor 4f8e688afc internal/syscall/unix: fix syscalls for alpha, ia64, s390
Also change the configure script to set GOARCH correctly for ia64, and
    add ia64 as a processor to match.sh and gotest.
    
    Reviewed-on: https://go-review.googlesource.com/25549

From-SVN: r239225
2016-08-07 22:32:46 +00:00
Ian Lance Taylor 851e6c6a8e libgo: fix getrandom build for 32-bit ppc
Add a ppc build constraint for internal/syscall/unix.
    
    Reviewed-on: https://go-review.googlesource.com/25547

From-SVN: r239210
2016-08-06 15:58:22 +00:00
Ian Lance Taylor e0f69f36ea libgo: change build procedure to use build tags
Previously the libgo Makefile explicitly listed the set of files to
    compile for each package.  For packages that use build tags, this
    required a lot of awkward automake conditionals in the Makefile.
    
    This CL changes the build to look at the build tags in the files.
    The new shell script libgo/match.sh does the matching.  This required
    adjusting a lot of build tags, and removing some files that are never
    used.  I verified that the exact same sets of files are compiled on
    amd64 GNU/Linux.  I also tested the build on i386 Solaris.
    
    Writing match.sh revealed some bugs in the build tag handling that
    already exists, in a slightly different form, in the gotest shell
    script.  This CL fixes those problems as well.
    
    The old code used automake conditionals to handle systems that were
    missing strerror_r and wait4.  Rather than deal with those in Go, those
    functions are now implemented in runtime/go-nosys.c when necessary, so
    the Go code can simply assume that they exist.
    
    The os testsuite looked for dir_unix.go, which was never built for gccgo
    and has now been removed.  I changed the testsuite to look for dir.go
    instead.
    
    Reviewed-on: https://go-review.googlesource.com/25546

From-SVN: r239189
2016-08-06 00:36:33 +00:00
Ian Lance Taylor e91f59b919 runtime: fix incorrectly commented out code in heapdump.c
Reviewed-on: https://go-review.googlesource.com/25490

From-SVN: r239144
2016-08-04 17:21:23 +00:00
Ian Lance Taylor aa8a418bbc text/template: reduce maxExecDepth for gccgo
When using gccgo on systems without full support for split stacks a
    recursive template can overrun the available stack space.  Reduce the
    limit from 100000 to 10000 to make this less likely.  It's still high
    enough that real uses will work.
    
    Reviewed-on: https://go-review.googlesource.com/25467

From-SVN: r239141
2016-08-04 16:48:28 +00:00
Ian Lance Taylor 9c26dfd08a gotest: multiple +build lines must all be true
The code that handled +build lines did not correctly require them to all
    be true.  While looking into this I discovered that multiple +build
    lines were mishandled in a different way, because the shell does not
    preseve line breaks in backquoted data.  Look for the +build token to
    tell us when we are switching from one +build line to another.
    
    Reviewed-on: https://go-review.googlesource.com/25460

From-SVN: r239100
2016-08-03 22:46:06 +00:00
Ian Lance Taylor c5fe5e8032 libgo: bump library version number for 1.7
Reviewed-on: https://go-review.googlesource.com/25211

From-SVN: r238743
2016-07-26 01:53:27 +00:00
Ian Lance Taylor 870e8ca5a7 os/user: fix Solaris declaration.
Patch from Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/25210

From-SVN: r238742
2016-07-26 01:38:33 +00:00
Ian Lance Taylor 22b955cca5 libgo: update to go1.7rc3
Reviewed-on: https://go-review.googlesource.com/25150

From-SVN: r238662
2016-07-22 18:15:38 +00:00
Ian Lance Taylor a38f74e823 cmd/go: bring in final version of gccgo pkg-config support
This updates gccgo to the final version of https://golang.org/cl/18790,
    by Michael Hudson-Doyle.
    
    Update golang/go#11739.
    
    Reviewed-on: https://go-review.googlesource.com/22400

From-SVN: r235380
2016-04-23 00:41:03 +00:00
Ian Lance Taylor 88b5d499b5 libgo: update to Go 1.6.1 release
Reviewed-on: https://go-review.googlesource.com/22007

From-SVN: r234958
2016-04-13 19:11:16 +00:00
Ian Lance Taylor d90936ff88 reflect: change Value.Call results to not be addressable
Leaving them incorrectly marked as addressable broke a use of the
    text/template package, because state.evalField checks CanAddr and takes
    the address if it is addressable.
    
    Reviewed-on: https://go-review.googlesource.com/21908

From-SVN: r234923
2016-04-12 22:20:30 +00:00
Ian Lance Taylor bb72703282 runtime: Use atomic load for in entersyscall.
Reportedly fixes PPC64 deadlock.
    
    From a comment by Gabriel Russell.
    
    Fixes golang/go#15051.
    
    Reviewed-on: https://go-review.googlesource.com/21450

From-SVN: r234694
2016-04-02 00:47:53 +00:00
Ian Lance Taylor 6b2cd37bd9 re PR go/69966 (libgo: Port syscall.SetsockoptUcred from golang)
PR go/69966
    syscall: Add new Getsockopt functions.
    
    Add GetsockoptICMPv6Filter, GetsockoptIPv6MTUInfo, GetsockoptUcred as
    appropriate.  These functions exist in the master library.
    
    For GCC PR 69966.

    Reviewed-on: https://go-review.googlesource.com/19960

From-SVN: r233747
2016-02-26 17:36:00 +00:00
Ian Lance Taylor 4501d9ad44 runtime: lock M during cgo call
cgo should lock the M.
    
    
    See also https://golang.org/cl/18882 .
    
    Reviewed-on: https://go-review.googlesource.com/18883

From-SVN: r233670
2016-02-24 15:03:04 +00:00
Ian Lance Taylor 43414a5dd3 libgo: Update to final Go 1.6 release.
Reviewed-on: https://go-review.googlesource.com/19592

From-SVN: r233515
2016-02-18 05:56:46 +00:00
Ian Lance Taylor 54c9c975f1 runtime: For c-archive/c-shared, install signal handlers synchronously.
This is a port of https://golang.org/cl/18150 to the gccgo runtime.
    
    The previous behaviour of installing the signal handlers in a separate
    thread meant that Go initialization raced with non-Go initialization if
    the non-Go initialization also wanted to install signal handlers.  Make
    installing signal handlers synchronous so that the process-wide behavior
    is predictable.
    
    Reviewed-on: https://go-review.googlesource.com/19494

From-SVN: r233393
2016-02-12 22:10:09 +00:00
Ian Lance Taylor 931f434a72 re PR go/66904 (cmd/go: "#cgo pkg-config:" comments do not work with gccgo)
PR go/66904
    cmd/go: fix "#cgo pkg-config:" comments with gccgo
    
    Copy of https://golang.org/cl/18790 by Michael Hudson-Doyle.
    
    The unique difficulty of #cgo pkg-config is that the linker flags are recorded
    when the package is compiled but (obviously) must be used when the package is
    linked into an executable -- so the flags need to be stored on disk somewhere.
    As it happens cgo already writes out a _cgo_flags file: nothing uses it
    currently, but this change adds it to the lib$pkg.a file when compiling a
    package, reads it out when linking (and passes a version of the .a file with
    _cgo_flags stripped out of it to the linker). It's all fairly ugly but it works
    and I can't really think of any way of reducing the essential level of
    ugliness.
    
    Update golang/go#11739.
    GCC PR 66904.

    Reviewed-on: https://go-review.googlesource.com/19431

From-SVN: r233290
2016-02-10 18:30:27 +00:00
Ian Lance Taylor de24ed7803 re PR go/69511 (G.gcstack_size uses uintptr instead of size_t)
PR go/69511
    runtime: change G gcstack_size field to size_t
    
    Because its address is passed to __splitstack_find, which expects size_t*.
    
    From Dominik Vogt in GCC PR 69511.
    
    Reviewed-on: https://go-review.googlesource.com/19429

From-SVN: r233260
2016-02-10 02:16:04 +00:00
Ian Lance Taylor cc240aa7d1 re PR go/69357 (libgo refers to _end in a non-weak way)
PR go/69537
    runtime: Don't refer to _end symbol in shared library.
    
    Fixes GCC PR 69357.
    
    Reviewed-on: https://go-review.googlesource.com/19362

From-SVN: r233235
2016-02-09 00:34:55 +00:00
Ian Lance Taylor d5bc1c65ef libgo: bump version number for upgrade to 1.6rc1
Reviewed-on: https://go-review.googlesource.com/19233

From-SVN: r233156
2016-02-04 22:54:20 +00:00
Ian Lance Taylor f98dd1a338 libgo: Update to go1.6rc1.
Reviewed-on: https://go-review.googlesource.com/19200

From-SVN: r233110
2016-02-03 21:58:02 +00:00
Ian Lance Taylor 06caa02ccf compiler, runtime: mark stub methods, ignore them in runtime.Caller.
This fixes the long-standing bug in which the testing package misreports
    the file/line of an error.
    
    Reviewed-on: https://go-review.googlesource.com/19179

From-SVN: r233098
2016-02-03 06:54:41 +00:00
Ian Lance Taylor de41ebf5dd re PR go/68980 (ps -o cmd in gotest isn't portable)
PR 68980
    libgo/testsuite: portable ps usage in gotest
    
    gotest is using "ps" to list descendant sleep
    processes in its timeout handling, grepping
    the command name.
    
    We are currently using the "cmd" ps output
    formatter, which is non-portable. We should
    use "comm" which is part of the POSIX
    standard, and outputs only the command name
    and not the arguments.
    
    Fixes https://gcc.gnu.org/PR68980
    
    Reviewed-on: https://go-review.googlesource.com/18426

From-SVN: r232234
2016-01-11 17:55:39 +00:00
Ian Lance Taylor 474c8a0757 syscall: Add definition for NLA_HDRLEN
This change updates mksysinfo.sh so it correctly
    includes the define NLA_HDRLEN in the syscall package.
    
    Fixes golang/go/#13629
    
    Reviewed-on: https://go-review.googlesource.com/17893

From-SVN: r231796
2015-12-18 01:15:37 +00:00
Ian Lance Taylor ae026741df re PR go/61303 (gccgo: segfault, regression since 4.8.2)
PR go/61303
    runtime: don't overallocate in select code
    
    If we've already allocated an fd_set, don't allocate another one.
    
    Also, don't bother to read from rdwake if it wasn't returned in select.
    
    Fixes https://gcc.gnu.org/PR61303.
    
    Reviewed-on: https://go-review.googlesource.com/17243

From-SVN: r230922
2015-11-26 00:24:21 +00:00
Ian Lance Taylor 8c61286797 re PR go/68496 ([libgo] reflect test fails on Linux x86-64)
PR go/68496
    reflect: Allocate space for FFI functions returning a zero-sized type.
    
    The libffi library does not understand zero-sized types.  We represent
    them as a struct with a single field of type void.  If such a type is
    returned from a function, libffi will copy 1 byte of data.  Allocate
    space for that byte, although we won't use it.
    
    Fixes https://gcc.gnu.org/PR68496.

    Reviewed-on: https://go-review.googlesource.com/17175

From-SVN: r230776
2015-11-23 21:17:45 +00:00
Ian Lance Taylor 3b29389671 re PR go/66378 (libgo syscall.Sendfile() does not honor/use offset argument)
PR go/66378
    syscall: Fix initial offset value in syscall.Sendfile.
    
    Bug reported in https://gcc.gnu.org/PR66378.
    
    Reviewed-on: https://go-review.googlesource.com/17159

From-SVN: r230699
2015-11-21 04:43:50 +00:00
Ian Lance Taylor eaa7bc3388 re PR go/65785 (libgo TestIPv4MulticastListener test fails on machine with no network connection)
PR go/65785
    net: don't run multicast listen test on nil interface in short mode
    
    This is a backport of https://golang.org/cl/17154.
    
    The gccgo bug report https://gcc.gnu.org/PR65785 points out that the
    multicast listen tests will use the network even with -test.short.
    Fix test by checking testing.Short with a nil interface.
    
    Reviewed-on: https://go-review.googlesource.com/17158

From-SVN: r230695
2015-11-21 01:41:24 +00:00
Ian Lance Taylor bbbe8b338b re PR go/66574 (Time is provided in millisecond precision instead of nanoseconds as described in go documentation)
PR go/66574
    runtime: Use clock_gettime to get current time.
    
    Fetch the current time in nanoseconds, not microseconds, by using
    clock_gettime rather than gettimeofday.
    
    Update golang/go#11222.
    
    Fixes https://gcc.gnu.org/PR66574.
    
    Reviewed-on: https://go-review.googlesource.com/17156

From-SVN: r230694
2015-11-21 01:27:44 +00:00
Ian Lance Taylor 4944c7791b re PR go/68072 (malformed DWARF TagVariable entry)
PR go/68072
    cmd/cgo: ignore vars with no name or type if they have a AttrSpecification
    
    Backport of master CL https://golang.org/cl/17151.
    
    Fixes https://gcc.gnu.org/PR/68072.
    
    Reviewed-on: https://go-review.googlesource.com/17152

From-SVN: r230685
2015-11-20 22:48:47 +00:00
Ian Lance Taylor dcfa3345eb cmd: Use correct install tool dir with gccgo
When using the go command built from gccgo to build and
    install a go tool, use the value from runtime GCCGOTOOLDIR as
    the install directory.
    
    This also fixes the output from 'go tool' when used with the
    gccgo-built go command, to only include the go tools and not
    other binaries found in the same directory.
    
    Reviewed-on: https://go-review.googlesource.com/16516

From-SVN: r230677
2015-11-20 21:30:16 +00:00
Ian Lance Taylor 88cf4de8b7 libgo: use Solaris sendfile lib, fix Solaris _in6_addr_t fields
Before Solaris 12 the sendfile function is found in -lsendfile, so look
    for it there.
    
    Solaris 12 adds some more types that use _in6_addr_t, that need to be
    edited in mksysinfo.
    
    Patch by Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/16779

From-SVN: r230132
2015-11-10 21:38:30 +00:00
Ian Lance Taylor ea5c200338 re PR go/68255 (cgo-generated constructor not being called)
PR go/68255
    cmd/go: always use --whole-archive for gccgo packages
    
    This is a backport of https://golang.org/cl/16775.
    
    This is, in effect, what the gc toolchain does.  It fixes cases where Go
    code refers to a C global variable; without this, if the global variable
    was the only thing visible in the C code, the generated cgo file might
    not get pulled in from the archive, leaving the Go variable
    uninitialized.
    
    This was reported against gccgo as https://gcc.gnu.org/PR68255 .
    
    Reviewed-on: https://go-review.googlesource.com/16778

From-SVN: r230120
2015-11-10 20:31:11 +00:00
Ian Lance Taylor f5eb9a8ec6 re PR go/66138 (json decoder Decode function fails for some structure return values)
PR go/66138
    reflect, encoding/json, encoding/xml: fix unexported embedded structs
    
    Bring in three changes from the master Go repository.  These changes
    will be in Go 1.6, but they are appropriate for gccgo now because they
    resolve a long-standing discrepancy between how gc and gccgo handle the
    PkgPath field for embedded unexported struct fields.  The core issue is
    described at https://golang.org/cl/7247.  This has been reported against
    gccgo as https://gcc.gnu.org/PR66138.
    
    The three changes being brought over are:
    
    https://golang.org/cl/14010
    
    reflect: adjust access to unexported embedded structs
    
    This CL changes reflect to allow access to exported fields and
    methods in unexported embedded structs for gccgo and after gc
    has been adjusted to disallow access to embedded unexported structs.
    
    Adresses #12367, #7363, #11007, and #7247.
    
    https://golang.org/cl/14011
    
    encoding/json: check for exported fields in embedded structs
    
    Addresses issue #12367.
    
    https://golang.org/cl/14012
    
    encoding/xml: check for exported fields in embedded structs
    
    Addresses issue #12367.
    
    Reviewed-on: https://go-review.googlesource.com/16723

From-SVN: r229907
2015-11-07 01:24:57 +00:00
Ian Lance Taylor 9da92cbda9 libgo: Solaris portability fixes.
Only build net/hook_cloexec.go on GNU/Linux and FreeBSD, because those
    are the only systems with accept4.
    
    Add syscall/libcall_bsd.go to define sendfile for *BSD and Solaris.
    
    Revert tcpsockopt_solaris.go back to the earlier version, so that it
    works on Solaris 10.
    
    Always pass the address of a Pid_t value to TIOCGPGRP and TIOCSPGRP.
    
    Include <unistd.h> in runtime/go-varargs.c.
    
    Reviewed-on: https://go-review.googlesource.com/16719

From-SVN: r229880
2015-11-06 19:15:45 +00:00
Ian Lance Taylor aa3ba34fba gotest: fix handling of --goarch option
I managed to add a new --goarch option to gotest without noticing that
    the script already had one.  Worse, they set different variables.
    Remove the old option in favor of the new one.
    
    Reviewed-on: https://go-review.googlesource.com/16613

From-SVN: r229734
2015-11-04 01:52:40 +00:00
Ian Lance Taylor 7372dfe4bb mksysinfo.sh: Make sure that CLONE_NEWUSER is defined.
Reviewed-on: https://go-review.googlesource.com/16588

From-SVN: r229711
2015-11-03 15:07:47 +00:00
Ian Lance Taylor 09df499401 libgo: Bump version number.
Reviewed-on: https://go-review.googlesource.com/16583

From-SVN: r229686
2015-11-02 23:30:21 +00:00
Ian Lance Taylor c5f6dbf60d mksysinfo.sh: Handle TIOCGPGRP if too complex for -dump-go-spec.
Reviewed-on: https://go-review.googlesource.com/16580

From-SVN: r229676
2015-11-02 20:23:09 +00:00
Ian Lance Taylor ec3838a735 syscall: Change raw_ioctl cmd type to uintptr.
Attempt to fix a build bug report:
    
    ../../../../libgo/go/syscall/exec_linux.go:185:37: error: integer constant overflow
       _, err1 = raw_ioctl_ptr(sys.Ctty, TIOCSPGRP, unsafe.Pointer(&pgrp))
    
    Reviewed-on: https://go-review.googlesource.com/16539

From-SVN: r229674
2015-11-02 19:58:15 +00:00
Ian Lance Taylor 1c47a3bfa3 mksysinfo.sh: Handle TIOCSPGRP if too complex for -fdump-go-spec.
Reviewed-on: https://go-review.googlesource.com/16534

From-SVN: r229645
2015-11-01 20:51:23 +00:00
Ian Lance Taylor 2b193803d7 runtime: If no split stacks, allocate stacks using mmap on 64-bit systems.
When not using split stacks, libgo allocate large stacks for each
    goroutine.  On a 64-bit system, libgo allocates a maximum of 128G for
    the Go heap, and allocates 4M for each stack.  When the stacks are
    allocated from the Go heap, the result is that a program can only create
    32K goroutines, which is not enough for an active Go server.  This patch
    changes libgo to allocate the stacks using mmap directly, rather than
    allocating them out of the Go heap.  This change is only done for 64-bit
    systems when not using split stacks.  When using split stacks, the
    stacks are allocated using mmap directly anyhow.  On a 32-bit system,
    there is no maximum size for the Go heap, or, rather, the maximum size
    is the available address space anyhow.
    
    Reviewed-on: https://go-review.googlesource.com/16531

From-SVN: r229636
2015-10-31 23:48:19 +00:00
Ian Lance Taylor b9702967ee libgo: Update from Go 1.5 to Go 1.5.1.
Reviewed-on: https://go-review.googlesource.com/16527

From-SVN: r229624
2015-10-31 15:23:52 +00:00
Ian Lance Taylor af146490bb runtime: Remove now unnecessary pad field from ParFor.
It is not needed due to the removal of the ctx field.
    
    Reviewed-on: https://go-review.googlesource.com/16525

From-SVN: r229616
2015-10-31 00:59:47 +00:00
Ian Lance Taylor f4a513a98e compiler, reflect, runtime: remove zero field from type descriptor
Type descriptors picked up a zero field because the gc map
    implementation used it.  However, it's since been dropped by the gc
    library.  It was never used by gccgo.  Drop it now in preparation for
    upgrading to the Go 1.5 library.
    
    Reviewed-on: https://go-review.googlesource.com/16486

From-SVN: r229546
2015-10-29 18:14:50 +00:00
Ian Lance Taylor 730f6d1425 compiler, runtime: change type hash/equal to Go funcs
Change the type descriptor hash and equal functions from C code pointers
    to Go func values.  This permits them to be set to a Go function
    closure.  This is in preparation for the Go 1.5, so that we can use a
    closure for the hash/equal functions returned by the new reflect.ArrayOf
    function.
    
    Reviewed-on: https://go-review.googlesource.com/16485

From-SVN: r229541
2015-10-29 17:14:51 +00:00
David Malcolm 9e531d3749 Testsuite: add dg-{begin|end}-multiline-output commands
This patch adds an easy way to write tests for expected multiline
output.  For example we can test carets and underlines for
a particular diagnostic with:

/* { dg-begin-multiline-output "" }
 typedef struct _GMutex GMutex;
                ^~~~~~~
   { dg-end-multiline-output "" } */

multiline.exp is used by prune.exp; hence we need to load it before
prune.exp via *load_gcc_lib* for the testsuites of the various
non-"gcc" support libraries (e.g. boehm-gc).

gcc/testsuite/ChangeLog:
	* lib/multiline.exp: New file.
	* lib/prune.exp: Load multiline.exp.
	(prune_gcc_output): Call into multiline.exp to handle any
	multiline output directives.
	* lib/libgo.exp: Load multiline.exp before prune.exp, using
	load_gcc_lib.

boehm-gc/ChangeLog:
	* testsuite/lib/boehm-gc.exp: Load multiline.exp before
	prune.exp, using load_gcc_lib.

libatomic/ChangeLog:
	* testsuite/lib/libatomic.exp: Load multiline.exp before
	prune.exp, using load_gcc_lib.

libgomp/ChangeLog:
	* testsuite/lib/libgomp.exp: Load multiline.exp before prune.exp,
	using load_gcc_lib.

libitm/ChangeLog:
	* testsuite/lib/libitm.exp: Load multiline.exp before prune.exp,
	using load_gcc_lib.

libvtv/ChangeLog:
	* testsuite/lib/libvtv.exp: Load multiline.exp before prune.exp,
	using load_gcc_lib.

From-SVN: r228655
2015-10-09 13:55:23 +00:00
Ian Lance Taylor 0786e1fe86 re PR go/67874 (fd_unix.go does not build when there is fcntl64 and no fcntl syscall)
PR go/67874
    net, runtime: Call C library fcntl function rather than syscall.Syscall.
    
    Not all systems define a fcntl syscall; some only have fcntl64.
    
    Fixes GCC PR go/67874.
    
    Reviewed-on: https://go-review.googlesource.com/15497

From-SVN: r228576
2015-10-07 17:22:08 +00:00
Ian Lance Taylor 055db850c6 runtime: Fix recent lfstack change on Solaris.
Reviewed-on: https://go-review.googlesource.com/14922

From-SVN: r228087
2015-09-24 13:33:20 +00:00
Ian Lance Taylor 9f59bddfbf re PR go/67695 (Please improve POSIX shell compatibility of libgo/mksysinfo.sh)
PR go/67695
    mksysinfo.sh: Use = with test rather than ==.
    
    Fixes GCC PR 67695.

    Reviewed-on: https://go-review.googlesource.com/14858

From-SVN: r228064
2015-09-23 20:43:46 +00:00
Ian Lance Taylor 46efdbbc01 runtime: rewrite lfstack packing/unpacking to look more like that in Go
Reviewed-on: https://go-review.googlesource.com/13037

From-SVN: r228057
2015-09-23 17:07:15 +00:00
Ian Lance Taylor a2bf11d16a libgo: If compiler can split-stack and linker can not, use -fno-split-stack.
If the compiler supports split-stack but we are using a gold linker that
    does not, as happens on PPC with current GCC but old gold, then we need
    to compile the Go code with -fno-split-stack to avoid a linker error
    avoid the inability to call from split-stack code to non-split-stack
    code.
    
    Reviewed-on: https://go-review.googlesource.com/14598

From-SVN: r227811
2015-09-15 21:15:37 +00:00
Ian Lance Taylor c33c18cdc6 libgo: test linking split-stack and non-split-stack together
PPC has split-stack support in current GCC, but old version of gold will
    reject attempts to link PPC split-stack and non-split-stack code
    together.  Test for that, and don't compile the C code with
    -fsplit-stack if it doesn't work.
    
    Reviewed-on: https://go-review.googlesource.com/14594

From-SVN: r227802
2015-09-15 17:05:14 +00:00
Ian Lance Taylor 7e56d66864 runtime: Ignore stack sizes when deciding when to GC.
This restores https://golang.org/cl/6081043 which was lost accidentally
    when updating a new version of libgo in https://golang.org/cl/22440043 .
    
    Reviewed-on: https://go-review.googlesource.com/14569

From-SVN: r227784
2015-09-15 12:32:31 +00:00
Ian Lance Taylor 44c925bdb0 libgo: don't provide ustat on arm64 GNU/Linux
This avoids linker warnings when linking against glibc, as apparently
    arm64 GNU/Linux does not support the ustat system call.
    
    Also update to automake 1.11.6, as that is the new GCC standard.
    
    Reviewed-on: https://go-review.googlesource.com/14567

From-SVN: r227777
2015-09-15 03:43:01 +00:00
Ian Lance Taylor 5dbd3b8045 libgo/runtime: return 0, not NULL, from main
Reviewed-on: https://go-review.googlesource.com/13421

From-SVN: r227673
2015-09-11 03:12:28 +00:00
Ian Lance Taylor 476013d60b libgo: Use stat_atim.go on Solaris 12+
From Rainer Orth.
    
    Solaris 12 changes the stat_[amc]tim members of struct stat from
    timestruc_t to timespec_t for XPG7 compatiblity, thus breaking the libgo
    build.  The following patch checks for this change and uses the common
    stat_atim.go if appropriate.
    
    Reviewed-on: https://go-review.googlesource.com/14495

From-SVN: r227665
2015-09-10 21:17:00 +00:00
Ian Lance Taylor f999c862ec libgo/testsuite: another fix for killing the sleep process
Avoid ps padding issues.  Make sure we locate and kill just the sleep
    process.
    
    Reviewed-on: https://go-review.googlesource.com/13634

From-SVN: r227037
2015-08-20 17:10:45 +00:00
Ian Lance Taylor d0ceffe507 libgo/testsuite: don't call kill without args
If the timeout subshell has no child processes,
    the "xargs | kill" will fail. Ensure there is
    some input for kill before calling it.
    
    Reviewed-on: https://go-review.googlesource.com/13295

From-SVN: r226719
2015-08-07 10:10:00 +00:00
Ian Lance Taylor f48495834f runtime: initialize variable to avoid compiler warning
Reviewed-on: https://go-review.googlesource.com/13095

From-SVN: r226543
2015-08-04 03:39:21 +00:00
Ian Lance Taylor 1ca95ba067 syscall: RawSockaddr fix for ppc64, ppc64le
The struct RawSockaddr contains a field Data which
    should be uint8 on ppc64 and ppc64le, but is declared
    as int8 in gccgo.  This change adds a two new files
    which contain the structure declaration for
    RawSockaddr, one with the correct types for for ppc64
    and ppc64le, and the other for non-ppc64 platforms.
    
    Fixes golang/go#11469
    
    Reviewed-on: https://go-review.googlesource.com/11946

From-SVN: r226533
2015-08-03 21:18:56 +00:00
Ian Lance Taylor ca81dee392 libgo/testsuite: kill sleep process in gotest
This change modifies the "gotest" shell script
    to kill all processes, including "sleep", spawned
    by the timeout subshell. This prevents the sleep
    process from living beyond the gotest process.
    
    BACKGROUND
    
    The "gotest" shell script spawns "sleep" processes
    in the background to kill off test cases that run
    past their specified timeout. There are commands
    included that appear to kill the sleep process,
    but they only kill the parent shell, causing the
    sleep process to reparent.
    
    The orphaned sleep process can cause issues when
    gotest is run under some build systems, such as
    Ninja [0]. The particular issue with Ninja is the
    method it uses to identify terminated processes:
    it creates a pipe, passes the write end to the
    child process, and waits for EOF. In the case of
    libgo/gotest, the orphaned sleep process inherits
    the pipe FD and keeps it open for 4 minutes by
    default.
    
    [0] https://github.com/martine/ninja
    
    Reviewed-on: https://go-review.googlesource.com/12227

From-SVN: r226526
2015-08-03 18:23:42 +00:00
Ian Lance Taylor 3d6d2a63b2 re PR go/67101 (mprof.goc:408:5: error: calling ‘__builtin_frame_address’ with a nonzero argument is unsafe [-Werror=frame-address])
PR go/67101

    runtime: Remove call to __builtin_frame_address.
    
    __builtin_frame_address was only supposed to use nonzero arguments
    for debugging purposes.  Calling it with nonzero arguments can have
    unpredictable results and uses are now marked unsafe when
    -Wframe-address is enabled.
    
    Reviewed-on: https://go-review.googlesource.com/13063

From-SVN: r226525
2015-08-03 17:54:50 +00:00
Ian Lance Taylor d266c7e943 syscall: Fix to libgo/mksysinfo.sh
In a recent change to mksysinfo.sh, a space was missing on
    some lines which caused the libgo build to hang on some
    systems.  This corrects that problem.
    
    Fixes golang/go#11924
    
    Reviewed-on: https://go-review.googlesource.com/12835

From-SVN: r226366
2015-07-29 21:42:30 +00:00
Ian Lance Taylor 2850beb940 syscall: Add ioctl consts from if_tun.h
During the gccgo build define constants from
    some header files are processed by mksysinfo.sh and
    added to syscall.go.  In some cases the constants
    are based on macros which are not processed
    correctly by mksysinfo.sh.  This adds the support
    to generate the correct values for the TUN* constants
    from linux/if_tun.h.
    
    Fixes golang/go#11707
    
    Reviewed-on: https://go-review.googlesource.com/12491

From-SVN: r226196
2015-07-25 00:01:04 +00:00
Ian Lance Taylor 67a546ab45 compiler,runtime: Determine if allocations need new pointers in runtime.
As the removed comment states, if the package being compiled played
    certain tricks with pointers that looked like integers, the compiler
    might allocate space for new pointers unnecessarily.  Since the type
    information on the heap is now precise, this logic can be moved to the
    runtime.
    
    Reviewed-on: https://go-review.googlesource.com/11581

From-SVN: r225757
2015-07-14 01:22:25 +00:00
Ian Lance Taylor 51cef06e02 syscall: remove calls to Entersyscall & Exitsyscall in Getdents
The syscall for Getdents in syscall/libcall_linux.go
    called Entersyscall and Exitsyscall, causing the
    runtime_sched counts for goroutines to be incorrect.
    Inconsistent counts caused checkdead in runtime/proc.c
    to panic.
    
    Fixes golang/go#11406
    
    Reviewed-on: https://go-review.googlesource.com/11761

From-SVN: r225745
2015-07-13 18:55:15 +00:00
Ian Lance Taylor 5ea73ae3b8 libgo: Use __USING_SJLJ_EXCEPTIONS__ rather than configure test.
From Eric Botcazou.

From-SVN: r223231
2015-05-16 00:17:46 +00:00
Ian Lance Taylor b1b0e90567 runtime: Fix runtime/pprof test when libgo is not optimized.
When libgo is not optimized the static function profilealloc
in malloc.goc shows up in the stack trace.  Rename it to
runtime_profilealloc so that runtime/pprof.printStackRecord
ignores it.

From-SVN: r223006
2015-05-11 16:19:23 +00:00
Ian Lance Taylor bd9e8f7e4a re PR go/66016 (Accessing nil Func's name results in crash)
PR go/66016
runtime: Don't crash in Func.Name if the Func is nil.

Related to Go issue 10696

From-SVN: r222816
2015-05-05 16:38:57 +00:00
Ian Lance Taylor 081564faed runtime: Support -buildmode=c-shared.
These changes permit using the go tool from the upcoming Go
1.5 release with -buildmode=c-archive to build gccgo code into
an archive file that can be linked with a C program.

From-SVN: r222594
2015-04-29 21:31:53 +00:00
Ian Lance Taylor bddc11a8ff re PR go/65616 (libgobegin.a not compiled with -fPIC)
PR go/65616
libgo: Compile go-main, in libgobegin, with -fPIC.

From-SVN: r222431
2015-04-24 22:08:32 +00:00
Ian Lance Taylor 46f120ca7b re PR go/65798 (runtime.Caller returns ok=true when return data is invalid)
PR go/65798
runtime: In Caller don't return ok == true if PC == 0.

GCC PR 65798 reports that this can happen in some cases.

From-SVN: r222204
2015-04-17 21:59:10 +00:00
Ian Lance Taylor d6c2d7c1ca re PR go/64683 (FAIL: runtime/pprof -- testing.go:278: The entry did not match)
PR go/64683
runtime/pprof: Assume function with no name is in runtime.

GCC PR 65797 causes some of the runtime functions to be
compiled with no name in the debug info.  This in turn causes
the runtime/pprof test to fail as reported in GCC PR 64683.

There are no good choices when a function has no name in the
debug info, but here we assume that if we see such a function
while reading the runtime functions, we assume that it is also
a runtime function.

From-SVN: r222200
2015-04-17 21:29:20 +00:00
Ian Lance Taylor 5fdb119fd5 re PR go/64999 (s390x libgo test failure in TestMemoryProfiler)
PR go/64999
	PR go/65180
runtime: Adjust libbacktrace PC value to what runtime.Callers expects.

From Lynn Boger.

From-SVN: r222196
2015-04-17 19:29:28 +00:00
Ian Lance Taylor 90e00f872d re PR go/65755 (incorrect reflection of struct fields with gccgo)
PR go/65755
compiler, runtime, reflect: Use reflection string for type comparisons.

Change the runtime and reflect libraries to always use only
the type reflection string to determine whether two types are
equal.  It previously used the PkgPath and Name values for a
type name, but that required a PkgPath that did not match the
gc compiler.

Change the compiler to use the same PkgPath value as the gc
compiler in all cases.

Change the compiler to put the receiver type in the reflection
string for a type defined inside a method.

From-SVN: r222194
2015-04-17 18:19:44 +00:00
Ian Lance Taylor 5d22575b1b mksysinfo.sh: Define Solaris zone_net_addr_t struct.
From Rainer Orth.

From-SVN: r221920
2015-04-08 14:17:13 +00:00
Ian Lance Taylor 4bcd34f6ad re PR go/63731 (Fallback to netgo does not work)
PR go/63731
libgo: Build and install libnetgo.a

libnetgo.a provides the net
package built with the netgo
tag enabled.  This provides the
netgo fallback solution for gccgo.
This lib must be explicitly linked
in using the -gccgoflags, so is
not included by default.

From-SVN: r221906
2015-04-07 18:09:28 +00:00
Ian Lance Taylor 2ee920291d Remove some files that were accidentally committed in 2014.
From-SVN: r221802
2015-03-31 19:47:23 +00:00
Ian Lance Taylor 9f5059b275 go/cmd/go: always link external test packages first
When linking complex packages that use both internal and external tests as well as many dependencies it is critical that the link order be external test package, internal test package, everything else.

This change is a back (forward?) port of the same change that canonical have been maintaining on their fork of the go tool for gccgo. Now that gccgo uses the go tool from upstream, this patch should be applied both to the gofrontend and golang/go repos.

From-SVN: r221800
2015-03-31 17:54:07 +00:00
Ian Lance Taylor ef99b3de9f re PR go/65587 (C package incomplete/not working for powerpc-linux-gnu)
PR go/65587
debug/elf: apply relocations for SHT_RELA/EM_PPC

From-SVN: r221698
2015-03-26 17:51:57 +00:00
Ian Lance Taylor d94a1e7fe9 libgo: Fix go/runtime test failure on S390.
The tests run out of memory on 31-bit S390 systems because
it does not have split stacks.

From-SVN: r221681
2015-03-26 00:39:45 +00:00
Ian Lance Taylor 7b980c32fa re PR go/65570 (cannot find package "runtime/cgo")
PR go/65570
libgo/Makefile.am: add runtime/cgo to list of standard packages

The runtime/cgo package is treated specially by the go tool.
It needs to know that it is always available for gccgo.

From-SVN: r221673
2015-03-25 21:19:01 +00:00
Ian Lance Taylor e93870c12b re PR go/65417 (debug/elf: lacks support for PPC relocations)
PR go/65417
debug/elf: support reading debug info from 32-bit PPC objects

This is a backport of http://golang.org/7590 from the master
Go library.

From-SVN: r221644
2015-03-24 20:55:43 +00:00
Ian Lance Taylor ab24432b9a re PR go/65462 (Use of 'go get' with gccgo is not finding dependencies correctly)
PR go/65462
cmd: Fix dependencies for 'go get' with gccgo

Problem described in GCC BZ 65462.
Generate the list of the standard GO package names based on what was built into libgo in the libgo Makefile.
Change the var name from reqPkgSrc to reqStdPkgSrc to clarify it only affects standard GO packages.
Skip the attempted loading of a package only if it is a standard GO package and the flag is set indicating its source is not required to be available.
This requires a corresponding change to gotools to build and link in the new file containing the list of standard GO package names that was generated by the libgo Makefile.

gotools/:
	PR go/65462
	* Makefile.am (go_cmd_go_files): Add $(libgodir)/zstdpkglist.go.
	* Makefile.in: Rebuild.

From-SVN: r221643
2015-03-24 19:50:31 +00:00
Ian Lance Taylor f41914c385 libgo/README: Minor updates.
In particular, mention that libgo should not be stripped.

From-SVN: r221427
2015-03-13 18:53:13 +00:00
Ian Lance Taylor 2960e09d9d go/build: cgo works on linux/arm64.
From-SVN: r221398
2015-03-12 17:05:22 +00:00
Ian Lance Taylor 64b54a6fd2 re PR go/65404 (cgo tool on powerpc-linux-gnu maybe incomplete)
PR go/65404
go/build: cgo works on linux/pcc.

From-SVN: r221396
2015-03-12 16:41:28 +00:00
Ian Lance Taylor 1c1f0c595b re PR go/65353 (unknown ptrSize for $GOARCH "arm64" on aarch64-linux-gnu)
PR go/65353.
cmd/cgo: Add all gccgo GOARCH values to size maps.

From-SVN: r221293
2015-03-10 00:14:58 +00:00
Ian Lance Taylor dc4d494ae9 re PR go/65349 (go tool crashes, can't compile go code on 32bit linux systems)
PR go/65349
runtime: Don't crash if explicitly freeing small map.

From-SVN: r221292
2015-03-09 23:43:16 +00:00
Ian Lance Taylor 4729d7726b re PR go/65349 (go tool crashes, can't compile go code on 32bit linux systems)
PR go/65349
runtime: Don't call malloc from __go_file_line callback.

When crashing, we call runtime_printcreatedby which calls
__go_file_line which used to call the Go malloc.  If we are
crashing due to a signal due to heap corruption of some sort,
the GO malloc lock might already be held, leading to a crash
within a crash.  Avoid that by assuming that the libbacktrace
strings will stick around, as we already do in go-callers.c.

From-SVN: r221291
2015-03-09 23:40:58 +00:00
Ian Lance Taylor c271e224c2 libgo: Upgrade to Go 1.4.2 release.
From-SVN: r221245
2015-03-06 16:19:05 +00:00
Ian Lance Taylor 898c81f831 mksysinfo.sh: Remove _zone_net_addr_t handling.
From Rainer Orth.

The recent godump changes broke Solaris 11.1+ bootstrap in
libgo: before, gen-sysinfo.so had

type _zone_net_addr_t struct { zna_family uint16; zna_plen uint16; zna_addru struct { znau_addr6 _in6_addr; }; }

which was filtered out by mksysinfo.sh due to the use of
_in6_addr.

After the change, there's now

type _zone_net_addr_t struct { zna_family uint16; zna_plen uint16; zna_addru struct { znau_addr6 [16]byte; Godump_0_align [0]uint32; }; }

instead, not filtered, but added a second time by the
_zone_net_addr_t code in mksysinfo.sh, which leads to
redefinition warnings/errors.

Simply removing the old _zone_net_addr_t fragment fixes this
and restores bootstrap.

From-SVN: r220481
2015-02-06 16:18:14 +00:00
Ian Lance Taylor 8c5c44aa7e runtime: Add memprofilerate to GODEBUG
Add memprofilerate as a value recognized
in the GODEBUG env var.  The value provided
is used as the new setting for
runtime.MemProfileRate, allowing the user
to adjust memory profiling.

From-SVN: r220470
2015-02-06 05:03:22 +00:00
Ian Lance Taylor bfdd75a859 go/types: Remove unused testdata files.
The go/types package was removed in July 2013, but the
testdata files were accidentally left behind.

From-SVN: r220378
2015-02-03 21:39:27 +00:00
Ian Lance Taylor ba986acb05 re PR go/64573 (Cmd.Start swallows error from fork()/clone())
PR go/64573
syscall: Restore line somehow lost in libgo merge.

From-SVN: r220068
2015-01-23 23:45:04 +00:00
Ian Lance Taylor 9d8d3ba2bc re PR go/64725 (FAIL: libgo/runtime TestFinalizerType testing.go:278: #2: finalizer for type func(*int) didn't run)
PR go/64725
runtime: Disable tests that require that a finalizer run.

From-SVN: r220067
2015-01-23 23:22:29 +00:00
Ian Lance Taylor e0a0c2f4c6 re PR go/64595 (go programs abort when debug info is stripped)
PR go/64595
runtime: Don't crash in runtime_callers if no debug info available.

From-SVN: r220057
2015-01-23 19:49:53 +00:00
Ian Lance Taylor 6632034718 runtime: Add the Go language version information to the Version output.
From-SVN: r219976
2015-01-21 23:03:41 +00:00
Ian Lance Taylor 73cb399d51 re PR go/64683 (FAIL: runtime/pprof -- testing.go:278: The entry did not match)
PR go/64683
runtime/pprof: Let memory profiler test pass if value not collected.

Since gccgo's GC is not precise, the transient value may not
be collected.  Let the regexp match that case as well.

From-SVN: r219900
2015-01-20 16:11:36 +00:00
Ian Lance Taylor cea526b81c runtime: No special case for 386 complex in FFI support.
All supported libgo 386 targets now have complex support in
libffi.

From Uros Bizjak.

From-SVN: r219877
2015-01-20 04:18:12 +00:00
Richard Henderson 3bac62c2b2 Add attribute unused to dummy arguments in ffi stub
From-SVN: r219862
2015-01-19 14:10:59 -08:00
Ian Lance Taylor b077669c47 reflect: Fix build for systems that do not define ffi_go_closure.
From-SVN: r219831
2015-01-19 02:56:28 +00:00
Ian Lance Taylor 0f59f5c120 runtime: Add __sparc__ case for SETCONTEXT_CLOBBERS_TLS.
The glibc setcontext incorrectly modifies %g7 on SPARC.

From Richard Henderson.

From-SVN: r219778
2015-01-16 23:23:31 +00:00
Ian Lance Taylor 20780a006f testing/quick: Revert Alpha specific change.
No longer needed now that libffi supports complex types.

From-SVN: r219777
2015-01-16 23:19:20 +00:00
Richard Henderson 38bf819a5f compiler, reflect, runtime: Use static chain for closures.
Change from using __go_set_closure to passing the closure
value in the static chain field.  Uses new backend support for
setting the closure chain in a call from C via
__builtin_call_with_static_chain.  Uses new support in libffi
for Go closures.

The old architecture specific support for reflect.MakeFunc is
removed, replaced by the libffi support.

All work done by Richard Henderson.

	* go-gcc.cc (Gcc_backend::call_expression): Add chain_expr argument.
	(Gcc_backend::static_chain_variable): New method.

From-SVN: r219776
2015-01-16 22:58:53 +00:00
Ian Lance Taylor 72d7151a72 net: Restore earlier Solaris-specific version of setKeepAlivePeriod.
The version from the master repository seems to be appropriate
for OpenSolaris but not for Solaris itself.  Solaris 11.2
proper does not define TCP_KEEPIDLE or TCP_KEEPINTVL.

From-SVN: r219749
2015-01-16 15:57:32 +00:00
Ian Lance Taylor cb054b6341 runtime: Use a struct, not void, for an empty struct for libffi.
A recent libffi upgrade caused the reflect test to fail on
386.  The problem case is a function that returns an empty
struct--a struct with no fields.  The libffi library does not
recognize the existence of empty structs, presumably since
they can't happen in C.  To work around this, the Go interface
to the libffi library changes an empty struct to void.  This
normally works fine, but with the new libffi upgrade it fails
for a function that returns an empty struct.  On 386 a
function that returns a struct is expected to pop the hidden
pointer when it returns.  So when we convert an empty struct
to void, libffi is calling a function that pops the hidden
pointer but does not expect that to happen.

In the older version of libffi, this didn't matter, because
the libffi code for 386 used a frame pointer, so the fact that
the stack pointer was wonky when the function returned was
ignored as the stack pointer was immediately replaced by the
saved frame pointer.  In the newer version of libffi, the 386
code is more efficient and does not use a frame pointer, and
therefore it matters whether libffi expects the function to
pop the hidden pointer or not.

This patch changes libgo to convert an empty to a struct with
a single field of type void.  This seems to be enough to get
the test cases working again.

Of course the real fix would be to change libffi to handle
empty types, but as libffi uses size == 0 as a marker for an
uninitialized type, that would be a non-trivial change.

From-SVN: r219701
2015-01-16 02:54:13 +00:00
Ian Lance Taylor 1d59990631 go/build: cgo works on linux/alpha.
From Uros Bizjak.

From-SVN: r219691
2015-01-15 22:06:54 +00:00
Ian Lance Taylor 4c16468417 reflect: Correct error in conversion of s390x support to Go 1.4.
From-SVN: r219685
2015-01-15 20:42:43 +00:00
Ian Lance Taylor d5d9c650a2 libgo: Bump version number in libgo configure script.
From-SVN: r219629
2015-01-15 00:52:38 +00:00
Ian Lance Taylor 3307c079d5 Add files somehow left out of last commit (upgrade to Go 1.4).
From-SVN: r219628
2015-01-15 00:40:25 +00:00
Ian Lance Taylor f8d9fa9e80 libgo, compiler: Upgrade libgo to Go 1.4, except for runtime.
This upgrades all of libgo other than the runtime package to
the Go 1.4 release.  In Go 1.4 much of the runtime was
rewritten into Go.  Merging that code will take more time and
will not change the API, so I'm putting it off for now.

There are a few runtime changes anyhow, to accomodate other
packages that rely on minor modifications to the runtime
support.

The compiler changes slightly to add a one-bit flag to each
type descriptor kind that is stored directly in an interface,
which for gccgo is currently only pointer types.  Another
one-bit flag (gcprog) is reserved because it is used by the gc
compiler, but gccgo does not currently use it.

There is another error check in the compiler since I ran
across it during testing.

gotools/:
	* Makefile.am (go_cmd_go_files): Sort entries.  Add generate.go.
	* Makefile.in: Rebuild.

From-SVN: r219627
2015-01-15 00:27:56 +00:00
Ian Lance Taylor bb782ca3ec cmd/go: Back-port CL 157460043 (pass $CGO_LDFLAGS to linker with the "gccgo" toolchain).
From-SVN: r219419
2015-01-10 01:01:10 +00:00
Ian Lance Taylor b44fb4c37a cmd/go: Adjust finding gccgo to match current upstream sources.
From-SVN: r219406
2015-01-09 21:18:04 +00:00
Ian Lance Taylor d9ebff44bb cmd/go: Use builtin constant to set default gccgo compiler.
Don't look it up on PATH.  This lets a go tool built as part
of a GCC build use the gccgo from the same build.

Also pass -c when assembling a .s file with gccgo.

From-SVN: r219358
2015-01-08 20:32:42 +00:00
Ian Lance Taylor 7d7d64c1ae libgo: Add sources for go, cgo, and gofmt commands.
The new commands are not yet built.  That will be done
separately.

Also include a few changes to go/build to support them.

From-SVN: r219272
2015-01-06 23:26:02 +00:00
Ian Lance Taylor 24fa8749bb re PR go/61871 (FAIL: regexp from libgo testsuite on non-split stack targets)
PR go/61871
runtime: Increase stack size on 64-bit non-split-stack systems.

From Uros Bizjak.

From-SVN: r219192
2015-01-05 16:13:06 +00:00
Ian Lance Taylor bca4b95c4a runtime: Remove undefined references to runtime_race*.
From-SVN: r219049
2014-12-23 20:33:53 +00:00
Ian Lance Taylor 658b028ad0 mksysinfo: Pass -O to compiler to avoid warnings on CentOS.
From Uros Bizjak.
https://gcc.gnu.org/ml/gcc-patches/2014-12/msg01366.html

From-SVN: r218819
2014-12-17 14:26:55 +00:00
Ian Lance Taylor 9ac18f8c2a re PR go/61258 (gccgo: assertion failure go-map-delete.c:37 [GoSmith])
PR go/61258
runtime: Don't crash when deleting zero-sized key.

From-SVN: r218702
2014-12-13 01:58:46 +00:00
Ian Lance Taylor e846322c86 testing: Add testing.MainStart function.
This patches in the Go 1.4 function, for convenience for
people using the Go 1.4 go tool with mainline gccgo.

From-SVN: r218700
2014-12-13 01:00:49 +00:00
Ian Lance Taylor c31fc2f424 runtime: Clear stack pointers for extra G's.
Fix an unusual C to Go callback case.  Newly created C threads
call into Go code, forcing the Go code to allocate new M and G
structures.  While executing Go code, the stack is split.  The
Go code then returns.  Returning from a Go callback is treated
as entering a system call, so the G gcstack field is set to
point to the Go stack.  In this case, though, we were called
from a newly created C thread, so we drop the extra M and G
structures.  The C thread then exits.

Then a new C thread calls into Go code, reusing the previously
created M and G.  The Go code requires a larger stack frame,
causing the old stack segment to be unmapped and a new stack
segment allocated.  At this point the gcstack field is
pointing to the old stack segment.

Then a garbage collection occurs.  The garbage collector sees
that the gcstack field is not nil, so it scans it as the first
stack segment.  Unfortunately it points to memory that was
unmapped.  So the program crashes.

The fix is simple: when handling extra G structures created
for callbacks from new C threads, clear the gcstack field.

From-SVN: r218699
2014-12-13 00:52:20 +00:00
Kyrylo Tkachov 69aef6dcdc Add load of target-utils.exp to libatomic, libitm, libvtv, libgo testsuite drivers
* testsuite/lib/libatomic.exp: Load target-utils.exp

	* testsuite/lib/libitm.exp: Load target-utils.exp.
	Move load of target-supports.exp earlier.

	* testsuite/lib/libvtv.exp: Load target-utils.exp

From-SVN: r218664
2014-12-12 12:00:01 +00:00
Ian Lance Taylor 4368bc4589 runtime: introduce mvifdiff.sh script to replace GCC's move-if-change
This goes towards making libgo more self-contained.

From-SVN: r218198
2014-12-01 01:06:29 +00:00
Ian Lance Taylor 6f7ccafa91 runtime: GOARCH values for ppc64 BE & LE
ppc64 for BE
ppc64le for LE
issue 8654

From-SVN: r217941
2014-11-21 18:22:05 +00:00
Ian Lance Taylor 4c46b5f0c2 runtime: set library name based on compiler name
Different compilers may have different release cadences or ABI
incompatibilities, so it does not make sense to use the same library
name for runtime libraries intended for different compilers.

This CL causes a libgo built by llgo to receive the name libgo-llgo.
Likewise, libgobegin is named libgobegin-llgo.

From-SVN: r217583
2014-11-14 18:02:50 +00:00
Ian Lance Taylor 327a26a3af libgo: Update libtool support to files in current GCC trunk.
From-SVN: r217404
2014-11-12 03:51:36 +00:00
Dominik Vogt 4ad4ebfeae runtime: Use stckf unconditionally on s390.
2014-11-05  Dominik Vogt  <vogt@linux.vnet.ibm.com>

* libgo/runtime/runtime.c (runtime_cputicks): s390: use stckf
unconditionally

From-SVN: r217195
2014-11-06 17:00:13 +00:00
Dominik Vogt 5c2648fb01 mksysinfo: Tolerate missing structures in upcase_fields.
2014-11-06  Dominik Vogt  <vogt@linux.vnet.ibm.com>

* libgo/mksysinfo.sh: Tolerate missing structures.

From-SVN: r217194
2014-11-06 16:44:32 +00:00
Ian Lance Taylor c9bc4e2d2b sync/atomic: fix data races in tests
Backport https://codereview.appspot.com/111320044 from Go
master library.

From-SVN: r217110
2014-11-05 03:39:49 +00:00
Ian Lance Taylor 1fec5f5274 libgo: add s390 support
From Dominik Vogt.

* libgo/go/syscall/libcall_linux_s390.go: New file for s390 support.
* libgo/go/syscall/syscall_linux_s390.go: Ditto.
* libgo/go/syscall/libcall_linux_s390x.go: New file for s390x support.
* libgo/go/syscall/syscall_linux_s390x.go: Ditto.
* libgo/go/runtime/pprof/pprof.go (printStackRecord): Support s390 and
s390x.
* libgo/runtime/runtime.c (runtime_cputicks): Add support for s390 and
s390x
* libgo/mksysinfo.sh: Ditto.
(upcase_fields): New helper function

* libgo/go/debug/elf/file.go (applyRelocations): Implement relocations
on s390x.
(applyRelocationsS390x): Ditto.
(DWARF): Ditto.
* libgo/go/debug/elf/elf.go (R_390): New constants for S390 relocations.
(r390Strings): Ditto.
(String): Helper function for S390 relocations.
(GoString): Ditto.

* libgo/go/reflect/makefuncgo_s390.go: New file.
(S390MakeFuncStubGo): Implementation of s390 abi.
* libgo/go/reflect/makefuncgo_s390x.go: New file.
(S390xMakeFuncStubGo): Implementation of s390x abi.
* libgo/go/reflect/makefunc_s390.c: New file.
(makeFuncStub): s390 and s390x specific implementation of function.
* libgo/go/reflect/makefunc.go
(MakeFunc): Add support for s390 and s390x.
(makeMethodValue): Ditto.
(makeValueMethod): Ditto.
* libgo/Makefile.am (go_reflect_makefunc_s_file): Ditto.
(go_reflect_makefunc_file): Ditto.
* libgo/go/reflect/makefunc_dummy.c: Ditto.
* libgo/runtime/runtime.h (__go_makefunc_can_recover): Export prototype
for use in makefunc_s390.c.
(__go_makefunc_returning): Ditto.

* libgo/go/syscall/exec_linux.go (forkAndExecInChild): Fix order of the
arguments of the clone system call for s390[x].

* libgo/configure.ac (is_s390): New variable.
(is_s390x): Ditto
(LIBGO_IS_S390): Ditto.
(LIBGO_IS_S390X): Ditto.
(GOARCH): Support s390 and s390x.
* libgo/go/go/build/build.go (cgoEnabled): Ditto.
* libgo/go/go/build/syslist.go (goarchList): Ditto.

From-SVN: r217106
2014-11-04 22:39:30 +00:00
Ian Lance Taylor 24606f7137 runtime: use "$GOC -dumpversion" instead of BASE-VER to discover compiler version
From-SVN: r217049
2014-11-03 16:30:51 +00:00
Ian Lance Taylor 5d51c2d70c debug/elf: add power64 support along with relocation test
Backport of https://codereview.appspot.com/125910043 from the
dev.power64 branch of the master repository.

From-SVN: r216813
2014-10-28 22:57:35 +00:00
Ian Lance Taylor 3a21b777bb libgo: Add consts for ioctl
TIOCSWINSZ_val, TCGETS_val, TCSETS_val

From-SVN: r216807
2014-10-28 18:18:39 +00:00
Ian Lance Taylor 50a504654d libgo: Update to Go 1.3.3 release.
From-SVN: r216746
2014-10-27 16:57:33 +00:00
Ian Lance Taylor 0f2aeaa817 compiler, runtime: Add type information to single object allocation.
From-SVN: r216490
2014-10-20 19:12:44 +00:00
Ian Lance Taylor 7b28fa2c6b reflect: allocate correct type in assignTo and cvtT2I
Backport https://codereview.appspot.com/155450044 from the
master Go library.  Original description:

I came across this while debugging a GC problem in gccgo.
There is code in assignTo and cvtT2I that handles assignment
to all interface values.  It allocates an empty interface even
if the real type is a non-empty interface.  The fields are
then set for a non-empty interface, but the memory is recorded
as holding an empty interface.  This means that the GC has
incorrect information.

This is extremely unlikely to fail, because the code in the GC
that handles empty interfaces looks like this:

obj = nil;
typ = eface->type;
if(typ != nil) {
        if(!(typ->kind&KindDirectIface) || !(typ->kind&KindNoPointers))
                obj = eface->data;

In the current runtime the condition is always true--if
KindDirectIface is set, then KindNoPointers is clear--and we
always want to set obj = eface->data.  So the question is what
happens when we incorrectly store a non-empty interface value
in memory marked as an empty interface.  In that case
eface->type will not be a *rtype as we expect, but will
instead be a pointer to an Itab.  We are going to use this
pointer to look at a *rtype kind field.  The *rtype struct
starts out like this:

type rtype struct {
        size          uintptr
        hash          uint32            // hash of type; avoids computation in hash tables
        _             uint8             // unused/padding
        align         uint8             // alignment of variable with this type
        fieldAlign    uint8             // alignment of struct field with this type
        kind          uint8             // enumeration for C

An Itab always has at least two pointers, so on a
little-endian 64-bit system the kind field will be the high
byte of the second pointer.  This will normally be zero, so
the test of typ->kind will succeed, which is what we want.

On a 32-bit system it might be possible to construct a failing
case by somehow getting the Itab for an interface with one
method to be immediately followed by a word that is all ones.
The effect would be that the test would sometimes fail and the
GC would not mark obj, leading to an invalid dangling
pointer.  I have not tried to construct this test.

I noticed this in gccgo, where this error is much more likely
to cause trouble for a rather random reason: gccgo uses a
different layout of rtype, and in gccgo the kind field happens
to be the low byte of a pointer, not the high byte.

From-SVN: r216489
2014-10-20 18:04:55 +00:00
Ian Lance Taylor 204b9fc2b8 configure: Quote some shell variables.
From Dominik Vogt.

From-SVN: r216355
2014-10-17 00:03:20 +00:00
Ian Lance Taylor 6c4ee063a5 runtime: Don't create threads with a small stack.
We want to create goroutines with a small stack, at least on
systems where split stacks are supported.  We don't need to
create threads with a small stack.

From-SVN: r216353
2014-10-16 22:39:45 +00:00
Ian Lance Taylor 19d4baed57 re PR go/60406 (recover.go: test13reflect2 test failure)
PR go/60406
runtime: Check callers in can_recover if return address	doesn't match.

Also use __builtin_extract_return_address and tighten up the
checks in FFI code.

Fixes PR 60406.

From-SVN: r216003
2014-10-08 14:03:13 +00:00
Ian Lance Taylor 22806403ec re PR go/61877 (reflect: cannot use []string as type string in Call)
PR go/61877
refect: fix direct call of variadic method value

As reported in bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61877
gcc mainline has regressed in this.  This CL adds the tests proposed
for the main Go repository:

        https://codereview.appspot.com/151280043/
        https://codereview.appspot.com/152060043/

restores the code from the amd64/386 path that makes this work and
was lost when the Go 1.3 stdlib was merged and changes the FFI path
to call into the same helper code as the amd64/386 path.

I've only tested this on amd64 but I did test a version that was
patched to unconditionally take the FFI path.

From-SVN: r215859
2014-10-03 15:51:38 +00:00
Ian Lance Taylor 60d9e9fc19 runtime: Check for CPU_COUNT itself, don't check glibc version.
Fixes issue 38.

From-SVN: r215832
2014-10-03 05:04:59 +00:00
Ian Lance Taylor a819231d57 libgo/configure: Use -Qunused-arguments for asm tests if supported.
This supports clang, which by default issues warnings about
unused command line arguments, a habit that interacts poorly
with configure scripts.

From-SVN: r215699
2014-09-29 23:37:27 +00:00
Ian Lance Taylor 76deefd0cd runtime: Mark runtime_goexit function as noinline.
If the compiler inlines this function into kickoff, it may reuse
the TLS block address to load g. However, this is not necessarily
correct, as the call to g->entry in kickoff may cause the TLS
address to change. If the wrong value is loaded for g->status in
runtime_goexit, it may cause a runtime panic.

By marking the function as noinline we prevent the compiler from
reusing the TLS address.

From-SVN: r215484
2014-09-22 21:14:43 +00:00
Ian Lance Taylor f0c1b5671a runtime: Restore copyright notice accidentally removed from mgc0.c.
From-SVN: r215423
2014-09-20 20:42:59 +00:00
Ian Lance Taylor 01c2fa9d53 runtime: Use the clone system call on GNU/Linux.
Without this we weren't supporting the standard Cloneflags
field of SysProcAttr.

From-SVN: r214972
2014-09-05 15:24:36 +00:00
Ian Lance Taylor a7188cc650 runtime: Use correct size for unsafe.Pointer GC instructions.
From-SVN: r214965
2014-09-05 14:43:24 +00:00
Chris Manghane f1d2ac4f84 compiler: Add precise type information on the heap.
* go-gcc.cc (Gcc_backend::implicit_variable): Remove init
	parameter.  Add is_hidden parameter.
	(Gcc_backend::implicit_variable_set_init): New method.
	(Gcc_backend::implicit_variable_reference): New method.

From-SVN: r214894
2014-09-03 22:56:09 +00:00
Ian Lance Taylor ab36d98dd2 runtime: Don't get confused if m changes during runtime_gc.
From-SVN: r214048
2014-08-15 22:16:55 +00:00
Ian Lance Taylor 798c183f7f compiler, runtime: Fix unexpected GC interfering with closure passing.
The Go frontend passes closures through to functions using the
functions __go_set_closure and __go_get_closure.  The
expectation is that there are no function calls between
set_closure and get_closure.  However, it turns out that there
can be function calls if some of the function arguments
require type conversion to an interface type.  Converting to
an interface type can allocate memory, and that can in turn
trigger a garbage collection, and that can in turn call pool
cleanup functions that may call __go_set_closure.  So the
called function can see the wrong closure value, which is bad.

This patch fixes the problem in two different ways.  First, we
move all type conversions in function arguments into temporary
variables so that they can not appear before the call to
__go_set_closure.  (This required shifting the flatten phase
after the simplify_thunk phase, since the latter expects to
work with unconverted argument types.)  Second, we fix the
memory allocation function to preserve the closure value
across any possible garbage collection.

A test case is the libgo database/sql check run with the
environment variable GOGC set to 1.

From-SVN: r213932
2014-08-13 22:31:44 +00:00
Ian Lance Taylor d79fe5971a runtime: Add casts to mincore call to compile on Solaris.
Based on patch from Rainer Orth.

From-SVN: r213599
2014-08-04 17:54:09 +00:00
Ian Lance Taylor dc14e88e07 re PR other/61895 (libbacktrace crashes with bus error with empty file argv[0])
PR other/61895

runtime: Ignore small argv[0] file for backtrace.

Reportedly in some cases Docker starts processes with argv[0]
pointing to an empty file.  That would cause libgo to pass
that empty file to libbacktrace, which would then fail to do
any backtraces.  Everything should work fine if libbacktrace
falls back to /proc/self/exe.

This patch to libgo works around the problem by ignoring
argv[0] if it is a small file, or if stat fails.  This is not
a perfect fix but it's an unusual problem.

From-SVN: r213513
2014-08-02 00:54:15 +00:00
Ian Lance Taylor d5d0580e64 runtime: remove unused variable
This variable is unused apparently as a result of local changes.
gccgo accepts this variable declaration, but other frontends may not.

From-SVN: r212873
2014-07-20 19:20:12 +00:00
Ian Lance Taylor aefa5ff4cf runtime: add a missing import
This adds an import of the runtime package to fix compilation
of the TestStopCPUProfilingWithProfilerOff function.

The gccgo compiler should never have accepted this.  The patch
for the comiler is http://codereview.appspot.com/116960043 .
The test is https://codereview.appspot.com/118000043 .

From-SVN: r212870
2014-07-20 15:09:04 +00:00
Ian Lance Taylor 1c2afaca89 runtime: also disable split stacks for runtime_snprintf function under Clang
From-SVN: r212862
2014-07-20 09:24:16 +00:00