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

5005 Commits

Author SHA1 Message Date
Shenghou Ma
41d75933d7 cmd/ld: fix operator precedence
LGTM=rsc
R=gobot, dave
CC=golang-codereviews, iant, rsc
https://golang.org/cl/114420043
2014-08-16 14:04:15 +10:00
Henning Schmiedehausen
7eba885ba5 cmd/dist: goc2c ignores GOROOT_FINAL
When building golang, the environment variable GOROOT_FINAL can be set
to indicate a different installation location from the build
location. This works fine, except that the goc2c build step embeds
line numbers in the resulting c source files that refer to the build
location, no the install location.

This would not be a big deal, except that in turn the linker uses the
location of runtime/string.goc to embed the gdb script in the
resulting binary and as a net result, the debugger now complains that
the script is outside its load path (it has the install location
configured).

See https://code.google.com/p/go/issues/detail?id=8524 for the full
description.

Fixes #8524.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/128230046
2014-08-15 15:19:02 -07:00
Rob Pike
ab0b0d9031 cmd/go: fix a couple of errors found by "go vet"
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/127410043
2014-08-15 12:35:01 -07:00
Matthew Dempsky
7f40e5e6e5 cmd/gc: disallow pointer constants
Fixes #7760.

LGTM=iant
R=iant, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/130720043
2014-08-15 11:33:31 -07:00
Matthew Dempsky
ba30c082c0 cmd/cgo: check for compiler errors in the C preamble
E.g., here's the new "go build" output:

$ go build misc/cgo/errors/issue8442.go
# command-line-arguments
could not determine kind of name for C.issue8442foo

gcc errors for preamble:
misc/cgo/errors/issue8442.go:11:19: error: unknown type name 'UNDEF'

Fixes #8442.

LGTM=iant
R=iant, alex.brainman
CC=golang-codereviews
https://golang.org/cl/129160043
2014-08-14 09:21:58 -07:00
Matthew Dempsky
078a9cbc6c cmd/cgo, debug/dwarf: fix translation of zero-size arrays
In cgo, now that recursive calls to typeConv.Type() always work,
we can more robustly calculate the array sizes based on the size
of our element type.

Also, in debug/dwarf, the decision to call zeroType is made
based on a type's usage	within a particular struct, but dwarf.Type
values are cached in typeCache, so the modification might affect
uses of the type in other structs.  Current compilers don't appear
to share DWARF type entries for "[]foo" and "[0]foo", but they also
don't consistently share type entries in other cases.  Arguably
modifying the types is an improvement in some cases, but varying
translated types according to compiler whims seems like a bad idea.

Lastly, also in debug/dwarf, zeroType only needs to rewrite the
top-level dimension, and only if the rest of the array size is
non-zero.

Fixes #8428.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/127980043
2014-08-13 11:16:30 -07:00
Thiago Fransosi Farina
aa549ce449 cmd/dist: Reuse streq whenever possible.
Basically this cleanup replaces all the usage usages of strcmp() == 0,
found by the following command line:

$ grep -R strcmp cmd/dist | grep "0"

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/123330043
2014-08-13 06:47:30 -07:00
Rob Pike
8bca148a3e all: copy cmd/ld/textflag.h into pkg/GOOS_GOARCH
The file is used by assembly code to define symbols like NOSPLIT.
Having it hidden inside the cmd directory makes it hard to access
outside the standard repository.
Solution: As with a couple of other files used by cgo, copy the
file into the pkg directory and add a -I argument to the assembler
to access it. Thus one can write just
        #include "textflag.h"
in .s files.

The names in runtime are not updated because in the boot sequence the
file has not been copied yet when runtime is built. All other .s files
in the repository are updated.

Changes to doc/asm.html, src/cmd/dist/build.c, and src/cmd/go/build.go
are hand-made. The rest are just the renaming done by a global
substitution. (Yay sam).

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/128050043
2014-08-12 17:04:45 -07:00
Russ Cox
ce35994d4e cmd/6c, cmd/6g: avoid address-as-constant in amd64 instructions
This allows implementing address-of-global
as a pc-relative address instead of as a
32-bit integer constant.

LGTM=rminnich, iant
R=golang-codereviews, rminnich, iant
CC=golang-codereviews
https://golang.org/cl/128070045
2014-08-12 19:53:11 -04:00
Russ Cox
3763a395b2 cmd/go: adjust import comment error
Fixes #7453.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/127210043
2014-08-12 19:52:04 -04:00
Russ Cox
9abf0b6e9f cmd/ld: handle large link base addresses
codeblk and datblk were truncating their
arguments to int32. Don't do that.

