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

4596 Commits

Author SHA1 Message Date
Shenghou Ma
6b188ef57a cmd/dist, build: support building statically linked toolchain
Added a new $GO_DISTFLAGS to make.bash, and while we're here,
added mention $CXX in make.bash (CL 13704044).

Fixes #6448.
Update #3564
We can pass GO_DISTFLAGS=-s from misc/dist to make.bash so that
it will build a statically linked toolchain.
(Note: OS X doesn't have the concept of static linking, so don't
pass GO_DISTFLAGS=-s for OS X builds)

R=adg, rsc, iant
CC=golang-dev
https://golang.org/cl/13887043
2013-10-01 23:44:20 -04:00
Dave Day
57f69710d5 cmd/go: use -installsuffix to determine the includes directory list
Currently, the directories generaed by includeArgs can have the "_race"
suffix added if invoked with -race flag, but ignores -installsuffix if
set.

R=adg, rsc
CC=golang-dev
https://golang.org/cl/14174043
2013-10-01 20:44:57 -04:00
Shenghou Ma
752960aa5c cmd/go: "go test -c -test.bench=XX fmt" shouldn't hang
Fixes #6480.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13925043
2013-09-25 16:18:33 -04:00
Ian Lance Taylor
935a826a2f cmd/cgo: fix so that tests pass again when using gccgo
Use the symbol prefixes with the prologue functions when using
gccgo.

Use an & when referring to a function declared as a variable.

Fix the malloc prologue function.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13878043
2013-09-24 18:11:13 -07:00
Russ Cox
5639d2754b cmd/cgo: retain Go pointer passed to C call for duration of call
Fixes #6397.

R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/13858043
2013-09-24 15:52:48 -04:00
Shenghou Ma
7616c94921 cmd/dist, cmd/go: embed default C++ compiler into cmd/go
Fixes #6426.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/13704044
2013-09-24 00:17:08 -04:00
Russ Cox
3c1ece2cb4 cmd/cgo: update #cgo docs to reflect reality
The syntax accepted is full build constraints, not just
GOOS, GOARCH, and GOOS/GOARCH.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13504048
2013-09-23 16:29:53 -04:00
Shenghou Ma
60513bf2f4 cmd/ld: fix "_image_base__ not defined" problem for cmd/8l.
Fixes #6431.

Change suggested by kin.wilson.za.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13314048
2013-09-23 13:08:00 -04:00
Brad Fitzpatrick
afda774e95 cmd/api: always do API check if hg is available
Fixes #6124

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13500046
2013-09-22 08:01:17 +01:00
Russ Cox
0826c04e14 cmd/yacc: report correct line for 'default action causes potential type clash'
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13588044
2013-09-20 16:00:13 -04:00
Russ Cox
5be1821a31 cmd/gc: fix imported and not used error for import .
Fixes issues 6420.

R=ken2
CC=golang-dev
https://golang.org/cl/13703044
2013-09-20 15:25:43 -04:00
Russ Cox
36f8480965 cmd/gc: print expression in 'duplicate case in switch' error
The line number alone does not help when the line is
case '~', '*', '(', ')', '[', ']', '{', '}', '?', ':', ';', ',', '*', '%', '^', '!', '=', '<', '>', '+', '-', '&', '|':

R=ken2
CC=golang-dev
https://golang.org/cl/13431046
2013-09-20 15:15:43 -04:00
Shenghou Ma
0d85d5423b cmd/ld: fix "ld -s" to not discard pclntab.
Fixes #6245.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/13751045
2013-09-20 10:04:52 -04:00
Rémy Oudompheng
381b72a7a3 cmd/gc: cleanup SWITCH nodes after walk.
Keeping pointers from the pre-walk phase confuses
the race detection instrumentation.

Fixes #6418.

R=golang-dev, dvyukov, r
CC=golang-dev
https://golang.org/cl/13368057
2013-09-19 09:23:04 +02:00
Shenghou Ma
c742179c49 cmd/ld: handle IMAGE_SYM_CLASS_LABEL symbols.
Was causing "invalid symbol binding" and thus "malformed pe file" error.

R=golang-dev, alex.brainman, adg
CC=golang-dev
https://golang.org/cl/13722050
2013-09-19 02:27:53 -04:00
Shenghou Ma
db71e1557b cmd/go: fix missing __mingw_fprintf symbol for cgo on windows
Fixes #5986.

R=golang-dev, rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/13261055
2013-09-19 01:20:02 -04:00
Shenghou Ma
9add729a1f cmd/ld: handle duplicate static symbols in COFF and Mach-O files.
Fixes #5740.

R=iant, rsc, luisbebop
CC=gobot, golang-dev
https://golang.org/cl/10345046
2013-09-18 22:27:25 -04:00
Rob Pike
ba10318607 cmd/go: write the WORK=/tmp/... line to stderr
Unlike the other output from the -x flag, it was going to stdout.
Fixes #6362.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13746044
2013-09-19 11:19:11 +10:00
Dave Cheney
b27e09331c cmd/gc: fix set but not used error
R=rsc, r
CC=golang-dev
https://golang.org/cl/13749044
2013-09-18 10:15:52 +10:00
Ian Lance Taylor
3d3bccc421 cmd/go: add basic docs on calling between Go and C/C++
This is a framework for docs on the subject more than it is
actual docs.

The section header in go/doc.go just says "C", not "C/C++,"
because otherwise godoc doesn't recognize the line as a
section header.

Fixes #5473.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13280050
2013-09-17 17:10:48 -07:00
Russ Cox
aa0439ba65 cmd/gc: eliminate redundant &x.Field nil checks
This eliminates ~75% of the nil checks being emitted,
on all architectures. We can do better, but we need
a bit more general support from the compiler, and
I don't want to do that so close to Go 1.2.
What's here is simple but effective and safe.

A few small code generation cleanups were required
to make the analysis consistent on all systems about
which nil checks are omitted, at least in the test.

Fixes #6019.

R=ken2
CC=golang-dev
https://golang.org/cl/13334052
2013-09-17 16:54:22 -04:00
Ian Lance Taylor
acae4d212c cmd/cgo: rearrange and update documentation
In particular document that the Go tool will look for certain
file extensions and compile with them with either the C or the
C++ compiler.

Fixes #6393.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13733043
2013-09-17 07:11:40 -07:00
Dave Cheney
8d5ec52e6c cmd/6c, cmd/6g, cmd/cc: fix undefined behavior warnings
Update #5764

Like Tribbles, the more you kill, the more spring up in their place.

R=rsc
CC=golang-dev
https://golang.org/cl/13324049
2013-09-17 13:43:27 +10:00
Rémy Oudompheng
045dbeaf05 cmd/gc, runtime: inline append in frontend.
A new transformation during walk turns append calls
into a combination of growslice and memmove.

benchmark                     old ns/op    new ns/op    delta
BenchmarkAppend                     141          141   +0.00%
BenchmarkAppend1Byte                 18           11  -39.56%
BenchmarkAppend4Bytes                19           10  -42.63%
BenchmarkAppend7Bytes                18           10  -42.16%
BenchmarkAppend8Bytes                18           10  -40.44%
BenchmarkAppend15Bytes               19           11  -41.67%
BenchmarkAppend16Bytes               19           11  -41.97%
BenchmarkAppend32Bytes               23           14  -38.82%
BenchmarkAppendStr1Byte              14           10  -23.78%
BenchmarkAppendStr4Bytes             14           11  -21.13%
BenchmarkAppendStr8Bytes             14           10  -25.17%
BenchmarkAppendStr16Bytes            19           11  -41.45%
BenchmarkAppendStr32Bytes            18           14  -19.44%
BenchmarkAppendSpecialCase           62           63   +1.77%

R=golang-dev, khr, cshapiro, rsc, dave
CC=golang-dev
https://golang.org/cl/12815046
2013-09-16 20:31:21 -04:00
Russ Cox
00061219f0 cmd/nm: make -S listing a bit more accurate
Hide container symbols like text and etext so that
the individual pieces inside are shown instead.
For example, if text and main.init have the same
address, it was a toss-up which name was printed.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13722046
2013-09-16 20:27:57 -04:00
Russ Cox
30ecb4cd05 build: disable precise collection of stack frames
The code for call site-specific pointer bitmaps was not ready in time,
but the zeroing required without it is too expensive to use by default.
We will have to wait for precise collection of stack frames until Go 1.3.

The precise collection can be re-enabled by

        GOEXPERIMENT=precisestack ./all.bash

but that will not be the default for a Go 1.2 build.

Fixes #6087.

R=golang-dev, jeremyjackins, dan.kortschak, r
CC=golang-dev
https://golang.org/cl/13677045
2013-09-16 20:26:10 -04:00
Ian Lance Taylor
5ffc0f8fbb cmd/cgo: remove inaccurate comment
All these features have in fact been implemented.

R=rsc
CC=golang-dev
https://golang.org/cl/13419049
2013-09-16 13:19:32 -07:00
Russ Cox
e9453e0545 cmd/gc: do not report fields when looking for methods
Fixes #6395.

R=ken2
CC=golang-dev
https://golang.org/cl/13470046
2013-09-16 15:55:16 -04:00
Russ Cox
51266761fd cmd/gc: fix divide by zero error in compiler
Fixes #6399.

R=ken2
CC=golang-dev
https://golang.org/cl/13253055
2013-09-16 14:22:37 -04:00
Russ Cox
647eaed93b cmd/cgo: allow C.malloc(0) always
Because we can, and because it otherwise might crash
the program if we think we're out of memory.

Fixes #6390.

