1
0
mirror of https://github.com/golang/go synced 2024-10-05 09:11:21 -06:00
Commit Graph

7060 Commits

Author SHA1 Message Date
Russ Cox
f034ee8c22 cmd/dist: apply final edits from CL 18199.
I broke the rule: never click the Submit button on the web.

Change-Id: If81a5cc31c1f28664960bad124cc596f5cab1222
Reviewed-on: https://go-review.googlesource.com/18203
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-29 17:25:06 +00:00
Russ Cox
d513ee774c cmd/dist: run shards of test dir in parallel
Saves 15 seconds from all.bash on my laptop (3:20 -> 3:05).

Change-Id: Ic5dc3c7804e78b584789dd856a3dada94000a8e2
Reviewed-on: https://go-review.googlesource.com/18199
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-29 17:18:04 +00:00
Russ Cox
b6473ff132 cmd/dist: run wiki, shootout etc tests only on builders
These find approximately nothing.
Takes 5% off my all.bash run time.

For #10571.

Change-Id: I21d3a844af756eb37f59bba0064f24995626da0d
Reviewed-on: https://go-review.googlesource.com/18198
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-29 16:26:50 +00:00
Russ Cox
baa928a782 cmd/dist: run various one-off tests in parallel
Takes 15% off my all.bash run time
(after this and earlier CLs, now down to 3½ from 5½ minutes).

For #10571.

Change-Id: Iac316ffb730c9ff0a0faa7cc3b82ed4f7e6d4361
Reviewed-on: https://go-review.googlesource.com/18088
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-29 15:50:04 +00:00
Russ Cox
f41378e225 cmd/dist: run limited tests in race and libgcc=none modes
Mostly we just care that the test binaries link and start up.
No need to run the full test suites.

Takes 12% off my all.bash run time.

For #10571.

Change-Id: I01af618f3d51deb841ea638424e1389a2df7d746
Reviewed-on: https://go-review.googlesource.com/18086
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-12-29 15:48:04 +00:00
Russ Cox
f70f277875 cmd/dist: make test default to --no-rebuild
I'm tired of having to remember it on every command.
Rebuilding everything is the wrong default.

This CL updates the build script, but the builders may
(or may not) need work, depending on whether they
rebuild using the test command (I doubt it).

Change-Id: I21f202a2f13e73df3f6bd54ae6a317c467b68151
Reviewed-on: https://go-review.googlesource.com/18084
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-29 15:20:00 +00:00
Robert Griesemer
d6a203ecab cmd/compile: const name and label name may match
Fixes #13684.

Change-Id: I3977119b6eb1d6b7dc2ea1e7d6656a8f0d421bc1
Reviewed-on: https://go-review.googlesource.com/18060
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-12-21 20:21:28 +00:00
Russ Cox
5b085482ae cmd/go: ignore XML errors after Go <meta> tags
Fixes #13683.

Change-Id: I26afb3ac346beb95624f9032d94a29b5bc7853ef
Reviewed-on: https://go-review.googlesource.com/18051
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-18 19:51:06 +00:00
Russ Cox
ab74f5944e cmd/go: do not skip dirs with syntax errors in wildcard matching (like ./...)
Fixes #11407.

Change-Id: If35a8e04a3abf8acf955250c909dde57131b6bb8
Reviewed-on: https://go-review.googlesource.com/17971
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-18 17:21:29 +00:00
Ian Lance Taylor
ebf64bcc24 cmd/vet: add some checks for invalid pointer passing using cgo
Update #12416.

Change-Id: I21d97cbe211ccc8048e5a78ea4d89664f4d195ba
Reviewed-on: https://go-review.googlesource.com/17041
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-18 00:31:21 +00:00
Brad Fitzpatrick
8db371b3d5 api: create go1.6.txt
Change-Id: If2b30ab412d6799c8be01eb007462d6b58660ece
Reviewed-on: https://go-review.googlesource.com/18014
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-17 22:45:50 +00:00
Russ Cox
c7b1ef9918 cmd/link: reject non-package main toplevel.a file, remove dead code
The test for non-package main top-level inputs is done while parsing
the export data. Issue #13468 happened because we were not parsing
the export data when using compiler-generated archives
(that is, when using go tool compile -pack).

Fix this by parsing the export data even for archives.

However, that turns up a different problem: the export data check
reports (one assumes spurious) skew errors now, because it has
not been run since Go 1.2.
(Go 1.3 was the first release to use go tool compile -pack.)

Since the code hasn't run since Go 1.2, it can't be that important.
Since it doesn't work today, just delete it.

Figuring out how to make this code work with Robert's export
format was one of the largest remaining TODOs for that format.
Now we don't have to.

Fixes #13468 and makes the world a better place.

Change-Id: I40a4b284cf140d49d48b714bd80762d6889acdb9
Reviewed-on: https://go-review.googlesource.com/17976
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-12-17 20:59:51 +00:00
Russ Cox
2f08bd96a0 cmd/go: for go get -insecure, do not fall back to HTTP for non-200 responses
Since we allow non-200 responses from HTTPS in normal operation,
it seems odd to reject them in -insecure operation.

Fixes #13037 (again).

Change-Id: Ie232f7544ab192addfad407525888db6b967befe
Reviewed-on: https://go-review.googlesource.com/17945
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 20:28:14 +00:00
Russ Cox
a227351b62 cmd/go: fix processing of HTTPS 404 without -insecure
The change here is to move the closeBody call into the if block.
The logging adjustments are just arranging to tell the truth:
in particular if we're not in insecure mode and we get a non-200
error then we do not actually ignore the response
(except as caused by closing the body incorrectly).

As the comment below the change indicates, it is intentional that
we process non-200 pages. The code does process them, because
the if err != nil || status != 200 block does not return.
But that block does close the body, which depending on timing
can apparently poison the later read from the body.

See #13037's initial report:

	$ go get -v bosun.org/cmd/bosun/cache
	Fetching https://bosun.org/cmd/bosun/cache?go-get=1
	ignoring https fetch with status code 404
	Parsing meta tags from https://bosun.org/cmd/bosun/cache?go-get=1 (status code 404)
	import "bosun.org/cmd/bosun/cache": parsing bosun.org/cmd/bosun/cache: http: read on closed response body
	package bosun.org/cmd/bosun/cache: unrecognized import path "bosun.org/cmd/bosun/cache"

The log print about ignoring the https fetch is not strictly true,
since the next thing that happened was parsing the body of that fetch.
But the read on the closed response body failed during parsing.

Moving the closeBody to happen only when we're about to discard the
result and start over (that is, only in -insecure mode) fixes the parse.

At least it should fix the parse. I can't seem to break the parse anymore,
because of #13648 (close not barring future reads anymore),
but this way is clearly better than the old way. If nothing else the old code
closed the body twice when err != nil and -insecure was not given.

Fixes #13037.

Change-Id: Idf57eceb6d5518341a2f7f75eb8f8ab27ed4e0b4
Reviewed-on: https://go-review.googlesource.com/17944
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 20:28:00 +00:00
Russ Cox
9f0055a232 Revert "cmd/go: allow omitted user name in git ssh repo syntax"
This caused #13657.
Reverting fixes #13657.

I was trying to be helpful by fixing #12313,
but I don't need the fix myself.
Will leave for someone with more motivation.

This reverts commit 3e9f063670.

Change-Id: Ifc78a6196f23e0f58e3b9ad7340e207a2d5de0a6
Reviewed-on: https://go-review.googlesource.com/17977
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 20:25:42 +00:00
Russ Cox
761ac75a94 cmd/go: fix git submodule fetch
Thanks to @toxeus on GitHub for the test case.

Fixes #12612.

Change-Id: I0c32fbe5044f3552053460a5347c062568093dff
Reviewed-on: https://go-review.googlesource.com/17974
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 20:18:18 +00:00
Ian Lance Taylor
54977cd3de cmd/go: runtime and runtime/internal packages depend on runtime/internal/sys
Fixes #13655.

Change-Id: I764019aecdd59743baa436b7339499e6c2126268
Reviewed-on: https://go-review.googlesource.com/17916
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 19:37:18 +00:00
Russ Cox
0cb68acea2 cmd/go: respect umask when creating executables
Also update many call sites where I forgot that the permission
argument is going to be masked by umask.

Fixes #12692.

Change-Id: I52b315b06236122ca020950447863fa396b68abd
Reviewed-on: https://go-review.googlesource.com/17950
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 19:24:06 +00:00
Russ Cox
0d641c754f cmd/go: allow ~ as first char of path element in general git import paths
This makes go get gitserver/~user/repo.git/foo work.

Fixes #9193.

Change-Id: I8c9d4096903288f7f0e82d6ed1aa78bf038fb81a
Reviewed-on: https://go-review.googlesource.com/17952
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:13:03 +00:00
Russ Cox
06b46c0d9c cmd/go: don't be clever about mtime precision in test
This doesn't happen enough in the tests to be worth debugging.
Empirically, I expect this to add 5 seconds to the overall 'go test -short cmd/go'
on systems with precise file systems, and nothing on systems without them
(like my Mac).

Fixes #12205.

Change-Id: I0a17cb37bdedcfc0f921c5ee658737f1698c153b
Reviewed-on: https://go-review.googlesource.com/17953
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 17:06:15 +00:00
Russ Cox
e357eb97a6 cmd/go: document that package documentation is ignored
Fixes #11801.

Change-Id: I2caeac7fdddc7f29015d6db8d4b3e296c8b9c423
Reviewed-on: https://go-review.googlesource.com/17954
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:04:55 +00:00
Russ Cox
3e9f063670 cmd/go: allow omitted user name in git ssh repo syntax
No test because the code has no test.

Fixes #12313.

Change-Id: I2cfd0a0422c0cd76f0371c2d3bbbdf5bb3b3f1eb
Reviewed-on: https://go-review.googlesource.com/17951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:01:05 +00:00
Russ Cox
f9137c5373 cmd/go: document that tests run in the source directory
Fixes #13538.

Change-Id: I621bbe2befe838d16d3664d7a5e30d5d7cceae33
Reviewed-on: https://go-review.googlesource.com/17949
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:00:37 +00:00
Russ Cox
f474885f8a cmd/go: document where get writes, and not vendor directories
Fixes #12260.

Change-Id: I95c27aad6de8064b9a205d4ee507bce75926f16d
Reviewed-on: https://go-review.googlesource.com/17948
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:00:02 +00:00
Russ Cox
8fac7e3cc7 cmd/go: document that go generate accepts all build flags
Fixes #12544.

Change-Id: I5e2fd1fbb21816e9f6fb022e2664484a71093b04
Reviewed-on: https://go-review.googlesource.com/17947
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 16:59:46 +00:00
Russ Cox
0a0f8bae27 cmd/go: document that -p applies to test binary execution
Fixes #11521.

Change-Id: I73615b881df4a0d5e2f5bc5059359d150ca8c105
Reviewed-on: https://go-review.googlesource.com/17946
Reviewed-by: Joe Shaw <joe@joeshaw.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 16:59:30 +00:00
Brad Fitzpatrick
7688f0d9fb cmd/pprof: fix scaling of "gigabyte" unit
Fixes #13654

Change-Id: Id2ce32c52efcfdbd66630725d62d2ca6bf0916d5
Reviewed-on: https://go-review.googlesource.com/17934
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 16:38:28 +00:00
Russ Cox
70cee781fc cmd/go: use tags when evaluating file system wildcards like ./...
Thanks to Albert Hafvenström for the diagnosis.

Fixes #11246.