LGTM=dvyukov, rminnich
R=iant, dvyukov, rminnich
CC=golang-codereviews
https://golang.org/cl/126050043
2014-08-12 17:41:16 -04:00
Russ Cox
0c6146711c cmd/go, go/build: implement import comment checking
See golang.org/s/go14customimport for design.

Added case to deps_test to allow go/build to import regexp.
Not a new dependency, because go/build already imports go/doc
which imports regexp.

Fixes #7453.

LGTM=r
R=r, josharian
CC=golang-codereviews
https://golang.org/cl/124940043
2014-08-12 17:41:03 -04:00
Matthew Dempsky
11016f62d8 cmd/cgo: make C function pointers non-assignable
Fixes #7757.
Fixes #8488.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/118690044
2014-08-12 12:55:12 -07:00
Thiago Fransosi Farina
e4d4787581 dist: Make vaddn private to buf.c
This function does not have a declaration/prototype in a.h, and it is used only
in buf.c, so it is local to it and thus can be marked as private by adding
'static' to it.

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/122300043
2014-08-12 07:49:10 -07:00
Matthew Dempsky
31a996edb6 cmd/cgo: fix default alignment for empty structs
Fixes #5242.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/125120043
2014-08-11 22:10:17 -07:00
Matthew Dempsky
03e6a88ef0 cmd/cgo: iterate over names in deterministic order
This makes GCC behavior (and cgo build failures) deterministic.

Fixes #8487.

Ran this shell command on linux/amd64 (Ubuntu 12.04) before and
after this change:

    for x in `seq 100`; do
      go tool cgo -debug-gcc=true issue8441.go 2>&1 | md5sum
    done | sort | uniq -c

Before:
    67 2cdcb8c7c4e290f7d9009abc581b83dd  -
    10 9a55390df94f7cec6d810f3e20590789  -
    10 acfad22140d43d9b9517bbc5dfc3c0df  -
    13 c337f8fee2304b3a8e3158a4362d8698  -

After:
    100 785c316cbcbcd50896695050e2fa23c1  -

LGTM=minux, iant
R=golang-codereviews, bradfitz, minux, iant
CC=golang-codereviews
https://golang.org/cl/126990043
2014-08-11 16:49:13 -07:00
Chris Manghane
897f7a31fa cmd/gc: comma-ok assignments produce untyped bool as 2nd result
LGTM=rsc
R=gri, rsc
CC=golang-codereviews
https://golang.org/cl/127950043
2014-08-11 16:11:55 -07:00
Shenghou Ma
b5674a2b72 cmd/8g: fix build
Fixes #8510.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/129720043
2014-08-11 17:11:31 -04:00
Russ Cox
5b63ce4e19 cmd/6g, cmd/8g: fix, test byte-sized magic multiply
Credit to Rémy for finding and writing test case.

Fixes #8325.

LGTM=r
R=golang-codereviews, r
CC=dave, golang-codereviews, iant, remyoudompheng
https://golang.org/cl/124950043
2014-08-11 15:24:36 -04:00
Matthew Dempsky
eae9fee3bf cmd/link: fix zig-zag decoding
The >>1 shift needs to happen before converting to int32, otherwise
large values will decode with an incorrect sign bit.

The <<31 shift can happen before or after, but before is consistent
with liblink and the go12symtab doc.

Bug demo at http://play.golang.org/p/jLrhPUakIu

LGTM=rsc
R=golang-codereviews, minux, rsc
CC=golang-codereviews
https://golang.org/cl/119630043
2014-08-11 13:53:38 -04:00
Mikio Hara
21f7d83ffd cmd/go: fix build in airplane mode
LGTM=iant
R=golang-codereviews, adg, iant
CC=golang-codereviews
https://golang.org/cl/122190043
2014-08-08 16:20:20 +09:00
Andrew Gerrand
10c2f56bf9 cmd/go: download test dependencies of all named packages
Fixes #8181.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/123870043
2014-08-08 08:56:40 +10:00
Ian Lance Taylor
750bf48a5a cmd/go: don't pass --buildid=none on OpenBSD
According to the OpenBSD builder, it doesn't work.

