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

5350 Commits

Author SHA1 Message Date
Josh Bleecher Snyder
8bbd80063b cmd/go: put user ldflags at the end of the linker invocation
If the user provided a key but no value via -ldflag -X,
another linker flag was used as the value.

Placing the user's flags at the end avoids this problem.
It also provides the user the opportunity to
override existing linker flags.

Fixes #8810.

Change-Id: I96f4190713dc9a9c29142e56658446fba7fb6bc8
Reviewed-on: https://go-review.googlesource.com/2242
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-02 18:36:44 +00:00
Alberto Donizetti
307e2706cb cmd/gc: update issue tracker link
Updated the issue tracker link the compiler prints out
when asking for a bug report after an internal error.

Change-Id: I092b118130f131c6344d9d058bea4ad6379032b8
Reviewed-on: https://go-review.googlesource.com/2218
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-02 15:45:17 +00:00
Shenghou Ma
cb1897a58c cmd/gc: give an error if only one argument is given to complex()
Fixes #8501

Change-Id: I0dbbdded7f7924351c3d1841d60cb5c934b295b7
Reviewed-on: https://go-review.googlesource.com/2143
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-01-02 02:52:56 +00:00
Shenghou Ma
76b2f06ee5 cmd/gc: fix filename output format verb for -s
%lL will prepend the current directory to the filename, which is not
what we want here (as the file name is already absolute).

Fixes #9150.

Change-Id: I4c9386be6baf421393b92d9401a264b4692986d0
Reviewed-on: https://go-review.googlesource.com/2231
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-31 23:11:07 +00:00
Chris Manghane
5cc29ab95e cmd/gc: logical operators should produce untyped bool for untyped
operands

Fixes #6671 for cmd/gc.

Change-Id: I4907655b6e243960f2ceb544c63ea16513c7bd68
Reviewed-on: https://go-review.googlesource.com/1251
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-29 23:36:30 +00:00
Shenghou Ma
ab0535ae3f liblink, cmd/ld, runtime: remove stackguard1
Now that we've removed all the C code in runtime and the C compilers,
there is no need to have a separate stackguard field to check for C
code on Go stack.

Remove field g.stackguard1 and rename g.stackguard0 to g.stackguard.
Adjust liblink and cmd/ld as necessary.

Change-Id: I54e75db5a93d783e86af5ff1a6cd497d669d8d33
Reviewed-on: https://go-review.googlesource.com/2144
Reviewed-by: Keith Randall <khr@golang.org>
2014-12-29 07:36:07 +00:00
Emil Hessman
b6e913806e cmd/pack: address go vet reports
Use log.Fatalf for formatting directives instead of log.Fatal

Change-Id: Ia207b320f5795c63cdfa71f92c19ca6d05cc833f
Reviewed-on: https://go-review.googlesource.com/2160
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-28 07:08:02 +00:00
Shenghou Ma
1c0c611fc2 cmd/ld: put .bss from external objects into real .bss section
Fixes #9359.

Change-Id: Iba62935b5a14de23d914f433a09a40417d7e88ed
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/1889
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-26 01:05:02 +00:00
Carlos Castillo
131758183f go/build: add variable expansion to cgo lines
When go parses #cgo lines, expand ${SRCDIR} into the path to the
source directory. This allows options to be passed to the
compiler and linker that involve file paths relative to the
source code directory. Without the expansion the paths would be
invalid when the current working directory changes.

Fixes #7891
Fixes #5428

Change-Id: I343a145a9771a5ccbaa958e4a1ecd1716fcae52d
Reviewed-on: https://go-review.googlesource.com/1756
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-23 20:35:49 +00:00
David du Colombier
a51b6ccfea cmd/dist: fatal shouldn't print errstr on Plan 9
During change 1864 discussion, Russ Cox pointed out
the fatal function shouldn't print errstr.

Change-Id: Icd71ec04be9c944bc235b8b198158465172e4fde
Reviewed-on: https://go-review.googlesource.com/2030
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-23 10:28:17 +00:00
Brad Fitzpatrick
1e4b642f8d cmd/api: work around Windows rename issue on the builders
More cmd/api/run.go hell.

Fixes #9407