R=golang-dev, iant, minux.ma
CC=golang-dev
https://golang.org/cl/13345048
2013-09-16 14:04:55 -04:00
Rob Pike
29b4de25b3 cmd/go: document that "main" is a reserved import path
Fixes #6312.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/13391049
2013-09-16 22:53:12 +10:00
Rob Pike
2ec53b0705 cmd/nm: put the -S flag in the usage message
The -S flag reports symbol size, but is missing from the usage message.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13660046
2013-09-16 16:13:27 +10:00
Andrew Gerrand
d445b76331 cmd/gofmt: document -s transformations
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13721043
2013-09-16 11:19:39 +10:00
Rémy Oudompheng
04c40c97c3 cmd/gc: don't generate algs for internal map types.
Fake types describing the internal structure of hashmaps are
generated for use by precise GC.

Generating hash and eq functions for these fake types slows down
the build and wastes space: the go tool binary size is 13MB
instead of 12MB, and the package size on amd64 is 48.7MB instead
of 45.3MB.

R=golang-dev, daniel.morsing, r, khr, rsc, iant
CC=golang-dev
https://golang.org/cl/13698043
2013-09-14 09:30:36 +02:00
Russ Cox
3acddba2ec cmd/5l: fix handling of RET.EQ in wrapper function
Keith is too clever for me.

R=ken2
CC=golang-dev, khr
https://golang.org/cl/13272050
2013-09-13 03:50:50 +00:00
Jamie Wilkinson
27cb23ceb1 goyacc: Fix debug printing of the lexed token's ID and name, and add whitespace in the 'stateX saw' message.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13352048
2013-09-13 13:18:02 +10:00
Russ Cox
913f1f1557 cmd/go: do not support code.google.com/r/zzz projects
This reverts CL 13261048. I have just learned that these are
no longer supported on code.google.com (that is, it is impossible
to create them), so there is little reason to add support in
Go 1.2.

Update #5408

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/13317046
2013-09-12 21:47:56 -04:00
Russ Cox
7276c02b41 runtime, cmd/gc, cmd/ld: ignore method wrappers in recover
Bug #1:

Issue 5406 identified an interesting case:
        defer iface.M()
may end up calling a wrapper that copies an indirect receiver
from the iface value and then calls the real M method. That's
two calls down, not just one, and so recover() == nil always
in the real M method, even during a panic.

[For the purposes of this entire discussion, a wrapper's
implementation is a function containing an ordinary call, not
the optimized tail call form that is somtimes possible. The
tail call does not create a second frame, so it is already
handled correctly.]

Fix this bug by introducing g->panicwrap, which counts the
number of bytes on current stack segment that are due to
wrapper calls that should not count against the recover
check. All wrapper functions must now adjust g->panicwrap up
on entry and back down on exit. This adds slightly to their
expense; on the x86 it is a single instruction at entry and
exit; on the ARM it is three. However, the alternative is to
make a call to recover depend on being able to walk the stack,
which I very much want to avoid. We have enough problems
walking the stack for garbage collection and profiling.
Also, if performance is critical in a specific case, it is already
faster to use a pointer receiver and avoid this kind of wrapper
entirely.

Bug #2:

The old code, which did not consider the possibility of two
calls, already contained a check to see if the call had split
its stack and so the panic-created segment was one behind the
current segment. In the wrapper case, both of the two calls
might split their stacks, so the panic-created segment can be
two behind the current segment.

Fix this by propagating the Stktop.panic flag forward during
stack splits instead of looking backward during recover.

Fixes #5406.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13367052
2013-09-12 14:00:16 -04:00
Dave Cheney
e38eddbfe4 cmd/8l: fix 386 builds
Remove set but unused variable.

R=rsc
CC=golang-dev
https://golang.org/cl/13490047
2013-09-12 11:18:34 +10:00
Russ Cox
1a6576db34 cmd/5l, cmd/6l, cmd/8l: refactor stack split code
Pull the stack split generation into its own function.
This will make an upcoming change to fix recover
easier to digest.

R=ken2
CC=golang-dev
https://golang.org/cl/13611044
2013-09-11 20:29:45 -04:00
Rémy Oudompheng
ff416a3f19 cmd/gc: inline copy in frontend to call memmove directly.
A new node type OSPTR is added to refer to the data pointer of
strings and slices in a simple way during walk(). It will be
useful for future work on simplification of slice arithmetic.

benchmark                  old ns/op    new ns/op    delta
BenchmarkCopy1Byte                 9            8  -13.98%
BenchmarkCopy2Byte                14            8  -40.49%
BenchmarkCopy4Byte                13            8  -35.04%
BenchmarkCopy8Byte                13            8  -37.10%
BenchmarkCopy12Byte               14           12  -15.38%
BenchmarkCopy16Byte               14           12  -17.24%
BenchmarkCopy32Byte               19           14  -27.32%
BenchmarkCopy128Byte              31           26  -15.29%
BenchmarkCopy1024Byte            100           92   -7.50%
BenchmarkCopy1String              10            7  -28.99%
BenchmarkCopy2String              10            7  -28.06%
BenchmarkCopy4String              10            8  -22.69%
BenchmarkCopy8String              10            8  -23.30%
BenchmarkCopy12String             11           11   -5.88%
BenchmarkCopy16String             11           11   -5.08%
BenchmarkCopy32String             15           14   -6.58%
BenchmarkCopy128String            28           25  -10.60%
BenchmarkCopy1024String           95           95   +0.53%

R=golang-dev, bradfitz, cshapiro, dave, daniel.morsing, rsc, khr, khr
CC=golang-dev
https://golang.org/cl/9101048
2013-09-12 00:15:28 +02:00
Russ Cox
6d47de2f40 cmd/5g, cmd/6g, cmd/8g: remove O(n) reset loop in copyprop
Simpler version of CL 13084043.

R=ken2
CC=golang-dev
https://golang.org/cl/13602045
2013-09-11 15:22:11 -04:00
Russ Cox
a0bc379d46 undo CL 13084043 / ef4ee02a5853
There is a cleaner, simpler way.

««« original CL description
cmd/5g, cmd/6g, cmd/8g: faster compilation
Replace linked list walk with memset.
This reduces CPU time taken by 'go install -a std' by ~10%.
Before:
real		user		sys
0m23.561s	0m16.625s	0m5.848s
0m23.766s	0m16.624s	0m5.846s
0m23.742s	0m16.621s	0m5.868s
after:
0m22.714s	0m14.858s	0m6.138s
0m22.644s	0m14.875s	0m6.120s
0m22.604s	0m14.854s	0m6.081s

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13084043
»»»

TBR=dvyukov
CC=golang-dev
https://golang.org/cl/13352049
2013-09-11 15:14:11 -04:00
Russ Cox
8cd6341cf8 cmd/gc: allow x[i:j:k] (and x[:j:k]) into the release
R=ken2
CC=golang-dev
https://golang.org/cl/13512053
2013-09-11 14:55:46 -04:00
Russ Cox
cdc5356c93 cmd/api: fix tool for recent go/build change
Asking about runtime/cgo when CgoEnabled=false now correctly
returns an error from build.Import (specifically, NoGoError), because
there are no buildable Go files in that directory.

The API tool was depending on it returning a package with no Go
files instead. Correct that assumption.

Fixes all.bash on local machines.
(Dashboard appears not to be running the api tool at all.)

Update #6124

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13385046
2013-09-11 14:42:34 -04:00
Russ Cox
6624b70866 undo CL 13632053 / dc7bfe0f022d
It was never going to last.

««« original CL description
cmd/api: break the builds

There is some question about whether the api tool is
running on Windows (see issue 6124), and now I'm
starting to question whether it runs on any of the builders,
since both darwin/amd64 and linux/amd64 are crashing for me
in the api tool due to a recent cgo-related change, and yet
the dashboard is happy.

If the dashboard is still happy after this CL, we have a problem.

Update #6124

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13632053
»»»

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13474045
2013-09-11 14:35:08 -04:00
Russ Cox
89a6a8fdb3 cmd/api: break the builds
There is some question about whether the api tool is
running on Windows (see issue 6124), and now I'm
starting to question whether it runs on any of the builders,
since both darwin/amd64 and linux/amd64 are crashing for me
in the api tool due to a recent cgo-related change, and yet
the dashboard is happy.

If the dashboard is still happy after this CL, we have a problem.

Update #6124

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13632053
2013-09-11 14:34:11 -04:00
Russ Cox
611b182190 go/build: reject directory with only cgo files if cgo not in use
The old test for "no Go files" was p.Name == "", meaning we never
saw a Go package statement. That test fails if there are cgo files
that we parsed (and recorded the package name) but then chose
not to use (because cgo is not available).

Test the actual file lists instead.

Fixes #6078.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13661043
2013-09-11 13:25:30 -04:00
Ian Lance Taylor
fdaf88ea5b cmd/yacc: replace units example with simpler expr example
The units example is nice but is covered by the Lucent
license, which may be a concern for some people making a
commercial source code distribution of Go.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13283045
2013-09-11 09:01:47 -07:00
Russ Cox
397ba2cb4a cmd/cgo: replace C.malloc with our own wrapper
This allows us to make two changes:

1. Force the argument type to be size_t, even on broken
   systems that declare malloc to take a ulong.

2. Call runtime.throw if malloc fails.
   (That is, the program crashes; it does not panic.)

Fixes #3403.
Fixes #5926.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13413047
2013-09-11 11:30:08 -04:00
Russ Cox
e6a49555a7 cmd/go: use pattern to prune file tree walk
For example, if the pattern is m... there is
no need to look in directories not beginning with m.

Fixes #5214.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13253049
2013-09-11 09:57:05 -04:00
Russ Cox
08b26e4104 cmd/cgo: don't say "gcc produced no output" if we ran clang
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13420048
2013-09-11 09:56:51 -04:00
Robert Daniel Kortschak
b34ec90e19 cmd/api: make api check directory per-user
Fixes #6353.

R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/13652043
2013-09-11 10:50:56 +10:00
Russ Cox
b99fdb2a11 cmd/go: report correct directory for 'no version control'
The scan starts at the directory we care about and works
backward to the GOPATH root. The error should say the
original directory name, not the name of the GOPATH root.