TBR=bradfitz
CC=golang-codereviews
https://golang.org/cl/126830043
2014-08-07 15:05:20 -07:00
Keith Randall
7aa4e5ac5f runtime: convert equality functions to Go
LGTM=rsc
R=rsc, khr
CC=golang-codereviews
https://golang.org/cl/121330043
2014-08-07 14:52:55 -07:00
Keith Randall
483cb61921 runtime: convert interface routines from C to Go.
LGTM=dvyukov
R=golang-codereviews, dave, bradfitz, dvyukov, khr
CC=golang-codereviews
https://golang.org/cl/98510044
2014-08-07 13:58:42 -07:00
Ian Lance Taylor
5ecbdb049b cmd/go: don't pass --buildid=none on FreeBSD
According to the FreeBSD builder, it doesn't work.

TBR=bradfitz
CC=golang-codereviews
https://golang.org/cl/121400043
2014-08-07 13:51:29 -07:00
Ian Lance Taylor
7fdb0292a5 cmd/go: pass --build-id=none when generating a cgo .o
Some systems, like Ubuntu, pass --build-id when linking.  The
effect is to put a note in the output file.  This is not
useful when generating an object file with the -r option, as
it eventually causes multiple build ID notes in the final
executable, all but one of which are for tiny portions of the
file and are therefore useless.

Disable that by passing an explicit --build-id=none when
linking with -r on systems that might do this.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/119460043
2014-08-07 12:38:39 -07:00
Russ Cox
08033f9816 cmd/addr2line, cmd/nm: factor object reading into cmd/internal/objfile
To do in another CL: make cmd/objdump use cmd/internal/objfile too.

There is a package placement decision in this CL:
cmd/internal/objfile instead of internal/objfile.
I chose to put internal under cmd to make clear (and enforce)
that no standard library packages should use this
(it's a bit dependency-heavy).

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/123910043
2014-08-07 12:33:06 -04:00
Andrew Gerrand
fad69a7b77 cmd/fix: mention -help instead of the non-existent -? flag
Update #8314

TBR=r
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/123890043
2014-08-07 23:24:32 +10:00
Peter Collingbourne
e03bce158f cmd/cc, runtime: eliminate use of the unnamed substructure C extension
Eliminating use of this extension makes it easier to port the Go runtime
to other compilers. This CL also disables the extension in cc to prevent
accidental use.

LGTM=rsc, khr
R=rsc, aram, khr, dvyukov
CC=axwalk, golang-codereviews
https://golang.org/cl/106790044
2014-08-07 09:00:02 -04:00
Russ Cox
689995a73e cmd/gc: remove ignored debugging arguments in Fconv print
LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/123880043
2014-08-07 08:17:41 -04:00
Russ Cox
fef54b22f8 cmd/go: revise disallowInternal
This fixes two problems: x/internal/y/z was using parent = x/internal/y instead of x,
and hasPathPrefix only looks at /, not \ for Windows.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/121280045
2014-08-06 17:59:30 -04:00
Russ Cox
1338f327b2 cmd/go: implement 'internal' convention
See golang.org/s/go14internal for design.

LGTM=r
R=r, adg
CC=golang-codereviews
https://golang.org/cl/120600043
2014-08-06 16:45:06 -04:00
Keith Randall
ea3ac6ba75 runtime: shorten hash declarations
LGTM=iant
R=dvyukov, iant
CC=golang-codereviews
https://golang.org/cl/117680044
2014-08-06 13:42:00 -07:00
Russ Cox
7aa3031eba cmd/gc: make liveness ~10x faster
1) The arrayindexof lookup function is O(n). Replace with O(1) lookups.

2) The checkptxt function is O(n²) and is purely for debugging.
Only run when the debugging flags are turned on.

3) Iterating over sparse bitmaps can be done faster word by word.
Introduce and use bvnext for that.

Run times before and after, on my 2.5 GHz Core i5 MacBook Pro.

x.go       9.48  0.84  issue 8259

x100.go    0.01  0.01  issue 8354
x1000.go   0.10  0.10
x2000.go   0.62  0.19
x3000.go   1.33  0.34
x4000.go   2.29  0.49
x5000.go   3.89  0.67
x6000.go   5.00  0.90
x7000.go   6.70  1.13
x8000.go   9.44  1.38
x9000.go  11.23  1.87
x10000.go 13.78  2.09

Fixes #8259.
Fixes #8354.

LGTM=iant, r
R=golang-codereviews, iant, r
CC=golang-codereviews
https://golang.org/cl/125720043
2014-08-06 15:46:33 -04:00
Matthew Dempsky
2b9f3fcead cmd/cgo: consistently map void* to *byte under -{c,go}defs
Fixes #8478.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/122150043
2014-08-06 10:28:19 -07:00
David du Colombier
de1ab89f03 dist: fix Plan 9 build
Since CL 115060044, mkanames declares an empty
array in anames8.c and anames6.c, which is not
valid for the Plan 9 compiler.

