As in:
const format = "%s"
fmt.Printf(format, "hi")
Also fix a couple of bugs by rewriting the routine.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6099057
This leads to ~30kB improvement on code size for ARM machines with VFP/NEON.
Example: go test -c math
GOARM=5 GOARM=6
Old: 1884200 1839144
New: 1884165 1805245
-: 35 33899
R=rsc, bradfitz, dave, kai.backman
CC=golang-dev
https://golang.org/cl/5975060
Without an explicit signal for a truncation, copy propagation
will sometimes propagate a 32-bit truncation and end up
overwriting uses of the original 64-bit value.
The case that arose in practice is in C but I believe
that the same could plausibly happen in Go.
The main reason we didn't run into the same in Go
is that I (perhaps incorrectly?) drop MOVL AX, AX
during gins, so the truncation was never generated, so
it didn't confuse the optimizer.
Fixes#1315.
Fixes#3488.
R=ken2
CC=golang-dev
https://golang.org/cl/6002043
Assignment of a computed uint64 value to an
address derived with a function call was executing
the call after computing the value, which trashed
the value (held in registers).
long long *f(void) { return 0; }
void g(int x, int y) {
*f() = (long long)x | (long long)y<<32;
}
Before:
(x.c:3) TEXT g+0(SB),(gok(71))
...
(x.c:4) ORL AX,DX
(x.c:4) ORL CX,BX
(x.c:4) CALL ,f+0(SB)
(x.c:4) MOVL DX,(AX)
(x.c:4) MOVL BX,4(AX)
After:
(x.c:3) TEXT g+0(SB),(gok(71))
(x.c:4) CALL ,f+0(SB)
...
(x.c:4) ORL CX,BX
(x.c:4) ORL DX,BP
(x.c:4) MOVL BX,(AX)
(x.c:4) MOVL BP,4(AX)
Fixes#3501.
R=ken2
CC=golang-dev
https://golang.org/cl/5998043
On windows Mercurial installed with easy_install typically creates
an hg.bat batch file in Python Scripts directory, which cannot be used
with CreateProcess unless full path is specified. Work around by
launching hg via cmd.exe /c.
Additionally, fix a rare FormatMessageW crash.
Fixes#3093.
R=golang-dev, rsc, alex.brainman, aram, jdpoirier, mattn.jp
CC=golang-dev
https://golang.org/cl/5937043
Before, "go get -v foo/bar" was assuming "foo" was a hostname
and trying to perform discovery on it. Now, require a dot in
the first path component (the hostname).
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5981057
"go1" dominates. Delete the text about weekly and release.
We can revisit this once the situation changes.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5969043
Another attempt at https://golang.org/cl/5754088.
Before, we only consulted $GOBIN for source code
found in $GOROOT, but that's confusing to explain
and less useful. The new behavior lets users set
GOBIN=$HOME/bin and have all go-compiled binaries
installed there.
Tested a few cases in test.bash.
Ran all.bash with and without $GOBIN and it works.
Even so, I expect it to break the builders,
like it did last time, we can debug from there.
Fixes#3269 (again).
Fixes#3396.
Fixes#3397.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5927051
Issue 3207 was caused by setting GOPATH=GOROOT.
This is a common mistake, so diagnose it at command start
and also correct the bug that it caused in get (downloading
to GOROOT/src/foo instead of GOROOT/src/pkg/foo).
Issue 3268 was caused by recognizing 'packages' that
had installed binaries but no source. This behavior is not
documented and causes trouble, so remove it. We can
revisit the concept of binary-only packages after Go 1.
Fixes#3207.
Fixes#3268.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5930044
In a browser with many open tabs, the tab titles become short
and uninformative because they all start with the same prefix
("Package ", "Directory ", etc.).
Permit use of shorter tab titles that start with the relevant
information first.
Fixes#3365.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5865056
The two optimizations for small structs and arrays
were missing the implicit cast from ideal bool.
Fixes#3351.
R=rsc, lvd
CC=golang-dev
https://golang.org/cl/5848062
Adds new file api/go1.txt, locking down the current API.
Any changes to the API will need to update that file.
run.bash (but not make.bash, or Windows) will check for
accidental API changes.
R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/5820070
This makes the last error-reporting CL a bit less
aggressive. errPrintedOutput is a sentinel value
that should not be wrapped.
R=gri
CC=golang-dev
https://golang.org/cl/5845052
Fixes part of issue 3253.
We still need to support scattered relocations though.
R=golang-dev, bsiegert, rsc, iant
CC=golang-dev
https://golang.org/cl/5822050
windows cmd.exe can't show utf-8 correctly basically.
chcp 65001 may make it show, but most people don't have fonts which can
show it.
R=golang-dev, rsc, adg, gri, r
CC=golang-dev
https://golang.org/cl/5820060
A "gccgoprefix" flag is added and used by the go tool,
to mirror the -fgo-prefix flag for gccgo, whose value
is required to know how to access functions from C.
Trying to export Go methods or unexported Go functions
will not work.
Also fix go test on "main" packages.
Updates #2313.
Fixes#3262.
R=mpimenov, rsc, iant
CC=golang-dev
https://golang.org/cl/5797046
Fixes#3324.
Robert suggested not reporting errors until the end of the output.
which I'd also like to do, but errPrintedOutput makes that a bigger
change than I want to do before Go 1. This change should at least
remove the confusion we had.
# Building packages and commands for linux/amd64.
runtime
errors
sync/atomic
unicode
unicode/utf8
math
sync
unicode/utf16
crypto/subtle
io
syscall
hash
crypto
crypto/md5
hash/crc32
crypto/cipher
crypto/hmac
crypto/sha1
go install unicode: copying /tmp/go-build816525784/unicode.a to /home/rsc/g/go/pkg/linux_amd64/unicode.a: short write
hash/adler32
container/list
container/ring
...
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5837054
A node spans multiple lines if the line difference
between start and end point is > 0 (rather than > 1).
Fixes some odd cases introduced by CL 5706055;
pointed out by dsymonds.
Added corresponding test case. The other change
in the .golden file reverts to the status before
the CL mentioned above and is correct.
gofmt -w src misc changes godoc.go back to where
it was before the CL mentioned above.
Fixes#3304.
R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/5820044
Windows has paths like C:/Users/ADMIN~1. Also, it so happens
that go/parser allows ~ in import paths. So does the spec.
Fixes the build too.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5777073
For URLs ending with /, the handler did not work, trying to append
".xml" to the path.
For instance, the "Share Memory by Communicating" returned the
following error:
open /Users/francisco.souza/lib/go/doc/codewalk/sharemem/.xml: no such file or directory
R=adg, minux.ma
CC=golang-dev
https://golang.org/cl/5797065
broke builders
««« original CL description
cmd/go: respect $GOBIN always
Before, we only consulted $GOBIN for source code
found in $GOROOT, but that's confusing to explain
and less useful. The new behavior lets users set
GOBIN=$HOME/bin and have all go-compiled binaries
installed there.
Fixes#3269.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5754088
»»»
TBR=bradfitz
CC=golang-dev
https://golang.org/cl/5794065
Before, we only consulted $GOBIN for source code
found in $GOROOT, but that's confusing to explain
and less useful. The new behavior lets users set
GOBIN=$HOME/bin and have all go-compiled binaries
installed there.
Fixes#3269.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5754088
Undo CL 5783076 and apply correct fix.
The /doc hack is wrong. The code to handle this case was
already there and just needs a simple fix:
// We didn't find any directories containing Go files.
// If some directory returned successfully, use that.
- if len(all) == 0 && first != nil {
+ if !haveGo {
for _, d := range first {
haveName[d.Name()] = true
all = append(all, d)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5783079
They were necessary to produce a canonical script
when we checked in build scripts, but now they're just
getting in the way.
Fixes#3279.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5796068
The generated syscall files for Windows are still breaking "go tool api"
(unknown function []byte); I'll look at fixing that separately.
Fixes#3285.
R=bradfitz
CC=golang-dev
https://golang.org/cl/5777062
1) The -D argument should always be a pseudo-import path,
like _/Users/rsc/foo/bar, never a standard import path,
because we want local imports to always resolve to pseudo-paths.
2) Disallow local imports in non-local packages. Otherwise
everything works but you get two copies of a package
(the real one and the "local" one) in your binary.
R=golang-dev, bradfitz, yiyu.jgl
CC=golang-dev
https://golang.org/cl/5787055
So that we don't duplicate knowledge about which OS/ARCH combination
supports cgo.
Also updated src/run.bash and src/sudo.bash to use 'go env'.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5792055
1. consistent usage section (go tool xxx)
2. reformat cmd/ld document with minor correction
document which -H flags are valid on which ld
document -d flag can't be used on Windows.
document -Hwindowsgui
R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/5782043
Before:
$ go run x.go
signal 11 (core dumped)
$
After:
$ go run x.go
runtime: cgo callback on thread not created by Go.
signal 11 (core dumped)
$
For issue 3068.
Not a fix, but as much of a fix as we can do before Go 1.
R=golang-dev, rogpeppe, gri
CC=golang-dev
https://golang.org/cl/5781047
doc: convert to use godoc built-in templates
tmpltohtml is gone, to avoid having a second copy of the code.
Instead, godoc -url /doc/go1.html will print the actual HTML
served for that URL. "make" will generate files named go1.rawhtml
etc, which can be fed through tidy.
It can be hard to tell from the codereview diffs, but all the
tmpl files have been renamed to be html files and then
have "Template": true added.
R=golang-dev, adg, r, gri
CC=golang-dev
https://golang.org/cl/5782046
Was missing recompilation of packages imported only
by external test packages (package foo_test), primarily
because Root was not set, so those packages looked like
they were from a different Go tree, so they were not
recompiled if they already existed.
Also clean things up so that only one call to computeStale
is needed.
Fixes#3238.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5786048
The spec is looser than the current implementation.
The spec edit was made in CL 4444050 (May 2011)
but I never implemented it.
Fixes#3244.
R=ken2
CC=golang-dev
https://golang.org/cl/5785049
.syso files are system objects copied directly
into the package archive.
Fixes#1552.
R=alex.brainman, iant, r, minux.ma, remyoudompheng
CC=golang-dev
https://golang.org/cl/5778043
The compiler must be changed with the Set method
so that the buildToolchain gets updated too.
Fixes#3231.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5768044
$ go run
go run: no go files listed
$ go run ../../pkg/math/bits.go
go run: cannot run non-main package
$
Fixes#3168.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5755064
Either documentation or implementation
of go run's flags is wrong currently.
This change assumes the documentation
to be right.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5752054
This CL permits using arbitrary, non-VCS-qualified URLs as
aliases for fully VCS-qualified and/or well-known code hosting
sites.
Example 1) A VCS-qualified URL can now be shorter.
Before:
$ go get camlistore.org/r/p/camlistore.git/pkg/blobref
After:
$ go get camlistore.org/pkg/blobref
Example 2) A custom domain can be used as the import,
referencing a well-known code hosting site.
Before:
$ go get github.com/bradfitz/sonden
After:
$ go get bradfitz.com/pkg/sonden
The mechanism used is a <meta> tag in the HTML document
retrieved from fetching:
https://<import>?go-get=1 (preferred)
http://<import>?go-get=1 (fallback)
The meta tag should look like:
<meta name="go-import" content="import-alias-prefix vcs full-repo-root">
The full-repo-root must be a full URL root to a repository containing
a scheme and *not* containing a ".vcs" qualifier.
The vcs is one of "git", "hg", "svn", etc.
The import-alias-prefix must be a prefix or exact match of the
package being fetched with "go get".
If there are multiple meta tags, only the one with a prefix
matching the import path is used. It is an error if multiple
go-import values match the import prefix.
If the import-alias-prefix is not an exact match for the import,
another HTTP fetch is performed, at the declared root (which does
*not* need to be the domain's root).
For example, assuming that "camlistore.org/pkg/blobref" declares
in its HTML head:
<meta name="go-import" content="camlistore.org git https://camlistore.org/r/p/camlistore" />
... then:
$ go get camlistore.org/pkg/blobref
... looks at the following URLs:
https://camlistore.org/pkg/blobref?go-get=1http://camlistore.org/pkg/blobref?go-get=1https://camlistore.org/?go-get=1http://camlistore.org/?go-get=1
Ultimately it finds, at the root (camlistore.org/), the same go-import:
<meta name="go-import" content="camlistore.org git https://camlistore.org/r/p/camlistore" />
... and proceeds to trust it, checking out git //camlistore.org/r/p/camlistore at
the import path of "camlistore.org" on disk.
Fixes#3099
R=r, rsc, gary.burd, eikeon, untheoretic, n13m3y3r, rsc
CC=golang-dev
https://golang.org/cl/5660051
GOROOT_FINAL is a build parameter that means "eventually
the Go tree will be installed here". Make the file name information
match that eventual location.
Fixes#3180.
R=ken, ken
CC=golang-dev
https://golang.org/cl/5742043
The motivation for this CL is to support $GOPATH well.
Since we already have a FileSystem interface, implement a
Plan 9-style name space. Bind each of the $GOPATH src
directories onto the $GOROOT src/pkg directory: now
everything is laid out exactly like a normal $GOROOT and
needs very little special case code.
The filter files are no longer used (by us), so I think they
can just be deleted. Similarly, the Mapping code and the
FileSystem interface were two different ways to accomplish
the same end, so delete the Mapping code.
Within the implementation, since FileSystem is defined to be
slash-separated, use package path consistently, leaving
path/filepath only for manipulating operating system paths.
I kept the -path flag, but I think it can be deleted too.
Fixes#2234.
Fixes#3046.
R=gri, r, r, rsc
CC=golang-dev
https://golang.org/cl/5711058
I tried before to make relative imports work by simply
invoking the compiler in the right directory, so that
an import of ./foo could be resolved by ./foo.a.
This required creating a separate tree of package binaries
that included the full path to the source directory, so that
/home/gopher/bar.go would be compiled in
tmpdir/work/local/home/gopher and perhaps find
a ./foo.a in that directory.
This model breaks on Windows because : appears in path
names but cannot be used in subdirectory names, and I
missed one or two places where it needed to be removed.
The model breaks more fundamentally when compiling
a test of a package that lives outside the Go path, because
we effectively use a ./ import in the generated testmain,
but there we want to be able to resolve the ./ import
of the test package to one directory and all the other ./
imports to a different directory. Piggybacking on the compiler's
current working directory is then no longer possible.
Instead, introduce a new compiler option -D prefix that
makes the compiler turn a ./ import into prefix+that,
so that import "./foo" with -D a/b/c turns into import
"a/b/c/foo". Then we can invent a package hierarchy
"_/" with subdirectories named for file system paths:
import "./foo" in the directory /home/gopher becomes
import "_/home/gopher/foo", and since that final path
is just an ordinary import now, all the ordinary processing
works, without special cases.
We will have to change the name of the hierarchy if we
ever decide to introduce a standard package with import
path "_", but that seems unlikely, and the detail is known
only in temporary packages that get thrown away at the
end of a build.
Fixes#3169.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5732045
Fixes a problem Rob is having with goprotobuf.
Cannot add a test because the same case is more broken
when using ./ imports. That still needs to be fixed,
and is one aspect of issue 3169.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5725043
Also remove useless "install" argument to pkgpath now that go/build
defines package install locations.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5714059
* Install tools into tool dir always
(Fixes issue 3049. Fixes issue 2868. Fixes issue 2925.)
* Make packages depend on compiler, linker (Fixes issue 3036.)
* Do not recompile packages across roots (Fixes issue 3149.)
* Allow use of binary-only packages (Fixes issue 2775.)
* Avoid duplicate cgo dependencies (Fixes issue 3001.)
* Show less in go get -x. (Fixes issue 2926.)
* Do not force repo root for existing checkout (Fixes issue 2969.)
* Show full syntax error list always (Fixes issue 2811.)
* Clean arguments before processing (Fixes issue 3034.)
* Add flags for compiler, linker arguments (Fixes issue 2996.)
* Pass flags in make.bash (Fixes issue 3091.)
* Unify build flags, defined in one place.
* Clean up error messages (Fixes issue 3075. Fixes issue 2923.)
* Support local import paths (Fixes issue 3118.)
* Allow top-level package outside $GOPATH (Fixes issue 3009.)
In addition to these fixes, all commands now take a list of
go files as a way to specify a single package, just as go build and
go run always have. This means you can:
go list -json x.go
go fix x.go
go vet x.go
go test x_test.go
Preliminary tests in test.bash.
Mainly testing things that the ordinary build does not.
I don't mind if the script doesn't run on Windows.
I expect that gccgo support is now broken, and I hope that
people will feel free to file issues and/or send CLs to fix it. :-)
R=golang-dev, dsymonds, r, rogpeppe
CC=golang-dev
https://golang.org/cl/5708054
This is an API change, but one I have been promising would
happen when it was clear what the go command needed.
This is basically a complete replacement of what used to be here.
build.Tree is gone.
build.DirInfo is expanded and now called build.Package.
build.FindTree is now build.Import(package, srcDir, build.FindOnly).
The returned *Package contains information that FindTree returned,
but applicable only to a single package.
build.ScanDir is now build.ImportDir.
build.FindTree+build.ScanDir is now build.Import.
The new Import API allows specifying the source directory,
in order to resolve local imports (import "./foo") and also allows
scanning of packages outside of $GOPATH. They will come back
with less information in the Package, but they will still work.
The old go/build API exposed both too much and too little.
This API is much closer to what the go command needs,
and it works well enough in the other places where it is
used. Path is gone, so it can no longer be misused. (Fixes issue 2749.)
This CL updates clients of go/build other than the go command.
The go command changes are in a separate CL, to be submitted
at the same time.
R=golang-dev, r, alex.brainman, adg
CC=golang-dev
https://golang.org/cl/5713043
The two string comparison optimizations were
missing the implicit cast from ideal bool.
Fixes#3119.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5696071
They are broken and hard to make work.
They have never worked: if you import "/tmp/x"
from "/home/rsc/p.c" then the compiler rewrites
this into import "/home/rsc/tmp/x", which is
clearly wrong.
Also we just disallowed the : character in import
paths, so import "c:/foo" is already not allowed.
Finally, in order to support absolute paths well in
a build tool we'd have to provide a mechanism to
instruct the compiler to resolve absolute imports
by looking in some other tree (where the binaries live)
and provide a mapping from absolute path to location
in that tree. This CL avoids adding that complexity.
This is not part of the language spec (and should not be),
so no spec change is needed.
If we need to make them work later, we can.
R=ken2
CC=golang-dev
https://golang.org/cl/5712043
This CL mostly deletes code.
Using existing position information is
just as good to determine if a new section
is needed; no need to track exact multi-
line information. Eliminates the need to
carry around a multiLine parameter with
practically every function.
Applied gofmt -w src misc resulting in only
a minor change to godoc.go. In return, a couple
of test cases are now formatted better.
Not Go1-required, but nice-to-have as it will
simplify fixes going forward.
R=rsc
CC=golang-dev
https://golang.org/cl/5706055
Work around profiling kernel bug with signal masks.
Still broken on 64-bit Snow Leopard kernel,
but I think we can ignore that one and let people
upgrade to Lion.
Add new trivial tools addr2line and objdump to take
the place of the GNU tools of the same name, since
those are not installed on OS X.
Adapt pprof to invoke 'go tool addr2line' and
'go tool objdump' if the system tools do not exist.
Clean up disassembly of base register on amd64.
Fixes#2008.
R=golang-dev, bradfitz, mikioh.mikioh, r, iant
CC=golang-dev
https://golang.org/cl/5697066
If stdout and stderr are indeed the same file (not a tty), which is
often the case, fully-buffered stdout will make it harder to see
progresses, for example, ./make.bash 2>&1 | tee log
R=r, rsc
CC=golang-dev
https://golang.org/cl/5700070
I've elected to omit escaping the output of Marshalers for now.
I haven't thought through the implications of that;
I suspect that double escaping might be the undoing of that idea.
Fixes#3127.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5694098