Change-Id: If8fb446a2471d6372beb0534c9ab6824029b404c
Reviewed-on: https://go-review.googlesource.com/2054
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-23 04:55:44 +00:00
Keith Randall
53c5226f9f runtime: make stack frames fixed size by modifying goproc/deferproc.
Calls to goproc/deferproc used to push & pop two extra arguments,
the argument size and the function to call.  Now, we allocate space
for those arguments in the outargs section so we don't have to
modify the SP.

Defers now use the stack pointer (instead of the argument pointer)
to identify which frame they are associated with.

A followon CL might simplify funcspdelta and some of the stack
walking code.

Fixes issue #8641

Change-Id: I835ec2f42f0392c5dec7cb0fe6bba6f2aed1dad8
Reviewed-on: https://go-review.googlesource.com/1601
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-23 01:08:29 +00:00
Austin Clements
005ba4db82 cmd/9l: improve R_CALLPOWER error messages
Change-Id: I8670540a2a9647efbd8b072a54272a04c530e54b
Reviewed-on: https://go-review.googlesource.com/2001
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-22 23:57:39 +00:00
Austin Clements
7e424ecdc1 cmd/5l,6l,8l: remove bogus dynsym section indexes
Previously, this code generated bogus section indexes for dynamic
symbols.  It turns out this didn't matter, since we only emit these
when generating an executable and in an executable it only matters
whether a symbol is defined or undefined, but it leads to perplexing
code full of mysterious constants.

Unfortunately, this happens too early to put in real section indexes,
so just use section index 1 to distinguish the symbol from an
undefined symbol.

Change-Id: I0e514604bf31f21683598ebd3e020b66acf767ef
Reviewed-on: https://go-review.googlesource.com/1720
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-22 23:00:15 +00:00
Austin Clements
326ceeabc4 cmd/ld: add a text generation pass
This will be used by ppc64 to add call stubs to the .text section.
ARM needs a similar pass to generate veneers for arm->thumb
transitions.

Change-Id: Iaee74036e60643a56fab15b564718f359c5910eb
Reviewed-on: https://go-review.googlesource.com/2004
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-22 22:47:05 +00:00
Keith Randall
fbc56cf050 runtime: hashmap: move overflow pointer to end of bucket
Pointers to zero-sized values may end up pointing to the next
object in memory, and possibly off the end of a span.  This
can cause memory leaks and/or confuse the garbage collector.

By putting the overflow pointer at the end of the bucket, we
make sure that pointers to any zero-sized keys or values don't
accidentally point to the next object in memory.

fixes #9384

Change-Id: I5d434df176984cb0210b4d0195dd106d6eb28f73
Reviewed-on: https://go-review.googlesource.com/1869
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-22 22:25:48 +00:00
Josh Bleecher Snyder
aaa4bf3720 cmd/gc: update hashmap code location in comments
Change-Id: I3b81f2e9eb29ee6349d758b68fe7951b34f15a81
Reviewed-on: https://go-review.googlesource.com/1974
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-22 22:25:26 +00:00
Austin Clements
1e93125aa6 cmd/ld: clean up nested if when loading bind local syms
Change-Id: I15269722ca3d2654a9dd7a3f8a89ad375dc9bee0
Reviewed-on: https://go-review.googlesource.com/1759
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-22 20:02:16 +00:00
Brad Fitzpatrick
45eaf500fc cmd/api: fix race in run.go with multiple builders on a machine
Fixes #9407

Change-Id: I765e8009c7ee22473ac8c2d81c7f6c8ec9866c51
Reviewed-on: https://go-review.googlesource.com/1980
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2014-12-22 19:40:32 +00:00
Ian Lance Taylor
1303f0d3d8 cmd/cgo: don't #include cgo_export.h in gccgo _cgo_main.c
Instead of relying on the asm names declared in the gccgo version of
cgo_export.h, just emit a dummy symbol with the right asm name.  This
is enough to let the _cgo_main link succeed, which is all that matters
here.

Fixes #9294.