char* cnames8[] = {
};

This change makes mkanames not declaring the
cnames array when no C_ constants are found.

LGTM=iant
R=minux, iant
CC=golang-codereviews
https://golang.org/cl/117680043
2014-08-06 06:11:41 -07:00
Shenghou Ma
6503d40051 undo CL 114420043 / b613f2acdf69
Broke freebsd/amd64 due to exposure of a latent bug.

««« original CL description
cmd/ld: fix operator precedence

LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/114420043
»»»

TBR=dfc
R=dave
CC=golang-codereviews
https://golang.org/cl/120630043
2014-08-06 02:07:31 -04:00
Shenghou Ma
d69d0fe92b liblink, cmd/dist, cmd/5l: introduce %^ and move C_* constants.
The helps certain diagnostics and also removed duplicated enums as a side effect.

LGTM=dave, rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/115060044
2014-08-06 00:31:22 -04:00
Shenghou Ma
ae027f52fe cmd/cc, cmd/gc: set ctxt->debugvlog with debug['v']
LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/118610043
2014-08-06 00:27:14 -04:00
Shenghou Ma
45bd2f8c45 cmd/5l, cmd/6l, cmd/8l, cmd/ld: remove unused code, consolidate enums
LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/120220043
2014-08-06 00:25:52 -04:00
Shenghou Ma
2c181f0355 cmd/ld: fix operator precedence
LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/114420043
2014-08-06 00:25:05 -04:00
Matthew Dempsky
0da4b2dbc2 cmd/cgo: fix recursive type mapping
Instead of immediately completing pointer type mappings, add them to
a queue to allow them to be completed later.  This fixes issues	caused
by Type() returning arbitrary in-progress type mappings.

Fixes #8368.
Fixes #8441.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/122850043
2014-08-05 18:16:56 -07:00
Matthew Dempsky
f7a8adbd51 cmd/cgo: fix handling of defs_linux.go
Instead of including <sys/types.h> to get size_t, instead include
the ISO C standard <stddef.h> header, which defines fewer additional
types at risk of colliding with the user code.  In particular, this
prevents collisions between <sys/types.h>'s userspace definitions with
the kernel definitions needed by defs_linux.go.

Also, -cdefs mode uses #pragma pack, so we can keep misaligned fields.

Fixes #8477.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/120610043
2014-08-05 18:12:32 -07:00
Ian Lance Taylor
f2f17c0ff2 cmd/cgo: for -godefs, promote first field of anonymous union
Update #6677

When a struct contains an anonymous union, use the type and
name of the first field in the union.

This should make the glibc <sys/resource.h> file work; in that
file struct rusage has fields like

__extension__ union
{
        long int ru_maxrss;
        __syscall_slong_t __ru_maxrss_word;
};

in which the field that matters is ru_maxrss and
__ru_maxrss_word just exists to advance to the next field on
systems where the kernel uses long long fields but userspace
expects long fields.

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/106260044
2014-08-05 17:10:15 -07:00
Dmitriy Vyukov
81674f3135 runtime: remove type.go
We have an autogenerated version in zruntime_defs.
I am not sure what are the consequences as gdb never printed any values for me.
But it looks unnecessary to manually duplicate it.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, iant, khr
https://golang.org/cl/115660043
2014-08-05 22:32:24 +04:00
Peter Collingbourne
fe513d8b3e cmd/go: use correct link flags if main package contains C++/ObjC files
LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/117470043
2014-08-01 16:45:33 -07:00
Keith Randall
668a55a882 runtime: move constants from map header to map type
A good cleanup anyway, and it makes some room for an additional
field needed for issue 8412.

Update #8412

LGTM=iant
R=iant, khr
CC=golang-codereviews
https://golang.org/cl/112700043
2014-08-01 14:38:56 -07:00
Keith Randall
a2a9768414 runtime: convert hash functions to Go calling convention.
Create proper closures so hash functions can be called
directly from Go.  Rearrange calling convention so return
value is directly accessible.

LGTM=dvyukov
R=golang-codereviews, dvyukov, dave, khr
CC=golang-codereviews
https://golang.org/cl/119360043
2014-07-31 15:07:05 -07:00
Keith Randall
cc9ec52d73 runtime: convert slice operations to Go.
LGTM=bradfitz, dvyukov
R=golang-codereviews, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/120190044
2014-07-31 12:43:40 -07:00