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

3928 Commits

Author SHA1 Message Date
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
Russ Cox
25d1fc9389 cmd/dist: fix build
The Unix and Plan 9 readfile call breset(b) but Windows was not,
leaving dregs in the buffer.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7229069
2013-01-31 22:57:30 -08:00
Russ Cox
7fc64a2a1d cmd/dist: redirect acid output to file to separate from errors
If runtime's proc.c does not compile, cmd/dist used to show
the compile errors in a sea of acid output, making them impossible
to find. Change the command invocation to write the acid output
to a file, so that the errors are the only thing shown on failure.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7221082
2013-01-31 22:02:20 -08:00
Russ Cox
ca727f1116 cmd/8l: fix build
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7241061
2013-01-31 16:13:48 -08:00
Russ Cox
c0e805efd2 cmd/vet: add missing -all logic
R=golang-dev, cookieo9, bradfitz
CC=golang-dev
https://golang.org/cl/7260043
2013-01-31 14:37:47 -08:00
Russ Cox
0cb0f6d090 cmd/ld: support for linking with host linker
A step toward a fix for issue 4069.

To allow linking with arbitrary host object files, add a linker mode
that can generate a host object file instead of an executable.
Then the host linker can be invoked to generate the final executable.

This CL adds a new -hostobj flag that instructs the linker to write
a host object file instead of an executable.

That is, this works:

        go tool 6g x.go
        go tool 6l -hostobj -o x.o x.6
        ld -e _rt0_amd64_linux x.o
        ./a.out

as does:

        go tool 8g x.go
        go tool 8l -hostld ignored -o x.o x.8
        ld -m elf_i386 -e _rt0_386_linux x.o
        ./a.out

Because 5l was never updated to use the standard relocation scheme,
it will take more work to get this working on ARM.

This is a checkpoint of the basic functionality. It does not work
with cgo yet, and cgo is the main reason for the change.
The command-line interface will likely change too.
The gc linker has other information that needs to be returned to
the caller for use when invoking the host linker besides the single
object file.

R=iant, iant
CC=golang-dev
https://golang.org/cl/7060044
2013-01-31 14:11:32 -08:00
Russ Cox
739aa6b1ba cmd/vet: check for misplaced and malformed build tags
Fixes #4184.

R=golang-dev, bradfitz, minux.ma, cookieo9
CC=golang-dev
https://golang.org/cl/7251044
2013-01-31 13:52:27 -08:00
Russ Cox
8b6534b78a cmd/go: many bug fixes
* Reject import paths of the form cmd/x/y.
* Reject 'go install' of command outside GOPATH
* Clearer error rejecting 'go install' of package outside GOPATH.
* Name temporary binary for first file in 'go run' list or for test.
* Provide a way to pass -ldflags arguments with spaces.
* Pass all Go files (even +build ignored ones) to go fix, go fmt, go vet.
* Reject 'go run foo_test.go'.
* Silence 'exit 1' prints from 'go tool' invocations.
* Make go test -xxxprofile leave binary behind for analysis.
* Reject ~ in GOPATH except on Windows.
* Get a little less confused by symlinks.
* Document that go test x y z runs three test binaries.
* Fix go test -timeout=0.
* Add -tags flag to 'go list'.
* Use pkg/gccgo_$GOOS_$GOARCH for gccgo output.

Fixes #3389.
Fixes #3500.
Fixes #3503.
Fixes #3760.
Fixes #3941.
Fixes #4007.
Fixes #4032.
Fixes #4074.
Fixes #4127.
Fixes #4140.
Fixes #4311.
Fixes #4568.
Fixes #4576.
Fixes #4702.

