Ian Lance Taylor [Tue, 19 Jun 2018 23:53:18 +0000 (16:53 -0700)]
go/internal/gccgoimporter: read export data from archives
When used with the go tool, gccgo will normally generate archive files.
This change teaches the gccgoimporter package how to read the export
data from an archive.
This is needed by, for example, cmd/vet, when typechecking packages.
Change-Id: I21267949a7808cd81c0042af425c774a4ff7d82f
Reviewed-on: https://go-review.googlesource.com/119895
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Ian Lance Taylor [Tue, 19 Jun 2018 23:55:19 +0000 (16:55 -0700)]
misc/cgo/test: avoid duplicate definition with gccgo
Current versions of gccgo issue a duplicate definition error when both
a definition and an empty declaration occur. Use build tags to avoid
that case for the issue9400 subdirectory.
Change-Id: I18517af87bab05e9ca43f2f295459cf34347c317
Reviewed-on: https://go-review.googlesource.com/119896
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Heschi Kreinick [Tue, 19 Jun 2018 19:41:45 +0000 (15:41 -0400)]
debug/elf,macho,pe: support compressed DWARF
Since we're going to start compressing DWARF on Windows and maybe
Darwin, copy the ELF support for .zdebug sections to macho and pe. The
code is almost completely the same across the three.
While I was here I added support for compressed .debug_type sections,
which I presume were overlooked before.
Tests will come in a later CL once we can actually generate compressed
PE/Mach-O binaries, since there's no other good way to get test data.
Dmitri Shuralyov [Tue, 19 Jun 2018 20:14:00 +0000 (16:14 -0400)]
doc: update "Mac OS X", "OS X" to macOS; bump up to 10.10
The name was "Mac OS X" during versions 10.0 to 10.7.
It was renamed to "OS X" starting from 10.8 until 10.11.
The current name is "macOS" starting with 10.12. [1]
Previous changes (e.g., CL 47252) updated "Mac OS X" to macOS
in some places, but not everywhere. This CL updates remaining
instances for consistency.
Only the pages that display current information were updated;
historical pages such as release notes for older Go releases,
past articles, blog posts, etc., were left in original form.
Rename the "#osx" anchor to "#macos" on /doc/install page,
along with the single reference to it on the same page.
Add an empty div with id="osx" to not break old links.
Update minimum macOS version from 10.8 to 10.10 per #23122.
Robert Griesemer [Tue, 19 Jun 2018 17:20:35 +0000 (10:20 -0700)]
cmd/compile: more accurate position for select case error message
Fixes #25958.
Change-Id: I1f4808a70c20334ecfc4eb1789f5389d94dcf00e
Reviewed-on: https://go-review.googlesource.com/119755 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Carlos Eduardo Seo [Tue, 29 May 2018 19:00:38 +0000 (16:00 -0300)]
runtime: implement procyield properly for ppc64x
The procyield() function should yield the processor as in other
architectures. On ppc64x, this is achieved by setting the Program
Priority Register to 'low priority' prior to the spin loop, and
setting it back to 'medium-low priority' afterwards.
Robert Griesemer [Mon, 18 Jun 2018 21:38:45 +0000 (14:38 -0700)]
cmd/compile: fix exporting of 'for' loops
The existing code for encoding 'for' loops in exported, inlineable
functions incorrectly assumed that the 'Right' field points to an
'expression' node. Adjusted the code to be able to handle any kind
of node. Made matching changes for the binary and indexed exporter.
This only shows up together with other pending compiler changes that
enable exporting of such functions which contain for loops.
No tests yet because we can't test this w/o those pending compiler
changes. Once those changes are in, this code will be tested implicitly.
However, the changes were tested manually together with the patches
described in the issue.
Fixes #25222.
Change-Id: I54babb87e5d665d2c1ef6116c1de1b8c50b1138e
Reviewed-on: https://go-review.googlesource.com/119595 Reviewed-by: David Chase <drchase@google.com>
Hana Kim [Mon, 18 Jun 2018 16:03:53 +0000 (12:03 -0400)]
runtime/pprof: fix incorrect assumption in TestMapping
TestMapping assumed that there was only one mapping entry corresponding
to /exe/main, but that is not always true.
This CL changes the test logic to examine whether all referenced mappings
are symbolized. Based on the result, the test determines whether the
corresponding mapping entries' HasFunctions fields to be true or false.
I initially attempted to create two mappings for referenced locations
(one for symbolized and another for unsymbolized) as described in the
TODO in proto.go as part of fixing this bug. But that change requires
non-trivial modification in the upstream profile package so I decided
to just fix the test for now.
Fixes #25891
Change-Id: Id27a5b07bb5b59e133755a0f863bf56c0a4f7f2b
Reviewed-on: https://go-review.googlesource.com/119455
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Keith Randall [Wed, 13 Jun 2018 21:39:36 +0000 (14:39 -0700)]
runtime: move semaphore ops from system calls to libc calls on Darwin
This CL removes the last of the direct system calls in the runtime package.
This is the last CL for 1.11.
Use libcCall instead of asmcgocall in a few places I accidentally used
the wrong one.
For 1.12, we need to think about whether/how the syscall package
should be moved over to libc.
Update #17490
Change-Id: I4f0bd9cd6023f662f2e29588266fdfae5233898f
Reviewed-on: https://go-review.googlesource.com/118736
Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Brad Fitzpatrick [Fri, 15 Jun 2018 20:10:47 +0000 (20:10 +0000)]
net/http: document how Hijack and Request.Context interact, take two
Second try. The previous version (CL 115039 in git rev 3988863) wasn't
accurate.
Fixes #22347
Change-Id: I473165f308c730f50b14ba787cb215f7cb9ea364
Reviewed-on: https://go-review.googlesource.com/119235 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Heschi Kreinick [Sun, 6 May 2018 01:49:40 +0000 (21:49 -0400)]
cmd/link: compress DWARF sections in ELF binaries
Forked from CL 111895.
The trickiest part of this is that the binary layout code (blk,
elfshbits, and various other things) assumes a constant offset between
symbols' and sections' file locations and their virtual addresses.
Compression, of course, breaks this constant offset. But we need to
assign virtual addresses to everything before compression in order to
resolve relocations before compression. As a result, compression needs
to re-compute the "address" of the DWARF sections and symbols based on
their compressed size. Luckily, these are at the end of the file, so
this doesn't perturb any other sections or symbols. (And there is, of
course, a surprising amount of code that assumes the DWARF segment
comes last, so what's one more place?)
Relevant benchmarks:
name old time/op new time/op delta
StdCmd 10.3s ± 2% 10.8s ± 1% +5.43% (p=0.000 n=30+30)
Russ Cox [Fri, 8 Jun 2018 17:59:17 +0000 (13:59 -0400)]
cmd/go: add dark copy of golang.org/x/vgo
This CL corresponds to golang.org/cl/118096 (7fbc8df48a7)
in the vgo repo.
It copies the bulk of the code from vgo back into the main repo,
but completely disabled - vgo.Init is a no-op and vgo.Enabled
returns false unconditionally.
The point of this CL is to make the two trees easier to diff and
to make future syncs smaller.
Change-Id: Ic34fd5ddd8272a70c5a3b3437b5169e967d0ed03
Reviewed-on: https://go-review.googlesource.com/118095 Reviewed-by: Bryan C. Mills <bcmills@google.com>
Misty De Meo [Fri, 15 Jun 2018 18:15:50 +0000 (18:15 +0000)]
ld/macho: add all missing load commands
The ld/macho code currently understands a subset of the mach-o load
commands. I've encountered one of these in the wild in a Go-produced
binary, which tripped up the Go linker because its switch statement
expects its list of load commands to be exhaustive; the rest I've
added for the sake of completion.
The ruby-macho library is a good non-Darwin header resource for these:
https://github.com/homebrew/ruby-macho
Fixes #25908
Change-Id: Ib54c065d27e87d8726a9870df05a2bae24828b98
GitHub-Last-Rev: 655e3f488a4c1a89896a40edb0e1f715a5d3f734
GitHub-Pull-Request: golang/go#25906
Reviewed-on: https://go-review.googlesource.com/119115 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Fangming.Fang [Thu, 24 May 2018 08:36:00 +0000 (08:36 +0000)]
cmd/dist: run msan test only in testsanitizer on arm64
With latest gcc (7.3.0), misc/cgo/testsanitizer test will fail with reporting sigmentation
fault when running tsan test. On arm64, tsan is not supported currently and only msan test
can be run. So skip tsan test on arm64.
What needs to be pointed out is that msan test can be really run when setting clang
as c/c++ complier.
Fixes #25601
Change-Id: I6ab1a8d9edd243e2ee00ee40bc0abd6a0e6a125c
Reviewed-on: https://go-review.googlesource.com/114857 Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Richard Musiol [Thu, 14 Jun 2018 17:22:55 +0000 (19:22 +0200)]
cmd/link: fix name section of WebAssembly binary
Chrome and Node.js were not showing the names of WebAssembly
functions any more. This was due to the name section containing
names also for import functions, which is redundant.
Richard Musiol [Wed, 13 Jun 2018 13:43:54 +0000 (15:43 +0200)]
syscall/js: improve import functions
1. Make import functions not use the js.Value type directly,
but only the ref field. This gives more flexibility on the Go side
for the js.Value type, which is a preparation for adding
garbage collection of js.Value.
2. Turn import functions which are methods of js.Value into
package-level functions. This is necessary to make vet happy.
Austin Clements [Fri, 4 May 2018 18:55:31 +0000 (14:55 -0400)]
cmd/link: separate virtual address layout from file layout
Currently these two forms of layout are done in a single pass. This
makes it difficult to compress DWARF sections because that must be
done after relocations are applied, which must happen after virtual
address layout, but we can't layout the file until we've compressed
the DWARF sections.
Fix this by separating the two layout steps. In the process, we can
also unify the copy-pasted code in Link.address to compute file
offsets, which currently has some unnecessary variation.
Unlike the current file offset computation, which depends on virtual
addresses, the new computation only uses file offsets and sizes. This
will let us compress the file representation of a segment and create
the file layout based on its on-disk size rather than its original
in-memory size.
Tested by comparing the test binary for the "strings" package on all
supported GOOS/GOARCH combinations. All binaries are identical
(except, of course, their build IDs).
Richard Musiol [Fri, 8 Jun 2018 16:12:57 +0000 (18:12 +0200)]
all: enable vet/all for js/wasm and fix vet issues
This commit enables vet/all for the js/wasm architecture. It got
skipped initially because the codebase did not fully compile yet
for js/wasm, which made vet/all fail.
startTimer and stopTimer are not needed in the syscall package.
Removed their assembly code since their Go stubs were already gone.
Brian Kessler [Wed, 13 Jun 2018 16:04:49 +0000 (10:04 -0600)]
math/big: handle negative exponents in Exp
For modular exponentiation, negative exponents can be handled using
the following relation.
for y < 0: x**y mod m == (x**(-1))**|y| mod m
First compute ModInverse(x, m) and then compute the exponentiation
with the absolute value of the exponent. Non-modular exponentiation
with a negative exponent still returns 1.
Fixes #25865
Change-Id: I2a35986a24794b48e549c8de935ac662d217d8a0
Reviewed-on: https://go-review.googlesource.com/118562
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Richard Musiol [Sat, 19 May 2018 22:56:36 +0000 (00:56 +0200)]
runtime, sycall/js: add support for callbacks from JavaScript
This commit adds support for JavaScript callbacks back into
WebAssembly. This is experimental API, just like the rest of the
syscall/js package. The time package now also uses this mechanism
to properly support timers without resorting to a busy loop.
JavaScript code can call into the same entry point multiple times.
The new RUN register is used to keep track of the program's
run state. Possible values are: starting, running, paused and exited.
If no goroutine is ready any more, the scheduler can put the
program into the "paused" state and the WebAssembly code will
stop running. When a callback occurs, the JavaScript code puts
the callback data into a queue and then calls into WebAssembly
to allow the Go code to continue running.
Rob Pike [Thu, 14 Jun 2018 01:09:28 +0000 (11:09 +1000)]
cmd/cover: remove use of diff in cover_test.go
It's non-portable, and the test isn't hard to write without diff.
It still produces helpful output in case of trouble:
--- FAIL: TestCoverHTML (0.75s)
cover_test.go:325: line 4 differs: got:
case <-ch:<span class="cov0" title="0"></span>
want:
case <-ch:<span class="cov0" xitle="0"></span>
This makes the test operating-system independent.
Change-Id: Iff35f00cb76ba89bc1b93db01c6f994e74341f4a
Reviewed-on: https://go-review.googlesource.com/118795 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Brian Kessler [Fri, 8 Jun 2018 17:48:18 +0000 (11:48 -0600)]
math/big: round x + (-x) to -0 for mode ToNegativeInf
Handling of sign bit as defined by IEEE 754-2008, section 6.3:
When the sum of two operands with opposite signs (or the difference of
two operands with like signs) is exactly zero, the sign of that sum (or
difference) shall be +0 in all rounding-direction attributes except
roundTowardNegative; under that attribute, the sign of an exact zero
sum (or difference) shall be −0. However, x+x = x−(−x) retains the same
sign as x even when x is zero.
This change handles the special case of Add/Sub resulting in exactly zero
when the rounding mode is ToNegativeInf setting the sign bit accordingly.
David Chase [Tue, 12 Jun 2018 18:10:33 +0000 (14:10 -0400)]
cmd/compile: ensure that operand of ORETURN is not double-walked
Inlining of switch statements into a RETURNed expression
can sometimes lead to the switch being walked twice, which
results in a miscompiled switch statement. The bug depends
on:
1) multiple results
2) named results
3) a return statement whose expression includes a call to a
function containing a switch statement that is inlined.
It may also be significant that the default case of that
switch is a panic(), though that's not proven.
Rearranged the walk case for ORETURN so that double walks are
not possible. Added a test, because this is so fiddly.
Added a check against double walks, verified that it fires
w/o other fix.
Constantin Konstantinidis [Thu, 14 Jun 2018 09:51:57 +0000 (11:51 +0200)]
mime/multipart: return error from NextPart if boundary is empty
NewReader cannot return an error. This behaviour is kept.
NextPart returns EOF when boundary is empty.
RFC 2046 does not allow it. The fix is to return an error
on the call of NextPart.
Alberto Donizetti [Wed, 13 Jun 2018 18:48:26 +0000 (20:48 +0200)]
runtime/pprof: use testenv.GoToolPath in TestMapping
The TestMapping test invokes the go tool in an exec.Command by
directly hard-coding a "go" string for the command. This can cause
test failures on systems where the "go" command points to an old
toolchain where the test is not supposed to work.
Use testenv.GoToolPath instead.
Also call 'go run' directly on the mappingtest/main.go file instead of
go-running the directory.
Alex Brainman [Mon, 11 Jun 2018 02:09:18 +0000 (12:09 +1000)]
internal/poll: specify current file position when calling TransmitFile
Current SendFile implementation assumes that TransmitFile starts from
the current file position. But that appears not true for Windows 10
Version 1803.
suggests, "You can use the lpOverlapped parameter to specify a 64-bit
offset within the file at which to start the file data transfer by
setting the Offset and OffsetHigh member of the OVERLAPPED structure."
Akhil Indurti [Thu, 14 Jun 2018 00:52:05 +0000 (20:52 -0400)]
cmd/go: document convention to signify generated code.
This change updates the go tool's documentation under the section
"Generate Go files by processing source" to mention the convention that
generated source files should have a line of text that matches the
following regular expression:
^// Code generated .* DO NOT EDIT\.$
Previously, the canonical documentation for this convention
(https://golang.org/s/generatedcode) referenced Rob Pike's comment at
https://golang.org/issue/13560#issuecomment-288457920. This change
merely moves that information to a more visible place.
Updates #25433.
Change-Id: I804d95d307d1dc68cb28da3750ebe9090178c474
Reviewed-on: https://go-review.googlesource.com/118756 Reviewed-by: Rob Pike <r@golang.org>
Ian Lance Taylor [Wed, 13 Jun 2018 22:49:52 +0000 (15:49 -0700)]
cmd/cgo: add import path to hash
This avoids name conflicts when two identical packages use cgo.
This can happen in practice when the same package is vendored multiple
times in a single build.
Fixes #23555
Change-Id: I9f0ec6db9165dcf9cdf3d314c668fee8ada18f9c
Reviewed-on: https://go-review.googlesource.com/118739
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Emmanuel T Odeke [Mon, 11 Jun 2018 00:17:49 +0000 (17:17 -0700)]
cmd/compile: make case insensitive suggestions aware of package
Ensure that compiler error suggestions after case insensitive
field lookups don't mistakenly reported unexported fields if
those fields aren't in the local package being processed.
Sabin Mihai Rapan [Sun, 28 Jan 2018 12:08:14 +0000 (14:08 +0200)]
cgo: update documentation on calling C variadic functions
The current implementation does not support calling C variadic
functions (as discussed in #975). Document that.
Fixes #23537
Change-Id: If4c684a3d135f3c2782a720374dc4c07ea66dcbb
Reviewed-on: https://go-review.googlesource.com/90415 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Tobias Klauser [Wed, 13 Jun 2018 13:54:42 +0000 (15:54 +0200)]
syscall: check Fchmodat flags parameter on Linux
As mentioned in #25845, port CL 46474 from golang.org/x/sys/unix to the
syscall package.
Currently Linux' fchmodat(2) syscall implementation doesn't support the
flags parameter (though it might in future versions [1]). Fchmodat in
the syscall package takes the parameter and (wrongly) passes it on to the
syscall which will ignore it.
According to the POSIX.1-2008 manual page [2], AT_SYMLINK_NOFOLLOW is
the only valid value for the flags parameter and EOPNOTSUPP should be
returned in case changing the mode of a symbolic link is not supported
by the underlying system. EINVAL should be returned for any other value
of the flags parameter.
Change-Id: I1021dd0e6a4f4cb3557cb1c1b34dd618c378cda6
Reviewed-on: https://go-review.googlesource.com/118658 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Wed, 13 Jun 2018 15:20:23 +0000 (08:20 -0700)]
runtime: move darwin kevent calls to libc
kqueue, kevent, closeonexec, setitimer, with sysctl and fcntl helpers.
TODO:arm,arm64
Change-Id: I9386f377186d6ac7cb99064c524a67e0c8282eba
Reviewed-on: https://go-review.googlesource.com/118561 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Hana Kim [Wed, 13 Jun 2018 17:37:33 +0000 (13:37 -0400)]
runtime/pprof: skip TestMapping if CGO is not available
The test requires cgo
Change-Id: I1bffee5f187afcf4b7e27516451c56ddfc263a26
Reviewed-on: https://go-review.googlesource.com/118638 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Tobias Klauser [Wed, 13 Jun 2018 13:40:50 +0000 (15:40 +0200)]
syscall: support Linux syscalls without error return on mipsx/mips64x
Like on other architectures, use rawSyscallNoError for Linux syscalls
that don't return an error and convert all applicable occurences of
RawSyscall to use it instead.
This was missed in CL 84485 because mkall.sh doesn't support
mipsx/mips64x, so add the corresponding entries as well.
Richard Musiol [Wed, 13 Jun 2018 08:36:01 +0000 (10:36 +0200)]
misc/wasm: remove use of performance.timeOrigin
This commit changes wasm_exec.js to not depend on the existence of
performance.timeOrigin. The field is not yet supported on all
browsers, e.g. it is unavailable on Safari.
Hana Kim [Tue, 12 Jun 2018 16:01:59 +0000 (12:01 -0400)]
runtime/pprof: set HasFunctions of mapping entries
The pprof tool utilizes attributes of mapping entries
such as HasFunctions to determine whether the profile
includes necessary symbol information.
If none of the attributes is set, pprof tool tries to
read the corresponding binary to use for local symbolization.
If the binary doesn't exist, it prints out error messages.
Go runtime generated profiles without any of the attributes
set so the pprof tool always printed out the error messages.
The error messages became more obvious with the new
terminal support that uses red color for error messages.
Go runtime can symbolize all Go symbols and generate
self-contained profile for pure Go program. Thus, there
is no reason for the pprof tool to look for the copy of
the binary. So, this CL sets one of the attributes
(HasFunctions) true if all PCs in samples look fully
symbolized.
For non-pure Go program, however, it's possible that
symbolization of non-Go PCs is incomplete. In this case,
we need to leave the attributes all false so pprof can attempt
to symbolize using the local copy of the binary if available.
It's hard to determine whether a mapping includes non-Go
code. Instead, this CL checks PCs from collected samples.
If unsuccessful symbolization is observed, it skips setting
the HasFunctions attribute.
Fixes #25743
Change-Id: I5108be45bbc37ab486d145fa03e7ce37d88fad50
Reviewed-on: https://go-review.googlesource.com/118275
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Russ Cox [Tue, 12 Jun 2018 20:40:52 +0000 (16:40 -0400)]
cmd/go: fix go list usage line
CL 108156 added -cgo and -export,
but in the usage line it added -cgo and -list.
CL 117015 correctly added -export to the usage line.
All that remains is to remove -list.
Suriyaa Sundararuban [Wed, 13 Jun 2018 07:06:04 +0000 (07:06 +0000)]
doc: use HTTPS for links
Change-Id: I9d2d25df067ca573589db5ff18296a5ec33866be
Reviewed-on: https://go-review.googlesource.com/118595 Reviewed-by: Ian Lance Taylor <iant@golang.org>
doc: document the lack of support for symlinks under GOPATH
In an effort to help others avoid the issues I've hit due to lack of
symlink support under GOPATH, I've added a note of warning to the
Workspaces section.
I have not changed the contents of go help gopath, because on reflection
it seems this change alone may be sufficient.
Fixes #21320
Change-Id: Ib8969bf12cecad878e89ff66b5864bbf3caaf219
Reviewed-on: https://go-review.googlesource.com/61930 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Austin Clements [Fri, 4 May 2018 18:55:31 +0000 (14:55 -0400)]
cmd/link: separate virtual address layout from file layout
Currently these two forms of layout are done in a single pass. This
makes it difficult to compress DWARF sections because that must be
done after relocations are applied, which must happen after virtual
address layout, but we can't layout the file until we've compressed
the DWARF sections.
Fix this by separating the two layout steps. In the process, we can
also unify the copy-pasted code in Link.address to compute file
offsets. Currently, each instance of this is slightly different, but
there's no reason for it to be. For example, we don't perform
PEFILEALIGN alignment on Segrodata or Selreltodata even when HeadType
== Hwindows, but it turns out it doesn't matter whether you do or
don't because these segments simply don't exist on Windows. Hence, in
the unified code path, we do this alignment for all segments.
Likewise, there are two ways of computing Fileoff:
seg.Vaddr - prev.Vaddr + prev.Fileoff
and
prev.Fileoff + uint64(Rnd(int64(prev.Filelen), int64(*FlagRound)))
At the moment, these always have the same value, but the latter will
continue to work after we start compressing sections on disk.
Tested by comparing test binaries for all packages in std before and
after this change for GOOS={linux,windows,darwin,plan9}. All binaries
are identical.
Russ Cox [Tue, 12 Jun 2018 20:05:29 +0000 (16:05 -0400)]
cmd/go: use build cache for tests when GOCACHE is unset
Before this CL, if you had GOCACHE=/some/dir, then the cmd/go tests used it.
But if you were relying on the implicit behavior that GOCACHE being empty
meant an appropriate system-specific cache directory, then the cmd/go tests
ran with no cache at all, which makes them about 4X slower.
During all.bash GOCACHE is set to a fresh temporary directory and is therefore
already getting proper caching; this CL mainly helps people running 'go test cmd/go'
by hand.
Change-Id: I7c322ca79b877c1d0a3b448b95d5354fbfcba7f8
Reviewed-on: https://go-review.googlesource.com/118320
Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Cherry Zhang [Mon, 11 Jun 2018 17:41:23 +0000 (13:41 -0400)]
cmd/compile: use a different register for updated value in AtomicAnd8/Or8 on ARM64
ARM64 manual says it is "constrained unpredictable" if the src
and dst registers of STLXRB are same, although it doesn't seem
to cause any problem on real hardwares so far. Fix by allocating
a different register to hold the updated value for
AtomicAnd8/Or8. We do this by making the ops returns <val,mem>
like AtomicAdd, although val will not be used elsewhere.
Robert Griesemer [Wed, 6 Jun 2018 17:21:15 +0000 (10:21 -0700)]
cmd/compile: correct alias cycle detection
The original fix (https://go-review.googlesource.com/c/go/+/35831)
for this issue was incorrect as it reported cycles in cases where
it shouldn't.
Instead, use a different approach: A type cycle containing aliases
is only a cycle if there are no type definitions. As soon as there
is a type definition, alias expansion terminates and there is no
cycle.
Approach: Split sprint_depchain into two non-recursive and more
easily understandable functions (cycleFor and cycleTrace),
and use those instead for cycle reporting. Analyze the cycle
returned by cycleFor before issueing an alias cycle error.
Also: Removed original fix (main.go) which introduced a separate
crash (#23823).
Fixes #18640.
Fixes #23823.
Fixes #24939.
Change-Id: Ic3707a9dec40a71dc928a3e49b4868c5fac3d3b7
Reviewed-on: https://go-review.googlesource.com/118078 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Elias Naur [Thu, 7 Jun 2018 10:19:42 +0000 (12:19 +0200)]
runtime: use libc for signal functions on iOS
Also:
- Add extra SystemStack space for darwin/arm64 just
like for darwin/arm.
- Removed redundant stack alignment; the arm64 hardware enforces
the 16 byte alignment.
- Save and restore the g registers at library initialization.
- Zero g registers since libpreinit can call libc functions
that in turn use asmcgocall. asmcgocall requires an initialized g.
- Change asmcgocall to work even if no g is set. The change mimics
amd64.
Change-Id: I1b8c63b07cfec23b909c0d215b50dc229f8adbc8
Reviewed-on: https://go-review.googlesource.com/117176
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Keith Randall [Sun, 20 May 2018 15:57:53 +0000 (08:57 -0700)]
runtime: use libc's signal functions on Darwin
sigaction, sigprocmask, sigaltstack, and raiseproc.
Fix bug in mstart_stub where we weren't saving callee-saved registers,
so if an m finished the pthread library calling mstart_stub would
sometimes fail.
Update #17490
Update #22805
Change-Id: Ie297ede0997910aa956834e49e85711b90cdfaa7
Reviewed-on: https://go-review.googlesource.com/116875
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Thomas Wanielista [Fri, 22 Dec 2017 21:17:56 +0000 (16:17 -0500)]
go/doc: classify function returning slice or array of T as constructor
Previously, go/doc would only consider functions and slices that
return types of T or any number of pointers to T: *T, **T, etc. This
change expands the definition of a constructor to include functions
that return arrays of a type (or pointer to that type) in its first
return.
With this change, the following return types also classify a function
as a constructor of type T:
[1]T
[1]*T
[1]**T
(and so on)
Fixes #22856.
Change-Id: I37957c5f2d6a7b2ceeb3fbaef359057f2039393d
Reviewed-on: https://go-review.googlesource.com/85355
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Brad Fitzpatrick [Wed, 6 Jun 2018 22:50:01 +0000 (22:50 +0000)]
net/http, net/http/httptrace: make Transport support 1xx responses properly
Previously the Transport had good support for 100 Continue responses,
but other 1xx informational responses were returned as-is.
But per https://tools.ietf.org/html/rfc7231#section-6.2:
> A client MUST be able to parse one or more 1xx responses received
> prior to a final response, even if the client does not expect one. A
> user agent MAY ignore unexpected 1xx responses.
We weren't doing that. Instead, we were returning any 1xx that wasn't
100 as the final result.
With this change we instead loop over up to 5 (arbitrary) 1xx
responses until we find the final one, returning an error if there's
more than 5. The limit is just there to guard against malicious
servers and to have _some_ limit.
By default we ignore the 1xx responses, unless the user defines the
new httptrace.ClientTrace.Got1xxResponse hook, which is an expanded
version of the previous ClientTrace.Got100Continue.
Still remaining:
* httputil.ReverseProxy work. (From rfc7231#section-6.2: "A proxy MUST
forward 1xx responses unless the proxy itself requested the
generation of the 1xx response."). Which would require:
* Support for an http.Handler to generate 1xx informational responses.
Those can happen later. Fixing the Transport to be resilient to others
using 1xx in the future without negotiation (as is being discussed
with HTTP status 103) is most important for now.
Updates #17739
Change-Id: I55aae8cd978164643fccb9862cd60a230e430486
Reviewed-on: https://go-review.googlesource.com/116855
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Tobias Klauser [Mon, 11 Jun 2018 12:41:58 +0000 (14:41 +0200)]
net: update file read position after sendfile syscall
On dragonfly, freebsd and solaris the sendfile syscall does not update
the read position of the source fd. Update it after sendfile so
successive calls start at the correct position.