Than McIntosh [Tue, 26 Mar 2019 16:02:36 +0000 (12:02 -0400)]
cmd/link: change -strictdups checking to handle mix of flags
Update the recently-added '-strictdups' sanity checking to avoid
failing the link in cases where we have objects feeding into the link
with a mix of command line flags (and in particular some with "-N" and
some without). This scenario will trigger errors/warnings due to
inlinable functions and wrapper functions that have different sizes
due to presence or lack of optimization.
Update #31034.
Change-Id: I1dd9e37c2f9bea5da0ab82e32e6fc210aebf6a65
Reviewed-on: https://go-review.googlesource.com/c/go/+/169160
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Clément Chigot [Mon, 25 Mar 2019 09:33:49 +0000 (10:33 +0100)]
cmd/link: allow buildmode c-archive for aix/ppc64
Change-Id: Ia268b0d64dc89866aa09bfffcaa109741088a904
Reviewed-on: https://go-review.googlesource.com/c/go/+/169119
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
John [Wed, 27 Mar 2019 17:30:32 +0000 (17:30 +0000)]
mime: add javascript module mime type (.mjs)
There are default mime types in this package for handling static content, but there's
a new one missing ".mjs" that is "Content-Type: text/javascript".
LE Manh Cuong [Fri, 22 Mar 2019 18:43:06 +0000 (01:43 +0700)]
cmd/compile: fix literal struct interface {} lost passing by value
CL 135377 introduces pass strings and slices to convT2{E,I} by value.
Before that CL, all types, except interface will be allocated temporary
address. The CL changes the logic that only constant and type which
needs address (determine by convFuncName) will be allocated.
It fails to cover the case where type is static composite literal.
Adding condition to check that case fixes the issue.
Also, static composite literal node implies constant type, so consttype
checking can be removed.
Fixes #30956
Change-Id: Ifc750a029fb4889c2d06e73e44bf85e6ef4ce881
Reviewed-on: https://go-review.googlesource.com/c/go/+/168858
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Clément Chigot [Mon, 25 Mar 2019 09:31:30 +0000 (10:31 +0100)]
runtime: create library startup for aix/ppc64
As .init_array section aren't available on AIX, the Go runtime
initialization is made with gcc constructor attribute.
However, as cgo tool is building a binary in order to get imported
C symbols, Go symbols imported for this initilization must be ignored.
-Wl,-berok is mandatory otherwize ld will fail to create this binary,
_rt0_aix_ppc64_lib and runtime_rt0_go aren't defined in runtime/cgo.
These two symbols must also be ignored when creating _cgo_import.go.
Change-Id: Icf2e0282f5b50de5fa82007439a428e6147efef1
Reviewed-on: https://go-review.googlesource.com/c/go/+/169118
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Clément Chigot [Tue, 26 Mar 2019 14:00:00 +0000 (15:00 +0100)]
misc/cgo: enable testso and testsovar on aix/ppc64
On AIX, shared objects must be wrapped under an archive file.
For testso, creating libcgosotest with an extern symbol isn't
AIX-friendly. By default, ld will block such behavior. Rather than
forcing ld to work as on Linux and using the run-time linking,
goCallback became a function pointer which is set by setCallback().
Updates #30565
Change-Id: I455ab32faddd41f1b0c84cc9e503788044ad49b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/169020
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
LE Manh Cuong [Mon, 11 Mar 2019 06:58:20 +0000 (13:58 +0700)]
os: reject WriteAt if file opened in append mode
WriteAt use pwrite syscall on *nix or WriteFile on Windows.
On Linux/Windows, these system calls always write to end of file in
append mode, regardless of offset parameter.
It is hard (maybe impossible) to make WriteAt work portably.
Making WriteAt returns an error if file is opened in append mode, we
guarantee to get consistent behavior between platforms, also prevent
user from accidently corrupting their data.
Elias Naur [Wed, 27 Mar 2019 13:25:24 +0000 (14:25 +0100)]
cmd/link/internal/ld: skip TLS section on Android
We don't use the TLS section on android, and dropping it avoids
complaints about underalignment from the Android Q linker.
Updates #29674
Change-Id: I91dabf2a58e6eb1783872639a6a144858db09cef
Reviewed-on: https://go-review.googlesource.com/c/go/+/169618 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ben Hoyt [Wed, 27 Mar 2019 11:36:27 +0000 (07:36 -0400)]
bytes: make TrimSpace return nil on all-space input
Issue #29122 introduced a subtle regression due to the way that
TrimFuncLeft is written: previously TrimSpace returned nil when given
an input of all whitespace, but with the #29122 changes it returned an
empty slice on all-space input.
This change adds a special case to the new, optimized TrimSpace to go
back to that behavior. While it is odd behavior and people shouldn't be
relying on these functions returning a nil slice in practice, it's not
worth the breakage of code that does.
This tweak doesn't change the TrimSpace benchmarks significantly.
Fixes #31038
Change-Id: Idb495d02b474054d2b2f593c2e318a7a6625688a
Reviewed-on: https://go-review.googlesource.com/c/go/+/169518 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Change-Id: I710c2061dfbaa8e866c92e6c824bd8df35784165
Reviewed-on: https://go-review.googlesource.com/c/go/+/169080 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Felix Bünemann [Mon, 25 Mar 2019 23:12:21 +0000 (23:12 +0000)]
crypto/x509: look for CAs at /etc/ssl/cert.pem for Alpine Linux
Alpine Linux uses /etc/ssl/cert.pem as default ca-bundle which
is preinstalled since 3.7 and was installed as part of the libressl
package in 3.5 and 3.6.
The path /etc/ssl/certs/ca-certificates.crt is only valid if the full
ca-certificates package is installed by hand, which contains all
single CA certs and uses update-ca-certificates to bundle them.
The priority for /etc/ssl/certs/ca-certificates.crt should be kept
higher than /etc/ssl/cert.pem in case the user installed custom
CA certs.
Clément Chigot [Mon, 25 Mar 2019 09:26:44 +0000 (10:26 +0100)]
runtime: improve sigtramp on aix/ppc64 to handle SIGPROF
R14, R15 must be saved in sigtramp because they might be modified by Go
code when a SIGPROF occurs.
Fixes #28555
Change-Id: I573541f108d7d6aac8e60d33c649e5db943f3ef5
Reviewed-on: https://go-review.googlesource.com/c/go/+/169117
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Dmitri Shuralyov [Thu, 21 Mar 2019 18:00:46 +0000 (14:00 -0400)]
cmd/go/internal/load: always use DefaultExecName to determine binary name
It should produce equivalent results to split on the import path of the
package rather than its directory, in GOPATH mode. That means the common
code in DefaultExecName can be used.
We're in the middle of Go 1.12 cycle, so now is a good time to make it
happen for Go 1.13.
Modify isVersionElement to accept path elements like "v2", "v3", "v10",
rather than "/v2", "/v3", "/v10". Then use it in DefaultExecName instead
of the ad-hoc isVersion function. There is no change in behavior.
Add tests for DefaultExecName and isVersionElement.
Updates #26869
Change-Id: Ic6da2c92587459aa2b327385e994b72a6e183092
Reviewed-on: https://go-review.googlesource.com/c/go/+/168678
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Matthew Dempsky [Mon, 25 Mar 2019 23:34:19 +0000 (16:34 -0700)]
cmd/compile: fix "append outside assignment" ICE
Some special-case code paths in order.go didn't expect OCALLFUNC to
have Ninit; in particular, OAS2FUNC and ODEFER/OGO failed to call
o.init on their child OCALLFUNC node. This resulted in not all of the
AST being properly ordered.
This was noticed because order is responsible for introducing an
invariant around how OAPPEND is used, which is enforced by walk.
However, there were perhaps simpler cases (e.g., simple order of
evaluation) that were being silently miscompiled.
Robert Griesemer [Mon, 18 Mar 2019 23:10:07 +0000 (16:10 -0700)]
math/big: accept non-decimal floats with Rat.SetString
This fixes an old oversight. Rat.SetString already permitted
fractions a/b where both a and b could independently specify
a base prefix. With this CL, it now also accepts non-decimal
floating-point numbers.
Jay Conrod [Thu, 21 Mar 2019 19:18:04 +0000 (15:18 -0400)]
cmd/dist: set GOPATH to internal directory during build
Since GO111MODULE=on by default, the Go command needs a location for
the module cache, even though it doesn't need to be written when
building std and cmd. If GOROOT is checked out to $HOME/go, which is
also the default location for GOPATH, this causes unnecessary problems
late in the build.
With this change, dist sets GOPATH to $GOROOT/pkg/obj/go-path. This is
next to the temporary GOCACHE, $GOROOT/pkg/obj/go-build.
Fixes #30960
Change-Id: I60771ee7f7c67ced1d2dc7c66b5885703fad1b63
Reviewed-on: https://go-review.googlesource.com/c/go/+/168697
Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
runtime: skip wb call in growslice when unnecessary
Instrumenting make.bash reveals that almost half (49.54%)
of the >16 million calls to growslice for
pointer-containing slices are
growing from an empty to a non-empty slice.
In that case, there is no need to call the write barrier,
which does some work before discovering that no pointers need shading.
Keith Randall [Tue, 15 Jan 2019 22:50:09 +0000 (14:50 -0800)]
cmd/compile: use existing instructions instead of nops for inline marks
Instead of always inserting a nop to use as the target of an inline
mark, see if we can instead find an instruction we're issuing anyway
with the correct line number, and use that instruction. That way, we
don't need to issue a nop.
sergey [Sun, 17 Feb 2019 18:29:39 +0000 (21:29 +0300)]
net/http: reduce allocs on write cookie
Pregrow buffer to reduce allocs on building cookie string.
We calc cookie name value and domain size (most distributed by value) and
add 110 extra characters allows to write most cookie attributes
without additional allocations in most cases.
Than McIntosh [Fri, 22 Mar 2019 19:24:36 +0000 (15:24 -0400)]
test: support -ldflags for "rundir" tests, new -P option
For "rundir" tests, allow users to add in linker flags as well as
compiler flags, e.g.
// rundir -m -ldflags -w
The directive above will pass "-m" to the compiler on each package compilation
and "-w" to the linker for the final link.
In addition, if "-P" is specified with 'rundir', then for each compile
pass in "-p <X>" to set the packagepath explicitly, which is closer to
how the compiler is run by 'go build'.
Than McIntosh [Fri, 22 Mar 2019 12:14:45 +0000 (08:14 -0400)]
cmd/compile: better handling for PAUTOHEAP in DWARF inline gen
When generating DWARF inline info records, the post-SSA code looks
through the original "pre-inline" dcl list for the function so as to
handle situations where formal params are promoted or optimized away.
This code was not properly handling the case where an output parameter
was promoted to the heap -- in this case the param node is converted
in place from class PPARAMOUT to class PAUTOHEAP. This caused
inconsistencies later on, since the variable entry in the abstract
subprogram DIE wound up as a local and not an output parameter.
Richard Musiol [Sun, 24 Mar 2019 17:21:11 +0000 (18:21 +0100)]
cmd/link/internal/wasm: do not generate more than 100000 data segments
Some WebAssembly runtimes (e.g. Node.js) fail to load a wasm binary if
it has more than 100000 data segments. Do not skip zero regions any more
if the limit was reached.
Petr Jediný [Sat, 23 Mar 2019 00:00:48 +0000 (00:00 +0000)]
log: expose Writer() method of the standard logger
The Go 1.12 introduced Writer() method for logger objects, but
it was not exposed as log package function for standard logger.
This commit adds such Writer() function.
Change-Id: Ia81b1524839fe05c152ecb5eaef047a076349fea
GitHub-Last-Rev: dc152ea641dd928178dbd921e2d0f6361661a0d6
GitHub-Pull-Request: golang/go#31009
Reviewed-on: https://go-review.googlesource.com/c/go/+/168920
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Daniel Martí [Wed, 20 Mar 2019 15:47:56 +0000 (15:47 +0000)]
text/template: allow using -}} with many spaces
lexSpace consumed all spaces, even if the last one was part of a right
delimiter like " -}}". Thus, "3 -}}" wouldn't lex as "3" and a right
delimiter, but as "3", "-", and "}}".
To fix that, make lexSpace stop if it encounters a right delimiter.
Fixes #30948.
Change-Id: I80a5546e5809e54f6823e2bf3a57a7e8808329be
Reviewed-on: https://go-review.googlesource.com/c/go/+/168457 Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Richard Musiol [Sat, 23 Mar 2019 13:18:19 +0000 (14:18 +0100)]
cmd/go: add GOWASM environment variable
This change adds the environment variable GOWASM, which is a comma
separated list of experimental WebAssembly features that the compiled
WebAssembly binary is allowed to use. The default is to use no
experimental features. Initially there are no features avaiable.
More information about feature proposals can be found at
https://github.com/WebAssembly/proposals
Richard Musiol [Sun, 17 Mar 2019 12:45:46 +0000 (13:45 +0100)]
src/cmd/internal/obj/wasm: optimize blocks in wasm binary
This change optimizes the blocks in the wasm binary by generating the
entryPointLoop only if it is used and adding an unwindExit block to
be able to use the short BrIf instruction for unwinding the stack.
These changes were suggested by the wasm-opt tool and reduce the
wasm binary size of "hello world" by 1.5%.
Austin Clements [Fri, 22 Mar 2019 18:18:22 +0000 (14:18 -0400)]
testing: fix fractional ns/op printing
CL 166717 changed the way ns/op benchmark results were printed and
inadvertently rounded all ns/op results down to an integer, even if
they were small enough to print with digits after the decimal place.
For example, prior to this change, we got output like
Dmitri Shuralyov [Thu, 21 Mar 2019 17:31:32 +0000 (13:31 -0400)]
cmd/go: fix the default build output name for versioned binaries
This change is a re-apply of the reverted CL 140863 with changes to
address issue #30821. Specifically, path.Split continues to be used
to split the '/'-separated import path, rather than filepath.Split.
Document the algorithm for how the default executable name is determined
in DefaultExecName.
Rename a variable returned from os.Stat from bs to fi for consistency.
CL 140863 factored out the logic to determine the default executable
name from the Package.load method into a DefaultExecName function,
and started using it in more places to avoid having to re-implement
the logic everywhere it's needed. Most previous callers already computed
the default executable name based on the import path. The load.Package
method, before CL 140863, was the exception, in that it used the p.Dir
value in GOPATH mode instead. There was a NOTE(rsc) comment that it
should be equivalent to use import path, but it was too late in Go 1.11
cycle to risk implementing that change.
This is part 1, a more conservative change for backporting to Go 1.12.2,
and it keeps the original behavior of splitting on p.Dir in GOPATH mode.
Part 2 will address the NOTE(rsc) comment and modify behavior in
Package.load to always use DefaultExecName which splits the import path
rather than directory. It is intended to be included in Go 1.13.
Fixes #27283 (again)
Updates #26869
Fixes #30821
Change-Id: Ib1ebb95acba7c85c24e3a55c40cdf48405af34f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/167503 Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reason for revert: There was a potential problem spotted in the original
fix, which resulted in it being rolled back from release-branch.go1.12
and not included in Go 1.12.1 release. We intend to improve the fix and
include it in Go 1.12.2 instead. To make the fix easier to backport,
revert this change before re-applying the improved fix (next commit).
Change-Id: If6c785f58482d2531b5927c5ea7002f548c21c7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/168402 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Than McIntosh [Thu, 21 Mar 2019 13:20:11 +0000 (09:20 -0400)]
cmd/link: add optional sanity checking for duplicate symbols
Introduce a new linker command line option "-strictdups", which
enables sanity checking of "ok to duplicate" symbols, especially
DWARF info symbols. Acceptable values are 0 (no checking) 1 (issue
warnings) and 2 (issue a fatal error checks fail).
Currently if we read a DWARF symbol (such as "go.info.PKG.FUNCTION")
from one object file, and then encounter the same symbol later on
while reading another object file, we simply discard the second one
and move on with the link, since the two should in theory be
identical.
If as a result of a compiler bug we wind up with symbols that are not
identical, this tends to (silently) result in incorrect DWARF
generation, which may or may not be discovered depending on who is
consuming the DWARF and what's being done with it.
When this option is turned on, at the point where a duplicate
symbol is detected in the object file reader, we check to make sure
that the length/contents of the symbol are the same as the previously
read symbol, and print a descriptive warning (or error) if not.
For the time being this can be used for one-off testing to find
problems; at some point it would be nice if we can enable it by
default.
Updates #30908.
Change-Id: I64c4e07c326b4572db674ff17c93307e2eec607c
Reviewed-on: https://go-review.googlesource.com/c/go/+/168410
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Daniel Martí [Wed, 13 Mar 2019 11:57:29 +0000 (11:57 +0000)]
cmd/compile: reduce rulegen's for loop verbosity
A lot of the naked for loops begin like:
for {
v := b.Control
if v.Op != OpConstBool {
break
}
...
return true
}
Instead, write them out in a more compact and readable way:
for v.Op == OpConstBool {
...
return true
}
This requires the addition of two bytes.Buffer writers, as this helps us
make a decision based on future pieces of generated code. This probably
makes rulegen slightly slower, but that's not noticeable; the code
generation still takes ~3.5s on my laptop, excluding build time.
The "v := b.Control" declaration can be moved to the top of each
function. Even though the rules can modify b.Control when firing, they
also make the function return, so v can't be used again.
While at it, remove three unnecessary lines from the top of each
rewriteBlock func.
In total, this results in ~4k lines removed from the generated code, and
a slight improvement in readability.
Iskander Sharipov [Fri, 22 Mar 2019 12:30:30 +0000 (15:30 +0300)]
sort: replace Errorf+FailNow with Fatalf
Change-Id: I4f8d0178e780b86d1f551b367e2ddac3789be5aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/168880
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Clément Chigot [Fri, 22 Mar 2019 11:54:37 +0000 (12:54 +0100)]
cmd: enable -buildmode=pie on aix/ppc64
Change-Id: I939518462c931ba9feb125b2f299ef0706b124ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/168879
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Clément Chigot [Fri, 22 Mar 2019 11:48:31 +0000 (12:48 +0100)]
cmd/compile, misc/cgo: fix fortran tests on aix/ppc64
Enable pattern lib.a/shared.so.X in cgo_import_dynamic as on AIX,
archive files (.a) often have shared objects (.so) inside them.
Change-Id: I21096c75eb7fbcc7064b0b832bfa8ed862142051
Reviewed-on: https://go-review.googlesource.com/c/go/+/168877
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Andrei Tudor Călin [Thu, 21 Mar 2019 15:04:25 +0000 (16:04 +0100)]
image/png: add Fuzz function
Add a Fuzz function to package png, under the gofuzz build
tag. This function is based on the png/png.go code, from
github.com/dvyukov/go-fuzz-corpus, modified to use direct
comparison of image bounds rather than reflect.DeepEqual.
Richard Musiol [Sun, 17 Mar 2019 14:51:30 +0000 (15:51 +0100)]
cmd/link/internal/wasm: optimize data section in wasm binary
This change optimizes the data section in the wasm binary by
omitting blocks of zeroes and instead emitting data segments
with offsets skipping the zeroes.
This optimization is inspired by the memory-packing pass of the
wasm-opt tool and reduces the wasm binary size of "hello world" by 14%.
Nigel Tao [Thu, 21 Mar 2019 04:08:41 +0000 (15:08 +1100)]
image/gif: don't assume Encode src's origin is (0, 0)
When gif.Encode is given an "m image.Image" argument that isn't an
*image.Paletted, it creates a temporary *image.Paletted (called pm) that
is intended to be a copy of this image, only with fewer colors.
That creation process, and specifically the opts.Drawer.Draw call that
does the copy, incorrectly assumed that m.Bounds().Min is the zero point
(0, 0). This commit fixes that.
Cherry Zhang [Thu, 21 Mar 2019 17:40:28 +0000 (13:40 -0400)]
cmd/compile: copy volatile values before emitting write barrier call
It is possible that a "volatile" value (one that can be clobbered
by preparing args of a call) to be used in multiple write barrier
calls. We used to copy the volatile value right before each call.
But this doesn't work if the value is used the second time, after
the first call where it is already clobbered. Copy it before
emitting any call.
Dmitri Shuralyov [Mon, 11 Mar 2019 13:15:38 +0000 (09:15 -0400)]
cmd/go/internal/modfetch: update comment referring to old Import function
The Import function was moved from modfetch/repo.go to modload/import.go
in vgo CL 122880, and its semantics have changed in vgo CL 123095 to do
more than just searching for a module. Both of these changes were ported
to cmd/go in CL 123576.
Delete the mention of the old Import function from the modfetch/repo.go
comment, since what it refers to does not exist anymore.
Change-Id: I6dc6984128152cf9611d30fbc4e6418e91a7641f
Reviewed-on: https://go-review.googlesource.com/c/go/+/166597 Reviewed-by: Jay Conrod <jayconrod@google.com>
Elias Naur [Thu, 21 Mar 2019 14:15:40 +0000 (15:15 +0100)]
misc/ios: don't override GOCACHE on the device
The iOS exec wrapper copies the environment variables to the binary
running on the device. However, some variables such as HOME, TMPDIR and
GOCACHE refer to directories that might not be valid on the device.
The wrapper already ignores HOME and TMPDIR, but after GO111MODULE
was flipped to on for the standard library, cmd/go tests started
failing without a valid and writable GOCACHE.
It took a while to reproduce because go test does not set an explicit
GOCACHE but cmd/dist test does.
Elias Naur [Tue, 19 Mar 2019 05:59:51 +0000 (06:59 +0100)]
misc/android: pass on GOPROXY to device environment
Android devices don't have git available, so many go tool commands
that fetch dependencies fail. Builders already have a GOPROXY
available, so pass that along to the device environment.
Elias Naur [Tue, 19 Mar 2019 11:19:48 +0000 (13:19 +0200)]
cmd/link/internal/ld: copy Mach-O platform version commands to go.o
To build for watchOS and tvOS the Apple toolchain requires a Mach-O
load command that matches the platform for all object files in a build.
The go.o object file produced by the Go linker contains no such command.
The loader commands are mutually exclusive so we need to pick the
right one. Fortunately, cgo must be enabled for watchOS and tvOS to
be useful, so we can copy the first loader command we find in the object
files produced by the host compiler.
Add a test that builds a small program for tvOS to test both this CL
and the previous CL that added bitcode support.
We're going to need the ability to extract the LC_VERSION_MIN_* and
LC_BUILD_VERSION load commands. This CL adds peekMachoPlatform to do
that and in the process simplifies machoCombineDwarf.
While here, disable DWARF combining for Apple platforms other than
macOS (watchOS, tvOS, bridgeOS), not just iOS.
Updates #22395
Change-Id: I4862b0f15ccc87b7be1a6532b4d37b47c8f7f243
Reviewed-on: https://go-review.googlesource.com/c/go/+/168459 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Elias Naur [Sun, 17 Mar 2019 16:48:57 +0000 (17:48 +0100)]
cmd/link/internal/ld: enable bitcode builds for iOS, tvOS, watchOS
The Go toolchain cannot output bitcode, but there is a trick where
object code can be marked with an __asm section, persuading the
Apple toolchain to include our object code in bitcode builds.
This enables Go builds with bitcode enabled; the next CL adds
the necessary plumbing for building on tvOS and watchOS.
Thanks to Aman Gupta for the trick.
Test is added two CLs from here.
Fixes #22395 (at least until Apple tightens bitcode requirements.)
The original goal of rounding to readable b.N
was to make it easier to eyeball times.
However, proper analysis requires tooling
(such as benchstat) anyway.
Instead, take b.N as it comes.
This will reduce the impact of external noise
such as GC on benchmarks.
This requires reworking our iteration estimates.
We used to calculate the estimated ns/op
and then divide our target ns by that estimate.
However, this order of operations was destructive
when the ns/op was very small; rounding could
hide almost an order of magnitude of variation.
Instead, multiply first, then divide.
Also, make n an int64 to avoid overflow.
Prior to this change, we attempted to cap b.N at 1e9.
Due to rounding up, it was possible to get b.N as high as 2e9.
This change consistently enforces the 1e9 cap.
This change also reduces the wall time required to run benchmarks.
Here's the impact of this change on the wall time to run
all benchmarks once with benchtime=1s on some std packages:
This is part of a general effort to shrink walk.
In an ideal world, we'd have an SSA op for allocation,
but we don't yet have a good mechanism for introducing
function calling during SSA compilation.
In the meantime, SSA conversion is a better place for it.
This also makes it easier to introduce new optimizations;
instead of doing the typecheck walk dance,
we can simply write what we want the backend to do.
I introduced a new opcode in this change because:
(a) It avoids a class of bugs involving correctly detecting
whether this ONEW is a "before walk" ONEW or an "after walk" ONEW.
It also means that using ONEW or ONEWOBJ in the wrong context
will generally result in a faster failure.
(b) Opcodes are cheap.
(c) It provides a better place to put documentation.
This change also is also marginally more performant:
Damien Neil [Tue, 19 Feb 2019 21:03:55 +0000 (13:03 -0800)]
os: make errors.Is work with ErrPermission et al.
As proposed in Issue #29934, update errors produced by the os package to
work with errors.Is sentinel tests. For example,
errors.Is(err, os.ErrPermission) is equivalent to os.IsPermission(err)
with added unwrapping support.
Move the definition for os.ErrPermission and others into the syscall
package. Add an Is method to syscall.Errno and others. Add an Unwrap
method to os.PathError and others.
Updates #30322
Updates #29934
Change-Id: I95727d26c18a5354c720de316dff0bffc04dd926
Reviewed-on: https://go-review.googlesource.com/c/go/+/163058 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Clément Chigot [Thu, 21 Feb 2019 09:56:35 +0000 (10:56 +0100)]
cmd/dist, misc/cgo: enable tests for aix/ppc64
Some cgo tests aren't yet available on aix/ppc64.
-shared and -static don't work as expected and will be fixed latter.
Updates #30565
Change-Id: Ic59cabe685cb1cbdf89a8d1d1a1d2c4b0e8ef442
Reviewed-on: https://go-review.googlesource.com/c/go/+/164018
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Clément Chigot [Thu, 21 Feb 2019 09:50:29 +0000 (10:50 +0100)]
cmd/nm: fix cgo tests for aix/ppc64
This commit handles AIX cgo in cmd/nm tests.
Change-Id: I6753a0102e4f2c4c7bd4d7c999f62a0cb3d2183c
Reviewed-on: https://go-review.googlesource.com/c/go/+/164017
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
LE Manh Cuong [Sun, 17 Mar 2019 04:56:29 +0000 (11:56 +0700)]
os: fix windows Lstat missing name for some files
On Windows, GetFileAttributesEx fails with ERROR_SHARING_VIOLATION for
some files, like c:\pagefile.sys. In this case,
newFileStatFromWin32finddata is used to fill file info, but it does not fill
name and path.
After getting file stat from newFileStatFromWin32finddata, just set file info
name and path before return fixes the issue.
Fixes #30883
Change-Id: I654e96c634e8a9bf5ce7e1aaa93968e88953620d
Reviewed-on: https://go-review.googlesource.com/c/go/+/167779
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Mikio Hara [Tue, 19 Mar 2019 09:32:11 +0000 (18:32 +0900)]
runtime: disable event scanning error reporting on solaris
It seems like we need to pay special attention to capturing error
condition on the event port of SmartOS. The previous attempt CL 167777
works on Oracle Solaris but doesn't work on SmartOS for the uncertain
reason. It's better to disable the reporting for now.
Updates #30624.
Fixes #30840.
Change-Id: Ieca5dac4fceb7e8c9cb4db149bb4c2e79691588c
Reviewed-on: https://go-review.googlesource.com/c/go/+/167782
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
erifan01 [Mon, 14 Jan 2019 09:36:18 +0000 (09:36 +0000)]
cmd/compile: intrinsify math/bits.Add64 for arm64
This CL instrinsifies Add64 with arm64 instruction sequence ADDS, ADCS
and ADC, and optimzes the case of carry chains.The CL also changes the
test code so that the intrinsic implementation can be tested.
* Reduce the scope of q.
* Remove duplicate handling of AADJSP.
* Move ab declaration closer to use.
* Collapse nested if statements.
* Change declaration of n for increased readability in context.
* Simplify AADJSP handling.
cmd/compile: move flagalloc op splitting to rewrite rules
Flagalloc has the unenviable task of splitting
flag-generating ops that have been merged with loads
when the flags need to "spilled" (i.e. regenerated).
Since there weren't very many of them, there was a hard-coded list
of ops and bespoke code written to split them.
This change migrates load splitting into rewrite rules,
to make them easier to maintain.