We add runtime/cgo to the list of import paths for various cases that
imply external linking mode, but before this change we did not add for
an explicit request of external linking mode. This fixes the case where
you are using a non-default buildmode that implies a different
compilation option (for example, -buildmode=pie implies -shared) and the
runtime/cgo package for that option is stale.
No test, as I'm not sure how to write one. It would require forcing a
stale runtime/cgo.
Change-Id: Id0409c7274ce67fe15d910baf587d3220cb53d83
Reviewed-on: https://go-review.googlesource.com/33070 Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
David Crawshaw [Fri, 4 Nov 2016 22:22:06 +0000 (18:22 -0400)]
reflect: unexported fields are tied to a package
An unexported field of a struct is not visible outside of the package
that defines it, so the package path is implicitly part of the
definition of any struct with an unexported field.
Change-Id: I17c6aac822bd0c24188ab8ba1cc406d6b5d82771
Reviewed-on: https://go-review.googlesource.com/32820
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Kevin Burke [Wed, 22 Jun 2016 17:00:31 +0000 (10:00 -0700)]
sync: add example for Pool
It was a little tricky to figure out how to go from the documentation
to figuring out the best way to implement a Pool, so I thought I'd
try to provide a simple example. The implementation is mostly taken
from the fmt package.
I'm not happy with the verbosity of the calls to WriteString() etc,
but I wanted to provide a non-trivial example.
Quentin Smith [Tue, 8 Nov 2016 21:47:04 +0000 (16:47 -0500)]
encoding/xml: check type when unmarshaling innerxml field
We only support unmarshaling into a string or a []byte, but we
previously would try (and panic while) setting a slice of a different
type. The docs say ",innerxml" is ignored if the type is not string or
[]byte, so do that for other slices as well.
Michael Munday [Tue, 8 Nov 2016 22:11:18 +0000 (17:11 -0500)]
runtime/pprof/internal/protopprof: skip TestTranslateCPUProfileWithSamples if < 2 mappings
A Go binary may only have 1 executable memory region if it has been
linked using internal linking. This change means that the test will
be skipped if this is the case, rather than fail.
Fixes #17852.
Change-Id: I59459a0f90ae8963aeb9908e5cb9fb64d7d0e0f4
Reviewed-on: https://go-review.googlesource.com/32920
Run-TryBot: Michael Munday <munday@ca.ibm.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
Robert Griesemer [Wed, 9 Nov 2016 00:01:56 +0000 (16:01 -0800)]
cmd/compile/internal/syntax: fix error handling for Read/Parse calls
- define syntax.Error for cleaner error reporting
- abort parsing after first error if no error handler is installed
- make sure to always report the first error, if any
- document behavior of API calls
- while at it: rename ReadXXX -> ParseXXX (clearer)
- adjust cmd/compile noder.go accordingly
Fixes #17774.
Change-Id: I7893eedea454a64acd753e32f7a8bf811ddbb03c
Reviewed-on: https://go-review.googlesource.com/32950 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
visit is just a func, and there's no formatting
verb for it, and it's on an internal-error path.
It has been thus many years, unchanged and unexecuted.
Change-Id: I4c2e2673ee9996218c24143bcc3be3eb4abdff25
Reviewed-on: https://go-review.googlesource.com/32970
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Martin Möhrmann [Wed, 9 Nov 2016 08:24:50 +0000 (09:24 +0100)]
C: add Martin Möhrmann's google.com email (Google CLA)
Change-Id: Ia439c4a3c873ef24f60f8ee54a74f767fdaafd29
Reviewed-on: https://go-review.googlesource.com/32799 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Michael Matloob [Fri, 4 Nov 2016 15:27:54 +0000 (11:27 -0400)]
runtime/pprof/internal: add package protopprof
This change adds code, originally written by Russ Cox <rsc@golang.org>
and open-sourced by Google, that converts from the "legacy"
binary pprof profile format to a struct representation of the
new protocol buffer pprof profile format.
This code reads the entire binary format for conversion to the
protobuf format. In a future change, we will update the code
to incrementally read and convert segments of the binary format,
so that the entire profile does not need to be stored in memory.
This change also contains contributions by Daria Kolistratova
<daria.kolistratova@intel.com> from the rolled-back change
golang.org/cl/30556 adapting the code to be used by the package
runtime/pprof.
This code also appeared in the change golang.org/cl/32257, which was based
on Daria Kolistratova's change, but was also rolled back.
Change-Id: I214c87579ef21ced8d0ba94aa170dd7780afec4b
Reviewed-on: https://go-review.googlesource.com/32312 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Volodymyr Paprotski [Fri, 14 Oct 2016 20:19:25 +0000 (16:19 -0400)]
crypto/elliptic: add s390x assembly implementation of NIST P-256 Curve
A paranoid go at constant time implementation of P256 curve.
This code relies on z13 SIMD instruction set. For zEC12 and below,
the fallback is the existing P256 implementation. To facilitate this
fallback mode, I've refactored the code so that implementations can
be picked at run-time.
Its 'slightly' difficult to grok, but there is ASCII art..
name old time/op new time/op delta
BaseMultP256 419µs ± 3% 27µs ± 1% -93.65% (p=0.000 n=10+8)
ScalarMultP256 1.05ms ±10% 0.09ms ± 1% -90.94% (p=0.000 n=10+8)
Change-Id: Ic1ded898a2ceab055b1c69570c03179c4b85b177
Reviewed-on: https://go-review.googlesource.com/31231
Run-TryBot: Michael Munday <munday@ca.ibm.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Mohit Agarwal [Tue, 8 Nov 2016 12:16:10 +0000 (17:46 +0530)]
os: cleanup directories created by TestLongPath
Add tmpdir as a parameter to the closure otherwise the subsequent
modifications to tmpdir causes only the last subdirectory to be
removed.
Additionally, add the missing argument for the t.Fatalf call.
Change-Id: I3df53f9051f7ea40cf3f846d47d9cefe445e9b9d
Reviewed-on: https://go-review.googlesource.com/32892 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Shenghou Ma [Sun, 1 Nov 2015 09:18:58 +0000 (04:18 -0500)]
os: add Executable() (string, error)
// Executable returns the path name for the executable that started
// the current process. There is no guarantee that the path is still
// pointing to the correct executable. If a symlink was used to start
// the process, depending on the operating system, the result might
// be the symlink or the path it pointed to. If a stable result is
// needed, path/filepath.EvalSymlinks might help.
//
// Executable returns an absolute path unless an error occurred.
//
// The main use case is finding resources located relative to an
// executable.
//
// Executable is not supported on nacl or OpenBSD (unless procfs is
// mounted.)
func Executable() (string, error) {
return executable()
}
Michael Munday [Mon, 7 Nov 2016 20:40:48 +0000 (15:40 -0500)]
crypto/tls: use default cipher suites in BenchmarkThroughput
CL 32871 updated the default cipher suites to use AES-GCM in
preference to ChaCha20-Poly1305 on platforms which have hardware
implementations of AES-GCM. This change makes BenchmarkThroughput
use the default cipher suites instead of the test cipher suites to
ensure that the recommended (fastest) algorithms are used.
Updates #17779.
Change-Id: Ib551223e4a00b5ea197d4d73748e1fdd8a47c32d
Reviewed-on: https://go-review.googlesource.com/32838
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Adam Langley <agl@golang.org>
Quentin Smith [Fri, 28 Oct 2016 17:01:51 +0000 (13:01 -0400)]
os: use extended-length paths on Windows when possible
Windows has a limit of 260 characters on normal paths, but it's possible
to use longer paths by using "extended-length paths" that begin with
`\\?\`. This commit attempts to transparently convert an absolute path
to an extended-length path, following the subtly different rules those
paths require. It does not attempt to handle relative paths, which
continue to be passed to the operating system unmodified.
This adds a new test, TestLongPath, to the os package. This test makes
sure that it is possible to write a path at least 400 characters long
and runs on every platform. It also tests symlinks and hardlinks, though
symlinks are not testable with our builder configuration.
HasLink is moved to internal/testenv so it can be used by multiple tests.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
has Microsoft's documentation on extended-length paths.
Adam Langley [Mon, 7 Nov 2016 18:25:57 +0000 (10:25 -0800)]
crypto/{cipher,tls,internal/cryptohw}: prioritise AES-GCM when hardware support is present.
Support for ChaCha20-Poly1305 ciphers was recently added to crypto/tls.
These ciphers are preferable in software, but they cannot beat hardware
support for AES-GCM, if present.
This change moves detection for hardware AES-GCM support into
cipher/internal/cipherhw so that it can be used from crypto/tls. Then,
when AES-GCM hardware is present, the AES-GCM cipher suites are
prioritised by default in crypto/tls. (Some servers, such as Google,
respect the client's preference between AES-GCM and ChaCha20-Poly1305.)
Brad Fitzpatrick [Mon, 7 Nov 2016 01:21:15 +0000 (01:21 +0000)]
cmd/go: parallelize some tests
Cuts tests from 35 to 25 seconds.
Many of these could be parallel if the test runner were modified to
give each test its own workdir cloned from the tempdir files they
use. But later. This helps for now.
Updates #17751
Change-Id: Icc2ff87cca60a33ec5fd8abb1eb0a9ca3e85bf95
Reviewed-on: https://go-review.googlesource.com/32850
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Joe Farrell [Mon, 7 Nov 2016 18:43:13 +0000 (18:43 +0000)]
doc: fix broken links in 1.7 release docs
Change-Id: Ibf73ee7be4591393f4e08d464edfa325c3ec2c11
Reviewed-on: https://go-review.googlesource.com/32798 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Lynn Boger [Fri, 4 Nov 2016 19:53:59 +0000 (14:53 -0500)]
cmd/link: don't use trampolines in ppc64le ext linking
On ppc64x, trampolines are used to resolve too-far
branches for internal linking. The external linking,
solution on ppc64x is to split text sections when they
get too large, allowing the external linker to handle
the long branches.
On arm trampolines are generanted for too-far branches
for internal and external linking. When the change
was made recently to enable trampolines for external linking
on arm, that broke the ppc64x fix for too-far branches
with external linking.
The fix adds a check to use trampolines only for internal
linking with ppc64x.
Alex Brainman [Sun, 6 Nov 2016 07:43:49 +0000 (18:43 +1100)]
runtime/race: allow TestFail to run longer than 0.00s
Fixes #17811
Change-Id: I7bf9cbc5245417047ad28a14d9b9ad6592607d3d
Reviewed-on: https://go-review.googlesource.com/32774 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Brad Fitzpatrick [Fri, 4 Nov 2016 19:12:09 +0000 (19:12 +0000)]
cmd/vet: parallelize tests
Was 2.3 seconds. Now 1.4 seconds.
Next win would be not running a child process and refactoring main so
it could be called from tests easily. But that would also require
rewriting the errchk written in Perl. This appears to be the last user
of errchk in the tree.
Leon Klingele [Fri, 4 Nov 2016 23:57:45 +0000 (00:57 +0100)]
plugin: fix doc example fmt usage
Change-Id: I0520a37a48a56d231a8ac2dc58b2bf1762282760
Reviewed-on: https://go-review.googlesource.com/32795 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Brad Fitzpatrick [Wed, 2 Nov 2016 21:45:27 +0000 (14:45 -0700)]
crypto/x509: update __MAC_OS_X_VERSION_MAX_ALLOWED on Mac
Reportedly, -mmacosx-version-min=10.6 -D__MAC_OS_X_VERSION_MAX_ALLOWED=1060
is problematic.
It means min 10.6 and max 10.6, thus exactly 10.6. But we only support
10.8+.
It never caused us problems, because we build on Macs, but apparently
if you cross-compile from Linux with some Mac compiler SDK thing, then
things break?
This was added in https://golang.org/cl/5700083 for #3131, and the
intent at the time was to pin to exactly 10.6. So it wasn't a mistake,
but it is definitely outdated.
Given that we now support 10.8 as the min, update it to 1080.
Alan Donovan [Fri, 4 Nov 2016 21:11:51 +0000 (17:11 -0400)]
go/types: avoid redundant call to recordUse for anonymous fields
Anonymous fields are type expressions, and Checker.typexpr already
correctly records uses within them. There's no need for a second
call, and the second call caused a bug when we implemented aliases.
Change-Id: I1bf2429cd4948d68b085e75dfb1bdc03ad8caffd
Reviewed-on: https://go-review.googlesource.com/32837 Reviewed-by: Robert Griesemer <gri@golang.org>
Brad Fitzpatrick [Thu, 3 Nov 2016 20:53:05 +0000 (20:53 +0000)]
net/http: tweak the new Client 307/308 redirect behavior a bit
This CL tweaks the new (unreleased) 307/308 support added in
https://golang.org/cl/29852 for #10767.
Change 1: if a 307/308 response doesn't have a Location header in its
response (as observed in the wild in #17773), just do what we used to
do in Go 1.7 and earlier, and don't try to follow that redirect.
Change 2: don't follow a 307/308 if we sent a body on the first
request and the caller's Request.GetBody func is nil so we can't
"rewind" the body to send it again.
Vladimir Stefanovic [Tue, 18 Oct 2016 21:50:25 +0000 (23:50 +0200)]
runtime/internal/sys: add arch defs for GOARCH=mips{,le}
Change-Id: I6288f1fca1ae4c64b3907af700811ee842053020
Reviewed-on: https://go-review.googlesource.com/31472 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Vladimir Stefanovic [Tue, 18 Oct 2016 21:50:29 +0000 (23:50 +0200)]
cmd/internal/sys: add support for GOARCH=mips{,le}
Change-Id: I8c6b8839c68818430510702719dca15b8d748fb8
Reviewed-on: https://go-review.googlesource.com/31473 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Vladimir Stefanovic [Wed, 31 Aug 2016 14:58:56 +0000 (16:58 +0200)]
runtime: 8-byte align the heap_live field for atomic access
mheap_.heap_live is an atomically accessed uint64. It is currently not 8-byte
aligned on 32-bit platforms, which has been okay because it's only accessed via
Xadd64, which doesn't require alignment on 386 or ARM32. However, Xadd64 on
MIPS32 does require 8-byte alignment.
Add a padding field to force 8-byte alignment of heap_live and prevent an
alignment check crash on MIPS32.
Change-Id: I7eddf7883aec7a0a7e0525af5d58ed4338a401d0
Reviewed-on: https://go-review.googlesource.com/31635
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Brad Fitzpatrick [Sat, 22 Oct 2016 14:25:21 +0000 (07:25 -0700)]
testing: add T.Context method
From the doc comment:
Context returns the context for the current test or benchmark.
The context is cancelled when the test or benchmark finishes.
A goroutine started during a test or benchmark can wait for the
context's Done channel to become readable as a signal that the
test or benchmark is over, so that the goroutine can exit.
Fixes #16221.
Fixes #17552.
Change-Id: I657df946be2c90048cc74615436c77c7d9d1226c
Reviewed-on: https://go-review.googlesource.com/31724 Reviewed-by: Rob Pike <r@golang.org>