Fixes #6175.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13366050
2013-09-10 15:28:29 -04:00
Russ Cox
6034406eae build: more "undefined behavior" fixes
Fixes #5764.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13441051
2013-09-10 14:54:55 -04:00
Russ Cox
80a153dd51 cmd/6l, cmd/8l: fix MOVL MOVQ optab
The entry for LEAL/LEAQ in these optabs was listed as having
two data bytes in the y array. In fact they had and expect no data
bytes. However, the general loop expects to be able to look at at
least one data byte, to make sure it is not 0x0f. So give them each
a single data byte set to 0 (not 0x0f).

Since the MOV instructions have the largest optab cases, this
requires growing the size of the data array.

Clang found this bug because the general o->op[z] == 0x0f
test was using z == 22, which was out of bounds.

In practice the next byte in memory was probably not 0x0f
so it wasn't truly broken. But might as well be clean.

Update #5764

R=ken2
CC=golang-dev
https://golang.org/cl/13241050
2013-09-10 14:53:41 -04:00
Russ Cox
baed067d87 cmd/go: show FAIL for errors during test setup
For example, if an x_test.go file contains a syntax error,
b.test fails with an error message. But it wasn't printing
the same FAIL line that a build failure later would print.
This makes all the test failures that happen (once we
decide to start running tests) consistently say FAIL.

Fixes #4701.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13431044
2013-09-10 14:43:57 -04:00
Russ Cox
627d17cf29 cmd/go: fix go test using package main_test
A package main binary (that is, a command) being installed
does not mean we can skip the build of the package archive
during a test.

Fixes #3417.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13462046
2013-09-10 14:43:35 -04:00
Russ Cox
90f9192886 cmd/go: run benchmarks in sequence
Fixes #5662.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13650043
2013-09-10 14:43:21 -04:00
Russ Cox
159c2b7e46 cmd/go: fix error for 'go install x.go' when GOBIN is not set
Fixes #6191.
Fixes #5426.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13234052
2013-09-10 14:41:07 -04:00
Ian Lance Taylor
a547ad6ac0 cmd/go: report real package in errors for go get with wildcard
Fixes #5054.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13609043
2013-09-10 11:27:29 -07:00
Ian Lance Taylor
7f062fa2de cmd/go: build SWIG shared libraries in work directory
Remove test of whether SWIG shared library is older than
sources--should be covered by test of package file anyhow.

Fixes #5739.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13352046
2013-09-10 11:00:26 -07:00
Russ Cox
d5fbad0de8 cmd/go: better error for shadowed directories in GOPATH
Fixes #5774.

R=golang-dev, adg, r, bradfitz
CC=golang-dev
https://golang.org/cl/9164043
2013-09-10 13:17:21 -04:00
Russ Cox
7d249ef28f cmd/go: fix build -n output when using swig
$INTBITS will not be defined, of course, but that's the best we can do.

Fixes #5978.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13253048
2013-09-10 12:55:07 -04:00
Russ Cox
7c6db642b0 cmd/go: implement -x correctly for 'go vet', 'go fmt', and so on
Fixes #5676.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13250047
2013-09-10 12:47:52 -04:00
Russ Cox
c971f95c10 go/build: allow $ in cgo LDFLAGS
Fixes #6038.

R=iant
CC=golang-dev
https://golang.org/cl/13649043
2013-09-10 12:47:43 -04:00
Ian Lance Taylor
f0ff63ea64 cmd/go: if there are C++ sources, use g++ as default external linker
This will bring in the C++ standard library without requiring
any special #cgo LDFLAGS options.

When using gccgo, just add -lstdc++ to link line; this should
do no harm if it is not needed.

No tests, since we don't want to assume a C++ compiler.

Update #5629

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/13394045
2013-09-09 12:50:49 -07:00
Russ Cox
7d734d9252 build: remove various uses of C undefined behavior
If you thought gcc -ansi -pedantic was pedantic, just wait
until you meet clang -fsanitize=undefined.

I think this addresses all the reported "errors", but we'll
need another run to be sure.

all.bash still passes.

Update #5764

Dave, can you please try again?

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13334049
2013-09-09 15:07:23 -04:00
Rémy Oudompheng
9c21ce54dd cmd/6g: handle very wide offsets.
Fixes #6036.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12992043
2013-09-09 20:36:19 +02:00
Russ Cox
0218dfe7eb cmd/gc: allow inlined struct == to mention unsafe.Pointer even in safe mode
Fixes #5578.

R=ken2
CC=golang-dev
https://golang.org/cl/13417044
2013-09-09 13:11:41 -04:00
Russ Cox
5b04d67091 cmd/cgo: record full source path to input .go files
Fixes #5122.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13395046
2013-09-09 13:04:14 -04:00
Russ Cox
933d7129c0 cmd/gc: squelch spurious "invalid recursive type" error
R=ken2
CC=golang-dev
https://golang.org/cl/13512047
2013-09-09 13:03:59 -04:00
Russ Cox
903c2fda18 cmd/gc: diagnose '_ = nil' better
Fixes #6004.

R=ken2
CC=golang-dev
https://golang.org/cl/13616044
2013-09-09 12:49:39 -04:00
Russ Cox
85195e2ccf cmd/gc: more detail in import conflict error message
Cannot happen when using the go command, but help
people running commands by hand or with other tools.

Fixes #5888.

R=ken2
CC=golang-dev
https://golang.org/cl/13324048
2013-09-09 12:30:53 -04:00
Russ Cox
8d530f2472 cmd/gc: show package name in 'imported and not used' error
Fixes #5957.

R=ken2
CC=golang-dev
https://golang.org/cl/13250046
2013-09-09 12:21:09 -04:00
Russ Cox
a7d8b35aac cmd/gc: fix 'internal error: typename ideal bool'
Fixes #6298.

R=ken2
CC=golang-dev
https://golang.org/cl/13624043
2013-09-09 12:00:16 -04:00
Alex Brainman
52f15df9e2 cmd/go: rename go.exe if cannot delete it during clean
Fixes #6179

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12916047
2013-09-06 16:55:35 -04:00
Rémy Oudompheng
c929ac5f7e cmd/gc: add missing typecheck for walk-generated constants.
Fixes #6131.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/12800045
2013-09-06 16:55:30 -04:00
Russ Cox
af2a3193af cmd/5g, cmd/6g, cmd/8g: simplify for loop in bitmap generation
Lucio De Re reports that the more complex
loop miscompiles on Plan 9.

R=ken2
CC=golang-dev
https://golang.org/cl/13602043
2013-09-06 16:49:11 -04:00
Josh Bleecher Snyder
08925ce6ee cmd/gofmt: sort more, remove some duplicate imports
* Sort imports by import path, then import name, then comment. Currently, gofmt sorts only by import path.
* If two imports have the same import path and import name, and one of them has no comment, remove the import with no comment. (See the discussion at issue 4414.)

Based on @rsc's https://golang.org/cl/7231070/

Fixes #4414.

R=gri, rsc
CC=golang-dev
https://golang.org/cl/12837044
2013-09-06 16:25:15 -04:00
Russ Cox
e1ac15743b cmd/gc: remove "send used as value" hint
This message was helpful for pre-Go 1 users updating to Go 1.
That time is past. Now the message is confusing because it
depends on knowing what pre-Go 1 looked like.

Update #4697.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13335051
2013-09-06 15:47:52 -04:00
Brad Fitzpatrick
8a70b50b1f cmd/api: include constant values
Update #5935

R=golang-dev, rsc, iant, dave
CC=golang-dev
https://golang.org/cl/13261050
2013-09-06 12:01:01 -07:00
Lucio De Re
fd7ddad160 cmd/dist: Plan 9 build needs an additional include path
cmd/cc: bv.c imports libc.h twice

When using the Plan 9 compiler, the invocation

        #include <../ld/textflag.h>

works for the toolchain, but not for the MACH library.

Module cmd/cc/bv.c includes libc.h and "cc.h", which in
turn also includes libc.h.  In the Plan 9 context, this
causes a number of duplicate definitions.

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/13303047
2013-09-06 16:15:44 +10:00
Rob Pike
6833d1b436 cmd/go: don't leave test binary around for coverage
It's not needed to analyze coverage data.
Fixes #6120

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13343050
2013-09-06 15:54:26 +10:00
Ian Lance Taylor
28bbc6c27a cmd/ld: emit relocations for .debug_frame in external link mode
This should have been part of revision 16731:cdedb129e020, but
I missed it.  This fixes printing local variables when doing
an external link.

No test because we aren't doing any debug info testing yet.

Fixes #5719.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13464046
2013-09-05 12:55:21 -07:00
Ian Lance Taylor
f2380a81d7 cmd/dist: don't print misleading warning when using GOROOT_FINAL
Fixes #5240.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13546044
2013-09-04 17:02:08 -07:00
Aulus Egnatius Varialus
2b44b36487 cgo: enable cgo on dragonfly
Enable cgo for dragonfly/386 and dragonfly/amd64.

R=golang-dev, jsing, iant, bradfitz
CC=golang-dev
https://golang.org/cl/13247046
2013-09-04 15:19:21 -07:00
Ian Lance Taylor
d011f0aa89 cmd/ld: don't allocate unused garbage space in pclntab file table
Fixes #6319.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13539043
2013-09-04 13:26:49 -07:00
Ian Lance Taylor
97d6a1e130 cmd/cgo: document command line options
Also remove incorrect statement that cgo does not support
gccgo.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13511043
2013-09-03 21:23:52 -07:00
Ian Lance Taylor
f68c23e2bb cmd/cgo: don't let #cgo directives mess up line numbering
Fixes #5272.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13498046
2013-09-03 21:15:15 -07:00
Joel Sing
fd0af9b56c cmd/8l: add support for dragonfly/386
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13328045
2013-08-31 09:33:38 -07:00
Keith Randall
fb376021be runtime: record type information for hashtable internal structures.
Remove all hashtable-specific GC code.