Change-Id: I2b9e670c0ecf6aa01e5bf4d7a402619e93cc4f4a
Reviewed-on: https://go-review.googlesource.com/17942
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 05:46:29 +00:00
Russ Cox
37f2afa625 cmd/go: disable use of -linkmode=external in tests when CGO_ENABLED=0
If cgo is turned off, there may not be an external linker available.

Fixes #13450.

Change-Id: Idbf3f3f57b4bb3908b67264f96d276acc952102a
Reviewed-on: https://go-review.googlesource.com/17941
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 05:46:21 +00:00
Russ Cox
4378746a4b cmd/dist: show output from failed compiler execution
Maybe it will say something that helps the user understand the problem.

Note that we can't use os/exec.ExitError's new Stderr field because
cmd/dist is compiled with Go 1.4.

Fixes #13099.

Change-Id: I4b5910434bf324d1b85107002a64684d8ba14dc8
Reviewed-on: https://go-review.googlesource.com/17940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 03:14:11 +00:00
Ian Lance Taylor
fcbf04f9b9 cmd/cgo: gccgo support for cgoCheckPointer
This uses weak declarations so that it will work with current versions
of gccgo that do not support pointer checking.

Change-Id: Ia34507e3231ac60517cb6834f0b673764715a256
Reviewed-on: https://go-review.googlesource.com/17429
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 03:01:38 +00:00
Russ Cox
8350e06556 cmd/go: add -args to 'go test' to resolve -v ambiguity
The new flag -args stops flag processing, leaving the rest of the command line
to be passed to the underlying test binary verbatim. Thus, both of these pass
a literal -v -n on the test binary command line, without putting the go command
into verbose mode or disabling execution of commands:

	go test . -args -v -n
	go test -args -v -n

Also try to make the documentation a bit clearer.

Fixes #7221.
Fixes #12177.

Change-Id: Ief9e830a6fbb9475d96011716a86e2524a35eceb
Reviewed-on: https://go-review.googlesource.com/17775
Reviewed-by: Rob Pike <r@golang.org>
2015-12-17 01:59:58 +00:00
Russ Cox
5c596b51fd Revert "cmd/dist: fix build after "go test" argument order change"
No longer needed - the change to 'go test' was rolled back.

This reverts commit 2c96e5d2fc.

Change-Id: Ibe9c5f48e3e4cbbbde2f5c8c516b2987ebba55ae
Reviewed-on: https://go-review.googlesource.com/17776
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-12-17 01:43:47 +00:00
Shenghou Ma
a766d8e59c cmd/cgo: map C unsigned char back to _Ctype_uchar in error messages
Fixes #13635.

Change-Id: Icab4a45567f435f002a8f6c85db9538acf054a70
Reviewed-on: https://go-review.googlesource.com/17863
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 22:13:17 +00:00
Russ Cox
03c8164849 cmd/compile: fix magic multiply smashing AX
Fixes #12411.

Change-Id: I2202a754c7750e3b2119e3744362c98ca0d2433e
Reviewed-on: https://go-review.googlesource.com/17818
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 20:58:17 +00:00
Russ Cox
63a6f305ef cmd/compile: diagnose invalid switch interface{} case earlier
Fixes #11737.

Change-Id: Id231b502ac5a44035dc3a02515b43bf665cb1e87
Reviewed-on: https://go-review.googlesource.com/17816
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 20:58:00 +00:00
Russ Cox
91c8e5f80b cmd/compile: fix export type conversion loss in inlined func body
Fixes #12677.

Change-Id: I72012f55615fcf5f4a16c054706c9bcd82e49ccd
Reviewed-on: https://go-review.googlesource.com/17817
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 20:30:04 +00:00
Russ Cox
a40281112c Revert "cmd/go: fix processing of flags for test binaries."
This broke a number of common "go test" invocations.
Will fix the original concern differently.

This reverts commit 6acb4d944d.

Fixes #13583.

Change-Id: If582b81061df28173c698bed1d7d8283b0713cae
Reviewed-on: https://go-review.googlesource.com/17773
Reviewed-by: Rob Pike <r@golang.org>
2015-12-16 20:25:59 +00:00
Russ Cox
bdd5d6e257 cmd/go: tiny cleanup
Change-Id: I65084e518c735f1e50d191a612cd32533b241685
Reviewed-on: https://go-review.googlesource.com/17742
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-16 20:22:28 +00:00
Russ Cox
0c428a5617 go/build: support vendor directories in Import
This fix, plus a one-line change to golang.org/x/tools/go/loader,
is sufficient to let that loader package process source code
using vendored packages. For example,

	GOPATH="" ssadump net/http # uses vendored http2

used to fail, not able to find net/http's import of the vendored
copy of golang.org/x/net/http2/hpack.

This CL plus the fix to loader (CL 17727) suffices to get ssadump working,
as well as - I expect - most other source code processing built
on golang.org/x/tools/go/loader.

Fixes #12278.

Change-Id: I83715e757419171159f67d49bb453636afdd91f0
Reviewed-on: https://go-review.googlesource.com/17726
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 20:22:18 +00:00
Robert Griesemer
65cd1ba682 cmd/compile: re-vendor math/big so we use latest version in compiler
This simply copies the current version of math/big into the
compiler directory. The change was created automatically by
running cmd/compile/internal/big/vendor.bash. No other manual
changes.

Change-Id: Ica225d196b3ac10dfd9d4dc1e4e4ef0b22812ff9
Reviewed-on: https://go-review.googlesource.com/17900
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-16 18:35:23 +00:00
Russ Cox
1babba2e4c cmd/compile: fix -race nit
Fixes #13264.