Change-Id: I803990705b6b226ed0adf17dc57b58a9f501b213
Reviewed-on: https://go-review.googlesource.com/1901
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-20 01:42:00 +00:00
Austin Clements
62eb6fef6e cmd/ld: add fallthrough comment
Change-Id: Ia6739c164575751a63cc0d4d41d1f6887fbbaee3
Reviewed-on: https://go-review.googlesource.com/1803
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 22:54:50 +00:00
Austin Clements
9b1b0a46dd liblink: fail for too-large register offset constants
Previously, liblink would silently truncate register offset constants
to 32 bits.  For example,

    MOVD $0x200000004(R2),R3

would assemble to

    addis   r31,r2,0
    addi    r3,r31,4

To fix this, limit C_LACON to 32 bit (signed) offsets and introduce a
new C_DACON operand type for larger register offsets.  We don't
implement this currently, but at least liblink will now give an error
if it encounters an address like this.

Change-Id: I8e87def8cc4cc5b75498b0fb543ac7666cf2964e
Reviewed-on: https://go-review.googlesource.com/1758
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 22:32:18 +00:00
Austin Clements
15c67e21da cmd/ld: set ELF ABI version for ppc64x
On ppc64, there are three ELF ABI versions an ELF file can request.
Previously, we used 0, which means "unspecified".  On our test
machines, this meant to use the default (v1 for big endian and v2 for
little endian), but apparently some systems can pick the wrong ABI if
neither is requested.  Leaving this as 0 also confuses libbfd, which
confuses gdb, objdump, etc.

Fix these problems by specifying ABI v1 for big endian and v2 for
little endian.

Change-Id: I4d3d5478f37f11baab3681a07daff3da55802322
Reviewed-on: https://go-review.googlesource.com/1800
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 22:30:56 +00:00
Keith Randall
2fc29a83ae cmd/gc: resolve static addresses of the form &x.f at link time
When we do y = &x for global variables x and y, y gets initialized
at link time.  Do the same for y = &x.f if x is a struct and y=&x[5]
if x is an array.

fixes #9217
fixes #9355

Change-Id: Iea3c0ce2ce1b309e2b760e345608fd95460b5713
Reviewed-on: https://go-review.googlesource.com/1691
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 21:53:03 +00:00
Ian Lance Taylor
24bf8f62be cmd/go: gc never permits C files; gccgo always does
Change-Id: I513665626ec0866f32036c26207dc234c17acea1
Reviewed-on: https://go-review.googlesource.com/1540
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 16:16:10 +00:00
Jan Mercl
a034e478a7 cmd/yacc: Prevent index out of range. Fixes #9099.
Change-Id: I7ef01a738b6ca49af1c148146d439c81b0a33b16
Reviewed-on: https://go-review.googlesource.com/1785
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-18 16:11:50 +00:00
Austin Clements
b21e936f3e liblink: generate correct code for MOVD $-n(Rm), x on ppc64
On ppc64, liblink rewrites MOVD's of >32-bit constants by putting the
constant in memory and rewriting the MOVD to load from that memory
address.  However, there were two bugs in the condition:

a) owing to an incorrect sign extension, it triggered for all negative
   constants, and

b) it could trigger for constant offsets from registers (addresses of
   the form $n(Rm) in assembly)

Together, these meant instructions of the form MOVD $-n(Rm), x were
compiled by putting -n in memory and rewriting the MOVD to load this
constant from memory (completely dropping Rm).

Change-Id: I1f6cc980efa3e3d6f164b46c985b2c3b55971cca
Reviewed-on: https://go-review.googlesource.com/1752
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 15:31:47 +00:00
Daniel Morsing
e0e1cee8e9 cmd/gc: remove outdated warning from pre-go1.
People are probably not making this mistake anymore.

Fixes #9164

Change-Id: I86b440ed63d09b4ca676bba7034838860f1a5d8b
Reviewed-on: https://go-review.googlesource.com/1782
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 08:52:30 +00:00
David du Colombier
1ba13a5ae8 cmd/gc: fix warning on Plan 9
warning: src/cmd/gc/bits.c:101 non-interruptable temporary

Change-Id: I74661fefab50455b912b8085d913fc45ba13c5c8
Reviewed-on: https://go-review.googlesource.com/1780
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-18 07:37:46 +00:00
Keith Randall
df1739c77d runtime: if key type is reflexive, don't call equal(k, k)
Most types are reflexive (k == k for all k of type t), so don't
bother calling equal(k, k) when the key type is reflexive.