Fixes bug 6119.

R=cshapiro, dvyukov, khr
CC=golang-dev
https://golang.org/cl/13078044
2013-08-31 09:09:50 -07:00
Joel Sing
d0206101c8 cmd/5l,cmd/6l,cmd/8l: fix dragonflydynld path
R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/13225043
2013-08-31 22:02:21 +10:00
Dmitriy Vyukov
79dca0327e libbio, all cmd: consistently use BGETC/BPUTC instead of Bgetc/Bputc
Also introduce BGET2/4, BPUT2/4 as they are widely used.
Slightly improve BGETC/BPUTC implementation.
This gives ~5% CPU time improvement on go install -a -p1 std.
Before:
real		user		sys
0m23.561s	0m16.625s	0m5.848s
0m23.766s	0m16.624s	0m5.846s
0m23.742s	0m16.621s	0m5.868s
after:
0m22.999s	0m15.841s	0m5.889s
0m22.845s	0m15.808s	0m5.850s
0m22.889s	0m15.832s	0m5.848s

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12745047
2013-08-30 15:46:12 +04:00
Keith Randall
ed467db6d8 cmd/cc,runtime: change preprocessor to expand macros inside of
#pragma textflag and #pragma dataflag directives.
Update dataflag directives to use symbols instead of integer constants.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13310043
2013-08-29 12:36:59 -07:00
Daniel Morsing
280c8b90e2 cmd/gc: make method names for function scoped types unique
Types in function scope can have methods on them if they embed another type, but we didn't make the name unique, meaning that 2 identically named types in different functions would conflict with eachother.

Fixes #6269.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13326045
2013-08-29 16:48:44 +02:00
Lucio De Re
bf58d20999 cmd/8g: add descriptions for some missing instructions.
These instructions are emitted when GO386=387 or the target
i386 CPU does not have SSE2 capabilities.

Fixes #6215.

R=golang-dev, remyoudompheng
CC=golang-dev
https://golang.org/cl/12812045
2013-08-29 14:41:01 +02:00
Rémy Oudompheng
66c8935f73 cmd/gc: fix detection of initialization loop.
The compiler computes initialization order by finding
a spanning tree between a package's global variables.
But it does so by walking both variables and functions
and stops detecting cycles between variables when they
mix with a cycle of mutually recursive functions.

Fixes #4847.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/9663047
2013-08-29 10:16:09 +02:00
Rémy Oudompheng
a9e119ac70 cmd/gc: fix method values whose receiver is an unnamed interface.
Fixes #6140.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13083043
2013-08-29 10:00:58 +02:00
Rob Pike
65f21ca2c6 cmd/go: make it work for code.google.com cloned repositories
Thanks to beatgammit for the fix.

Fixes #5408.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13261048
2013-08-29 17:15:35 +10:00
Rob Pike
d595b67a12 cmd/go: add -race flag to 'go list'
Causes the package dependencies to include those for race detection.
Fixes #5653.

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/13236045
2013-08-29 11:16:53 +10:00
Rémy Oudompheng
a85cfbd433 cmd/gc: tag builtin error, byte, rune to avoid exporting them.
Fixes #5910.
Fixes #6260.

R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/13257044
2013-08-27 21:18:32 +02:00
Rémy Oudompheng
4fc7ff497d cmd/5g: avoid clash between R13 and F3 registers.
Fixes #6247.

R=golang-dev, lucio.dere, bradfitz
CC=golang-dev
https://golang.org/cl/13216043
2013-08-27 21:09:16 +02:00
Volker Dobler
7c8be15b8a cmd/gc: mark panicslice as unlikely
No measurable impact on performance on amd64

R=golang-dev, khr, bradfitz
CC=golang-dev
https://golang.org/cl/13096045
2013-08-27 06:38:11 -07:00
Brad Fitzpatrick
e7b125fc65 cmd/api: be more robust against OS deleting temp files
OS X in particular deletes tmp files (but not directories)
pretty reliably.

Ask hg whether the go.tools directory in tmp is good before
using it.

Fixes issue Rob and others were reporting, which I just hit
myself now.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13084049
2013-08-24 16:54:56 -05:00
Brad Fitzpatrick
cb79c57dfa cmd/api: ignore GOARCH when building cmd/api.
This was breaking people setting GOARCH=386 before running
all.bash on amd64 machines.

cmd/go puts different architecture binaries where "go tool"
can't find them.

R=golang-dev, r, khr
CC=golang-dev
https://golang.org/cl/13139044
2013-08-24 09:51:42 -05:00
Keith Randall
b15a64e35d cmd/gc: Reset haspointers computation. When converting from a
slice type to an array type, the haspointer-ness may change.
Before this change, we'd sometimes get types like [1]int marked
as having pointers.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13189044
2013-08-23 17:28:15 -07:00
Joel Sing
e18ed3c111 cmd/5l,cmd/8l: unbreak arm and 386 linkers
Add dragonflydynld to 5l and 8l so that they compile again.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12739048
2013-08-24 01:32:01 +10:00
Joel Sing
71dc91db0f all: compiler/bootstrap for dragonfly/amd64
Add dragonfly/amd64 support to the Go compiler, bootstrap and GOOS list.

R=devon.odell, bradfitz
CC=golang-dev
https://golang.org/cl/12796050
2013-08-24 01:18:04 +10:00
Carl Shapiro
87fdb8fb9a undo CL 13010045 / 04f8101b46dd
Update the original change but do not read interface types in
the arguments area.  Once the arguments area is zeroed as the
locals area is we can safely read interface type values there
too.

««« original CL description
undo CL 12785045 / 71ce80dc4195

This has broken the 32-bit builds.

««« original CL description
cmd/gc, runtime: use type information to scan interface values

R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/12785045
»»»

R=khr, golang-dev, khr
CC=golang-dev
https://golang.org/cl/13010045
»»»

R=khr, khr
CC=golang-dev
https://golang.org/cl/13073045
2013-08-21 13:51:00 -07:00
Dmitriy Vyukov
06e686def6 cmd/5g, cmd/6g, cmd/8g: faster compilation
Replace linked list walk with memset.
This reduces CPU time taken by 'go install -a std' by ~10%.
Before:
real		user		sys
0m23.561s	0m16.625s	0m5.848s
0m23.766s	0m16.624s	0m5.846s
0m23.742s	0m16.621s	0m5.868s
after:
0m22.714s	0m14.858s	0m6.138s
0m22.644s	0m14.875s	0m6.120s
0m22.604s	0m14.854s	0m6.081s

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13084043
2013-08-21 14:20:28 +04:00
Carl Shapiro
ca2d32b46d undo CL 12785045 / 71ce80dc4195
This has broken the 32-bit builds.

««« original CL description
cmd/gc, runtime: use type information to scan interface values

R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/12785045
»»»

R=khr, golang-dev, khr
CC=golang-dev
https://golang.org/cl/13010045
2013-08-19 14:16:55 -07:00
Carl Shapiro
21ea5103a4 cmd/gc, runtime: use type information to scan interface values
R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/12785045
2013-08-19 10:19:59 -07:00
Andrew Gerrand
2f6e9a1e24 cmd/go: only try to clean executables for package main
Fixes #5665.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12807044
2013-08-19 16:22:33 +10:00
Rob Pike
c974b8b6ac cmd/go: diagnose import cycles better
Before this CL, the import stack was a) not printed and b) overwritten later
in the build, destroying the information about the cycle. This CL fixes both.

I made time depend on os (os already depends on time) and with this CL the error is:

/Users/r/go/src/pkg/fmt/print.go:10:2: import cycle not allowed
package code.google.com/p/XXX/YYY:
        imports fmt
        imports os
        imports time
        imports os

Doesn't give line numbers for the actual imports, as requested in the bug, but
I don't believe that's important.

Fixes #4292.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13100043
2013-08-19 15:50:57 +10:00
David Symonds
a790388afb cmd/gc: regenerate y.tab.{c,h} with Bison 2.5.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12744048
2013-08-19 13:47:43 +10:00
Anthony Martin
f316a7ea87 cmd/gc: don't attempt to generate wrappers for blank interface methods
Fixes #5691.

R=golang-dev, bradfitz, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/10255047
2013-08-19 11:53:34 +10:00
Rob Pike
d00bd1d1f4 cmd/gc: better error messages for C-style if statements.
Given
        if (i == 0)
                x++