R=adg
CC=golang-dev
https://golang.org/cl/7225074
2013-01-31 08:06:38 -08:00
Russ Cox
87c3c1b002 cmd/vet: handle added string constants in printf format check
Fixes #4599.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7226067
2013-01-31 07:53:38 -08:00
Russ Cox
592b480746 cmd/ld: retry short writes, to get error detail
Fixes #3802.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7228066
2013-01-31 07:49:33 -08:00
Rémy Oudompheng
354a3a1513 cmd/8l: fix misassembling of MOVB involving (AX)(BX*1)
The linker accepts MOVB involving non-byte-addressable
registers, by generating XCHG instructions to AX or BX.
It does not handle the case where nor AX nor BX are available.

See also revision 1470920a2804.

Assembling
    TEXT ·Truc(SB),7,$0
    MOVB BP, (BX)(AX*1)
    RET

gives before:
   08048c60 <main.Truc>:
    8048c60:       87 dd         xchg   %ebx,%ebp
    8048c62:       88 1c 03      mov    %bl,(%ebx,%eax,1)
    8048c65:       87 dd         xchg   %ebx,%ebp
    8048c67:       c3            ret

and after:
   08048c60 <main.Truc>:
    8048c60:       87 cd         xchg   %ecx,%ebp
    8048c62:       88 0c 03      mov    %cl,(%ebx,%eax,1)
    8048c65:       87 cd         xchg   %ecx,%ebp
    8048c67:       c3            ret

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7226066
2013-01-31 08:52:46 +01:00
Rémy Oudompheng
73b83a228e cmd/gc: inlining of variadic functions.
R=rsc, lvd, golang-dev, kardianos
CC=golang-dev
https://golang.org/cl/7093050
2013-01-31 08:40:59 +01:00
Anthony Martin
6d2d2ae4d9 cmd/go: fix build -n for cgo enabled packages
R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7095067
2013-01-30 15:09:34 -08:00
Anthony Martin
e7ef3b6daf cmd/gc: support GNU Bison 2.7 in bisonerrors
R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7235064
2013-01-30 15:06:35 -08:00
Brad Fitzpatrick
7e9f00c80c cmd/godoc: fix buggy use of strings.HasSuffix
This code never worked. Maybe it's not necessary?

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7225070
2013-01-30 12:30:26 -08:00
Rémy Oudompheng
fc7b75f216 cmd/gc: fix export data for aggressive inlining.
Export data was broken after revision 6b602ab487d6
when -l is specified at least 3 times: it makes the compiler
write out func (*T).Method() declarations in export data, which
is not supported.

Also fix the formatting of recover() in export data. It was
not treated like panic() and was rendered as "<node RECOVER>".

R=golang-dev, lvd, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7067051
2013-01-30 21:10:19 +01:00
Daniel Morsing
ba05a43608 cmd/gc: Error out on division by constant zero.
Fixes #4264.

R=cldorian, rsc
CC=golang-dev
https://golang.org/cl/6845113
2013-01-30 20:21:08 +01:00
Russ Cox
e6861d8c34 cmd/5l: reestablish uniform union field naming
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7226063
2013-01-30 09:10:06 -08:00
Elias Naur
3bdeaf2a64 6l/5l: PIC and shared library support for the linkers.
Added the -shared flag to 5l/6l to output a PIC executable with the required
dynamic relocations and RIP-relative addressing in machine code.
Added dummy support to 8l to avoid compilation errors

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

and

https://groups.google.com/d/topic/golang-nuts/P05BDjLcQ5k/discussion

R=rsc, iant
CC=golang-dev
https://golang.org/cl/6926049
2013-01-30 08:46:56 -08:00
Russ Cox
6adbc545f6 cmd/dist: fix code example in README
Fixes #4729.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7232060
2013-01-30 08:46:50 -08:00
James Gray
dab268fac3 cmd/cgo: allow for stdcall decorated dynimport names
To allow for stdcall decorated names on Windows, two changes were needed:
1. Change the symbol versioning delimiter '@' in cgo's dynimport output to a '#', and in cmd/ld when it parses dynimports.
2. Remove the "@N" decorator from the first argument of cgo's dynimport output (PE only).

Fixes #4607.

