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

4077 Commits

Author SHA1 Message Date
Russ Cox
ffbcd89f62 cmd/go: allow ~ in middle of path, just not at beginning
An earlier CL disallowed ~ anywhere in GOPATH, to avoid
problems with GOPATH='~/home' instead of GOPATH=~/home.
But ~ is only special in the shell at the beginning of each of
the paths in the list, and some paths do have ~ in the middle.
So relax the requirement slightly.

Fixes #4140.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7799045
2013-03-13 23:32:12 -04:00
Russ Cox
e778f93022 cmd/go: add go1.1 build tag, add -installsuffix flag
The new build tag "go1.1" will be satisfied by any Go 1.z release >= 1.1.
In general, the build tag "go1.x" will be satisfied by any Go 1.z release >= 1.x.
What happens when we reach Go 2 is yet to be decided.

The tags "go1" or "go1.0" are missing, because +build tags did not exist
before then, and also because the Go 1.0 releases do not recognize them.

The new -installsuffix flag gives access to the build context's InstallSuffix
(formerly named InstallTag, but not part of Go 1.0), for use in isolating
builds to custom directories. For example -race implies -installsuffix race,
and an AppEngine-specific build might use -tags appengine -installsuffix appengine.

Fixes #4116.
Fixes #4443.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/7794043
2013-03-13 17:37:49 -04:00
Russ Cox
3048a4c7b3 cmd/vet: make struct tag literal test work better with no go/types
Eliminate false positives when you can tell even without
type information that the literal does not need field tags.

Far too noisy otherwise.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7797043
2013-03-13 17:37:37 -04:00
Rob Pike
2211634113 cmd/go: better documentation about profiling
Point the user to "go tool pprof" and mention some
important flags.

Fixes #4990.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7657045
2013-03-13 13:56:51 -07:00
Dave Cheney
8883c484cf cmd/gc: silence valgrind error
valgrind complained that under some circumstances,

    *nr = *nc

was being called when nr and nc were the same *Node. The suggestion my Rémy was to introduce a tmp node to avoid the potential for aliasing in subnode.

R=remyoudompheng, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7780044
2013-03-13 16:12:38 -04:00
Russ Cox
f7ad816c5c cmd/ld: fix 'use after free' error in new obj code
Many thanks to Elias Naur for finding this with Valgrind on Linux.
Perhaps this is what is breaking the windows/amd64 builder.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7595044
2013-03-12 17:57:13 -04:00
Rob Pike
4ce79096b6 go/types: delete from main repo; part of move to go.exp
See also https://golang.org/cl/7656044

R=golang-dev, gri, rsc
CC=golang-dev
https://golang.org/cl/7625048
2013-03-12 13:55:58 -07:00
Russ Cox
d2be8f2948 cmd/addr2line: exit 0 for --help
This is what pprof expects, or else it won't use the program.
And if it doesn't use the program, it gets very bad results.

Fixes #4818.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7728043
2013-03-11 18:12:07 -04:00
Rémy Oudompheng
401e0fea3a cmd/gc: reject complex calls with mismatched argument types.
The specification says "the two arguments must be of the same
floating-point type."

R=rsc, gri
CC=golang-dev
https://golang.org/cl/7671045
2013-03-11 22:55:14 +01:00
Brad Fitzpatrick
e15c0ac693 all: remove now-unnecessary unreachable panics
Take advantage of the new terminating statement rule.

R=golang-dev, r, gri
CC=golang-dev
https://golang.org/cl/7712044
2013-03-11 14:16:55 -07:00
Rob Pike
5f91a62a3c cmd/go: fix description of -o flag to build
Fixes #5003.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7476047
2013-03-11 14:07:47 -07:00
Russ Cox
7b4ac31cab cmd/dist: make cc rule match what cmd/go uses
We added -I$GOROOT/pkg/$GOOS_$GOARCH in cmd/go
(I think for use by cgo and swig, primarily) but didn't
update cmd/dist. I was testing some other code and
found that my changes built with cmd/go but failed
during the initial bootstrap. Make them match again.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7707044
2013-03-11 16:50:44 -04:00
Akshat Kumar
76374412c3 lib9, cmd/dist, cmd/ld: Plan 9: fix build
lib9: fix runcmd, removeall, and tempdir functions

cmd/dist: Include run_plan9.c and tempdir_plan9.c
        from lib9 for build, and in general consider
        file names containing "plan9" for building.

cmd/ld: provide function args for the new functions
        from lib9.

R=rsc, rminnich, ality, bradfitz
CC=golang-dev
https://golang.org/cl/7666043
2013-03-11 13:34:57 -07:00
Rémy Oudompheng
386ad0ab90 cmd/gc: enable inlining in generated method wrappers.
Method calls on interfaces with large stored values
will call the pointer receiver method which may be
a wrapper over a method with value receiver.

This is particularly inefficient for very small bodies.
Inlining the wrapped method body saves a potentially expensive
function call.

benchmark                old ns/op    new ns/op    delta
BenchmarkSortString1K       802295       641387  -20.06%
BenchmarkSortInt1K          359914       238234  -33.81%
BenchmarkSortInt64K       35764226     22803078  -36.24%

Fixes #4707.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7214044
2013-03-11 21:24:51 +01:00
Shenghou Ma
960d7082ee cmd/ld, runtime/cgo: allow a symbol to be both cgo_export and cgo_import.
Fixes #4878.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7420052
2013-03-11 14:24:51 +08:00
Russ Cox
72dd01451f cmd/5l: fix build (define stub machoreloc1)
R=ken2
CC=golang-dev
https://golang.org/cl/7694043
2013-03-11 01:27:03 -04:00
Russ Cox
3b85b724c5 cmd/ld: darwin support for host linking
R=ken2
CC=golang-dev
https://golang.org/cl/7626045
2013-03-11 00:51:42 -04:00
Russ Cox
9e13803ae1 cmd/ld: avoid redundant external relocation calculations
R=ken2, ken
CC=golang-dev
https://golang.org/cl/7483045
2013-03-10 19:07:16 -07:00
Jeff R. Allen
53f034c7a8 cmd/go: send output of build and install to stderr
"go build" and "go install" were mixing stdout and stderr
from the toolchain, then putting it all on stdout. With this
change, it stays mixed, and is sent to stderr. Because
the toolchain does not create output in a clean compile/install,
sending all output to stderr makese more sense.