The old message was
        x.go:6: syntax error: unexpected semicolon or newline before {
Now we see
        x.go:6: syntax error: missing { after if clause

Fixes #5687

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12822045
2013-08-19 11:49:59 +10:00
David Symonds
24f302a69d cmd/dist: join with TMPDIR more carefully to avoid // in path.
This might fix the mkdtemp problem on the darwin builders if they
have TMPDIR set to a path ending in a slash; at worse this will
result in cleaner path names.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13097043
2013-08-19 11:11:27 +10:00
Rob Pike
7fb121aa47 cmd/dist: more informative error for mkdtemp failing
The Darwin builders are all failing here but strerror doesn't provide context.

R=golang-dev, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13095043
2013-08-19 08:29:43 +10:00
Russ Cox
3b4d792606 cmd/gc: separate "has pointers" from "needs zeroing" in stack frame
When the new call site-specific frame bitmaps are available,
we can cut the zeroing to just those values that need it due
to scope escaping.

R=cshapiro, cshapiro
CC=golang-dev
https://golang.org/cl/13045043
2013-08-16 21:45:59 -04:00
Carl Shapiro
d3b04f46b5 cmd/5g, cmd/6g, cmd/8g: update frame zeroing for new bitmap format
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12740046
2013-08-16 01:15:04 -04:00
Rob Pike
f0fef32383 cmd/go: fix at least some instances of double compilation
When the packages the tested package depends on don't build,
we weren't getting out early. Added a simple check for a successful
build to an existing early out.

There may be other ways that double compilation arises, but
this fixes the one listed in the issue.
Fixes #5679

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13036043
2013-08-16 12:49:51 +10:00
Rob Pike
703b897f78 cmd/gc: remove mentions of "ideal" from error messages.
_ = complex("foo", 0)
        _ = complex(true, 0)
now trigger:
        x.go:4: invalid operation: complex("foo", 0) (mismatched types untyped string and untyped number)
        x.go:5: invalid operation: complex(true, 0) (mismatched types untyped bool and untyped number)

Fixes #4521

R=golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/12973043
2013-08-16 12:40:02 +10:00
Russ Cox
b75a08d03c cmd/gc: ensure addable in checknil (fix race build)
TBR=dvyukov
CC=golang-dev
https://golang.org/cl/12791044
2013-08-15 21:05:05 -04:00
Rob Pike
71eae5a46a cmd/go: delete 'go doc'
It's next to useless and confusing as well. Let's make godoc better instead.

Fixes #4849.

R=golang-dev, dsymonds, adg, rogpeppe, rsc
CC=golang-dev
https://golang.org/cl/12974043
2013-08-16 10:30:05 +10:00
Russ Cox
999a36f9af cmd/gc: &x panics if x does
See golang.org/s/go12nil.

This CL is about getting all the right checks inserted.
A followup CL will add an optimization pass to
remove redundant checks.

R=ken2
CC=golang-dev
https://golang.org/cl/12970043
2013-08-15 14:38:32 -04:00
Rob Pike
f718036217 cmd/go: fix bad error message in coverage for package without non-test files
Was checking for nil map; must check for empty map instead.

Fixes #6065

Before:

go test -cover
# testmain
/var/folders/00/013l0000h01000cxqpysvccm0004fc/T/go-build233480051/_/Users/r/issue/_test/_testmain.go:11: imported and not used: "_/Users/r/issue"
FAIL	_/Users/r/issue [build failed]

Now:

go test -cover
testing: warning: no tests to run
PASS
coverage: 0.0% of statements
ok  	_/Users/r/issue	0.021s

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12916043
2013-08-15 10:36:46 +10:00
David Symonds
80ca8c5d04 cmd/go: fix detached heads that are remnants of bad git clones.
Fixes #6042.

R=adg
CC=golang-dev
https://golang.org/cl/12923043
2013-08-15 09:44:23 +10:00
Carl Shapiro
3ec0427a07 cmd/go, runtime/cgo: explicitly target ARMv5T
The baseline architecture had been left to the GCC configured
default which can be more accomodating than the rest of the Go
toolchain.  This prevented instructions used by the 5g compiler,
like BLX, from being used in GCC compiled assembler code.

R=golang-dev, dave, rsc, elias.naur, cshapiro
CC=golang-dev
https://golang.org/cl/12954043
2013-08-14 15:21:53 -07:00
Elias Naur
3b4da67ee3 cmd/ld: Remove superfluous redundant iself check
CL 12741044 added an extra iself condition to an if statement that already contained it. Remove it.

R=rsc
CC=golang-dev
https://golang.org/cl/12949043
2013-08-14 16:28:40 -04:00
Rémy Oudompheng
0d9db86f74 cmd/5g, cmd/6g, cmd/8g: restore occurrences of R replaced by nil in comments.
R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12842043
2013-08-14 21:24:48 +02:00
Russ Cox
308a3e6c52 cmd/dist: fix darwin build
The TLS block on Darwin is not the same as on ELF.

TBR=elias.naur
CC=golang-dev
https://golang.org/cl/12741044
2013-08-14 12:57:05 -04:00
Elias Naur
a5f257a042 cmd/cgo: fix windows build
The shared library changes broke the windows build because __attribute__ ((visibility ("hidden"))) is not supported in windows gcc. This change removes the attribute, as it is only needed when building shared libraries.

R=rsc
CC=golang-dev
https://golang.org/cl/12829044
2013-08-14 12:47:06 -04:00
Elias Naur
45233734e2 runtime.cmd/ld: Add ARM external linking and implement -shared in terms of external linking
This CL is an aggregate of 10271047, 10499043, 9733044. Descriptions of each follow:

10499043
runtime,cmd/ld: Merge TLS symbols and teach 5l about ARM TLS

This CL prepares for external linking support to ARM.

The pseudo-symbols runtime.g and runtime.m are merged into a single
runtime.tlsgm symbol. When external linking, the offset of a thread local
variable is stored at a memory location instead of being embedded into a offset
of a ldr instruction. With a single runtime.tlsgm symbol for both g and m, only
one such offset is needed.

The larger part of this CL moves TLS code from gcc compiled to internally
compiled. The TLS code now uses the modern MRC instruction, and 5l is taught
about TLS fallbacks in case the instruction is not available or appropriate.

10271047
This CL adds support for -linkmode external to 5l.

For 5l itself, use addrel to allow for D_CALL relocations to be handled by the
host linker. Of the cases listed in rsc's comment in issue 4069, only case 5 and
63 needed an update. One of the TODO: addrel cases was since replaced, and the
rest of the cases are either covered by indirection through addpool (cases with
LTO or LFROM flags) or stubs (case 74). The addpool cases are covered because
addpool emits AWORD instructions, which in turn are handled by case 11.

In the runtime, change the argv argument in the rt0* functions slightly to be a
pointer to the argv list, instead of relying on a particular location of argv.

9733044
The -shared flag to 6l outputs a shared library, implemented in Go
and callable from non-Go programs such as C.

The main part of this CL change the thread local storage model.
Go uses the fastest and least general mode, local exec. TLS data in shared
libraries normally requires at least the local dynamic mode, however, this CL
instead opts for using the initial exec mode. Initial exec mode is faster than
local dynamic mode and can be used in linux since the linker has reserved a
limited amount of TLS space for performance sensitive TLS code.

Initial exec mode requires an extra load from the GOT table to determine the
TLS offset. This penalty will not be paid if ld is not in -shared mode, since
TLS accesses will be reduced to local exec.

The elf sections .init_array and .rela.init_array are added to register the Go
runtime entry with cgo at library load time.

The "hidden" attribute is added to Cgo functions called from Go, since Go
does not generate call through the GOT table, and adding non-GOT relocations for
a global function is not supported by gcc. Cgo symbols don't need to be global
and avoiding the GOT table is also faster.

The changes to 8l are only removes code relevant to the old -shared mode where
internal linking was used.

This CL only address the low level linker work. It can be submitted by itself,
but to be useful, the runtime changes in CL 9738047 is also needed.

Design discussion at
https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q

Fixes #5590.

R=rsc
CC=golang-dev
https://golang.org/cl/12871044
2013-08-14 15:38:54 +00:00
Russ Cox
72636eb506 cmd/5g: fix temp-merging on ARM
mkvar was taking care of the "LeftAddr" case,
effectively hiding it from the temp-merging optimization.

Move it into prog.c.

R=ken2
CC=golang-dev
https://golang.org/cl/12884045
2013-08-14 00:34:18 -04:00
Russ Cox
48b90bbc55 encoding: new package
See golang.org/s/go12encoding for design.

R=r
CC=golang-dev
https://golang.org/cl/12541051
2013-08-14 00:18:20 -04:00
Andrew Gerrand
5dde7ccecf cmd/go: add -t flag to 'go get' to download test dependencies
Fixes #5126.

R=golang-dev, dsymonds, bradfitz, r, rsc, rogpeppe
CC=golang-dev
https://golang.org/cl/12566046
2013-08-14 11:01:17 +10:00
Rob Pike
c32a8830bd cmd/go: nicer error diagnosis in go test
Before,
        go test -bench .
would just dump the long generic "go help" message. Confusing and
unhelpful. Now the message is short and on point and also reminds the
user about the oft-forgotten "go help testflag".

        % go test -bench
        go test: missing argument for flag bench
        run "go help test" or "go help testflag" for more information
        %

R=rsc
CC=golang-dev
https://golang.org/cl/12662046
2013-08-14 07:03:18 +10:00
Alberto García Hierro
c18dc11ef2 cmd/cgo: Add support for C function pointers
* Add a new kind of Name, "fpvar" which stands for function pointer variable
* When walking the AST, find functions used as expressions and create a new Name object for them
* Track functions which are only used in expr contexts, and avoid generating bridge code for them

R=golang-dev, minux.ma, fullung, rsc, iant
CC=golang-dev
https://golang.org/cl/9835047
2013-08-13 12:42:21 -04:00
Russ Cox
fa72679f07 cmd/gc: add temporary-merging optimization pass
The compilers assume they can generate temporary variables
as needed to preserve the right semantics or simplify code
generation and the back end will still generate good code.
This turns out not to be true. The back ends will only
track the first 128 variables per function and give up
on the remainder. That needs to be fixed too, in a later CL.

This CL merges temporary variables with equal types and
non-overlapping lifetimes using the greedy algorithm in
Poletto and Sarkar, "Linear Scan Register Allocation",
ACM TOPLAS 1999.

The result can be striking in the right functions.

Top 20 frame size changes in a 6g godoc binary by bytes saved:

5464 1984 (-3480, -63.7%) go/build.(*Context).Import
4456 1824 (-2632, -59.1%) go/printer.(*printer).expr1
2560   80 (-2480, -96.9%) time.nextStdChunk
3496 1608 (-1888, -54.0%) go/printer.(*printer).stmt
1896  272 (-1624, -85.7%) net/http.init
2688 1400 (-1288, -47.9%) fmt.(*pp).printReflectValue
2800 1512 (-1288, -46.0%) main.main
3296 2016 (-1280, -38.8%) crypto/tls.(*Conn).clientHandshake
1664  488 (-1176, -70.7%) time.loadZoneZip
1760  608 (-1152, -65.5%) time.parse
4104 3072 (-1032, -25.1%) runtime/pprof.writeHeap
1680  712 ( -968, -57.6%) go/ast.Walk
2488 1560 ( -928, -37.3%) crypto/x509.parseCertificate
1128  392 ( -736, -65.2%) math/big.nat.divLarge
1528  864 ( -664, -43.5%) go/printer.(*printer).fieldList
1360  712 ( -648, -47.6%) regexp/syntax.(*parser).factor
2104 1528 ( -576, -27.4%) encoding/asn1.parseField
1064  504 ( -560, -52.6%) encoding/xml.(*Decoder).text
 584   48 ( -536, -91.8%) html.init
1400  864 ( -536, -38.3%) go/doc.playExample

In the same godoc build, cuts the number of functions with
too many vars from 83 to 32.

R=ken2
CC=golang-dev
https://golang.org/cl/12829043
2013-08-13 00:09:31 -04:00
Brad Fitzpatrick
4d2494330e cmd/api: don't fail API check if there's no network
If the hg checkout of go.tools fails, check for Internet
connectivity before failing.

R=golang-dev, shivakumar.gn
CC=golang-dev
https://golang.org/cl/12814043
2013-08-12 19:18:47 -07:00
Russ Cox
4984e6e9fd cmd/6l: fix printing of frame size in TEXT instruction
R=ken2
CC=golang-dev
https://golang.org/cl/12827043
2013-08-12 22:04:24 -04:00
Russ Cox
dbf96addfb cmd/gc: move flow graph into portable opt
Now there's only one copy of the flow graph construction
and dominator computation, and different optimizations
can attach different annotations to the instructions.

R=ken2
CC=golang-dev
https://golang.org/cl/12797045
2013-08-12 22:02:10 -04:00
Russ Cox
9a0a59f171 cmd/6g, cmd/8g: proginfo carry fixes
Bugs pointed out by cshapiro in CL 12637051.

R=cshapiro
CC=golang-dev
https://golang.org/cl/12815043
2013-08-12 21:02:55 -04:00
Russ Cox
b3b87143f2 cmd/gc: support for "portable" optimization logic
Code in gc/popt.c is compiled as part of 5g, 6g, and 8g,
meaning it can use arch-specific headers but there's
just one copy of the code.

This is the same arrangement we use for the portable
code generation logic in gc/pgen.c.

Move fixjmp and noreturn there to get the ball rolling.

R=ken2
CC=golang-dev
https://golang.org/cl/12789043
2013-08-12 19:14:02 -04:00
Russ Cox
a07218385c cmd/5g: factor out prog information
Like CL 12637051, but for 5g instead of 6g.

R=ken2
CC=golang-dev
https://golang.org/cl/12779043
2013-08-12 13:42:23 -04:00
Russ Cox
5636b60b70 cmd/5l: fix encoding of new MOVB, MOVH instructions
They are just like MOVW and should be setting only
two register fields, not three.

R=ken2
CC=golang-dev, remyoudompheng
https://golang.org/cl/12781043
2013-08-12 13:42:04 -04:00
Russ Cox
ac0df6ce89 cmd/8g: factor out prog information
Like CL 12637051, but for 8g instead of 6g.
Fix a few minor 6g errors too.

R=ken2
CC=golang-dev
https://golang.org/cl/12778043
2013-08-12 13:05:40 -04:00
Russ Cox
24c8035fbe cmd/6g: move opt instruction decode into common function
Add new proginfo function that returns information about a
Prog*. The information includes various instruction
description bits as well as a list of required registers set
and used and indexing registers used.

Convert the large instruction switches to use proginfo.

This information was formerly duplicated in multiple
optimization passes, inconsistently. For example, the
information about which registers an instruction requires
appeared three times for most instructions.

Most of the switches were incomplete or incorrect in some way.
For example, the switch in copyu did not list cases for INCB,
JPS, MOVAPD, MOVBWSX, MOVBWZX, PCDATA, POPQ, PUSHQ, STD,
TESTB, TESTQ, and XCHGL. Those were all falling into the
"unknown instruction" default case and stopping the rewrite,
perhaps unnecessarily. Similarly, the switch in needc only
listed a handful of the instructions that use or set the carry bit.

We still need to decide whether to use proginfo to generalize
a few of the remaining smaller switches in peep.c.

If this goes well, we'll make similar changes in 8g and 5g.

R=ken2
CC=golang-dev
https://golang.org/cl/12637051
2013-08-11 21:46:38 -04:00
Russ Cox
7910cd68b5 cmd/gc: zero pointers on entry to function
On entry to a function, zero the results and zero the pointer
section of the local variables.

This is an intermediate step on the way to precise collection
of Go frames.

This can incur a significant (up to 30%) slowdown, but it also ensures
that the garbage collector never looks at a word in a Go frame
and sees a stale pointer value that could cause a space leak.
(C frames and assembly frames are still possibly problematic.)

This CL is required to start making collection of interface values
as precise as collection of pointer values are today.
Since we have to dereference the interface type to understand
whether the value is a pointer, it is critical that the type field be
initialized.

A future CL by Carl will make the garbage collection pointer
bitmaps context-sensitive. At that point it will be possible to
remove most of the zeroing. The only values that will still need
zeroing are values whose addresses escape the block scoping
of the function but do not escape to the heap.

benchmark                         old ns/op    new ns/op    delta
BenchmarkBinaryTree17            4420289180   4331060459   -2.02%
BenchmarkFannkuch11              3442469663   3277706251   -4.79%
BenchmarkFmtFprintfEmpty                100          142  +42.00%
BenchmarkFmtFprintfString               262          310  +18.32%
BenchmarkFmtFprintfInt                  213          281  +31.92%
BenchmarkFmtFprintfIntInt               355          431  +21.41%
BenchmarkFmtFprintfPrefixedInt          321          383  +19.31%
BenchmarkFmtFprintfFloat                444          533  +20.05%
BenchmarkFmtManyArgs                   1380         1559  +12.97%
BenchmarkGobDecode                 10240054     11794915  +15.18%
BenchmarkGobEncode                 17350274     19970478  +15.10%
BenchmarkGzip                     455179460    460699139   +1.21%
BenchmarkGunzip                   114271814    119291574   +4.39%
BenchmarkHTTPClientServer             89051        89894   +0.95%
BenchmarkJSONEncode                40486799     52691558  +30.15%
BenchmarkJSONDecode                94193361    112428781  +19.36%
BenchmarkMandelbrot200              4747060      4748043   +0.02%
BenchmarkGoParse                    6363798      6675098   +4.89%
BenchmarkRegexpMatchEasy0_32            129          171  +32.56%
BenchmarkRegexpMatchEasy0_1K            365          395   +8.22%
BenchmarkRegexpMatchEasy1_32            106          152  +43.40%
BenchmarkRegexpMatchEasy1_1K            952         1245  +30.78%
BenchmarkRegexpMatchMedium_32           198          283  +42.93%
BenchmarkRegexpMatchMedium_1K         79006       101097  +27.96%
BenchmarkRegexpMatchHard_32            3478         5115  +47.07%
BenchmarkRegexpMatchHard_1K          110245       163582  +48.38%
BenchmarkRevcomp                  777384355    793270857   +2.04%
BenchmarkTemplate                 136713089    157093609  +14.91%
BenchmarkTimeParse                     1511         1761  +16.55%
BenchmarkTimeFormat                     535          850  +58.88%

benchmark                          old MB/s     new MB/s  speedup
BenchmarkGobDecode                    74.95        65.07    0.87x
BenchmarkGobEncode                    44.24        38.43    0.87x
BenchmarkGzip                         42.63        42.12    0.99x
BenchmarkGunzip                      169.81       162.67    0.96x
BenchmarkJSONEncode                   47.93        36.83    0.77x
BenchmarkJSONDecode                   20.60        17.26    0.84x
BenchmarkGoParse                       9.10         8.68    0.95x
BenchmarkRegexpMatchEasy0_32         247.24       186.31    0.75x
BenchmarkRegexpMatchEasy0_1K        2799.20      2591.93    0.93x
BenchmarkRegexpMatchEasy1_32         299.31       210.44    0.70x
BenchmarkRegexpMatchEasy1_1K        1074.71       822.45    0.77x
BenchmarkRegexpMatchMedium_32          5.04         3.53    0.70x
BenchmarkRegexpMatchMedium_1K         12.96        10.13    0.78x
BenchmarkRegexpMatchHard_32            9.20         6.26    0.68x
BenchmarkRegexpMatchHard_1K            9.29         6.26    0.67x
BenchmarkRevcomp                     326.95       320.40    0.98x
BenchmarkTemplate                     14.19        12.35    0.87x

R=cshapiro
CC=golang-dev
https://golang.org/cl/12616045
2013-08-09 23:10:58 -04:00
Carl Shapiro
abc516e420 cmd/cc, cmd/gc, runtime: Uniquely encode iface and eface pointers in the pointer map.
Prior to this change, pointer maps encoded the disposition of
a word using a single bit.  A zero signaled a non-pointer
value and a one signaled a pointer value.  Interface values,
which are a effectively a union type, were conservatively
labeled as a pointer.

This change widens the logical element size of the pointer map
to two bits per word.  As before, zero signals a non-pointer
value and one signals a pointer value.  Additionally, a two
signals an iface pointer and a three signals an eface pointer.

Following other changes to the runtime, values two and three
will allow a type information to drive interpretation of the
subsequent word so only those interface values containing a
pointer value will be scanned.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12689046
2013-08-09 16:48:12 -07:00
Russ Cox
b78410bda1 cmd/api: eliminate duplicate package import work
On my Mac, cuts the API checks from 15 seconds to 6 seconds.
Also clean up some tag confusion: go run list-of-files ignores tags.

R=bradfitz, gri
CC=golang-dev
https://golang.org/cl/12699048
2013-08-09 18:44:00 -04:00
Carl Shapiro
2db5e4bb0b cmd/cc: use a temporary bitmap when constructing pointer maps
This change makes the way cc constructs pointer maps closer to
what gc does and is being done in preparation for changes to
the internal content of the pointer map such as a change to
distinguish interface pointers from ordinary pointers.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12692043
2013-08-09 13:02:33 -07:00
Russ Cox
b0a1b82ec1 cmd/go: cgo programs depend on syscall
Fixes #5048.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12651044
2013-08-09 09:03:25 -04:00
Rick Arnold
66e8471391 cmd/gc: make missing package error fatal
No longer continue assuming package main.

Fixes #4776.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12677043
2013-08-09 16:05:40 +10:00
Rémy Oudompheng
357f733695 cmd/5c, cmd/5g, cmd/5l: turn MOVB, MOVH into plain moves, optimize short arithmetic.
Pseudo-instructions MOVBS and MOVHS are used to clarify
the semantics of short integers vs. registers:
 * 8-bit and 16-bit values in registers are assumed to always
   be zero-extended or sign-extended depending on their type.
 * MOVB is truncation or move of an already extended value
   between registers.
 * MOVBU enforces zero-extension at the destination (register).
 * MOVBS enforces sign-extension at the destination (register).
And similarly for MOVH/MOVS/MOVHU.

The linker is adapted to assemble MOVB and MOVH to an ordinary
mov. Also a peephole pass in 5g that aims at eliminating
redundant zero/sign extensions is improved.

encoding/binary:
benchmark                              old ns/op    new ns/op    delta
BenchmarkReadSlice1000Int32s              220387       217185   -1.45%
BenchmarkReadStruct                        12839        12910   +0.55%
BenchmarkReadInts                           5692         5534   -2.78%
BenchmarkWriteInts                          6137         6016   -1.97%
BenchmarkPutUvarint32                        257          241   -6.23%
BenchmarkPutUvarint64                        812          754   -7.14%
benchmark                               old MB/s     new MB/s  speedup
BenchmarkReadSlice1000Int32s               18.15        18.42    1.01x
BenchmarkReadStruct                         5.45         5.42    0.99x
BenchmarkReadInts                           5.27         5.42    1.03x
BenchmarkWriteInts                          4.89         4.99    1.02x
BenchmarkPutUvarint32                      15.56        16.57    1.06x
BenchmarkPutUvarint64                       9.85        10.60    1.08x

crypto/des:
benchmark                              old ns/op    new ns/op    delta
BenchmarkEncrypt                            7002         5169  -26.18%
BenchmarkDecrypt                            7015         5195  -25.94%
benchmark                               old MB/s     new MB/s  speedup
BenchmarkEncrypt                            1.14         1.55    1.36x
BenchmarkDecrypt                            1.14         1.54    1.35x

strconv:
benchmark                              old ns/op    new ns/op    delta
BenchmarkAtof64Decimal                       457          385  -15.75%
BenchmarkAtof64Float                         574          479  -16.55%
BenchmarkAtof64FloatExp                     1035          906  -12.46%
BenchmarkAtof64Big                          1793         1457  -18.74%
BenchmarkAtof64RandomBits                   2267         2066   -8.87%
BenchmarkAtof64RandomFloats                 1416         1194  -15.68%
BenchmarkAtof32Decimal                       451          379  -15.96%
BenchmarkAtof32Float                         547          435  -20.48%
BenchmarkAtof32FloatExp                     1095          986   -9.95%
BenchmarkAtof32Random                       1154         1006  -12.82%
BenchmarkAtoi                               1415         1380   -2.47%
BenchmarkAtoiNeg                            1414         1401   -0.92%
BenchmarkAtoi64                             1744         1671   -4.19%
BenchmarkAtoi64Neg                          1737         1662   -4.32%

Fixes #1837.

R=rsc, dave, bradfitz
CC=golang-dev
https://golang.org/cl/12424043
2013-08-09 06:43:17 +02:00
Russ Cox
51e9858a70 cmd/go: install godoc into correct directory
Fixes #6043.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12693043
2013-08-08 23:48:03 -04:00
Russ Cox
237e7c134c cmd/cc: restore correct meaning of %Q
g% 6c ~/x.c
/Users/rsc/x.c:1 duplicate types given: STRUCT s and VOID
/Users/rsc/x.c:1 no return at end of function: f
g%

Fixes #6083.

R=ken2
CC=golang-dev
https://golang.org/cl/12691043
2013-08-08 21:06:06 -04:00
Brad Fitzpatrick
b379b32f31 cmd/api: add a benchmark over the standard library
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/12603045
2013-08-08 15:25:15 -07:00
Rémy Oudompheng
3670337097 cmd/5c, cmd/5g, cmd/5l: introduce MOVBS and MOVHS instructions.
MOVBS and MOVHS are defined as duplicates of MOVB and MOVH,
and perform sign-extension moving.
No change is made to code generation.

Update #1837

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/12682043
2013-08-08 23:28:53 +02:00
Robert Griesemer
9449c18ac8 cmd/api: rewrite using go/types
- adjusted test files so that they actually type-check
- adjusted go1.txt, go1.1.txt, next.txt
- to run, provide build tag: api_tool

Fixes #4538.

R=bradfitz
CC=golang-dev
https://golang.org/cl/12300043
2013-08-08 14:10:59 -07:00
Russ Cox
390656affd cmd/gc: fix stkptrsize calculation
I moved the pointer block from one end of the frame
to the other toward the end of working on the last CL,
and of course that made the optimization no longer work.

Now it works again:

0030 (bug361.go:12) DATA    gclocals·0+0(SB)/4,$4
0030 (bug361.go:12) DATA    gclocals·0+4(SB)/4,$3
0030 (bug361.go:12) GLOBL   gclocals·0+0(SB),8,$8

Fixes arm build (this time for sure!).

TBR=golang-dev
CC=cshapiro, golang-dev, iant
https://golang.org/cl/12627044
2013-08-08 16:44:16 -04:00
Russ Cox
f91e682cca cmd/gc: make bitmaps shorter
Sort non-pointer-containing data to the low end of the
stack frame, and make the bitmaps only cover the
pointer-containing top end.

Generates significantly less garbage collection bitmap
for programs with large byte buffers on the stack.

Only 2% shorter for godoc, but 99.99998% shorter
in some test cases.

Fixes arm build.

TBR=golang-dev
CC=cshapiro, golang-dev, iant
https://golang.org/cl/12541047
2013-08-08 16:38:02 -04:00
Brad Fitzpatrick
9a9e541c4d cmd/api: show output of api tool even if exit status is 0
We weren't seeing additions. (stuff to put in next.txt)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12678043
2013-08-08 13:36:22 -07:00
Brad Fitzpatrick
9497e5e2f0 cmd/api: update run.go to fetch from go.tools when needed
R=gri
CC=golang-dev
https://golang.org/cl/12639043
2013-08-08 11:06:38 -07:00
Russ Cox
1f4d58ad5d cmd/gc: move large stack variables to heap
Individual variables bigger than 10 MB are now
moved to the heap, as if they had escaped on
their own.

This avoids ridiculous stacks for programs that
do things like
        x := [1<<30]byte{}
        ... use x ...

If 10 MB is too small, we can raise the limit.

Fixes #6077.

R=ken2
CC=golang-dev
https://golang.org/cl/12650045
2013-08-08 13:46:30 -04:00
Brad Fitzpatrick
d5e97ea2f5 build: change how cmd/api is run in run.bash and run.bat
In prep for Robert's forthcoming cmd/api rewrite which
depends on the go.tools subrepo, we'll need to be more
careful about how and when we run cmd/api.

Rather than implement this policy in both run.bash and
run.bat, this change moves the policy and mechanism into
cmd/api/run.go, which will then evolve.

The plan is in a TODO in run.go.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/12482044
2013-08-07 13:49:37 -07:00
Carl Shapiro
73c93a404c cmd/cc, cmd/gc, runtime: emit bitmaps for scanning locals.
Previously, all word aligned locations in the local variables
area were scanned as conservative roots.  With this change, a
bitmap is generated describing the locations of pointer values
in local variables.

With this change the argument bitmap information has been
changed to only store information about arguments.  The locals
member, has been removed.  In its place, the bitmap data for
local variables is now used to store the size of locals.  If
the size is negative, the magnitude indicates the size of the
local variables area.

R=rsc
CC=golang-dev
https://golang.org/cl/12328044
2013-08-07 12:47:01 -07:00
Keith Randall
5a54696d78 cmd/ld: Put the textflag constants in a separate file.
We can then include this file in assembly to replace
cryptic constants like "7" with meaningful constants
like "(NOPROF|DUPOK|NOSPLIT)".

Converting just pkg/runtime/asm*.s for now.  Dropping NOPROF
and DUPOK from lots of places where they aren't needed.
More .s files to come in a subsequent changelist.

A nonzero number in the textflag field now means
"has not been converted yet".

R=golang-dev, daniel.morsing, rsc, khr
CC=golang-dev
https://golang.org/cl/12568043
2013-08-07 10:23:24 -07:00
Keith Randall
19e2922688 cmd/gc: get rid of redundant slice bound check.
For normal slices a[i:j] we're generating 3 bounds
checks: j<={len(string),cap(slice)}, j<=j (!), and i<=j.
Somehow snuck in as part of the [i:j:k] implementation
where the second check does something.
Remove the second check when we don't need it.

R=rsc, r
CC=golang-dev
https://golang.org/cl/12311046
2013-08-05 13:24:33 -07:00
Rémy Oudompheng
49da9a8e44 cmd/gc: fix inlining of unnamed structs with embedded fields.
Update #5910.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/11373044
2013-08-05 22:09:53 +02:00
Alex Brainman
a039bf20be cmd/dist: generate cmd/cgo/zdefaultcc.go on windows (fixes windows build)
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12404043
2013-08-03 18:32:14 +10:00
Brad Fitzpatrick
7acf9e93de cmd/go: fix build
This was missed in c3b45d0dc5c0

R=golang-dev
CC=golang-dev
https://golang.org/cl/12379043
2013-08-02 14:28:52 -07:00
Alberto García Hierro
bbf1430021 cmd/go: Fix go get when the fetched XML uses ASCII encoding
Also, add a meaningful error message when an encoding which
can't be parsed is found.

Fixes #5801.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12343043
2013-08-02 14:15:33 -07:00
Keith Randall
9cd570680b runtime: reimplement reflect.call to not use stack splitting.
R=golang-dev, r, khr, rsc
CC=golang-dev
https://golang.org/cl/12053043
2013-08-02 13:03:14 -07:00
Russ Cox
b8c8cb8509 cmd/dist: fix build again
I am really bad at this. Didn't hg add this file.

TBR=bradfitz
CC=golang-dev
https://golang.org/cl/12372043
2013-08-02 15:20:42 -04:00
Russ Cox
e6ddddadda cmd/dist: fix build
TBR=bradfitz
CC=golang-dev
https://golang.org/cl/12369043
2013-08-02 15:13:06 -04:00
Russ Cox
2ddb672ddc build: on OS X 10.8 and later, use clang instead of gcc
Fixes #5822.
Will no doubt cause other problems, but Apple has forced our hand.

R=golang-dev, bradfitz, khr
CC=golang-dev
https://golang.org/cl/12350044
2013-08-02 14:58:27 -04:00
Alex Brainman
6f8acd5fb9 cmd/go: change error message to refer to correct bootstrap command
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12317043
2013-08-02 15:55:21 +10:00
Russ Cox
b99fa81555 cmd/ld: report pclntab, funcdata sizes in 6l -v output
Also move chatty recent additions to -v -v.

For what it's worth:

$ go build -o /dev/null -ldflags -v cmd/go
...
 0.87 pclntab=1110836 bytes, funcdata total 69700 bytes
...
$

This broke the ELF builds last time because I tried to dedup
the funcdata in case the same funcdata was pointed at by
multiple functions. That doesn't currently happen, so I've
removed that test.

If we start doing bitmap coalescing we'll need to figure out
how to measure the size more carefully, but I think at that
point the bitmaps will be an extra indirection away from the
funcdata anyway, so the dedup I used before wouldn't help.

R=ken2
CC=golang-dev
https://golang.org/cl/12269043
2013-08-01 12:58:27 -04:00
Andrew Gerrand
4fa83edf06 cmd/godoc: delete from core repository
The godoc command now lives at code.google.com/p/go.tools/cmd/godoc.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12206044
2013-08-01 11:21:17 +10:00
Andrew Gerrand
e011ac5420 cmd/go: install go.tools/cmd/godoc to $GOROOT/bin/godoc
Also suggest "go get" if godoc not found when running "go doc".

R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/12214043
2013-08-01 11:17:42 +10:00
Brad Fitzpatrick
b08d0c2c62 undo CL 12193043 / cc5858966b08
Breaks all ELF builds.

««« original CL description
       cmd/ld: report pclntab, funcdata sizes in 6l -v output
       Also move chatty recent additions to -v -v.

       For what it's worth:

       $ go build -o /dev/null -ldflags -v cmd/godoc
       ...
        0.73 pclntab=1259976 bytes, funcdata total 79788 bytes
       ...
       $

R=ken2
CC=cshapiro, golang-dev
https://golang.org/cl/12193043
»»»

R=rsc
CC=golang-dev
https://golang.org/cl/12202043
2013-07-31 15:31:43 -07:00
Russ Cox
d43ee1b714 cmd/ld: report pclntab, funcdata sizes in 6l -v output
Also move chatty recent additions to -v -v.

       For what it's worth:

       $ go build -o /dev/null -ldflags -v cmd/godoc
       ...
	0.73 pclntab=1259976 bytes, funcdata total 79788 bytes
       ...
       $

R=ken2
CC=cshapiro, golang-dev
https://golang.org/cl/12193043
2013-07-31 15:36:49 -04:00
Dmitriy Vyukov
8679d5f2b5 cmd/gc: record argument size for all indirect function calls
This is required to properly unwind reflect.methodValueCall/makeFuncStub.
Fixes #5954.
Stats for 'go install std':
61849 total INSTCALL
24655 currently have ArgSize metadata
27278 have ArgSize metadata with this change
godoc size before: 11351888, after: 11364288

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12163043
2013-07-31 20:00:33 +04:00
Russ Cox
57933b86b1 cmd/go: send timed out test SIGQUIT before SIGKILL
There is a chance that the SIGQUIT will make the test process
dump its stacks as part of exiting, which would be nice for
finding out what it is doing.

Right now the builders are occasionally timing out running
the runtime test. I hope this will give us some information
about the state of the runtime.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/12041051
2013-07-30 22:52:10 -04:00
Russ Cox
cd2eb48722 cmd/gc: don't report mark if other things are broken
Fixes #5598.

R=ken2
CC=golang-dev
https://golang.org/cl/12104043
2013-07-30 10:27:26 -04:00
Russ Cox
27d17255db cmd/gc: insert \n at end of every input file
Not just the first one.

Fixes #5433.
Fixes #5913.

R=ken2
CC=golang-dev
https://golang.org/cl/12028049
2013-07-30 10:27:08 -04:00
Rémy Oudompheng
4eaf91a7a7 cmd/gc: make bisonerrors compatible with GNU Bison 3.0
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11990043
2013-07-30 04:31:15 +02:00
Dmitriy Vyukov
d5c7ef6216 cmd/dist: fix crash on windows
currently 'dist install' always crashes on windows

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11919043
2013-07-27 13:53:18 +04:00
Alex Brainman
a79e125b2f cmd/pack: support removing of leading file prefix on windows
Fixes #5550

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11904043
2013-07-26 16:56:24 +10:00
Alex Brainman
32a3ce6799 gc: fix line directive processing on windows
This change should have been part of 5671737303a0.

Fixes #5904

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11894043
2013-07-26 13:38:24 +10:00
Keith Randall
ad5cd931d8 undo CL 11788043 / 62d06cccc261
Reason for breakage fixed with CL 11888043.

««« original CL description
undo CL 11683043 / bb75d03e6ccb

Broke arm build.
R=dave

««« original CL description
cc: generate argument pointer maps for C functions.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11683043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/11788043
»»»

TBR=dave
CC=golang-dev
https://golang.org/cl/11789043
2013-07-25 17:51:33 -07:00
Keith Randall
de6da4a8bd 5c: fix pc recalculation in the presence of AFUNCDATA
This makes CL 11683043 not break arm anymore.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/11888043
2013-07-25 17:40:29 -07:00
Ian Lance Taylor
d9d3debee5 cmd/cgo: gccgo fixes
Don't require a full-scale callback for calls to the special
prologue functions.

Always use a simple wrapper function for C functions, so that
we can handle static functions defined in the import "C"
comment.

Disable a test that relies on gc-specific function names.

Fixes #5905.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11406047
2013-07-25 09:53:57 -04:00
Rémy Oudompheng
d7c99cdf9f cmd/gc: avoid passing unevaluated constant expressions to backends.
Backends do not exactly expect receiving binary operators with
constant operands or use workarounds to move them to
register/stack in order to handle them.

Fixes #5841.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/11107044
2013-07-25 09:42:05 -04:00
Kevin Klues
f7dfeea90f cmd/cgo: Fix issue with cgo cdefs
The problem is that the cdecl() function in cmd/cgo/godefs.go isn't
properly translating the Go array type to a C array type when an
asterisk follows the [] in the array type declaration (it is perfectly
legal to put the asterisk on either side of the [] in go syntax,
depending on how you set up your pointers).

That said, the cdefs tool is only designed to translate from Go types
generated using the cgo *godefs* tool -- where the godefs tool is
designed to translate gcc-style C types into Go types. In essence, the
cdefs tool translates from gcc-style C types to Go types (via the godefs
tool), then back to kenc-style C types. Because of this, cdefs does not
need to know how to translate arbitraty Go types into C, just the ones
produced by godefs.

The problem is that during this translation process, the logic is
slightly wrong when going from (e.g.):

char *array[10];
to:
array [10]*int8;
back to:
int8 *array[10];

In the current implementation of cdecl(), the translation from the Go
type declaration back to the kenc-style declaration looks for Go
types of the form:

name *[]type;
rather than the actual generated Go type declaration of:
name []*type;

Both are valid Go syntax, with slightly different semantics, but the
latter is the only one that can ever be generated by the godefs tools.
(The semantics of the former are not directly expressible in a
single C statement -- you would have to have to first typedef the array
type, then declare a pointer to that typedef'd type in a separate
statement).

This commit changes the logic of cdecl() to look properly for, and
translate, Go type declarations of the form:
name []*type;

Additionally, the original implementation only allowed for a single
asterisk and a single sized aray (i.e. only a single level of pointer
indirection, and only one set of []) on the type, whereas the patched
version allows for an arbitrary number of both.

Tests are included in misc/cgo/testcdefs and the all.bash script has been
updated to account for these.

R=golang-dev, bradfitz, dave, iant
CC=golang-dev
https://golang.org/cl/11377043
2013-07-24 17:27:42 -07:00
Keith Randall
b3defa2e8e undo CL 11683043 / bb75d03e6ccb
Broke arm build.
R=dave

««« original CL description
cc: generate argument pointer maps for C functions.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11683043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/11788043
2013-07-24 15:04:10 -07:00
Keith Randall
9b1f1833de cc: generate argument pointer maps for C functions.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11683043
2013-07-24 09:41:06 -07:00