Change-Id: Ia716b4198b8b298687843b94b878dbc5e8fc2c65
Reviewed-on: https://go-review.googlesource.com/1480
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-15 21:43:49 +00:00
Rob Pike
fde3ab843f cmd/go: handle \r in input text
Remove carriage returns from //go:generate lines.
Carriage returns are the predecessor of BOMs and still
live on Windows.

Fixes #9264

Change-Id: I637748c74335c696b3630f52f2100061153fcdb4
Reviewed-on: https://go-review.googlesource.com/1564
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-15 20:52:08 +00:00
Russ Cox
557a61d270 cmd/gc: add //go:nowritebarrier to diagnose unintended write barriers
//go:nowritebarrier can only be used in package runtime.
It does not disable write barriers; it is an assertion, checked
by the compiler, that the following function needs no write
barriers.

Change-Id: Id7978b779b66dc1feea39ee6bda9fd4d80280b7c
Reviewed-on: https://go-review.googlesource.com/1224
Reviewed-by: Rick Hudson <rlh@golang.org>
2014-12-12 20:48:10 +00:00
Brad Fitzpatrick
11d1c05fee cmd/api: treat a hex-y VERSION as devel and permit API changes
Change-Id: I2b05b7ff217586851ab41744e3077fddc480253c
Reviewed-on: https://go-review.googlesource.com/1405
Reviewed-by: David Symonds <dsymonds@golang.org>
2014-12-12 06:06:31 +00:00
Brad Fitzpatrick
082a2374fb cmd/api: update the API checker to Go 1.4 and git
Still using the ancient go/types API. Updating that to the modern API
should be a separate effort in a separate change.

Change-Id: Ic1c5ae3c13711d34fe757507ecfc00ee883810bf
Reviewed-on: https://go-review.googlesource.com/1404
Reviewed-by: David Symonds <dsymonds@golang.org>
2014-12-12 04:59:51 +00:00
Shenghou Ma
d3072127cc cmd/dist: ignore \r in crlf EOL when splitlines()
Fixes build on Windows. Fixes #9234.

Change-Id: Iebf4317e7cc20ba1afea5558553166cd89783316
Reviewed-on: https://go-review.googlesource.com/1421
Reviewed-by: <iant@golang.org>
2014-12-12 04:38:47 +00:00
Russ Cox
bd8077116e [release-branch.go1.4] cmd/api: make API check fail for undeclared API in release branch
We forgot to do the usual API review.
Make that not possible in the future.
I'll pull this change over to the main
branch too, but it's more important
(and only testable) here.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/185050043
2014-12-12 15:37:58 +11:00
Russ Cox
77e96c9208 [release-branch.go1.4] api: create go1.4.txt
I read through and vetted these but others should look too.

LGTM=bradfitz, adg
R=r, minux, bradfitz, adg
CC=adg, golang-codereviews, gri, iant
https://golang.org/cl/182560043
2014-12-12 14:01:01 +11:00
Austin Clements
3fa5d3a6dc cmd/pprof: remove -show_bytes from command line help
This flag no longer exists.  It has been replaced with -unit=byte.

Change-Id: Iff9fc501f2c666067c9b1948c4623c8e3adddb8d
Reviewed-on: https://go-review.googlesource.com/1287
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-11 15:23:18 +00:00
Keith Randall
7a4a64e8f3 runtime: faster aeshash implementation
The aesenc instruction has high latency.  For hashing large objects,
hash several streams in parallel.

benchmark                         old ns/op     new ns/op     delta
BenchmarkHash5                    7.02          7.45          +6.13%
BenchmarkHash16                   6.53          6.94          +6.28%
BenchmarkHash32                   8.38          8.26          -1.43%
BenchmarkHash64                   12.6          12.0          -4.76%
BenchmarkHash1024                 247           62.9          -74.53%
BenchmarkHash65536                17335         2966          -82.89%
BenchmarkHashInt32Speed           14.7          14.9          +1.36%
BenchmarkHashInt64Speed           14.6          14.9          +2.05%
BenchmarkHashBytesSpeed           35.4          28.6          -19.21%
BenchmarkHashStringSpeed          22.0          20.4          -7.27%
BenchmarkHashStringArraySpeed     65.8          56.3          -14.44%