Also fix test.bash because of "mktemp: too few X's
in template `testgo'" on Linux.

Fixes #4917.

R=golang-dev, rsc, adg
CC=golang-dev
https://golang.org/cl/7393073
2013-03-11 11:31:14 +11:00
Russ Cox
96b243fa47 cmd/ld: replace dynimpname with extname
Dynimpname was getting too confusing.
Replace flag-like checks with tests of s->type.

R=ken2
CC=golang-dev
https://golang.org/cl/7594046
2013-03-10 18:19:53 -04:00
Russ Cox
4c40e5ae51 cmd/ld: wrap long data lines in -a output
Also move symbol names onto lines by themselves: some are very long.
Show relocations.

R=ken2
CC=golang-dev
https://golang.org/cl/7689043
2013-03-10 16:32:00 -04:00
Russ Cox
df6072b41c cmd/ld: include full symbol table in Mach-O output
This makes binaries work with OS X nm.

R=ken2
CC=golang-dev
https://golang.org/cl/7558044
2013-03-10 16:24:01 -04:00
Russ Cox
b83d4af330 cmd/ld: make mach-o sections match internal sections
This brings Mach-O generation more in line with ELF generation.

Having separate sections for the symtab and pclntab mean that we
can find them that way, instead of using the deprecated debug segments.
(And the host linker will keep separate sections for us, but probably
not the debug segments.)

R=ken2
CC=golang-dev
https://golang.org/cl/7688043
2013-03-10 14:17:04 -04:00
Russ Cox
e982ecacd1 cmd/ld: add tmpdir flag to preserve temp files
R=ken2
CC=golang-dev
https://golang.org/cl/7497044
2013-03-10 12:50:44 -04:00
Lucio De Re
a8e55f8858 cmd/8l/obj.c: NetBSD passes the test, Hnetbsd added.
myrtle$ go version
go version devel +d533352b414d Sat Mar 09 05:39:15 2013 +0100 netbsd/386
myrtle$ time go test -ldflags -hostobj ../misc/cgo/test
ok      _/var/project/GoLang/misc/cgo/test      10.962s
   68.63s real    49.60s user    19.06s system
myrtle$ uname -a
NetBSD myrtle.plan9.local 6.0_BETA2 NetBSD 6.0_BETA2 (GENERIC) i386

R=rsc
CC=golang-dev
https://golang.org/cl/7641047
2013-03-09 14:54:56 -08:00
Steve McCoy
18f926aab3 cgo: enable external linking mode on FreeBSD amd64.
Tested on FreeBSD 9.1 amd64, per rsc's instructions at
https://groups.google.com/d/topic/golang-dev/HjRTLvRsJXo/discussion .

R=golang-dev, lucio.dere, devon.odell, rsc
CC=golang-dev
https://golang.org/cl/7664044
2013-03-09 14:51:57 -08:00
Russ Cox
cd94cabad6 cmd/ld: external linking fixes for linux/386
The sticking point on 386 has been the "PC relative" relocations
used to point the garbage collection metadata at the type info.
These aren't in the code segment, and I don't trust that the linker
isn't doing something special that would be okay in code but
not when interpreting the pointers as data (for example, a PLT
jump table would be terrible).

Solve the problem in two steps:

1. Handle "PC relative" relocations within a section internally,
so that the external linker never sees them.

2. Move the gcdata and gcbss tables into the rodata section,
where the type information lives, so that the relocations can
be handled internally.

(To answer the obvious question, we make the gc->type
references relative so that they need not be relocated
individually when generating a shared object file.)

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7629043
2013-03-08 20:22:38 -08:00
Russ Cox
e0c430d5b7 cmd/6l, cmd/8l: fix BSD builds
Before this CL, running

        cd misc/cgo/test
        go test -c
        readelf --dyn-syms test.test | grep cgoexp

turned up many UNDEF symbols corresponding to symbols actually
in the binary but marked only cgo_export_static. Only symbols
marked cgo_export_dynamic should be listed in this mode.
And if the symbol is going to be listed, it should be listed with its
actual address instead of UNDEF.

The Linux dynamic linker didn't care about the seemingly missing
symbols, but the BSD one did.

This CL eliminates the symbols from the dyn-syms table.

R=golang-dev
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7624043
2013-03-07 21:23:59 -08:00
Russ Cox
7663ffcae6 cmd/ld: steps toward 386 host linking
- Introduce MaxAlign constant and use in data layout
and ELF section header.

- Allow up to 16-byte alignment for large objects
(will help Keith's hash changes).

- Emit ELF symbol for .rathole (global /dev/null used by 8c).

- Invoke gcc with -m32/-m64 as appropriate.

- Don't invoke gcc if writing the .o file failed.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7563045
2013-03-07 19:57:25 -08:00
Keith Randall
297bb12809 cmd/6a, cmd/8a, cmd/6l, cmd/8l: add AES instructions
Instructions for use in AES hashing.  See CL#7543043

R=rsc
CC=golang-dev
https://golang.org/cl/7548043
2013-03-07 12:54:00 -08:00
Rémy Oudompheng
4c203172a2 cmd/8g: fix code generation of int64(0) == int64(0).
The code would violate the contract of cmp64.

Fixes #5002.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/7593043
2013-03-07 21:47:45 +01:00
Russ Cox
60f783d92b cmd/ld: host linking support for linux/amd64
Still to do: non-linux and non-amd64.
It may work on other ELF-based amd64 systems too, but untested.

"go test -ldflags -hostobj $GOROOT/misc/cgo/test" passes.

Much may yet change, but this seems a reasonable checkpoint.

R=iant
CC=golang-dev
https://golang.org/cl/7369057
2013-03-07 09:19:02 -05:00
Tyler Bunnell
ae7aa345db cmd/fix: remove redundant 0 port
Fixes #4505.

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7468043
2013-03-07 19:06:19 +09:00
Rob Pike
bcb1da7065 all: delete a couple of mentions of the exp and old trees
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7551043
2013-03-06 16:52:03 -08:00
Russ Cox
fb59aed60b cmd/cgo: split cgo_export into cgo_export_static and cgo_export_dynamic
Also emit cgo_ldflag pragmas.

R=golang-dev, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/7530043
2013-03-06 16:57:14 -05:00
Rob Pike
0ed517e5e6 cmd/vet: isolate the type checking code into a separate file
We can enable/disable type checking with a build tag.
Should simplify cutting the go1.1 distribution free of go/types.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7482045
2013-03-06 12:49:56 -08:00
Russ Cox
7610a0552f lib9: add mktempdir, removeall, runprog
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7523043
2013-03-06 15:48:28 -05:00
David Symonds
a22361d68d vet: check for useless assignments.
The only check so far is for self-assignments of the form "expr = expr",
but even that found one instance in the standard library.

R=r, adg, mtj, rsc
CC=golang-dev
https://golang.org/cl/7455048
2013-03-06 09:55:04 +11:00
Rob Pike
8cf6e75e2a cmd/vet: change some warnings to errors for consistency.
Fixes #4980.

R=golang-dev, rsc, dsymonds
CC=golang-dev
https://golang.org/cl/7479044
2013-03-05 14:31:17 -08:00
David Symonds
eeade74529 vet: clean up taglit error print when typechecking fails.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7416050
2013-03-05 09:56:46 +11:00
Russ Cox
ecab408c42 cmd/gc: implement new return requirements
Fixes #65.

R=ken2
CC=golang-dev
https://golang.org/cl/7441049
2013-03-04 17:02:04 -05:00
Russ Cox
6dc3c9cfdd cmd/cgo: use explicit flag to emit dynamic linker path
Using -import_runtime_cgo would have worked great except
that it doesn't get passed to the second invocation of cgo,
and that's the one that writes the relevant file.

Fixes ARM build on systems with a different dynamic linker
than the one 5l assumes (like Gentoo).

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7432048
2013-03-04 11:23:17 -05:00
Daniel Morsing
b65acaeab2 cmd/gc: disallow selectors to the blank identifier
Fixes #4941.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7415051
2013-03-04 17:01:42 +01:00
Rémy Oudompheng
a85fce282e cmd/gc: simplify and fix defaultlit.
Fixes #4882.
Fixes #4936.
Fixes #4937.

R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7432044
2013-03-04 16:51:42 +01:00
Rémy Oudompheng
b0bb6f8cee cmd/gc: unbreak exporting of composite literals.
Fixes #4932.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7437043
2013-03-04 16:42:03 +01:00
Andrew Gerrand
15825dc935 cmd/godoc: move note argument to godoc.go
Fixes the App Engine version of godoc. The other fix is to duplicate
this code inside appinit.go. I think initHandlers is the right place
to put the strings.Split call, as the notesToShow var is used by
docServer, which is what initHandlers sets up.

R=dsymonds
CC=golang-dev
https://golang.org/cl/7434044
2013-03-04 09:02:45 +11:00
Shenghou Ma
3d50aaf483 cmd/dist: support for NetBSD/ARM
1. when executing a unsupported VFP instruction, the NetBSD kernel somehow
doesn't report SIGILL, and instead just spin and spin, we add a alarm(2)
to detect this case (albeit this is a kernel bug).
2. NetBSD/ARM's VFP11 support is not complete, so temporarily disable it.
3. The default gcc shipped with NetBSD-current mis-optimizes our code
at -O2, so lower the optimization level to -O1 on NetBSD/ARM.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/7286044
2013-03-03 06:50:17 +08:00
Carlos Castillo
7c793826d4 cmd/go: pass -intgosize to SWIG
swig >= 2.0.9 requires the size of int values to be passed via a command line flag. Should swig complain about the -intgosize not being supported, then alert the user to their outdated version of swig.

Fixes #4756.

R=golang-dev, minux.ma, iant
CC=golang-dev
https://golang.org/cl/7331048
2013-03-01 16:48:21 -08:00
Rob Pike
749082e2a4 cmd/vet: use go/printer to pretty-print expressions in printf messages
Fixes #4945.
Most examples in this issue now better, but #10 is incomplete and I'm not
certain how to reproduce it. It actually looks like a go/types problem, since
the type being reported is coming directly from that package.
Please reopen the issue if you disagree.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7448046
2013-03-01 12:30:09 -08:00
Rémy Oudompheng
80d2eac14d cmd/cgo: don't reimplement os/exec in util.go.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7450049
2013-03-01 15:04:14 -05:00
Russ Cox
8d732368c2 cmd/ld: fix windows build
Fixes #4948.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/7445045
2013-03-01 05:03:25 -08:00
Russ Cox
7556ccc7b1 cmd/cgo, cmd/ld: new cgo object file section
Switch to new pragma names, but leave old ones available for now.
Merge the three cgo-related sections in the .6 files into a single
cgo section.

R=golang-dev, iant, ality
CC=golang-dev
https://golang.org/cl/7424048
2013-03-01 00:27:57 -05:00
Russ Cox
40ed753ebd cmd/ld: fix symbol table sorting
runtime: double-check that symbol table is sorted

If the symbol table is unsorted, the binary search in findfunc
will not find its func, which will make stack traces stop early.
When the garbage collector starts using the stack tracer,
that would be a serious problem.

The unsorted symbol addresses came from from two things:

1. The symbols in an ELF object are not necessarily sorted,
   so sort them before adding them to the symbol list.

2. The __i686.get_pc_thunk.bx symbol is present in multiple
   object files and was having its address adjusted multiple
   times, producing an incorrect address in the symbol table.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7440044
2013-02-28 16:21:58 -05:00
Rob Pike
3dc7f17e89 cmd/vet: %b is a valid floating-point format.
Also add a report about "invalid type" from gotype, if -v is set.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7420045
2013-02-28 11:32:53 -08:00
Robin Eklind
f82ea304f0 cgo: fix reference to puts in implementation comment.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7431046
2013-02-28 11:31:52 -08:00
Russ Cox
b89000bcab cmd/cgo: extend implementation comment
This is the plan for how to make host linking work with
the rest of the system.

There are two complications:

1. It is a goal to preserve the property that pure Go programs
(even ones importing "net") can be compiled without needing
gcc, so that a Go toolchain download works out of the box.
This forces the support for two linking modes: with and without
gcc.

2. It is a goal to allow users with old copies of SWIG to continue
to use those copies. This forces the support for "internal only"
packages. Perhaps it is reasonable to require a new SWIG.
I don't know.

R=iant
CC=golang-dev
https://golang.org/cl/7433043
2013-02-28 10:44:29 -08:00
Shenghou Ma
6ecb39fce6 cmd/go: fix "go run" cgo source when cgo is disabled
also move a cgo-depend test to appropriate source file in runtime.

R=golang-dev, dave, adg, rsc
CC=golang-dev
https://golang.org/cl/7393063
2013-02-28 16:07:26 +08:00
Russ Cox
062a239046 cmd/cgo: add implementation comment
R=golang-dev, r, bradfitz, iant
CC=golang-dev
https://golang.org/cl/7407050
2013-02-27 20:55:01 -08:00
Rob Pike
9e19337de9 cmd/vet: continue past first error
Also delete bogus tests for f.pkg (does the file have a package) since all
files have a package attached. The tests for pkg.types and pkg.values
suffice.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7418043
2013-02-27 15:43:33 -08:00
Daniel Morsing
43c04ba1b8 cmd/gc: don't emit type instructions for nonexisting locals
If all locals are optimized away, the type instructions would stay in the instruction stream. Call fixautoused to scrub the output.

Fixes #4915.

R=rsc
CC=golang-dev
https://golang.org/cl/7385055
2013-02-27 19:47:14 +01:00
Russ Cox
56a06db360 cmd/ld: change GC_CALL to 32-bit relative address
The current code uses 64-bit pc-relative on 64-bit systems,
but in ELF linkers there is no such thing, so we cannot
express this in a .o file. Change to 32-bit.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7383055
2013-02-26 19:42:56 -08:00
Russ Cox
c8dcaeb25d cmd/ld, runtime: adjust symbol table representation
This CL changes the encoding used for the Go symbol table,
stored in the binary and used at run time. It does not change
any of the semantics or structure: the bits are just packed
a little differently.

The comment at the top of runtime/symtab.c describes the new format.

Compared to the Go 1.0 format, the main changes are:

* Store symbol addresses as full-pointer-sized host-endian values.
  (For 6g, this means addresses are 64-bit little-endian.)

* Store other values (frame sizes and so on) varint-encoded.

The second change more than compensates for the first:
for the godoc binary on OS X/amd64, the new symbol table
is 8% smaller than the old symbol table (1,425,668 down from 1,546,276).

This is a required step for allowing the host linker (gcc) to write
the final Go binary, since it will have to fill in the symbol address slots
(so the slots must be host-endian) and on 64-bit systems it may
choose addresses above 4 GB.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7403054
2013-02-26 22:38:14 -05:00
Rob Pike
6c2cbdb142 cmd/vet: fix printf test for unsafe Pointer
And fix test. Pointer to unsafe.Pointer tests nothing important...
Also identify the incorrect type: go/types.Type is a Stringer.

Also fix a couple of incorrect format verbs found by new printf checker,
now that we can run it on more files.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7385051
2013-02-26 10:36:13 -08:00
Anthony Martin
2b39e418be all: clean up C function prototypes
R=minux.ma, rsc, akumar, bradfitz
CC=golang-dev
https://golang.org/cl/7313070
2013-02-26 09:51:33 -08:00
Anthony Martin
f08acae76e build: do not set GOBIN on Plan 9
Also, I synced the rc files with changes
that have been made to make.bash, etc.

R=seed, rminnich, r
CC=golang-dev
https://golang.org/cl/7389049
2013-02-26 09:25:46 -08:00
Anthony Martin
c14d255ac5 cmd/go: do not print GCC environment variables on Plan 9
R=seed, rminnich, r, minux.ma
CC=golang-dev
https://golang.org/cl/7397059
2013-02-26 08:34:47 -08:00
Cosmos Nicolaou
d6a057c90e cmd/godoc: add support for display Notes parsed by pkg/go/doc
pkg/go/doc: move BUG notes from Package.Bugs to the general Package.Notes field.
Removing .Bugs would break existing code so it's left in for now.

R=gri, gri, gary.burd, dsymonds, rsc, kevlar
CC=golang-dev
https://golang.org/cl/7341053
2013-02-25 20:34:09 -08:00
Rob Pike
78b3ef261d cmd/vet: silence error from type checker unless verbose is set.
Also restores the checking of _test.go files, which disappeared
as a result of the package-at-a-time change.
Fixes #4895.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7399051
2013-02-25 16:29:09 -08:00
Rob Pike
31444a796a cmd/vet: move the tests into separate files
Then mark them with a build tag so they're not compiled into the binary.
They are called test_*.go rather than *_test.go because they are not
for go test. Use make test to test the command.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7377052
2013-02-25 16:25:34 -08:00
Rémy Oudompheng
71b3b46073 cmd/gc: accept cases with same value but different types in switch.
Fixes #4781.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7365056
2013-02-26 00:45:43 +01:00
Rémy Oudompheng
9e66ee4562 cmd/gc: fix corruption in export of &T{} literals.
Composite literals using the &T{} form were incorrectly
exported, leading to weird errors at import time.

Fixes #4879.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7395054
2013-02-26 00:43:31 +01:00
Rémy Oudompheng
9fe60801ae cmd/gc: apply escape analysis results to closures.
This avoids an allocation when closures are used
as "macros", in Walk idioms, or as argument to defer.

benchmark                old ns/op    new ns/op    delta
BenchmarkSearchWrappers       1171          354  -69.77%
BenchmarkCallClosure             3            3  -12.54%
BenchmarkCallClosure1          119            7  -93.95%
BenchmarkCallClosure2          183           74  -59.18%
BenchmarkCallClosure3          187           75  -59.57%
BenchmarkCallClosure4          187           76  -58.98%

Compared to Go 1:
benchmark                  old ns/op    new ns/op    delta
BenchmarkSearchWrappers         3208          354  -88.97%

Fixes #3520.

R=daniel.morsing, bradfitz, minux.ma, dave, rsc
CC=golang-dev
https://golang.org/cl/7397056
2013-02-26 00:40:28 +01:00
Shenghou Ma
8cdee79063 libmach, cmd/5a, cmd/5c, cmd/5g, cmd/5l: enable DWARF type info for Linux/ARM
Fixes #3747.

Update #4912
This CL adds gotype into .5 object file.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7376054
2013-02-26 06:15:29 +08:00
Russ Cox
aa3efb28f0 cmd/gc: can stop tracking gotype in regopt
Now that the type information is in TYPE instructions
that are not rewritten by the optimization passes,
we don't have to try to preserve the type information
(no longer) attached to MOV instructions.

R=ken2
CC=golang-dev
https://golang.org/cl/7402054
2013-02-25 16:11:34 -05:00
Shenghou Ma
1a01ffd386 cmd/gc: fix mkbuiltin (gc -A always write all symbols to export section)
Regenerate cmd/gc/builtin.c.
Fixes #4908.

R=rsc
CC=golang-dev
https://golang.org/cl/7383053
2013-02-26 03:14:59 +08:00
Francisco Souza
f5afc7d44f cmd/go: fix vet
Now that vet does typechecking, it should use only pkg.gofiles, instead
of pkg.allgofiles. Ignored files should not be checked by vet, because
they wouldn't typecheck.

Fixes #4906.

R=rsc, r
CC=golang-dev
https://golang.org/cl/7401051
2013-02-25 10:43:04 -08:00
Russ Cox
f5dce6c853 cmd/5g: fix arm build
R=ken2
CC=golang-dev
https://golang.org/cl/7365057
2013-02-25 12:21:12 -05:00
Russ Cox
1d5dc4fd48 cmd/gc: emit explicit type information for local variables
The type information is (and for years has been) included
as an extra field in the address chunk of an instruction.
Unfortunately, suppose there is a string at a+24(FP) and
we have an instruction reading its length. It will say:

        MOVQ x+32(FP), AX

and the type of *that* argument is int (not slice), because
it is the length being read. This confuses the picture seen
by debuggers and now, worse, by the garbage collector.

Instead of attaching the type information to all uses,
emit an explicit list of TYPE instructions with the information.
The TYPE instructions are no-ops whose only role is to
provide an address to attach type information to.

For example, this function:

        func f(x, y, z int) (a, b string) {
                return
        }

now compiles into:

        --- prog list "f" ---
        0000 (/Users/rsc/x.go:3) TEXT    f+0(SB),$0-56
        0001 (/Users/rsc/x.go:3) LOCALS  ,
        0002 (/Users/rsc/x.go:3) TYPE    x+0(FP){int},$8
        0003 (/Users/rsc/x.go:3) TYPE    y+8(FP){int},$8
        0004 (/Users/rsc/x.go:3) TYPE    z+16(FP){int},$8
        0005 (/Users/rsc/x.go:3) TYPE    a+24(FP){string},$16
        0006 (/Users/rsc/x.go:3) TYPE    b+40(FP){string},$16
        0007 (/Users/rsc/x.go:3) MOVQ    $0,b+40(FP)
        0008 (/Users/rsc/x.go:3) MOVQ    $0,b+48(FP)
        0009 (/Users/rsc/x.go:3) MOVQ    $0,a+24(FP)
        0010 (/Users/rsc/x.go:3) MOVQ    $0,a+32(FP)
        0011 (/Users/rsc/x.go:4) RET     ,

The { } show the formerly hidden type information.
The { } syntax is used when printing from within the gc compiler.
It is not accepted by the assemblers.

The same type information is now included on global variables:

0055 (/Users/rsc/x.go:15) GLOBL   slice+0(SB){[]string},$24(AL*0)

This more accurate type information fixes a bug in the
garbage collector's precise heap collection.

The linker only cares about globals right now, but having the
local information should make things a little nicer for Carl
in the future.

Fixes #4907.

R=ken2
CC=golang-dev
https://golang.org/cl/7395056
2013-02-25 12:13:47 -05:00
Volker Dobler
d97b975d5c cmd/godoc: show examples in text mode
Added the command line flag -ex to godoc to print examples in
text output.

Samples from the generated output:

$ godoc -ex strings Index
...
func Index(s, sep string) int
    Index returns the index of the first instance of sep in s, or -1 if sep
    is not present in s.

    Example:
        fmt.Println(strings.Index("chicken", "ken"))
        fmt.Println(strings.Index("chicken", "dmr"))
        // Output:
        // 4
        // -1
...

$ godoc -ex container/heap
...
package heap
    import "container/heap"

    Package heap provides heap operations for any type that implements
    heap.Interface. A heap is a tree with the property that each node is the
    minimum-valued node in its subtree.

    Example:
        // This example demonstrates an integer heap built using the heap interface.
        package heap_test

        import (
            "container/heap"
            "fmt"
        ...

    Example:
        // This example demonstrates a priority queue built using the heap interface.
        package heap_test

        import (
            "container/heap"
            "fmt"
        )
...

Fixes #3587.

R=golang-dev, minux.ma, adg, rsc, gri
CC=golang-dev
https://golang.org/cl/7356043
2013-02-25 10:37:17 +11:00
Rob Pike
1174a18c3d cmd/vet: fix up some nits in print.go found by kamil.kisiel@gmail.com
R=golang-dev, kamil.kisiel, bradfitz
CC=golang-dev
https://golang.org/cl/7369049
2013-02-24 13:18:36 -08:00
Rob Pike
83e22f1a47 cmd/vet: eliminate false positives for slices in untagged literal test
Made possible by go/types, as long as the package type-checks OK.

Fixes #4684.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7407045
2013-02-24 13:18:21 -08:00
Shenghou Ma
89ec3a610d cmd/dist: avoid using %ebx on i386.
Or gcc (-fPIC) will complain:
cmd/dist/unix.c: In function ‘cansse2’
cmd/dist/unix.c:774: error: can't find a register in class ‘BREG’ while reloading ‘asm’
cmd/dist/unix.c:774: error: ‘asm’ operand has impossible constraints

This affects bootstrapping on native Darwin/386 where all code is
compiled with -fPIC.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7394047
2013-02-24 22:45:53 +08:00
Rob Pike
72b6daa3ba cmd/vet: check argument types in printf formats
Fixes #4404.

R=gri, rsc
CC=golang-dev
https://golang.org/cl/7378061
2013-02-23 15:08:36 -08:00
Shenghou Ma
eec961470f cmd/cgo, cmd/dist, cmd/go: cgo with clang fixes
1. Workaround the smart clang diagnostics with -Qunused-arguments:
clang: error: argument unused during compilation: '-XXX'
2. if "clang -print-libgcc-file-name" returns non-absolute path, don't
provide that on linker command line.
3. Fix dwarf.PtrType.Size() in cmd/cgo as clang doesn't generate
DW_AT_byte_size for pointer types.
4. Workaround warnings for -Wno-unneeded-internal-declaration with
-Wno-unknown-warning-option.
5. Add -Wno-unused-function.
6. enable race detector test on darwin with clang
(at least Apple clang version 1.7 (tags/Apple/clang-77) works).

Requires CL 7354043.

Update #4829
This should fix most parts of the problem, but one glitch still remains.
DWARF generated by newer clang doesn't differentiate these
two function types:
    void *malloc(size_t);
    void *malloc(unsigned long int);
so you might need to do this to make make.bash pass:
sed -i -e 's/C.malloc(C.size_t/C.malloc(C.ulong/' pkg/os/user/lookup_unix.go

R=golang-dev, dave, iant, rsc
CC=golang-dev
https://golang.org/cl/7351044
2013-02-23 20:24:38 +08:00
Rob Pike
4434212f15 cmd/vet: use types to test Error methods correctly.
We need go/types to discriminate the Error method from
the error interface and the Error method of the testing package.
Fixes #4753.

R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/7396054
2013-02-22 17:16:31 -08:00
Carl Shapiro
66ba4a85e4 cmd/gc: mark LOCALS argument as a constant to print correctly
Fixes #4875.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7376049
2013-02-22 15:32:54 -08:00
Rob Pike
48f79a95d0 cmd/vet: restructure to be package-driven
This is a simple refactoring of main.go that will enable the type checker
to be used during vetting.
The change has an unimportant effect on the arguments: it now assumes
that all files named explicitly on the command line belong to the same
package. When run by the go command, this was true already.

Also restore a missing parenthesis from an error message.

R=golang-dev, gri, bradfitz
CC=golang-dev
https://golang.org/cl/7393052
2013-02-22 13:32:43 -08:00
Russ Cox
9f647288ef cmd/gc: avoid runtime code generation for closures
Change ARM context register to R7, to get out of the way
of the register allocator during the compilation of the
prologue statements (it wants to use R0 as a temporary).

Step 2 of http://golang.org/s/go11func.

R=ken2
CC=golang-dev
https://golang.org/cl/7369048
2013-02-22 14:25:50 -05:00
Russ Cox
d57fcbf05c cmd/5l, cmd/6l, cmd/8l: accept CALL reg, reg
The new src argument is ignored during linking
(that is, CALL r1, r2 is identical to CALL r2 for linking),
but it serves as a hint to the 5g/6g/8g optimizer
that the src register is live on entry to the called
function and must be preserved.

It is possible to avoid exposing this fact to the rest of
the toolchain, keeping it entirely within 5g/6g/8g,
but I think it will help to be able to look in object files
and assembly listings and linker -a / -W output to
see CALL instructions are "Go func value" calls and
which are "C function pointer" calls.

R=ken2
CC=golang-dev
https://golang.org/cl/7364045
2013-02-22 14:23:21 -05:00
Russ Cox
6066fdcf38 cmd/6g, cmd/8g: switch to DX for indirect call block
runtime: add context argument to gogocall

Too many other things use AX, and at least one
(stack zeroing) cannot be moved onto a different
register. Use the less special DX instead.

Preparation for step 2 of http://golang.org/s/go11func.
Nothing interesting here, just split out so that we can
see it's correct before moving on.

R=ken2
CC=golang-dev
https://golang.org/cl/7395050
2013-02-22 10:47:54 -05:00
Anthony Martin
ed1ac05673 cmd/go: don't call ImportDir unnecessarily
This significantly speeds up the go tool on
slow file systems (or those with cold caches).

The following numbers were obtained using
an encrypted ext4 file system running on
Linux 3.7.9.

# Before
$ sudo sysctl -w 'vm.drop_caches=3'
$ time go list code.google.com/p/go.net/... | wc -l
9

real	0m16.921s
user	0m0.637s
sys	0m0.317s

# After
$ sudo sysctl -w 'vm.drop_caches=3'
$ time go list code.google.com/p/go.net/... | wc -l
9

real	0m8.175s
user	0m0.220s
sys	0m0.177s

R=rsc, r
CC=golang-dev
https://golang.org/cl/7369044
2013-02-21 20:09:31 -08:00
Dave Cheney
6138e368f8 cmd/gc: fix FreeBSD build
R=jsing, mikioh.mikioh, bradfitz
CC=golang-dev
https://golang.org/cl/7390048
2013-02-22 10:28:03 +11:00
Russ Cox
1903ad7189 cmd/gc, reflect, runtime: switch to indirect func value representation
Step 1 of http://golang.org/s/go11func.

R=golang-dev, r, daniel.morsing, remyoudompheng
CC=golang-dev
https://golang.org/cl/7393045
2013-02-21 17:01:13 -05:00
Carl Shapiro
f466617a62 cmd/5g, cmd/5l, cmd/6l, cmd/8l, cmd/gc, cmd/ld, runtime: accurate args and locals information
Previously, the func structure contained an inaccurate value for
the args member and a 0 value for the locals member.

This change populates the func structure with args and locals
values computed by the compiler.  The number of args was
already available in the ATEXT instruction.  The number of
locals is now passed through in the new ALOCALS instruction.

This change also switches the unit of args and locals to be
bytes, just like the frame member, instead of 32-bit words.

R=golang-dev, bradfitz, cshapiro, dave, rsc
CC=golang-dev
https://golang.org/cl/7399045
2013-02-21 12:52:26 -08:00
Russ Cox
0cdc0b3b78 cmd/5g, cmd/6g: fix node dump formats
lvd changed the old %N to %+hN and these
never got updated.

R=ken2
CC=golang-dev
https://golang.org/cl/7391045
2013-02-21 12:53:25 -05:00
Russ Cox
df93283d56 cmd/fix: delete pre-Go 1 fixes
Assume people who were going to update to Go 1 have done so.
Those with pre-Go 1 trees remaining will need to update first
to Go 1.0 (using its 'go fix') and then to Go 1.1.

Cuts the cmd/fix test time by 99% (3 seconds to 0.03 seconds).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7402046
2013-02-21 12:19:54 -05:00
Robert Griesemer
9dcf3eee41 cmd/godoc: better console error message for example error
(per r's suggestion)

R=r
CC=golang-dev
https://golang.org/cl/7376045
2013-02-20 12:28:12 -08:00
Robert Griesemer
3ee87d02b0 cmd/godoc: use go/build to determine package and example files
Also:
- faster code for example extraction
- simplify handling of command documentation:
  all "main" packages are treated as commands
- various minor cleanups along the way

For commands written in Go, any doc.go file containing
documentation must now be part of package main (rather
then package documentation), otherwise the documentation
won't show up in godoc (it will still build, though).

For commands written in C, documentation may still be
in doc.go files defining package documentation, but the
recommended way is to explicitly ignore those files with
a +build ignore constraint to define package main.

Fixes #4806.

R=adg, rsc, dave, bradfitz
CC=golang-dev
https://golang.org/cl/7333046
2013-02-19 11:19:58 -08:00
Russ Cox
07e87885ad cmd/6c: fix build
copy+paste error while cleaning up CL 7303099 before submit

R=ken2
CC=golang-dev
https://golang.org/cl/7308104
2013-02-18 13:29:55 -05:00
Russ Cox
139448fe95 cmd/6c, cmd/8c: cut stack frames by about half
The routine that adds an automatic to the stack was
adding ptrsize-1 to the size before rounding up.
That addition would only make sense to turn a round down
into a round up. Before a round up, it just wastes a word.

The effect was that a 6c function with one local and
one two-word function call used (8+8)+(16+8) = 40 bytes
instead of 8+16 = 24 bytes.

The wasted space mostly didn't matter, but one place where
it does matter is when trying to stay within the 128-byte
total frame constraint for #pragma textflag 7 functions.

This only affects the C compilers, not the Go compilers.

5c already had correct code, which is now copied to 6c and 8c.

R=ken2
CC=golang-dev
https://golang.org/cl/7303099
2013-02-18 13:24:04 -05:00
Russ Cox
6d888f1e1b build: clang support
This works with at least one version of clang
that existed at one moment in time.
No guarantees about clangs past or future.

To try:
        CC=clang all.bash

It does not work with the Xcode clang,
because that clang fails at printing a useful answer
to:
        clang -print-libgcc-file-name
The clang that works prints a full path name for
that command, not just "libgcc.a".

Fixes #4713.

R=iant, minux.ma
CC=golang-dev
https://golang.org/cl/7323068
2013-02-15 13:37:43 -08:00
Russ Cox
2d4164596f cmd/go: reject case-insensitive file name, import collisions
To make sure that Go code will work when moved to a
system with a case-insensitive file system, like OS X or Windows,
reject any package built from files with names differing
only in case, and also any package built from imported
dependencies with names differing only in case.

Fixes #4773.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7314104
2013-02-15 14:39:39 -05:00
Anthony Martin
f2c3122307 cmd/ld: fix -s flag for ELF executables
This fixes a regression introduced in changeset 98034d036d03
which added support for producing host object files.

R=rsc, minux.ma
CC=dave, golang-dev
https://golang.org/cl/7307107
2013-02-14 18:43:54 -08:00
Carl Shapiro
817a3f39fd src/cmd/gc: fix some typos in the escape analysis comments
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7342044
2013-02-14 15:38:57 -08:00
Robert Griesemer
5b1885c241 go/parser: cleanups following CL 7307085
- use the new AllErrors flag where appropriate
- unless AllErrors is set, eliminate spurious
  errors before they are added to the errors list
  (it turns out that reporting spurious errors always
  leads to too many uninformative errors after all)

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7323065
2013-02-14 13:36:40 -08:00
Daniel Morsing
38244018ce cmd/gc: remove node printing in redeclare errors
I suspect this is some debugging which got through the submission process.

Fixes #4789.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7310079
2013-02-14 21:11:47 +01:00
Russ Cox
11884db3d7 cmd/go: fix vet
The IgnoredGoFiles are already listed in allgofiles,
so they were being run twice. Worse, the ones in
IgnoredGoFiles are not fully qualified paths, so they
weren't being found when executed outside the
package directory.

Fixes #4764.

R=golang-dev, minux.ma, franciscossouza
CC=golang-dev
https://golang.org/cl/7308049
2013-02-14 15:00:51 -05:00
Russ Cox
31072e41f4 cmd/gc: replace x*8 by x<<3 etc
Fixes #4199.

R=ken2
CC=golang-dev
https://golang.org/cl/7322081
2013-02-14 14:54:00 -05:00
Russ Cox
ac1015e7f3 cmd/8g: fix sse2 compare code gen
Fixes #4785.

R=ken2
CC=golang-dev
https://golang.org/cl/7300109
2013-02-14 14:49:04 -05:00
Russ Cox
357a18a2c6 cmd/go: set $PWD when running commands
This makes os.Getwd inside those commands much faster.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7324055
2013-02-14 14:21:44 -05:00
Russ Cox
7f284f85f9 cmd/vet: drop column information from error
The column information can be misleading.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/7300100
2013-02-13 22:34:37 -05:00
Russ Cox
594360cb1b cmd/8c: disable use of prefetch with GO386=387
Fixes #4798.

R=ken2
CC=golang-dev
https://golang.org/cl/7323061
2013-02-13 21:13:07 -05:00
Lucio De Re
a3855013a2 cmd/5l: fix print format
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7304065
2013-02-13 16:47:33 -05:00
Rob Pike
d282532901 vet: improve flag handling
Simplify the internal logic for flags controlling what to vet,
by introducing a map of flags that gathers them all together.
This change should simplify the process of adding further flags.

Add a test for untagged struct literals.
Delete a redundant test that was also in the wrong file.
Clean up some ERROR patterns that weren't working.

"make test" passes again.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7305075
2013-02-11 13:33:11 -08:00
Lucio De Re
fece09e58a cmd/8l/asm.c: Unused function arguments, suppress warnings.
R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/7304069
2013-02-11 10:15:56 +11:00
Robert Daniel Kortschak
482f3e8481 cmd/go: indicate that flags unrecognized by 'go test' must follow package specification
R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/7300063
2013-02-08 16:00:59 -05:00
Rémy Oudompheng
f42fa807a6 cmd/5g: add missing splitclean.
See issue 887 for the 8g analogue.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7306069
2013-02-08 08:19:47 +01:00
David Symonds
3c1dfb2b9a cmd/godoc: fix format strings.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7309061
2013-02-08 12:00:35 +11:00
Russ Cox
7594440ef1 cmd/8g: add a few missing splitclean
Fixes #887.

R=ken2
CC=golang-dev
https://golang.org/cl/7303061
2013-02-07 17:55:25 -05:00
Shenghou Ma
255fb521da cmd/dist: add -Wstrict-prototypes to CFLAGS and fix all the compiler errors
Plan 9 compilers insist this but as we don't have Plan 9
builders, we'd better let gcc check the prototypes.

Inspired by CL 7289050.

R=golang-dev, seed, dave, rsc, lucio.dere
CC=akumar, golang-dev
https://golang.org/cl/7288056
2013-02-05 21:43:04 +08:00
Russ Cox
fd178d6a7e cmd/gc: add way to specify 'noescape' for extern funcs
A new comment directive //go:noescape instructs the compiler
that the following external (no body) func declaration should be
treated as if none of its arguments escape to the heap.

Fixes #4099.

R=golang-dev, dave, minux.ma, daniel.morsing, remyoudompheng, adg, agl, iant
CC=golang-dev
https://golang.org/cl/7289048
2013-02-05 07:00:38 -05:00
Russ Cox
572d984eaa cmd/gc: fix escape analysis
If the analysis reached a node twice, then the analysis was cut off.
However, if the second arrival is at a lower depth (closer to escaping)
then it is important to repeat the traversal.

The repeating must be cut off at some point to avoid the occasional
infinite recursion. This CL cuts it off as soon as possible while still
passing all tests.

Fixes #4751.

R=ken2
CC=golang-dev, lvd
https://golang.org/cl/7303043
2013-02-04 22:48:31 -05:00
Shenghou Ma
49fe632c7d cmd/go: update doc.go
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7279047
2013-02-05 05:45:35 +08:00
Russ Cox
399dcc75a8 cmd/gc: fix &^ code generation bug
Was not re-walking the new AND node, so that its ullman
count was wrong, so that the code generator attempted to
store values in registers across the call.

Fixes #4752.

R=ken2
CC=golang-dev
https://golang.org/cl/7288054
2013-02-04 00:21:44 -05:00
Russ Cox
89a2a8c8df cmd/go, testing: revise docs for test flags
In cmd/go's 'go help testflag':
* Rewrite list of flags to drop test. prefix on every name.
* Sort list of flags.
* Add example of using -bench to match all benchmarks.

In testing:
* Remove mention of undefined 'CPU group' concept.

Fixes #4488.
Fixes #4508.

R=adg
CC=golang-dev
https://golang.org/cl/7288053
2013-02-03 23:47:03 -05:00
Russ Cox
2c09d6992f cmd/gc: slightly better code generation
* Avoid treating CALL fn(SB) as justification for introducing
and tracking a registerized variable for fn(SB).

* Remove USED(n) after declaration and zeroing of n.
It was left over from when the compiler emitted more
aggressive set and not used errors, and it was keeping
the optimizer from removing a redundant zeroing of n
when n was a pointer or integer variable.

Update #597.

R=ken2
CC=golang-dev
https://golang.org/cl/7277048
2013-02-03 14:51:21 -05:00
Russ Cox
f02067a99a cmd/gc: implement latest rules for checking make sizes
Fixes #4085.

R=ken2
CC=golang-dev
https://golang.org/cl/7277047
2013-02-03 14:28:44 -05:00
Russ Cox
46d6f3c62f cmd/go: update 'go get' help message
It accepts all the build flags.
Say that instead of making a copy that will go stale.

Fixes #4742.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7229081
2013-02-03 13:08:23 -05:00
Shenghou Ma
2ebfaa36b5 cmd/5l, cmd/ld: support generating ELF binaries for NetBSD/ARM
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7261043
2013-02-04 00:40:11 +08:00
Russ Cox
09a17ca1f1 cmd/gc: make inlined labels distinct
Fixes #4748.

R=ken2
CC=golang-dev
https://golang.org/cl/7261044
2013-02-03 11:19:22 -05:00
Russ Cox
d82dcadb57 cmd/gc: clean up string index errors
Unify with array/slice errors, which were already good.

Fixes #4232.

R=ken2
CC=golang-dev
https://golang.org/cl/7271046
2013-02-03 02:01:05 -05:00
Russ Cox
4ad505d102 cmd/gc: update ideal bool rules to match latest spec
Fixes #3915.
Fixes #3923.

R=ken2
CC=golang-dev
https://golang.org/cl/7281044
2013-02-03 01:44:03 -05:00
Russ Cox
b2e0c34cf3 cmd/gc: remove reference to ? and @ symbols in error message
Those symbols are only allowed during imports;
the parser may expect them but saying that doesn't help users.

Fixes #3434.

R=ken2
CC=golang-dev
https://golang.org/cl/7277045
2013-02-03 01:25:47 -05:00
Russ Cox
2eafbb8878 cmd/gc: elide self-assignment during return
More efficient, less racy code.

Fixes #4014.

R=ken2, ken
CC=golang-dev
https://golang.org/cl/7275047
2013-02-03 01:18:28 -05:00
Russ Cox
ffc742b658 cmd/gc: allow new conversion syntax
For consistency with conversions that look like function calls,
conversions that don't look like function calls now allow an
optional trailing comma.

That is, int(x,) has always been syntactically valid.
Now []int(x,) is valid too.

Fixes #4162.

R=ken2
CC=golang-dev
https://golang.org/cl/7288045
2013-02-03 00:03:10 -05:00
Russ Cox
2af3cbe308 cmd/gc: treat &T{} like new(T): allocate on stack if possible
Fixes #4618.

R=ken2
CC=golang-dev
https://golang.org/cl/7278048
2013-02-02 23:54:21 -05:00
Russ Cox
a72f9f46a2 cmd/gc: avoid duplicate allocation during inlining
Fixes #4667.

R=ken2
CC=golang-dev
https://golang.org/cl/7275046
2013-02-02 23:17:25 -05:00
Russ Cox
fc6b530f0f cmd/gc: remove spurious newline from node dump
R=ken2
CC=golang-dev
https://golang.org/cl/7276048
2013-02-02 23:09:49 -05:00
Russ Cox
18178fd138 cmd/go: run examples in source order, not name order
Add Order field to doc.Example and write doc comments there.

Fixes #4662.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7229071
2013-02-02 16:26:12 -05:00
Daniel Morsing
5ea52a4d91 cmg/gc: Fix evaluation order of map indexing during multiple assignments
Fixes #4620.

R=rsc
CC=golang-dev
https://golang.org/cl/7241051
2013-02-02 12:39:04 +01:00
Russ Cox
8931306389 cmd/gc: reject non-Go constants
Expressions involving nil, even if they can be evaluated
at compile time, do not count as Go constants and cannot
be used in const initializers.

Fixes #4673.
Fixes #4680.

R=ken2
CC=golang-dev
https://golang.org/cl/7278043
2013-02-01 23:10:02 -05:00
Russ Cox
f607c479ea cmd/gc: silence redundant error prints for misuse of [...]int
Fixes #4452.

R=ken2
CC=golang-dev
https://golang.org/cl/7241065
2013-02-01 21:21:27 -05:00
Russ Cox
e2711cb202 cmd/gc: put 'not used' message on correct line
Fixes #4663.

R=ken2
CC=golang-dev
https://golang.org/cl/7235081
2013-02-01 21:13:41 -05:00
Russ Cox
79a16a3b70 cmd/gc: clearer error for defer/go of conversion or invalid function call
Fixes #4654.

R=ken2
CC=golang-dev
https://golang.org/cl/7229072
2013-02-01 21:02:15 -05:00
Elias Naur
44cf814d50 runtime, cmd/ld: make code more position-independent
Change the stack unwinding code to compensate for the dynamic
relocation of symbols.
Change the gc instruction GC_CALL to use a relative offset instead of
an absolute address.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7248048
2013-02-01 11:24:49 -08:00
Brad Fitzpatrick
e515d80d5d bytes, strings: add TrimPrefix and TrimSuffix
Everybody either gets confused and thinks this is
TrimLeft/TrimRight or does this by hand which gets
repetitive looking.

R=rsc, kevlar
CC=golang-dev
https://golang.org/cl/7239044
2013-02-01 08:41:25 -08:00
Elias Naur
fe14ee52cc cmd/6c, cmd/6g: add flag to support large-model code generation
Added the -pic flag to 6c and 6g to avoid assembler instructions that
cannot use RIP-relative adressing. This is needed to support the -shared mode
in 6l.

See also:
https://golang.org/cl/6926049
https://golang.org/cl/6822078

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7064048
2013-02-01 08:35:33 -08:00
Russ Cox
32a6097fde cmd/go: clean cgo compiler errors
Cut out temporary cgo file in error message.
Show C.foo instead of _Ctype_foo.

Before:
x.go:20[/var/folders/00/05_b8000h01000cxqpysvccm000n9d/T/go-build242036121/command-line-arguments/_obj/x.cgo1.go:19]: cannot use tv.Usec (type int32) as type _Ctype___darwin_suseconds_t in assignment

After:
x.go:20: cannot use tv.Usec (type int32) as type C.__darwin_suseconds_t in assignment

Fixes #4255.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7231075
2013-02-01 08:34:21 -08:00
Russ Cox
f20e3a1065 cmd/cgo: fix line number annotations in generated C code
The old version was using go/ast's CommentGroup.Text method,
but that method drops leading blank lines from the result, so that
if the comment looked like one of

//
// syntax error
import "C"

/*
syntax error
*/
import "C"

then the line numbers for the syntax error would be off by the
number of leading blank lines (1 in each of the above cases).

The new text extractor preserves blank lines.

Fixes #4019.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7232071
2013-02-01 08:34:08 -08:00
Russ Cox
ed9fc7531d cmd/cgo: document //export preamble restriction
Fixes #3497.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7235075
2013-02-01 08:33:52 -08:00