R=minux.ma, adg, rsc
CC=golang-dev
https://golang.org/cl/7047043
2013-01-30 08:29:33 -08:00
Rodrigo Rafael Monti Kochenburger
6073176512 cmd/vet: detect misuse of atomic.Add*
Re-assigning the return value of an atomic operation to the same variable being operated is a common mistake:

x = atomic.AddUint64(&x, 1)

Add this check to go vet.

Fixes #4065.

R=dvyukov, golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/7097048
2013-01-30 07:57:11 -08:00
Akshat Kumar
c74f3c4576 runtime: add support for panic/recover in Plan 9 note handler
This change also resolves some issues with note handling: we now make
sure that there is enough room at the bottom of every goroutine to
execute the note handler, and the `exitstatus' is no longer a global
entity, which resolves some race conditions.

R=rminnich, npe, rsc, ality
CC=golang-dev
https://golang.org/cl/6569068
2013-01-30 02:53:56 -08:00
Gustavo Franco
56517aed95 cmd/go: add helpful error message when vcs is not found.
Fixes #4652.

R=bradfitz, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7094049
2013-01-29 08:20:43 -08:00
Carl Shapiro
10da526069 cmd/gc: document more of the declaration context enumeration
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7231051
2013-01-28 16:57:36 -08:00
Brad Fitzpatrick
0e1305abc2 cmd/api: normalize byte to uint8 and rune to int32
R=golang-dev, adg, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7195049
2013-01-28 16:45:45 -08:00
Carl Shapiro
1c6b6b125e cmd/ld: avoid a segfault when dumping the symbol table
The dumping routine incorrectly assumed that all incoming
symbols would be non-nil and load through it to retrieve the
symbol name.  Instead of using the symbol to retrieve a name,
use the name provided by the caller.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7224043
2013-01-28 15:47:25 -08:00
Dave Cheney
c48f7d6b8a cmd/go: add missing tests
These changes to test.bash were intended to be submitted with CL 6941058, but were accidentally excluded from the original CL.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7232043
2013-01-25 23:07:21 -05:00
Brad Fitzpatrick
93d92d51dd cmd/api: fix type scrubbing
It wasn't removing names from func parameters for func types,
and it was handling "a, b string" as "string", not "string, string".

Fixes #4688

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7181051
2013-01-22 14:29:38 -08:00
Anthony Martin
e6e60cda12 cmd/go: suppress extraneous newlines in list
Before:
$ go list -f '{{range .Deps}}{{println $.Name .}}{{end}}' math time
math runtime
math unsafe

time errors
time runtime
time sync
time sync/atomic
time syscall
time unsafe

$

After:
$ go list -f '{{range .Deps}}{{println $.Name .}}{{end}}' math time
math runtime
math unsafe
time errors
time runtime
time sync
time sync/atomic
time syscall
time unsafe
$

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7130052
2013-01-22 17:05:13 -05:00
Dustin Shields-Cloues
a61dcef232 cmd/go: add hg ssh support
R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/7133048
2013-01-22 14:43:37 -05:00
Shenghou Ma
faaa7c07d7 cmd/cgo: doc updates
1. note that to use C.free <stdlib.h> must be included
2. can also extract errno from a void C function

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6935045
2013-01-22 02:52:34 +08:00
Shenghou Ma
e00c9f0dbb cmd/5l: move offset2 into Adr.u0 union to save 4/8 bytes for Adr/Prog resp.
sizeof(Adr) from 24 bytes down to 20 bytes.
sizeof(Prog) from 84 bytes down to 76 bytes.

5l linking cmd/godoc statistics:
Before:
Maximum resident set size (kbytes): 106668
After:
Maximum resident set size (kbytes):  99412

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7100059
2013-01-22 02:50:27 +08:00
Dave Cheney
9b568ef2b8 cmd/5l: reduce the size of Prog and Sym
Prog
* Remove the unused Prog* dlink
* note that align is also unused, but removing it does not help due to alignment issues.

Saves 4 bytes, sizeof(Prog): 84 => 80.

Sym
* Align {u,}char fields on word boundaries

Saves 4 bytes, sizeof(Sym): 136 => 132.

Tested on linux/arm and freebsd/arm.

R=minux.ma, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/7106050
2013-01-20 20:14:24 +11:00
Anthony Martin
42c86828b1 cmd/api: sort features
R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7141062
2013-01-19 22:20:46 -08:00
Dave Cheney
254caaf90b cmd/8l, cmd/6l: avoid zeroing zeroed fields
mal() returns zeroed memory, so zeroing these fields is redundant.

R=golang-dev, bradfitz, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7096049
2013-01-19 20:23:25 +11:00
Anthony Martin
2bddbf5e8f cmd/8g, cmd/dist, cmd/gc: fix warnings on Plan 9
cmd/8g/gsubr.c: unreachable code
cmd/8g/reg.c: overspecifed class
cmd/dist/plan9.c: unused parameter
cmd/gc/fmt.c: stkdelta is now a vlong
cmd/gc/racewalk.c: used but not set

R=golang-dev, seed, rsc
CC=golang-dev
https://golang.org/cl/7067052
2013-01-18 19:08:00 -08:00
Anthony Martin
60826e0be6 cmd/6c, cmd/8c: fix print format for Prog
The FmtLong flag should only be used with the %D verb
when printing an ATEXT Prog. It was erroneously used
for every Prog except ADATA. This caused a preponderance
of exclamation points, "!!", in the assembly listings.

I also cleaned up the code so that the list.c files look
very similar. Now the real differences are easily spotted
with a simple diff.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7128045
2013-01-18 19:00:38 -08:00
Matthew Dempsky
bb192d1399 cmd/6c: Optimize rotate expressions to use rotate instructions.
For simplicity, only recognizes expressions of the exact form
"(x << a) | (x >> b)" where x is a variable and a and b are
integer constant expressions that add to x's bit width.

Fixes #4629.

$ cat rotate.c
unsigned int
rotate(unsigned int x)
{
        x = (x << 3) | (x >> (sizeof(x) * 8 - 3));
        return x;
}

## BEFORE
$ go tool 6c -S rotate.c
(rotate.c:2)	TEXT	rotate+0(SB),$0-8
(rotate.c:2)	MOVL	x+0(FP),!!DX
(rotate.c:4)	MOVL	DX,!!AX
(rotate.c:4)	SALL	$3,!!AX
(rotate.c:4)	MOVL	DX,!!CX
(rotate.c:4)	SHRL	$29,!!CX
(rotate.c:4)	ORL	CX,!!AX
(rotate.c:5)	RET	,!!
(rotate.c:5)	RET	,!!
(rotate.c:5)	END	,!!

## AFTER
$ go tool 6c -S rotate.c
(rotate.c:2)	TEXT	rotate+0(SB),$0-8
(rotate.c:4)	MOVL	x+0(FP),!!AX
(rotate.c:4)	ROLL	$3,!!AX
(rotate.c:5)	RET	,!!
(rotate.c:5)	RET	,!!
(rotate.c:5)	END	,!!

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/7069056
2013-01-18 17:29:53 -05:00
Daniel Morsing
c0d9bf5650 cmd/gc: more robust checking of OIND nodes.
Fixes #4610.

R=golang-dev, remyoudompheng, rsc
CC=golang-dev, nigeltao
https://golang.org/cl/7058057
2013-01-18 22:46:10 +01:00
Rémy Oudompheng
1d6eb2e9fa cmd/gc: fix handling of struct padding in hash/eq.
The test case of issue 4585 was not passing due to
miscalculation of memequal args, and the previous fix
does not handle padding at the end of a struct.

Handling of padding at end of structs also fixes the case
of [n]T where T is such a padded struct.

Fixes #4585.
(again)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7133059
2013-01-18 22:40:32 +01:00
Carl Shapiro
47568c747d cmd/5a, cmd/5c, cmd/6a, cmd/6c, cmd/8a, cmd/8c, cmd/ld: update reference
Reference the 80386 compiler documentation now that the
documentation for the 68020 is offline.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7127053
2013-01-18 13:39:53 -08:00
Rémy Oudompheng
d127ed5378 cmd/gc, cmd/6g: fix error on large stacks.
Fixes #4666.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7141047
2013-01-18 22:36:43 +01:00
Matthew Dempsky
41ec481a53 cmd/6c: Improve peep hole optimization of rotate and shift instructions.
Update #4629.

$ cat shift2.c
unsigned int
shift(unsigned int x, unsigned int y)
{
        x = (x << 3);
        y = (y << 5);
        x = (x << 7);
        y = (y << 9);
        return x ^ y;
}

## BEFORE
$ go tool 6c -S shift2.c
(shift2.c:2)	TEXT	shift+0(SB),$0-8
(shift2.c:4)	MOVL	x+0(FP),!!AX
(shift2.c:4)	SALL	$3,!!AX
(shift2.c:4)	MOVL	AX,!!DX
(shift2.c:5)	MOVL	y+4(FP),!!AX
(shift2.c:5)	SALL	$5,!!AX
(shift2.c:5)	MOVL	AX,!!CX
(shift2.c:6)	MOVL	DX,!!AX
(shift2.c:6)	SALL	$7,!!AX
(shift2.c:6)	MOVL	AX,!!DX
(shift2.c:7)	MOVL	CX,!!AX
(shift2.c:7)	SALL	$9,!!AX
(shift2.c:7)	MOVL	AX,!!CX
(shift2.c:8)	MOVL	DX,!!AX
(shift2.c:8)	XORL	CX,!!AX
(shift2.c:8)	RET	,!!
(shift2.c:8)	RET	,!!
(shift2.c:8)	END	,!!

## AFTER
$ go tool 6c -S shift2.c
(shift2.c:2)	TEXT	shift+0(SB),$0-8
(shift2.c:4)	MOVL	x+0(FP),!!AX
(shift2.c:4)	SALL	$3,!!AX
(shift2.c:5)	MOVL	y+4(FP),!!CX
(shift2.c:5)	SALL	$5,!!CX
(shift2.c:6)	SALL	$7,!!AX
(shift2.c:7)	SALL	$9,!!CX
(shift2.c:8)	XORL	CX,!!AX
(shift2.c:8)	RET	,!!
(shift2.c:8)	RET	,!!
(shift2.c:8)	END	,!!

R=rsc, minux.ma, dave, nigeltao
CC=golang-dev
https://golang.org/cl/7066055
2013-01-18 16:33:25 -05:00
Rémy Oudompheng
dfdfba14b9 cmd/gc: allow registerization of temporaries created by inlining.
Names beginning with a dot are ignored by optimizers.

R=rsc, lvd, golang-dev, dave
CC=golang-dev
https://golang.org/cl/7098049
2013-01-18 22:25:17 +01:00
Russ Cox
f579faa69d cmd/go: diagnose un-bootstrapped runtime
Fixes #4665.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7132057
2013-01-18 16:24:00 -05:00
Anthony Martin
0c026c45b4 cmd/dist: update for new flag parsing on Plan 9
R=golang-dev, seed, rsc
CC=golang-dev
https://golang.org/cl/7069053
2013-01-18 15:19:51 -05:00
Russ Cox
d795f07718 build: change GO386=sse to GO386=sse2
sse2 is a more precise description of the requirement,
and it matches what people will see in, for example
        grep sse2 /proc/cpuinfo # linux
        sysctl hw.optional.sse2 # os x

R=golang-dev, dsymonds, iant
CC=golang-dev
https://golang.org/cl/7057050
2013-01-18 15:10:36 -05:00
Rémy Oudompheng
2ad57b4583 cmd/gc: don't hash nor compare struct padding or blank fields.
Fixes #4585.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/7142052
2013-01-18 18:26:43 +01:00
Shenghou Ma
d46d0f15a7 all: remove exec bit on files
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7128048
2013-01-18 02:41:17 +08:00