Change-Id: I74b941164610921a03814733fea08631f18b6178
Reviewed-on: https://go-review.googlesource.com/17815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-16 17:20:26 +00:00
Shenghou Ma
86f1944e86 cmd/dist, runtime: make runtime version available as runtime.buildVersion
So that there is a uniformed way to retrieve Go version from a Go
binary, starting from Go 1.4 (see https://golang.org/cl/117040043)

Updates #13507.

Change-Id: Iaa2b14fca2d8c4d883d3824e2efc82b3e6fe2624
Reviewed-on: https://go-review.googlesource.com/17459
Reviewed-by: Keith Randall <khr@golang.org>
2015-12-16 05:42:40 +00:00
Matthew Dempsky
22a204dd0f cmd/compile: change dead code into assert
After fixing #13587, I noticed that the "OAS2FUNC in disguise" block
looked like it probably needed write barriers too.  However, testing
revealed the multi-value "return f()" case was already being handled
correctly.

It turns out this block is dead code due to "return f()" already being
transformed into "t1, t2, ..., tN := f(); return t1, t2, ..., tN" by
orderstmt when f is a multi-valued function.

Updates #13587.

Change-Id: Icde46dccc55beda2ea5fd5fcafc9aae26cec1552
Reviewed-on: https://go-review.googlesource.com/17759
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-12-15 18:52:01 +00:00
Robert Griesemer
d0c17461a7 go/constant: switch to floating-point representation when fractions become too large
Use two internal representations for Float values (similar to what is done
for Int values). Transparently switch to a big.Float representation when
big.Rat values become unwieldy. This is almost never needed for real-world
programs but it is trivial to create test cases that cannot be handled with
rational arithmetic alone.

As a consequence, the go/constant API semantics changes slightly: Until now,
a value could always be represented in its "smallest" form (e.g., float values
that happened to be integers would be represented as integers). Now, constant
Kind depends on how the value was created, rather than its actual value. (The
reason why we cannot automatically "normalize" values to their smallest form
anymore is because floating-point numbers are not exact in general; and thus
normalization is often not possible in the first place, or would throw away
precision when it is not desired.) This has repercussions as to how constant
Values are used go/types and required corresponding adjustments.

Details of the changes:

go/constant package:
- use big.Rat and big.Float values to represent floating-point values
  (internal change)
- changed semantic of Value.Kind accordingly
- String now returns a short, human-readable form of a value
  (this leads to better error messages in go/types)
- added ToInt, ToFloat, and ToComplex conversion functions
- added ExactString to obtain an exact string form of a value

go/types:
- adjusted and simplified implementation of representableConst
- adjusted various places where Value.Kind was expected to be "smallest"
  by calling the respective ToInt/Float/Complex conversion functions
- enabled 5 disabled tests in stdlib_test.go that now work

api checker:
- print all constant values in a short human-readable form (floats are
  printed in floating-point form), but also print an exact form if it
  is different from the short form
- adjusted test golden file and go.1.1.text reference file

Fixes #11327.

Change-Id: I492b704aae5b0238e5b7cee13e18ffce61193587
Reviewed-on: https://go-review.googlesource.com/17360
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-14 23:42:01 +00:00
Matthew Dempsky
6094dad084 cmd/cgo: use _Complex in rewritten Go code too
Followup to CL 17716, which updated cgo's boilerplate prologue code to
use standard C's _Complex instead of GCC's __complex extension.

Change-Id: I74f29b0cc3d13cab2853441cafbfe77853bba4f9
Reviewed-on: https://go-review.googlesource.com/17820
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-14 22:32:54 +00:00
Russ Cox
9917165083 cmd/internal/obj: remove 3 incorrect copyright notices
These three files contain only code written for Go
(and trivial amounts at that), not any code ported
from Inferno or Plan 9.

Remove the incorrect Inferno/Plan 9 notices.

Fixes #13576.

Change-Id: Ib9901fb360232282aae5ee0f4aa527bd6f4eaaed
Reviewed-on: https://go-review.googlesource.com/17779
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-14 21:09:39 +00:00
Ian Lance Taylor
91c3cae83a cmd/cgo: use standard C syntax for complex types
(instead of using a GCC extension).

Change-Id: I110dc45bfe5f1377fe3453070eccde283b5cc161
Reviewed-on: https://go-review.googlesource.com/17716
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-14 18:15:32 +00:00
Matthew Dempsky
85dd62d5dd cmd/compile: add missing write barriers for return statements
Copying return values to heap-escaped result parameters requires write
barriers.

Fixes #13587.

Change-Id: Ifa04ff7fa4adcc6393acdd82e527beb8f2a00a8b
Reviewed-on: https://go-review.googlesource.com/17762
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-12 06:46:56 +00:00
Keith Randall
4f97ec0866 cmd/compile: captureless closures are constants
In particular, we can initialize globals with them at link time instead
of generating code for them in an init() function.  Less code, less
startup cost.

But the real reason for this change is binary size.  This change reduces
the binary size of hello world by ~4%.

The culprit is fmt.ssFree, a global variable which is a sync.Pool of
scratch scan states.  It is initalized with a captureless closure as the
pool's New action.  That action in turn references all the scanf code.

If you never call any of the fmt.Scanf* routines, ssFree is never used.
But before this change, ssFree is still referenced by fmt's init
function.  That keeps ssFree and all the code it references in the
binary.  With this change, ssFree is initialized at link time.  As a
result, fmt.init never mentions ssFree.  If you don't call fmt.Scanf*,
ssFree is unreferenced and it and the scanf code are not included.

This change is an easy fix for what is generally a much harder problem,
the unnecessary initializing of unused globals (and retention of code
that they reference).  Ideally we should have separate init code for
each global and only include that code if the corresponding global is
live.  (We'd need to make sure that the initializing code has no side
effects, except on the global being initialized.)  That is a much harder
change.

Update #6853

Change-Id: I19d1e33992287882c83efea6ce113b7cfc504b67
Reviewed-on: https://go-review.googlesource.com/17398
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-10 19:55:33 +00:00
Rob Pike
2aa5874490 cmd/doc: search the tree in breadth-first order
This is a simple change to the command that should resolve problems like finding
vendored packages before their non-vendored siblings. By searching in breadth-first
order, we find the matching package lowest in the hierarchy, which is more likely
to be correct than the deeper one, such as a vendored package, that will be found
in a depth-first scan.

This may be sufficient to resolve the issue, and has the merit that it is very easy
to explain. I will leave the issue open for now in case my intuition is wrong.

Update #12423

Change-Id: Icf69e8beb1845277203fcb7d19ffb7cca9fa41f5
Reviewed-on: https://go-review.googlesource.com/17691
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-10 18:08:16 +00:00
Robert Griesemer
732e2cd746 cmd/compile: don't truncate tiny float constants to 0 in error messages
Fixes #13559.

Change-Id: I6fe8b5083192e8eb6c1b3ca1919fde81a00ccb7e
Reviewed-on: https://go-review.googlesource.com/17695
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-12-10 16:39:46 +00:00
Matthew Dempsky
07f9c25b35 cmd/compile: remove unneeded error message cleanup pass
This code used to be necessary because of the error messages generated
by the YACC-based parser, but they're no longer relevant under the new
recursive descent parser:

  - LBRACE no longer exists, so "{ or {" can never occur.

  - The parser never generates error messages about "@" or "?" now
    (except in import sections, where they're actually legitimate).

  - The s/LLITERAL/litbuf/ substitution is handled in p.syntax_error.

Change-Id: Id39f747e4aa492c5830d14a47b161920bd4589ad
Reviewed-on: https://go-review.googlesource.com/17690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 21:25:05 +00:00
Ian Lance Taylor
0b37a6f47b cmd/compile, cmd/internal/obj: ignore AUSEFIELD
When using GOEXPERIMENT=fieldtrack, we can see AUSEFIELD instructions.
We generally want to ignore them.

No tests because as far as I can tell there are no tests for
GOEXPERIMENT=fieldtrack.

Change-Id: Iee26f25592158e5db691a36cf8d77fc54d051314
Reviewed-on: https://go-review.googlesource.com/17610
Reviewed-by: David Symonds <dsymonds@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-09 21:07:32 +00:00
Robert Griesemer
c488548967 cmd/compile: recognize labels even if they have the same name as packages
Another (historic) artifact due to partially resolving symbols too early.

Fixes #13539.

Change-Id: Ie720c491cfa399599454f384b3a9735e75d4e8f1
Reviewed-on: https://go-review.googlesource.com/17600
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-09 02:02:11 +00:00
Robert Griesemer
670642d389 go/parser, go/types: report invalid else branch in if statements
- Only accept valid if statement syntax in go/parser.

- Check AST again in go/types since it may have been modified and the
  AST doesn't preclude other statements in the else branch of an if
  statement.

- Removed a test from gofmt which verified that old-style if statements
  permitting any statement in the else branch were correctly reformatted.
  It's been years since we switched to the current syntax; no need to
  support this anymore.

- Added a comment to go/printer.

Fixes #13475.

Change-Id: Id2c8fbcc68b719cd511027d0412a37266cceed6b
Reviewed-on: https://go-review.googlesource.com/17408
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-07 21:36:31 +00:00
Aleksandr Demakin
c5aa53c8c5 cmd/go: fix bad shared lib name with buildmode=shared
Use import paths of packages to build a shared lib name.
Use arguments for meta-packages 'std', 'cmd', and 'all'.

Fixes #12236

Change-Id: If274d63301686ef34e198287eb012f9062541ea0
Reviewed-on: https://go-review.googlesource.com/13921
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-07 21:23:48 +00:00
Didier Spezia
70da2d0a2a cmd/compile/internal/gc: fix internal compiler error on invalid declaration
Following an empty import, a declaration involving a ? symbol
generates an internal compiler error when the name of the
symbol (in newname function).

package a
import""
var?

go.go:2: import path is empty
go.go:3: internal compiler error: newname nil

Make sure dclname is not called when the symbol is nil.
The error message is now:

go.go:2: import path is empty
go.go:3: invalid declaration
go.go:4: syntax error: unexpected EOF

This CL was initially meant to be applied to the old parser,
and has been updated to apply to the new parser.

Fixes #11610

Change-Id: I75e07622fb3af1d104e3a38c89d9e128e3b94522
Reviewed-on: https://go-review.googlesource.com/15268
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-07 20:21:21 +00:00
Robert Griesemer
715f63778d cmd/compile: avoid converting huge floats to integers
Fixes #13471.

Change-Id: I232ad1729343d020254e313cfff182695ad6fc54
Reviewed-on: https://go-review.googlesource.com/17401
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-07 20:20:56 +00:00
Didier Spezia
7ebb96a489 cmd/compile/internal/gc: fix panic in Type Stringer
The following code:

func n() {(interface{int})}

generates:

3: interface contains embedded non-interface int
3: type %!v(PANIC=runtime error: invalid memory address or nil pointer dereference) is not an expression

It is because the corresponding symbol (Sym field in Type object)
is nil, resulting in a panic in typefmt.

Just skip the symbol if it is nil, so that the error message becomes:

3: interface contains embedded non-interface int
3: type interface { int } is not an expression

Fixes #11614

Change-Id: I219ae7eb01edca264fad1d4a1bd261d026294b00
Reviewed-on: https://go-review.googlesource.com/14015
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-12-07 20:18:03 +00:00
Matthew Dempsky
423b0cc25a cmd/compile: base mapaccess optimizations on algtype
algtype already controls the behavior of the normal map access code
paths, so it makes sense to base the decision on which optimized paths
are applicable on it too.

Enables use of optimized paths for key types like [8]byte and struct{s
string}.

Fixes #13271.

Change-Id: I48c52d97abaa7259ad5aba9641ea996a967cd359
Reviewed-on: https://go-review.googlesource.com/17464
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-12-07 20:13:32 +00:00
Daniel Theophanes
b2492d16a0 cmd/go: always show current value for GO15VENDOREXPERIMENT
Prior behavior would show empty string when unset. In go1.5 this
would result in "off". In go1.6 this will result in "on". This
change will make empty or "0" off and "1" on for go1.5 and go1.6.
Vendor tools can then rely on this value.

Discussion:
https://groups.google.com/forum/#!topic/golang-dev/oZzcXrlRrkA

Change-Id: I7e145a32e813dfde02dc262a9186c7af28db7b92
Reviewed-on: https://go-review.googlesource.com/17487
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-07 15:52:15 +00:00
Russ Cox
5b1a8a5239 cmd/vet: move cmd/vet/whitelist to cmd/vet/internal/whitelist
This was a mistake made when bringing cmd/vet into the main repo.

Fixes #13416.

Change-Id: I03b512ab944577c56085aea06df8ff5e1acc16d7
Reviewed-on: https://go-review.googlesource.com/17455
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2015-12-05 06:26:17 +00:00
Matthew Dempsky
336c998291 cmd/compile: reject slice/map/func comparisons against converted nil
Fixes #13480.

Change-Id: Icbf4f83e965e84f7020f56c3f346193f8b91e7bf
Reviewed-on: https://go-review.googlesource.com/17461
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 05:46:48 +00:00
Didier Spezia
77328b8d12 cmd/link: clean up dwarf.go
Try to remove the most visible artefacts resulting from the
C to Go translation. It includes:

- refactoring the find function to eliminate goto and variable declarations
- removing useless variables still having a _ = xxx
- decreasing the number of upfront variable declarations

No semantic changes.

Change-Id: I84d981c48b2d9e22e6b9db5f2a703c80c60249ba
Reviewed-on: https://go-review.googlesource.com/15681
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 04:13:18 +00:00
Mohit Agarwal
08ab43eca2 cmd/pprof: exit with non-zero status code on error
Set the status code in case of error.

Fixes #11510

Change-Id: If461c30a1f6d2275539f33a2eabd7b19bbfa411d
Reviewed-on: https://go-review.googlesource.com/16718
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 04:09:15 +00:00
Konstantin Shaposhnikov
3fb9e08758 cmd/vet: make "-all -shadow" mean all default checks and -shadow
Prior to this change "go tool vet -all -shadow" ran only -shadow check.

Also fix godoc package path in the usage text.

Fixes #13020

Change-Id: I87c60d6b06a02106ae8bff56adb79df032cc4646
Reviewed-on: https://go-review.googlesource.com/16325
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 04:07:36 +00:00
Didier Spezia
e0c05fcb5b cmd/pprof/internal: map/slice literals janitoring
Simplify slice/map literal expression.
Caught with gofmt -d -s, fixed with gofmt -w -s

Change-Id: I19723900d0649019bf79b9330d68525a68ed69c4
Reviewed-on: https://go-review.googlesource.com/13835
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 04:01:28 +00:00
Matthew Dempsky
7a4022ee36 cmd/compile: fix live variable reuse in orderstmt
The call "poptemp(t, order)" at line 906 should match up with the
assignment "t := marktemp(order)" at line 770, so use a new temporary
variable for stripping the ODCL nodes from a "case x := <-ch" node's
Ninit list.

Fixes #13469.
Passes toolstash/buildall.

Change-Id: Ia7eabd40c79cfdcb83df00b6fbd0954e0c44c5c7
Reviewed-on: https://go-review.googlesource.com/17393
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2015-12-03 21:29:22 +00:00
Austin Clements
e1544d3bb6 dwbug/elf: support old-style compressed DWARF
GCC and LLVM support zlib-compressing DWARF debug sections (and
there's some evidence that this may be happening by default in some
circumstances now).

Add support for reading compressed DWARF sections. Since ELF
relocations apply to the decompressed data, decompression is done
before applying relocations. Since relcations are applied by
debug/elf, decompression must also be handled there.

Note that this is different from compressed ELF sections, which is a
more general mechanism used by very recent versions of GCC.

Updates #11773.

Change-Id: I3f4bf1b04d0802cc1e8fcb7c2a5fcf6c467c5089
Reviewed-on: https://go-review.googlesource.com/17340
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-03 20:53:04 +00:00
Rahul Chaudhry
e65db59c12 cmd/go: allow buildmode=c-shared for android/arm64.
Also, enable test misc/cgo/testcshared for android/arm64.
c/17245 and c/17246 provide the missing pieces for making
this test work.

"androidtest.bash" now passes on a Nexus 9 (volantis)
device running Android build "LMY48T".

Change-Id: Icb9fd2d17d97e0f04cb18d0cd91640c80fbd3fb4
Reviewed-on: https://go-review.googlesource.com/17333
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-02 22:00:15 +00:00
Michael Hudson-Doyle
3a1bed82a6 cmd/internal/obj: fix stack barriers in ppc64le shared libs
runtime.stackBarrier is a strange function: it is only ever "called" by
smashing its address into a LR slot on the stack. Calling it like this
certainly does not adhere to the rule that r12 is set to the global entry point
before calling it and the prologue instrutions that compute r2 from r12 in fact
just corrupt r2, which is bad because the function that stackBarrier returns to
probably uses r2 to access global data.

Fortunately stackBarrier itself does not access any global data and so does not
depend on the value of r2, meaning we can ignore the ABI rules and simply skip
inserting the prologue instructions into this specific function.

Fixes 64bit.go, append.go and fixedbugs/issue13169.go from "cd test; go run
run.go -linkshared".

Change-Id: I606864133a83935899398e2d42edd08a946aab24
Reviewed-on: https://go-review.googlesource.com/17281
Reviewed-by: Austin Clements <austin@google.com>
2015-12-02 21:15:37 +00:00
Ian Lance Taylor
5a049aa4a6 cmd/cgo: error, not panic, if not enough arguments to function
Fixes #13423.

Change-Id: I41bb45790cca36c57a107796f0eca61287acb2a9
Reviewed-on: https://go-review.googlesource.com/17332
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-02 21:02:28 +00:00
Håvard Haugen
8a34cf7ee0 cmd/compile: don't allow blank method declarations on builtins
Move test for isblank into addmethod so that most of the type checking
for methods is also performed for blank methods.

Fixes #11366.

Change-Id: I13d554723bf96d906d0b3ff390d7b7c87c1a5020
Reviewed-on: https://go-review.googlesource.com/16866
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-12-02 18:26:38 +00:00
Ian Lance Taylor
b64b3a7713 cmd/go: fix reading PT_NOTE segment with multiple notes
The old code was assuming that a PT_NOTE segment never had more than one
note, but there is no such requirement.

Fixes #13364.

Change-Id: I3f6b3716130bf7af6abe81b8e10571a8c7cd943c
Reviewed-on: https://go-review.googlesource.com/17331
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-02 17:21:44 +00:00
Robert Griesemer
06f4cbd3d7 cmd/compile: remove unused global variable loophack
Old parser remains.

Change-Id: I05ef1737802e23afc2c2129f58cb66feef8e3425
Reviewed-on: https://go-review.googlesource.com/17244
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-30 22:23:58 +00:00
Robert Griesemer
8ae423ef84 cmd/compile: document parsing decision for imported interfaces
Fixes #13245.

Change-Id: I87be63cc7b27f70ca2f9fb6bc9908b9061fe3d9d
Reviewed-on: https://go-review.googlesource.com/17203
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-30 22:23:34 +00:00
Ian Lance Taylor
f3b064ae01 cmd/compile: add 386 special case for testing first field of struct variable
This is the 386 version of the amd64-specific https://golang.org/cl/16933.

Update #12416.

Change-Id: Ibc3a99dcc753d6281839d8b61016d6c21dbd9649
Reviewed-on: https://go-review.googlesource.com/16970
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-29 16:56:03 +00:00
Ian Lance Taylor
17360accab cmd/cgo: make the char * pointer in GoString const
This makes it more convenient for C code to use GoString with string
constants.  Since Go string values are immutable, the const qualifier is
appropriate in C.

Change-Id: I5fb3cdce2ce5079f1f0467a1544bb3a1eb27b811
Reviewed-on: https://go-review.googlesource.com/17067
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-29 16:55:40 +00:00
Robert Griesemer
de531fc255 cmd/compile: remove gratuituous type conversions
Follow-up cleanup for https://go-review.googlesource.com/17248:
Use properly typed local variable op now that that variable use
is not overloaded anymore.

Also: Remove unnecessary if stmt from common lexical path.

Change-Id: I984b0b346f3fdccd5aedc937330c0a5f99acf324
Reviewed-on: https://go-review.googlesource.com/17249
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-28 03:36:21 +00:00
Robert Griesemer
e18cd34c76 cmd/compile: use correct line number for := (LCOLAS)
- use same local variable name (lno) for line number for LCOLAS everywhere
- remove now unneeded assignment of line number to yylval.i in lexer

Fix per suggestion of mdempsky.

Fixes #13415.

Change-Id: Ie3c7f5681615042a12b81b26724b3a5d8a979c25
Reviewed-on: https://go-review.googlesource.com/17248
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-28 03:36:00 +00:00
Shenghou Ma
98abf2937e cmd/cover: allow part selection to be retained across page refreshes
Usually, you are primarily interested to see the coverage of a particular
file (e.g. when you're changing tests that affects a given source file),
it is very valuable if you can just refresh the page and immediately see
changes to the part you're already looking at (without selecting from the
selector again.)

Change-Id: I615207c9be6713f436e444771134fceaf4600ff3
Reviewed-on: https://go-review.googlesource.com/17238
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-27 06:13:12 +00:00
Tamir Duberstein
adf4c38b6e cmd/yacc: memory allocation improvements
Places a fixed size initial stack and the lval inside the parser
struct so that they are allocated together. Places $$char inside the
parser struct to avoid allocating the closure used in Lookahead().

Change-Id: I0de664a6d612279fdc3255633e2dff904030bc36
Reviewed-on: https://go-review.googlesource.com/16705
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-26 17:42:14 +00:00
Dmitry Vyukov
7b767f4e52 internal/race: add package
Factor out duplicated race thunks from sync, syscall net
and fmt packages into a separate package and use it.

Fixes #8593

Change-Id: I156869c50946277809f6b509463752e7f7d28cdb
Reviewed-on: https://go-review.googlesource.com/14870
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-26 16:50:31 +00:00
sergey.arseev
e9081b3c76 cmd/internal/obj/x86: add support for TSX instructions
Transactional memory, will later be used for semaphore implementation.
Nacl not supported yet.

Change-Id: Ic18453dcaa08d07bb217c0b95461584f007d518b
Reviewed-on: https://go-review.googlesource.com/16479
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-26 16:39:00 +00:00
Matthew Dempsky
10cb39afc4 cmd/cgo: fix C.complexfloat and C.complexdouble
This also fixes an unintended behavior where C's "complex float" and
"complex double" types were interchangeable with Go's "complex64" and
"complex128" types.

Fixes #13402.

Change-Id: I73f96d9a4772088d495073783c6982e9634430e8
Reviewed-on: https://go-review.googlesource.com/17208
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-25 23:06:59 +00:00
Matthew Dempsky
de640d369d cmd/cgo: handle another Clang DWARF quirk
Without the fix:

    $ CC=clang-3.5 ./test.bash
    misc/cgo/errors/test.bash: BUG: expected error output to contain "C.ushort" but saw:
    # command-line-arguments
    ./issue13129.go:13: cannot use int(0) (type int) as type C.unsignedshort in assignment

Fixes #13129.

Change-Id: I2c019d2d000f5bfa3e33c477e533aff97031a84f
Reviewed-on: https://go-review.googlesource.com/17207
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-25 21:13:41 +00:00
Robert Griesemer
c7a3403140 cmd/compile: clearer error for invalid array/slice literal elements
Fixes #13365.

Change-Id: I5a447ff806dbbb11c8c75e2b5cfa7fd4a845fb92
Reviewed-on: https://go-review.googlesource.com/17206
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-25 19:49:38 +00:00
Robert Griesemer
3cac3b5fca cmd/compile: remove references to go.y and update documentation
This is a comment/documentation change only but for a minor
code change in the file and package_ methods (move recognition
of semi to match grammar better).

Per request from r.

Change-Id: I81ec985cc5831074d9eb5e8ffbf7e59466284819
Reviewed-on: https://go-review.googlesource.com/17202
Reviewed-by: Rob Pike <r@golang.org>
2015-11-24 23:53:42 +00:00
Ilya Tocar
b597e1ed54 runtime: speed up memclr with avx2 on amd64
Results are a bit noisy, but show good improvement (haswell)

name            old time/op    new time/op     delta
Memclr5-48        6.06ns ± 8%     5.65ns ± 8%    -6.81%  (p=0.000 n=20+20)
Memclr16-48       5.75ns ± 6%     5.71ns ± 6%      ~     (p=0.545 n=20+19)
Memclr64-48       6.54ns ± 5%     6.14ns ± 9%    -6.12%  (p=0.000 n=18+20)
Memclr256-48      10.1ns ±12%      9.9ns ±14%      ~     (p=0.285 n=20+19)
Memclr4096-48      104ns ± 8%       57ns ±15%   -44.98%  (p=0.000 n=20+20)
Memclr65536-48    2.45µs ± 5%     2.43µs ± 8%      ~     (p=0.665 n=16+20)
Memclr1M-48       58.7µs ±13%     56.4µs ±11%    -3.92%  (p=0.033 n=20+19)
Memclr4M-48        233µs ± 9%      234µs ± 9%      ~     (p=0.728 n=20+19)
Memclr8M-48        469µs ±11%      472µs ±16%      ~     (p=0.947 n=20+20)
Memclr16M-48       947µs ±10%      916µs ±10%      ~     (p=0.050 n=20+19)
Memclr64M-48      10.9ms ±10%      4.5ms ± 9%   -58.43%  (p=0.000 n=20+20)
GoMemclr5-48      3.80ns ±13%     3.38ns ± 6%   -11.02%  (p=0.000 n=20+20)
GoMemclr16-48     3.34ns ±15%     3.40ns ± 9%      ~     (p=0.351 n=20+20)
GoMemclr64-48     4.10ns ±15%     4.04ns ±10%      ~     (p=1.000 n=20+19)
GoMemclr256-48    7.75ns ±20%     7.88ns ± 9%      ~     (p=0.227 n=20+19)

name            old speed      new speed       delta
Memclr5-48       826MB/s ± 7%    886MB/s ± 8%    +7.32%  (p=0.000 n=20+20)
Memclr16-48     2.78GB/s ± 5%   2.81GB/s ± 6%      ~     (p=0.550 n=20+19)
Memclr64-48     9.79GB/s ± 5%  10.44GB/s ±10%    +6.64%  (p=0.000 n=18+20)
Memclr256-48    25.4GB/s ±14%   25.6GB/s ±12%      ~     (p=0.647 n=20+19)
Memclr4096-48   39.4GB/s ± 8%   72.0GB/s ±13%   +82.81%  (p=0.000 n=20+20)
Memclr65536-48  26.6GB/s ± 6%   27.0GB/s ± 9%      ~     (p=0.517 n=17+20)
Memclr1M-48     17.9GB/s ±12%   18.5GB/s ±11%      ~     (p=0.068 n=20+20)
Memclr4M-48     18.0GB/s ± 9%   17.8GB/s ±14%      ~     (p=0.547 n=20+20)
Memclr8M-48     17.9GB/s ±10%   17.8GB/s ±14%      ~     (p=0.947 n=20+20)
Memclr16M-48    17.8GB/s ± 9%   18.4GB/s ± 9%      ~     (p=0.050 n=20+19)
Memclr64M-48    6.19GB/s ±10%  14.87GB/s ± 9%  +140.11%  (p=0.000 n=20+20)
GoMemclr5-48    1.31GB/s ±10%   1.48GB/s ± 6%   +13.06%  (p=0.000 n=19+20)
GoMemclr16-48   4.81GB/s ±14%   4.71GB/s ± 8%      ~     (p=0.341 n=20+20)
GoMemclr64-48   15.7GB/s ±13%   15.8GB/s ±11%      ~     (p=0.967 n=20+19)

Change-Id: I393f3f20e2f31538d1b1dd70d6e5c201c106a095
Reviewed-on: https://go-review.googlesource.com/16773
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Klaus Post <klauspost@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2015-11-24 16:49:30 +00:00
Robert Griesemer
8f931e49f5 cmd/compile: remove dead code
Get rid of residue after removing old parser.

Change-Id: I0dace1037d50959071a082c276f9f374eef6edb2
Reviewed-on: https://go-review.googlesource.com/17179
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-24 03:30:02 +00:00
Robert Griesemer
b5fe07710f cmd/compile: remove yacc-based parser
- moved yySymType and token constants (L...) to lex.go
- removed oldparser flag and related code
- removed go generate that generated y.go

Fixes #13240.

Change-Id: I2576ec61ee1efe482f2a5132175725c9c02ef977
Reviewed-on: https://go-review.googlesource.com/17176
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-24 00:23:14 +00:00
Ian Lance Taylor
f1b919574c cmd/link: support R_PPC_REL32 relocation
This relocation is found in libgcc.a in the .eh_frame, and therefore
needs to be handled when doing an internal link.

Fixes #13375.

Change-Id: Idd9e8178e08851a101b43261a30939bcfaf394f9
Reviewed-on: https://go-review.googlesource.com/17173
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2015-11-24 00:02:06 +00:00
Robert Griesemer
656a732a21 cmd/compile: simplify parsing of possibly absent type
Introduce a try_ntype function which doesn't return an error upon
not finding a type. Use it instead of having separate repeated
token checks. Simpler, less code, and more efficient.

Change-Id: I81e482158b71901eb179470269349688636aa0ba
Reviewed-on: https://go-review.googlesource.com/17157
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-23 21:29:27 +00:00
Ian Lance Taylor
0417872809 cmd/cgo: ignore vars with no name or type if they have a AttrSpecification
Fixes #13344.

Change-Id: I33c6721fd33d144c85c87840ddf27ce15aa72328
Reviewed-on: https://go-review.googlesource.com/17151
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-23 04:04:07 +00:00
Russ Cox
5951823853 cmd/go: disable TestNoteReading on dragonfly
It started failing on the dragonfly builder at an unrelated commit
(one that changed the wording in a few comments in the compiler).

Created #13364 to track this.

Change-Id: I462880bed8ff565a9950e7e185de97d43999c5e2
Reviewed-on: https://go-review.googlesource.com/17143
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-23 02:29:57 +00:00
Robert Griesemer
aad18b849b cmd/compile: address several more 1.6 TODOs in parser
- fix/check location of popdcl calls where questioned
- remove unnecessary handling of ... (LDDD) in ntype (couldn't be reached)
- inlined and fnret_type and simplified fnres as a consequence
- leave handling of ... (LDDD) in arg_list alone (remove TODO)
- verify that parser requires a ';' after last statement in a case/default
  (added test case)

Fixes #13243.

Change-Id: Iad94b498591a5e85f4cb15bbc01e8e101415560d
Reviewed-on: https://go-review.googlesource.com/17155
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-21 07:21:23 +00:00
Robert Griesemer
0383bb473d cmd/compile: simplify tracing code (cleanup)
Change-Id: I7c084542996226f3ed464314a5622fcfaac02d61
Reviewed-on: https://go-review.googlesource.com/17103
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-21 07:20:39 +00:00
Robert Griesemer
af8cd3f6bd cmd/compile: fix TODO in tracing code
For #13243.

Change-Id: I214945278255a49f93120f9407f536a6c01a29fb
Reviewed-on: https://go-review.googlesource.com/17101
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:56:51 +00:00
Robert Griesemer
64cd86798b cmd/compile: better syntax error recovery
Use a combination of follow- and stop-token lists and nesting levels
to better synchronize parser after a syntax error.

Fixes #13319.

Change-Id: I9592e0b5b3ba782fb9f9315fea16163328e204f7
Reviewed-on: https://go-review.googlesource.com/17080
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:56:27 +00:00
Robert Griesemer
7218b79f23 cmd/compile: match markdcl and popdcl even in case of errors
Change-Id: I22a8a233bc157fa09cd0283fcd4bc14d90faed70
Reviewed-on: https://go-review.googlesource.com/17066
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:56:11 +00:00
Robert Griesemer
de2bc5722d cmd/compile: no need to keep ()'s for all pseudocalls
Minor internal optimization.

Change-Id: I229d4a9df3da542b77f830c2830f63ec23ec1d61
Reviewed-on: https://go-review.googlesource.com/17065
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:55:51 +00:00
Robert Griesemer
52f111fb34 cmd/compile: print regular error message in BOM corner-case
This never happens but for pathological input where a BOM sequence
is unfinished and ends in EOF (src: "package p\n\nfunc \xef\xef").
No test case added because the /test framework doesn't lend itself
easily to it in this case (file must end in EOF rather than comment).
Instead, tested manually.

Fixes #13268.

Change-Id: I049034e6dde7ad884b0a8c329921adac1866ff18
Reviewed-on: https://go-review.googlesource.com/17047
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:55:15 +00:00
Hyang-Ah Hana Kim
bda885511d cmd: allow buildmode=c-shared for android/386
Update golang/go#9327.

Change-Id: Iab7dad31cf6b9f9347c3f34faebb67ecb38b17fc
Reviewed-on: https://go-review.googlesource.com/16701
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-20 14:55:35 +00:00
Hyang-Ah Hana Kim
ec3daf0c62 cmd/dist: run testcshared test on linux/386
Change-Id: Iaa0fb133e5fc2078bfaf59ed721fd07a1a713ab3
Reviewed-on: https://go-review.googlesource.com/17075
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-20 04:22:35 +00:00
Hyang-Ah Hana Kim
cbc55971e2 cmd/go, cmd/link: enable -buildmode=c-shared on linux/386
All the heavy lifting was done by Michael Hudson-Doyle.

Change-Id: I176f15581055078854c2ad9a5807c4dcf0f8d8c5
Reviewed-on: https://go-review.googlesource.com/17074
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-20 03:49:13 +00:00
Rob Pike
997ed6fd3b cmd/go: make it clearer that go generate accepts all build flags
Just add one word to clarify that -n -v -x are not the only build flags supported.

Fixes #13237.

Change-Id: I880472639bf2fc1a0751a83041bc7ddd0c9e55f4
Reviewed-on: https://go-review.googlesource.com/17062
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-20 00:28:11 +00:00
Ian Lance Taylor
f2a0fc10c9 cmd/cgo: final docs for pointer passing
Update #12416.

Change-Id: I39eb0d1090c08ef9be9dc38d27abab62672cf664
Reviewed-on: https://go-review.googlesource.com/17064
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-20 00:19:48 +00:00
Ian Lance Taylor
5005a33987 cmd/cgo: put the real C function in the dynamic symbol table
In the past, cgo generated Go code and C code.  The C code was linked
into a shared library.  The Go code was built into an executable that
dynamically linked against that shared library.  C wrappers were
exported from the shared library, and the Go code called them.

It was all a long time ago, but in order to permit C code to call back
into Go, somebody implemented #pragma dynexport (https://golang.org/cl/661043)
to export a Go symbol into the dynamic symbol table.  Then that same
person added code to cgo to recognize //export comments
(https://golang.org/cl/853042).  The //export comments were implemented
by generating C code, to be compiled by GCC, that would refer to C code,
to be compiled by 6c, that would call the Go code.  The GCC code would
go into a shared library.  The code compiled by 6c would be in the Go
executable.  The GCC code needed to refer to the 6c code, so the 6c
function was marked with #pragma dynexport.  The important point here is
that #pragma dynexport was used to expose an internal detail of the
implementation of an exported function, because at the time it was
necessary.

Moving forward to today, cgo no longer generates a shared library and 6c
no longer exists.  It's still true that we have a function compiled by
GCC that refers to a wrapper function now written in Go.  In the normal
case today we are doing an external link, and we use a
//go:cgo_export_static function to make the Go wrapper function visible
to the C code under a known name.

The #pragma dynexport statement has become a //go:cgo_export_dynamic
comment on the Go code.  That comment only takes effect when doing
internal linking.  The comment tells the linker to put the symbol in the
dynamic symbol table.  That still makes sense for the now unusual case
of using internal linking with a shared library.

However, all the changes to this code have carefully preserved the
property that the //go:cgo_export_dynamic comment refers to an internal
detail of the implementation of an exported function.  That was
necessary a long time ago, but no longer makes sense.

This CL changes the code to put the actual C-callable function into the
dynamic symbol table.  I considered dropping the comment entirely, but
it turns out that there is even a test for this, so I preserved it.

Change-Id: I66a7958e366e5974363099bfaa6ba862ca327849
Reviewed-on: https://go-review.googlesource.com/17061
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-20 00:19:07 +00:00
Shenghou Ma
23791ee11d cmd/compile: set log prefix and suppress date
Fixes #13320.

Change-Id: I3a96a6707982629caf89656c479d096891783328
Reviewed-on: https://go-review.googlesource.com/17050
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-11-19 23:55:50 +00:00
Russ Cox
476aa95015 cmd/go: skip TestNoteReading2K on Windows
It's intended primarily as a torture test for OS X.
Apparently Windows can't take it.

Updates fix for #12327.

Change-Id: If2af249ea8e2f55bff8f232dce06172e6fef9f49
Reviewed-on: https://go-review.googlesource.com/17073
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-19 21:22:48 +00:00
Austin Clements
402e37d4a9 cmd/compile: special case nowritebarrierrec for allocm
allocm is a very unusual function: it is specifically designed to
allocate in contexts where m.p is nil by temporarily taking over a P.
Since allocm is used in many contexts where it would make sense to use
nowritebarrierrec, this commit teaches the nowritebarrierrec analysis
to stop at allocm.

Updates #10600.

Change-Id: I8499629461d4fe25712d861720dfe438df7ada9b
Reviewed-on: https://go-review.googlesource.com/17005
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-19 21:17:19 +00:00
Russ Cox
26119179fa cmd/go: fix loading of buildid on OS X executables
This is a bit of a belt-and-suspenders fix.
On OS X, we now parse the Mach-O file to find the __text section,
which is arguably the more proper fix. But it's a bit worrisome to
depend on a name like __text not changing, so we also read more
of the initial file (now 32 kB, up from 8 kB) and scan that too.

Fixes #12327.

Change-Id: I3a201a3dc278d24707109bb3961c3bdd8b8a0b7b
Reviewed-on: https://go-review.googlesource.com/17038
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-19 20:57:16 +00:00
Russ Cox
3ea668a0f2 cmd/dist: rewrite mkdeps.bash to work on OS X
My version of bash doesn't know what 'declare -A' means.

Change-Id: Icf6b0e60ebaea3feaa8661ec0423012f213b53e8
Reviewed-on: https://go-review.googlesource.com/17070
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-19 20:53:50 +00:00
Rob Pike
4d9f68028a cmd/asm: add doc.go
There was no documentation produced by "go doc cmd/asm".
Follow the style set by cmd/compile.

Fixes #13148.

Change-Id: I02e08ce2e7471f855bfafbbecee98ffdb7096995
Reviewed-on: https://go-review.googlesource.com/16997
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-19 20:49:27 +00:00
Russ Cox
8b1b81f463 cmd/compile: fix crash with -race on large expr containing string->[]byte conversion
The assumption is that there are no nested function calls in complex expressions.
For the most part that assumption is true. It wasn't for these calls inserted during walk.
Fix that.

I looked through all the calls to mkcall in walk and these were the only cases
that emitted calls, that could be part of larger expressions (like not delete),
and that were not already handled.

Fixes #12225.

Change-Id: Iad380683fe2e054d480e7ae4e8faf1078cdd744c
Reviewed-on: https://go-review.googlesource.com/17034
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-19 19:54:55 +00:00
Michael Matloob
45c3cf68b0 cmd/compile: identify the runtime pkg using myimportpath
Because there are now multiple packages that compose the runtime
we need to distinguish between the case where a runtime package
is being compiled versus the case the "runtime" package is being
compiled. In golang.org/cl/14204 I mistakenly used
  localpkg.Name == "runtime"
to check against the "runtime" package, but doing this would treat
a package with the path "foo.org/bar/runtime" as the runtime package.
The correct check is
  myimportpath == "runtime"
.

Change-Id: If90e95cef768d91206f2df1c06e27be876722e4e
Reviewed-on: https://go-review.googlesource.com/17059
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-19 19:50:03 +00:00
Ian Lance Taylor
0e2c635788 cmd/cgo, runtime: exported Go functions can't return a Go pointer
Update #12416.

Change-Id: Iccbcb12709d1ca9bea87274f44f93cfcebadb070
Reviewed-on: https://go-review.googlesource.com/17048
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-19 18:28:39 +00:00
Michael Hudson-Doyle
0fbf0955d4 cmd/internal/obj/x86: still use (fake) local exec TLS mode on android/386
golang.org/cl/16383 broke android/386 because by a sort of confluence of hacks
no TLS relocations were emitted at all when Flag_shared != 0. The hack in
runtime/cgo works as well in a PIE executable as it does with a position
dependent one, so the simplest fix is to still emit a R_TLS_LE reloc when goos
== "android".

A real fix is to use something more like the IE model code but loading the
offset from %gs to the thread local storage from a global variable rather than
from a location chosen by the system linker (this is how android/arm works).

Issue #9327.

Change-Id: I9fbfc890ec7fe191f80a595b6cf8e2a1fcbe3034
Reviewed-on: https://go-review.googlesource.com/17049
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-11-19 17:43:37 +00:00
Michael Hudson-Doyle
e8e0d906dc cmd/dist: run testshared on linux/386
Change-Id: I22d40248e83fcad5ab73c0d402183d06e91064c7
Reviewed-on: https://go-review.googlesource.com/16388
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-19 00:23:38 +00:00
Michael Hudson-Doyle
09d7de8d61 cmd/link, runtime: call addmoduledata when dynamically linking on linux/386
Change-Id: If1faa2bba28a4e9a8061693173797c4114a7d699
Reviewed-on: https://go-review.googlesource.com/16387
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-19 00:22:56 +00:00
Robert Griesemer
34cbccd341 cmd/compile/internal/gc: add line numbers for complit elts if needed (addresses TODO)
For #13243.

Change-Id: I802cef3dad5d1236e70d0cd52047008a6a7a311a
Reviewed-on: https://go-review.googlesource.com/17045
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:52:58 +00:00
Robert Griesemer
431c232842 cmd/compile/internal/gc: address TODO (better comment)
For #13243.

Change-Id: I544a8c44971fad126103157575e983ab528309bf
Reviewed-on: https://go-review.googlesource.com/17044
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:26:24 +00:00
Robert Griesemer
fe762b6466 cmd/compile/internal/gc: better error message for parenthesized go/defer exprs
Change-Id: Ie24d56422ae2196198a6c306716fa867c1442d6e
Reviewed-on: https://go-review.googlesource.com/17043
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:26:07 +00:00
Robert Griesemer
5500d46914 cmd/compile/internal/gc: fix incorrect parsing of &(T{}) when followed by {
Handling of &(T{}) assumed that the parser would not introduce ()'s.

Also: Better comments around handling of OPAREN syntax tree optimization.

Fixes #13261.

Change-Id: Ifc5047a0448f5e7d74cd42f6608b87dcc9c2f2fb
Reviewed-on: https://go-review.googlesource.com/17040
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:25:48 +00:00
Robert Griesemer
1a111ea2c7 cmd/compile/internal/gc: fix parsing of <-x (recv op vs recv-only chan)
Also:
- better error messages in some cases
- factored out function to produce syntax error at given line number

Fixes #13273.

Change-Id: I0192a94731cc23444680a26bd0656ef663e6da0b
Reviewed-on: https://go-review.googlesource.com/16992
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:22:56 +00:00
Michael Hudson-Doyle
342f17eaf7 cmd/internal/obj/x86, cmd/link: enable access to global data via GOT when -dynlink on 386
Change-Id: I97504a11291ee60e656efb7704e37387e864d74f
Reviewed-on: https://go-review.googlesource.com/16385
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 21:27:45 +00:00
Michael Hudson-Doyle
cb0393866a cmd/internal/obj/x86: position independent access to global data on 386 when -shared
This works by adding a call to __x86.get_pc_thunk.cx immediately before any
instruction that accesses global data and then assembling the instruction to
use the appropriate offset from CX instead of the absolute address. Some forms
cannot be assembled that way and are rewritten to load the address into CX
first.

-buildmode=pie works now, but is not yet tested.

Fixes #13201 (I think)

Change-Id: I32a8561e7fc9dd4ca6ae3b0e57ad78a6c50bf1f5
Reviewed-on: https://go-review.googlesource.com/17014
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 21:26:42 +00:00
Michael Hudson-Doyle
3c85e1b186 cmd/internal/obj/x86: factor rewriting to use GOT into separate function
I was prodded into doing this in review comments for the ARM version, and it's
going to make shared libs for 386 easier.

Change-Id: Id12de801b1425b8c6b5736fe91b418fc123a4e40
Reviewed-on: https://go-review.googlesource.com/17012
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-18 21:25:55 +00:00
Russ Cox
6bf794a36d cmd/link: link go.o first
Does not fix #12327 but nicer anyway.

Change-Id: I4ad730a4ca833d76957b7571895b3a08a6a530d4
Reviewed-on: https://go-review.googlesource.com/16964
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 19:00:45 +00:00
Russ Cox
918a2644f2 cmd/compile: fix Val vs Opt collision
Fixes #12686.

Change-Id: I7a9f49dbd1f60b1d0240de57787753b425f9548c
Reviewed-on: https://go-review.googlesource.com/17031
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 18:31:27 +00:00
Ian Lance Taylor
921e7dfd06 cmd/dist: don't run internal link tests on arm or darwin/arm64
Change-Id: I373a64fc30dee804d99e106d4627b780e1846917
Reviewed-on: https://go-review.googlesource.com/16999
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-18 17:35:27 +00:00
Ian Lance Taylor
8d2f60f8a8 cmd/link: add -libgcc option
An internal link may need the C compiler support library, libgcc.a.  Add
a -libgcc option to set the name of the compiler support library.  If
-libgcc is not used, run the compiler to find it.  Permit -libgcc=none
to skip using libgcc at all and hope for the best.

Change cmd/dist to not copy libgcc into the distribution.  Add tests to
ensure that all the standard packages that use cgo can be linked in
internal mode without using libgcc.  This ensures that somebody with a
Go installation without a C compiler can build programs.

Change-Id: I8ba35fb87ab0dd20e5cc0166b5f4145b04ce52a4
Reviewed-on: https://go-review.googlesource.com/16993
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-18 02:04:10 +00:00
Michael Hudson-Doyle
3bf61fb2e5 cmd/internal/obj/x86, cmd/link/internal/x86: support IE model TLS on linux/386
This includes the first parts of the general approach to PIC: load PC into CX
whenever it is needed. This is going to lead to large binaries and poor
performance but it's a start and easy to get right.

Change-Id: Ic8bf1d0a74284cca0d94a68cf75024e8ab063b4e
Reviewed-on: https://go-review.googlesource.com/16383
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 01:57:01 +00:00
Michael Hudson-Doyle
61da0e92d0 cmd/compile, cmd/compile/internal/x86: do not let regopt use CX in position independent code
We might be able to do better than this, but it's a start.

Change-Id: I80ebce9094e084a4746039106ccf1ad9c4b8bb7c
Reviewed-on: https://go-review.googlesource.com/16384
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 01:44:32 +00:00
Michael Hudson-Doyle
c8abb02178 cmd/go: enable -buildmode=pie on linux/386
Change-Id: Ie4cdf50fdaf7b368a189a84f4e2aea4cedd5ca7d
Reviewed-on: https://go-review.googlesource.com/17013
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 01:35:54 +00:00
Hyang-Ah Hana Kim
888aadfa60 cmd: enable android/386 build (buildmode=pie by default)
no buildmode=c-shared yet.

Update golang/go#9327.

Change-Id: I9989d954d574807bac105da401c3463607fe8a99
Reviewed-on: https://go-review.googlesource.com/16700
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-17 22:37:26 +00:00
Joe Tsai
07d48993f2 cmd/doc: fix strange indentation artifacts with unexported fields
The NamePos value was not being set, and would default to a value
of zero. This would cause the printing logic to get confused as
to where exactly to place the "Has unexported fields" string.

A trivial package changes from

<
type A struct {
	A int // A
	B int
			// B
	// Has unexported fields.
}
>

to

<
type A struct {
	A int // A
	B int // B
	// Has unexported fields.
}
>

Fixes #12971

Change-Id: I53b7799a1f1c0ad7dcaddff83d9aaeb1d6b7823e
Reviewed-on: https://go-review.googlesource.com/16286
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-11-17 20:51:19 +00:00
Robert Griesemer
662ab8be31 cmd/compile/internal/gc: add dropped line correction again
The line correction when reporting a missing package clause
was removed before since it wasn't clear that it was needed.
Added it again because of issue 13267.

No explicit test case has been added to test/fixedbugs because
it would require a file that contains a single byte and such a
file doesn't fit the existing test harness. Instead documented
the problematic line in the parser for future reference.

Fixes #13267.

Change-Id: I590fe8f358042aab73acf16c2ed9567872b174f4
Reviewed-on: https://go-review.googlesource.com/16975
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:06:11 +00:00
Robert Griesemer
0133d24c94 cmd/compile/internal/gc: don't ignore EOF in new parser
Fixes #13274.
Fixes #13272.

Change-Id: Ie67a2c4671ee2b49831898fff7677cd65d780942
Reviewed-on: https://go-review.googlesource.com/16972
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:39 +00:00
Robert Griesemer
a20556bf56 cmd/compile/internal/gc: correctly use internal call to error reporting
Fixes #13266.

Change-Id: I31da922e0599989e52acf346374c2077b157ebb7
Reviewed-on: https://go-review.googlesource.com/16971
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:07 +00:00
Russ Cox
2c11164db5 cmd/compile: fix value range check for complex constants
Fixes #11590.

Change-Id: I4144107334604a2cc98c7984df3b5d4cde3d30af
Reviewed-on: https://go-review.googlesource.com/16920
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:48:47 +00:00
Russ Cox
292ad59291 cmd/compile: do not emit args_stackmap for func _
Fixes #11699.

Change-Id: I01bf506d76260bcdf828bbde52791e328aa441a5
Reviewed-on: https://go-review.googlesource.com/16921
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:52 +00:00
Russ Cox
247959d9b8 cmd/compile: reject identifiers beginning with non-ASCII digit
Fixes #11359.

Change-Id: I0fdfa410939f7e42020cbb19d74a67e1cc3cd610
Reviewed-on: https://go-review.googlesource.com/16919
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:42 +00:00
Russ Cox
f2eb3de636 cmd/compile: document -trimpath
Fixes #8999.

Change-Id: I1390605bdf908f59b596975ea51eb04bd03bbae0
Reviewed-on: https://go-review.googlesource.com/16918
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:34 +00:00
Ian Lance Taylor
9aed0b7e3d cmd/compile: add special case for testing first field of struct variable
The change to the write barrier in https://golang.org/cl/16899 means
that the compiler now emits tests of the first field of a struct.  That
was using a register that was not used before.  This change fixes that
for amd64 by adding a special case for the first field of a struct.

Update #12416.

Change-Id: Ia57baa62cd741592fbeb9be82f1e846be73d6edd
Reviewed-on: https://go-review.googlesource.com/16933
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16 18:39:40 +00:00
Ian Lance Taylor
be1ef46775 runtime: add optional expensive check for invalid cgo pointer passing
If you set GODEBUG=cgocheck=2 the runtime package will use the write
barrier to detect cases where a Go program writes a Go pointer into
non-Go memory.  In conjunction with the existing cgo checks, and the
not-yet-implemented cgo check for exported functions, this should
reliably detect all cases (that do not import the unsafe package) in
which a Go pointer is incorrectly shared with C code.  This check is
optional because it turns on the write barrier at all times, which is
known to be expensive.

Update #12416.

Change-Id: I549d8b2956daa76eac853928e9280e615d6365f4
Reviewed-on: https://go-review.googlesource.com/16899
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16 18:39:06 +00:00
Ian Lance Taylor
1860a0fa57 cmd/dist: check more GOOS/GOARCH combinations in mkdeps.bash
The current mkdeps.bash just checks for dependencies for GOOS=windows
with the current GOARCH.  This is not always accurate as some package
imports only happen on specific GOOS/GOARCH combinations.  Check a
selected, easily changed, combination of GOOS/GOARCH values.

This generates a deps.go identical to the one in the repository today.

Fixes #13221.

Change-Id: I96d67d49c8c63641d578acedbb28be807607db65
Reviewed-on: https://go-review.googlesource.com/16882
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-16 18:34:48 +00:00
Rahul Chaudhry
f7c7ed7c41 cmd/go: set buildmode=pie default for android/arm64.
Just like android/arm, android/arm64 refuses to execute non-PIE
binaries. In addition, starting from the M release (Marshmallow),
Android refuses to execute binaries with any text relocations
(this was just a warning in the L release). This makes "-shared"
necessary as well when building executables for Android.

Change-Id: Id8802de5be98ff472fc370f8d22ffbde316aaf1e
Reviewed-on: https://go-review.googlesource.com/16744
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 18:32:57 +00:00
Michael Hudson-Doyle
25a28da080 cmd/dist, cmd/go: run testshared on arm64
And enable PIE in the go tool.

Change-Id: Ibb60ccfe62518cde6e33080bbc78bfcbecff6a4e
Reviewed-on: https://go-review.googlesource.com/14000
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-15 23:41:28 +00:00
Michael Hudson-Doyle
4bae454d68 cmd/link: work around arm64 linker bugs with GOT relocations against local symbols
Change-Id: Ie14530c57720f1af1960ab77686b860e906058c6
Reviewed-on: https://go-review.googlesource.com/16582
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-15 23:40:59 +00:00
Michael Hudson-Doyle
3534e2bef4 cmd/internal/obj, cmd/link: access global data via a GOT in -dynlink mode on arm64
Change-Id: I6ca9406207e40c7c2c661075ccfe57b6600235cf
Reviewed-on: https://go-review.googlesource.com/13997
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-15 23:40:22 +00:00
Michael Hudson-Doyle
7af0839e11 cmd/go, runtime: always use position-independent code to invoke vsyscall helper on linux/386
golang.org/cl/16346 changed the runtime on linux/386 to invoke the vsyscall
helper via a PIC sequence (CALL 0x10(GS)) when dynamically linking. But it's
actually quite easy to make that code sequence work all the time, so do that,
and remove the ugly machinery that passed the buildmode from the go tool to the
assembly.

This means enlarging m.tls so that we can safely access 0x10(GS) (GS is set to
&m.tls + 4, so 0x10(GS) accesses m_tls[5]).

Change-Id: I1345c34029b149cb5f25320bf19a3cdd73a056fa
Reviewed-on: https://go-review.googlesource.com/16796
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-15 06:42:19 +00:00
Didier Spezia
0624fd3f14 cmd/compile: regenerate builtin.go
Following a recent change, file builtin.go is not up-to-date.
Generate it again by running go generate.

Fixes #13203

Change-Id: Ib91c5ccc93665c043da95c7d3783ce5d94e48466
Reviewed-on: https://go-review.googlesource.com/16821
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-14 22:17:20 +00:00
Shenghou Ma
3a96bf0d80 cmd/dist: disable shootout/spectralnorm on linux/mips64 builder
It is too slow with kernel FPU emulator.

Updates #12688.

Change-Id: Ib3a5adfeb46e894550231b14eb0f4fb20aecee11
Reviewed-on: https://go-review.googlesource.com/16922
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-14 21:43:49 +00:00
Ian Lance Taylor
754f707f5f cmd/link, cmd/go, cmd/dist: use copy of libgcc.a for internal linking
Change the linker to use a copy of the C compiler support library,
libgcc.a, when doing internal linking.  This will be used to satisfy any
undefined symbols referenced by host objects.

Change the dist tool to copy the support library into a new directory
tree under GOROOT/pkg/libgcc.  This ensures that libgcc is available
even when building Go programs on a system that has no C compiler.  The
C compiler is required when building the Go installation in the first
place, but is not required thereafter.

Change the go tool to not link libgcc into cgo objects.

Correct the linker handling of a weak symbol in an ELF input object to
not always create a new symbol, but to use an existing symbol if there
is one; this is necessary on freebsd-amd64, where libgcc contains a weak
definition of compilerrt_abort_impl.

Fixes #9510.

Change-Id: I1ab28182263238d9bcaf6a42804e5da2a87d8778
Reviewed-on: https://go-review.googlesource.com/16741
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-14 18:56:17 +00:00
Robert Griesemer
ac658a83c2 cmd/compile/internal/gc: consume at least one token in case of syntax error
Fixes #13248.

TBR: iant

Change-Id: Ic8b10704f945e6daef04bb38a00e249854b4ef19
Reviewed-on: https://go-review.googlesource.com/16930
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-11-14 05:40:52 +00:00
Russ Cox
d8dd9c714b cmd/dist: default to clang, not gcc, on freebsd
Fixes #11380.

Change-Id: I0a284ad2a46826ce82486479ea4e79f0f470292f
Reviewed-on: https://go-review.googlesource.com/16635
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-14 03:35:41 +00:00
Robert Griesemer
12126752cc cmd/compile: associate tracking issue numbers with TODOs
Comment changes only.

Change-Id: Ib365b3cd16af9995cb0a2cce48fbe35d73899438
Reviewed-on: https://go-review.googlesource.com/16898
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 01:21:18 +00:00
Robert Griesemer
59dc25730b cmd/compile: cleanup in parser (3)
Factored out functionality of dotname (was inlined in 3 places).

Change-Id: Ica782737c8decbb757465830b25ba87faa9115a4
Reviewed-on: https://go-review.googlesource.com/16897
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 01:19:54 +00:00
Robert Griesemer
8d733ecafb cmd/compile: cleanup in parser.go (2)
Inlined fntype, othertype, recvchantype, ptrtype into ntype
and simplified callers. Minor cleanups elsewhere (better names).

Change-Id: I54924969996641a802de00c078b4cd0eabfda8c1
Reviewed-on: https://go-review.googlesource.com/16894
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 01:19:31 +00:00
Robert Griesemer
18160e0740 cmd/compile: cleanup in parser.go
Inlined non_dcl_stmt in stmt since it was called only from there.

Change-Id: I616c41332cfd86bbf3493d0ce7b1256384215220
Reviewed-on: https://go-review.googlesource.com/16893
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 00:33:27 +00:00
Robert Griesemer
c8bc7f1abd cmd/compile: better syntax error handling for new parser
- better error messages
- better error recovery by advancing to "follow" token after error
- make sure that we make progress after all errors
- minor cleanups

Change-Id: Ie43b8b02799618d70dc8fc227fab3e4e9e0d8e3a
Reviewed-on: https://go-review.googlesource.com/16892
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-14 00:32:57 +00:00
Robert Griesemer
b569b87ca1 cmd/compile/internal/gc: recursive-descent parser
This is a translation of the yacc-based parser with adjustements
to make the grammar work for a recursive-descent parser followed
by cleanups and simplifications.

The yacc actions were mostly literally copied for correctness
with better temporary names.

A few of the syntax tests were adjusted for slightly different
error messages (it is very difficult to match the yacc-based
error messages in all cases, and sometimes the new parser could
produce better errors).

The new parser is enabled by default.
To switch back to the yacc-based parser, set -oldparser.
To hardwire the switch back, uncomment "oldparser = 1" in lex.go.

- passes all.bash
- ~18% reduced parse time per file on average for make.bash
- ~3% reduced compile time for building cmd/compile

Change-Id: Icb5651bb9d8b9f66261762d2c94a03793050d4ce
Reviewed-on: https://go-review.googlesource.com/16665
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 14:53:57 +00:00
Ian Lance Taylor
b5c1b5d7a0 cmd/go: fix build -n when adding to archive with gc toolchain
Fix the output of build -n when adding to an existing archive with the
gc toolchain by observing that we are, now, always doing that.  When
using the gc toolchain the archive is now always created by the Go
compiler, and never by the pack command.

No test because we have not historically tested build -n output.

Fixes #13118.

Change-Id: I3a5c43cf45169fa6c9581e4741309c77d2b6e58b
Reviewed-on: https://go-review.googlesource.com/16761
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-13 14:23:27 +00:00
David Crawshaw
9958a7b563 Revert "cmd/internal/obj/arm64, cmd/link: use two instructions rather than three for loads from memory"
This reverts commit 3a9bc571b0.

Breaks darwin/arm64.

Change-Id: Ib958beacabca48020a6a47332fbdec99d994060b
Reviewed-on: https://go-review.googlesource.com/16906
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2015-11-13 11:40:10 +00:00
Shenghou Ma
2a031e6a2a cmd/internal/obj/arm64: rewrite branches that are too far
Fixes #12540.

Change-Id: I7893fdc023145b0aca4b4c7df7e08e47edcf5bba
Reviewed-on: https://go-review.googlesource.com/16902
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 03:40:58 +00:00
Shenghou Ma
d42cc10283 cmd/dist: set timeout for go1 benchmark too
so that GO_TEST_TIMEOUT_SCALE can be applied too.
It's for the mips64 builder, which is so slow that the
go1 benchmark can't finish startup within 10 minutes.

Change-Id: I1b824eb0649460101b294fb442da784e872403e7
Reviewed-on: https://go-review.googlesource.com/16901
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-13 02:34:53 +00:00
Michael Hudson-Doyle
37ac54dc2b cmd/dist: run testshared on linux/ppc64le
Change-Id: I4d079d29408e5344701056c88882cfd3b3857478
Reviewed-on: https://go-review.googlesource.com/15973
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
2015-11-13 00:53:54 +00:00
Michael Hudson-Doyle
1ccefcd1b8 cmd/link, runtime: implement & call addmoduledata on ppc64le
Change-Id: I3980d82c7df95e69522c3d2c90311f89c6fef0e1
Reviewed-on: https://go-review.googlesource.com/15972
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 00:51:45 +00:00
Michael Hudson-Doyle
64fbca41c8 cmd/internal/obj/ppc64: avoid calling morestack via a PLT when dynamically linking
Change-Id: Ie79f72786b1d7154f1910e717a0faf354b913b89
Reviewed-on: https://go-review.googlesource.com/15970
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 00:36:22 +00:00
Michael Hudson-Doyle
2ac993107f cmd/internal/obj, cmd/link: access global data via GOT when dynlinking on ppc64le
Change-Id: I79c60241df6c785f35371e70c777a7bd6e93571c
Reviewed-on: https://go-review.googlesource.com/15968
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 00:25:21 +00:00
Michael Hudson-Doyle
9a476028c0 cmd/go, cmd/link: enable -buildmode=shared on linux/ppc64le
Change-Id: Ifba76413b8aa78a221385bf505b92a3a5fbc3d24
Reviewed-on: https://go-review.googlesource.com/16713
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-12 23:58:52 +00:00
Michael Hudson-Doyle
a35c85c0cc cmd/internal/obj, runtime: implement IE model TLS on ppc64le
This requires changing the tls access code to match the patterns documented in
the ABI documentation or the system linker will "optimize" it into ridiculousness.

With this change, -buildmode=pie works, although as it is tested in testshared,
the tests are not run yet.

Change-Id: I1efa6687af0a5b8db3385b10f6542a49056b2eb3
Reviewed-on: https://go-review.googlesource.com/15971
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 23:50:27 +00:00
Michael Hudson-Doyle
bd329d47d9 cmd/internal/obj, cmd/link: generate position independent loads of static data
Change-Id: I0a8448c2b69f5cfa6f099d772f5eb3412f853045
Reviewed-on: https://go-review.googlesource.com/15969
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 23:33:12 +00:00
Michael Hudson-Doyle
368d548417 cmd/compile, cmd/link, runtime: on ppc64x, maintain the TOC pointer in R2 when compiling PIC
The PowerPC ISA does not have a PC-relative load instruction, which poses
obvious challenges when generating position-independent code. The way the ELFv2
ABI addresses this is to specify that r2 points to a per "module" (shared
library or executable) TOC pointer. Maintaining this pointer requires
cooperation between codegen and the system linker:

 * Non-leaf functions leave space on the stack at r1+24 to save the TOC pointer.
 * A call to a function that *might* have to go via a PLT stub must be followed
   by a nop instruction that the system linker can replace with "ld r1, 24(r1)"
   to restore the TOC pointer (only when dynamically linking Go code).
 * When calling a function via a function pointer, the address of the function
   must be in r12, and the first couple of instructions (the "global entry
   point") of the called function use this to derive the address of the TOC
   for the module it is in.
 * When calling a function that is implemented in the same module, the system
   linker adjusts the call to skip over the instructions mentioned above (the
   "local entry point"), assuming that r2 is already correctly set.

So this changeset adds the global entry point instructions, sets the metadata so
the system linker knows where the local entry point is, inserts code to save the
TOC pointer at 24(r1), adds a nop after any call not known to be local and copes
with the odd non-local code transfer in the runtime (e.g. the stuff around
jmpdefer). It does not actually compile PIC yet.

Change-Id: I7522e22bdfd2f891745a900c60254fe9e372c854
Reviewed-on: https://go-review.googlesource.com/15967
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 23:18:58 +00:00
Michael Hudson-Doyle
c83c806535 cmd/internal/obj, cmd/link, runtime: use a larger stack frame on ppc64
The larger stack frames causes the nosplit stack to overflow so the next change
increases the stackguard.

Change-Id: Ib2b4f24f0649eb1d13e3a58d265f13d1b6cc9bf9
Reviewed-on: https://go-review.googlesource.com/15964
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 22:32:37 +00:00
Michael Hudson-Doyle
c1b6e392f5 cmd/internal/obj, cmd/link, runtime: increase stack limit to accommodate larger frames on ppc64x
Larger stack frames mean nosplit functions use more stack and so the limit
needs to increase.

The change to test/nosplit.go is a bit ugly but I can't really think of a
way to make it nicer.

Change-Id: I2616b58015f0b62abbd62951575fcd0d2d8643c2
Reviewed-on: https://go-review.googlesource.com/16504
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 22:32:16 +00:00
Shenghou Ma
b28eeea136 cmd/dist: copy textflag.h for runtime/internal/* too
Change-Id: I22216df83898e560cfe6d97344f05e3678c2db99
Reviewed-on: https://go-review.googlesource.com/16872
Reviewed-by: Michael Matloob <matloob@golang.org>
2015-11-12 19:57:46 +00:00
Michael Matloob
80d0b98d80 runtime/internal/atomic: delete arch1_*.go files
I made a copy of the per-arch _CacheLineSize definitons when checking in
runtime/internal/atomic. Now that runtime/internal/sys is checked in,
we can use the definition there.

Change-Id: I7242f6b633e4164f033b67ff471416b9d71c64d2
Reviewed-on: https://go-review.googlesource.com/16847
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-12 17:37:22 +00:00
Burcu Dogan
b619d5573e Revert "cmd/go: use shallow clones for new git checkouts"
This reverts commit bc1f9d20b4.

The current go-get strategy doesn't support cases that servers
cannot handle shallow clients.

Also, `go get -u` is broken and is not compatible with already
go-getted unshallow repos.

Fixes #13213.
Fixes #13206.

Change-Id: Ie89d7603d96d323db64ad82997793fda0972f709
Reviewed-on: https://go-review.googlesource.com/16832
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 17:27:32 +00:00
Michael Matloob
87a65f6ce7 cmd/compile: delete the runtime_internal_atomic.go builtin defs file
The file was automatically placed in the cl by a tool I had built.
Since the compiler doesn't hook into the atomic package, it's unnecessary.

Change-Id: I631fd876813b381bb12604865b00fc5b268dce84
Reviewed-on: https://go-review.googlesource.com/16844
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-12 17:27:28 +00:00
Russ Cox
7e72505173 cmd/dist: remove race binaries when rebuilding everything
Fixes #13214.

Change-Id: Id8fbb252b8beadb0b41f839dcd85d6165dea86a3
Reviewed-on: https://go-review.googlesource.com/16845
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-12 17:07:06 +00:00
Michael Matloob
432cb66f16 runtime: break out system-specific constants into package sys
runtime/internal/sys will hold system-, architecture- and config-
specific constants.

Updates #11647

Change-Id: I6db29c312556087a42e8d2bdd9af40d157c56b54
Reviewed-on: https://go-review.googlesource.com/16817
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 17:04:45 +00:00
Ian Lance Taylor
d54c35675c cmd/go: subdirs of runtime other than runtime/internal do depend on runtime
Correct an error in the last change: it caused runtime/cgo and
runtime/race to not depend on runtime.

Fixes #13214.

Change-Id: Ib48b3b5e9a74567ddfaccb7ab4a897ee2aedc2b8
Reviewed-on: https://go-review.googlesource.com/16837
Reviewed-by: Michael Matloob <matloob@golang.org>
2015-11-12 15:35:48 +00:00
Yao Zhang
704f83184f cmd/dist: added support for GOARCH=mips64{,le}
Change-Id: I22ea3352ad0794fc611334c2f2ec5f1e894985ce
Reviewed-on: https://go-review.googlesource.com/14460
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:54:40 +00:00
Yao Zhang
b4501ac4a5 cmd/cgo: added support for GOARCH=mips64{,le}
The actual cgo is not supported for now. This is just the cgo command.

Change-Id: I25625100ee552971f47e681b7d613cba16a2132f
Reviewed-on: https://go-review.googlesource.com/14446
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:45:54 +00:00
Yao Zhang
d5cd4ab46a cmd/compile: added support for mips64{,le}
It is based on ppc64 compiler.

Change-Id: I15a101df05f2919ba5292136957ba0009227d067
Reviewed-on: https://go-review.googlesource.com/14445
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:44:20 +00:00
Yao Zhang
053c75411f cmd/link: added support for mips64{,le}
Only internal linking without cgo is supported for now.

Change-Id: Ie6074a8ff3ec13605b72028f2d60758034f87185
Reviewed-on: https://go-review.googlesource.com/14444
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:44:00 +00:00
Yao Zhang
43ea305435 cmd/asm: added support for GOARCH=mips64{,le}
Change-Id: I951387f88993715e86b6ab9f18d38ed5c691ee0f
Reviewed-on: https://go-review.googlesource.com/14443
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:43:42 +00:00
Yao Zhang
fa6a1ecd63 cmd/internal/obj/mips: added support for GOARCH=mips64{,le}
MIPS64 has 32 general purpose 64-bit integer registers (R0-R31), 32
64-bit floating point registers (F0-F31). Instructions are fixed-width,
and are 32-bit wide. Instructions are all in standard 1-, 2-, 3-operand
forms.

MIPS64-specific relocations are added. For this reason, test data of
cmd/newlink are regenerated.

No other changes are made to portable structures.

Branch delay slots are current filled with NOP instructions. The function
for instruction scheduling (try to fill the delay slot with a useful
instruction) is implemented but disabled for now.

Change-Id: Ic364999c7a33245260c1381fc26a2fa8972d38b3
Reviewed-on: https://go-review.googlesource.com/14442
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:42:44 +00:00
Michael Hudson-Doyle
4255b78c7d cmd/go: handle linking against a shared library that implicitly includes a package
If you say "go install -buildmode=shared a b" and package a depends on another
package c, package c is implicitly included in the resulting shared library (as
specified by "Go Execution Modes"). But if c depends on b, linking against this
shared library hangs, because the go tool doesn't know when computing c's
dependencies that c is part of the same shared library as c.

Fix this by tracking the shared library a package *is* in separately from the
shared library a package has been explicitly linked into.

Fixes #13044

Change-Id: Iacfedab24ae9731ed53d225678b447a2a888823c
Reviewed-on: https://go-review.googlesource.com/16338
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-12 00:08:07 +00:00
Michael Hudson-Doyle
9514285da9 cmd/compile/internal/x86: avoid CX in a couple of places in the int64 code
I want to use CX as a scratch register in position independent code and these
uses are easy to remove.

Change-Id: I9e3cb470d7f0000d85786c30bd769d9ec86d532a
Reviewed-on: https://go-review.googlesource.com/16382
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-11 23:44:50 +00:00
Michael Hudson-Doyle
cf125a36d5 cmd/link: fix size of filetab slice
The linker writes the number of file symbols (Nhistfile) to the filetab slice
and then Nhistfile offsets -- which means the slice contains Nhistfile+1
entries, not just Nhistfile.

I think this bug has been around since at least 1.4 but it's easier to trigger
with shared libraries and a tiny binary that only has a couple of functions in
it -- try go install -buildmode=shared std && go run -linkshared test/fixedbugs/issue4388.go.

Change-Id: I6c0f01f1e607b9b2b96872e37ffce81281911504
Reviewed-on: https://go-review.googlesource.com/16342
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-11 23:17:25 +00:00
Hyang-Ah Hana Kim
05c4c6e2f4 cmd,runtime: TLS setup for android/386
Same ugly hack as https://go-review.googlesource.com/15991.

Update golang/go#9327.

Change-Id: I58284e83268a15de95eabc833c3e01bf1e3faa2e
Reviewed-on: https://go-review.googlesource.com/16678
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-11 21:59:24 +00:00
Meng Zhuo
bc1f9d20b4 cmd/go: use shallow clones for new git checkouts
Currently go get will clone the full history of git repos.
We can improve the download waiting time/size by passing depth argument.

The docs about shallow clones and the --depth argument are here:
https://git-scm.com/docs/git-clone
https://git-scm.com/docs/git-pull

Fixes #13078

Change-Id: Ie891d905d9c77f6ecadf7dcd5b44b477f4e079e0
Reviewed-on: https://go-review.googlesource.com/16360
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-11 14:28:58 +00:00
Ian Lance Taylor
9dcc58c3d1 cmd/cgo, runtime: add checks for passing pointers from Go to C
This implements part of the proposal in issue 12416 by adding dynamic
checks for passing pointers from Go to C.  This code is intended to be
on at all times.  It does not try to catch every case.  It does not
implement checks on calling Go functions from C.

The new cgo checks may be disabled using GODEBUG=cgocheck=0.

Update #12416.

Change-Id: I48de130e7e2e83fb99a1e176b2c856be38a4d3c8
Reviewed-on: https://go-review.googlesource.com/16003
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10 22:22:10 +00:00
Robert Griesemer
50fa646776 cmd/compile/internal/gc: avoid potential endless loop in float printing
The compiler should not usually call Fconv with an infinity, but if
it does, Fconv will end in an endless loop. Test for infinities early.

Change-Id: I48f366466538b0bd26a851e01258725025babaff
Reviewed-on: https://go-review.googlesource.com/16777
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10 20:36:52 +00:00
Ian Lance Taylor
2fdff9586b cmd/go: always use --whole-archive for gccgo packages
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 .

Change-Id: I3e769dd174f64050ebbff268fbbf5e6fab1e2a1b
Reviewed-on: https://go-review.googlesource.com/16775
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10 20:22:13 +00:00
Michael Hudson-Doyle
07a6cbf58a cmd/dist, cmd/go, misc/cgo/testshared: update testshared and run it on arm
And enable PIE in cmd/go because that's all it seems to take.

Change-Id: Ie017f427ace5e91de333a9f7cba9684c4641dfd5
Reviewed-on: https://go-review.googlesource.com/14222
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-10 19:57:30 +00:00