Change-Id: Ia8ba03063acc64a9066b8ab2d79f2c9aaac1770f
Reviewed-on: https://go-review.googlesource.com/1330
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-11 05:23:00 +00:00
Keith Randall
ea51f2d304 cmd/objdump: Fix error logging
Change-Id: I6b1b4d3e8c039ba3198cb4b9765de75859ea8c32
Reviewed-on: https://go-review.googlesource.com/1214
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-09 00:27:39 +00:00
Keith Randall
8eb8b40a49 runtime: use doubly-linked lists for channel send/recv queues.
Avoids a potential O(n^2) performance problem when dequeueing
from very popular channels.

benchmark                old ns/op     new ns/op     delta
BenchmarkChanPopular     2563782       627201        -75.54%

Change-Id: I231aaeafea0ecd93d27b268a0b2128530df3ddd6
Reviewed-on: https://go-review.googlesource.com/1200
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-08 19:20:12 +00:00
David Symonds
f33fc0eb95 cmd/dist: convert dist from Hg to Git. 2014-12-08 13:53:11 +11:00
Russ Cox
31457cef6d all: merge dev.garbage (d1238958d4ae) into default branch
When we start work on Gerrit, ppc64 and garbage collection
work will continue in the master branch, not the dev branches.

(We may still use dev branches for other things later, but
these are ready to be merged, and doing it now, before moving
to Git means we don't have to have dev branches working
in the Gerrit workflow on day one.)

TBR=rlh
CC=golang-codereviews
https://golang.org/cl/183140043
2014-12-05 20:34:45 -05:00
Russ Cox
09d92b6bbf all: power64 is now ppc64
Fixes #8654.

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/180600043
2014-12-05 19:13:20 -05:00
Russ Cox
dcb2ec3b65 runtime: generate windows callback list with go generate
This is the last system-dependent file written by cmd/dist.
They are all now written by go generate.

cmd/dist is not needed to start building package runtime
for a different system anymore.

Now all the generated files can be assumed generated, so
delete the clumsy hacks in cmd/api.

Re-enable api check in run.bash.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/185040044
2014-12-05 16:24:20 -05:00
Russ Cox
444839014b [dev.garbage] all: merge dev.cc (81884b89bd88) into dev.garbage
TBR=rlh
CC=golang-codereviews
https://golang.org/cl/181100044
2014-12-05 11:40:41 -05:00
Russ Cox
829b286f2c [dev.cc] all: merge default (8d42099cdc23) into dev.cc
TBR=austin
CC=golang-codereviews
https://golang.org/cl/178700044
2014-12-05 11:18:10 -05:00
Shenghou Ma
274976f45c [dev.cc] cmd/ld: finalize linkmode before determining whether to import runtime/cgo
Frankly, I don't understand how the current code could possibly work except
when every android program is using cgo. Discovered this while working on
the iOS port.

LGTM=crawshaw, rsc
R=rsc, crawshaw
CC=golang-codereviews
https://golang.org/cl/177470043
2014-12-05 02:22:20 -05:00
Rob Pike
41c6b84342 cmd/go: fix build
The new semantics of split require the newline be present.
The test was stale.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/182480043
2014-12-05 09:37:56 +09:00
Rob Pike
dd26fc3822 cmd/go: avoid use of bufio.Scanner in generate
Scanner can't handle stupid long lines and there are
reports of stupid long lines in production.

Note the issue isn't long "//go:generate" lines, but
any long line in any Go source file.

To be fair, if you're going to have a stupid long line
it's not a bad bet you'll want to run it through go
generate, because it's some embeddable asset that
has been machine generated. (One could ask why
that generation process didn't add a newline or two,
but we should cope anyway.)

Rewrite the file scanner in "go generate" so it can
handle arbitrarily long lines, and only stores in memory
those lines that start "//go:generate".

Also: Adjust the documentation to make clear that it
does not parse the file.

Fixes #9143.
Fixes #9196.

LGTM=rsc, dominik.honnef
R=rsc, cespare, minux, dominik.honnef
CC=golang-codereviews
https://golang.org/cl/182970043
2014-12-05 09:15:38 +09:00