1
0
mirror of https://github.com/golang/go synced 2024-09-24 01:10:14 -06:00
Commit Graph

1171 Commits

Author SHA1 Message Date
David Crawshaw
d8ae2156fe runtime, plugin: error not throw on duplicate open
Along the way, track bad modules. Make sure they don't end up on
the active modules list, and aren't accidentally reprocessed as
new plugins.

Fixes #19004

Change-Id: I8a5e7bb11f572f7b657a97d521a7f84822a35c07
Reviewed-on: https://go-review.googlesource.com/61171
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-09 16:26:33 +00:00
David Crawshaw
4e2ef7f7f9 cmd/go: add source file contents to plugin hash
It is common to have multiple plugins built from ephemeral
source files all with the same name:

	# generate main.go
	go build -buildmode=plugin -o=p1.so main.go
	# rm main.go, generate new main.go
	go build -buildmode=plugin -o=p2.so main.go
	...

These different plugins currently have the same build ID,
and hence the same package path. This means only one can be
loaded.

To remove this restriction, this commit adds the contents of the
main package source files to the plugin hash.

Fixes #19358

Change-Id: Icd42024b085feb29c09c2771aaecb85f8b528dd3
Reviewed-on: https://go-review.googlesource.com/61170
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-09 15:58:20 +00:00
David Crawshaw
605331f43e cmd/go: pass plugin package name to compile -p
When compiling a plugin, package main gets a new name so as not to
conflict with the main package in the host binary, or any other
plugins. It is already defined by cmd/go, and used by cmd/link when
filling out the "" package placeholder in symbols.

With this CL, the plugin-specific name for main is also passed to
cmd/compile's -p flag. This is used to fill out the pkgpath field
of types, and ensures that two types defined in two different plugin
mains with the same name will not be mistaken for one another at
runtime.

Fixes #21386

Change-Id: I8a646d8d7451caff533fe0007343ea8b8e1704ed
Reviewed-on: https://go-review.googlesource.com/60910
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-01 18:27:59 +00:00
Hiroshi Ioka
f74b52cf50 cmd/cgo: support large unsigned macro again
The approach of https://golang.org/cl/43476 turned out incorrect.
The problem is that the sniff introduced by the CL only work for simple
expression. And when it fails it fallback to uint64, not int64, which
breaks backward compatibility.
In this CL, we use DWARF for guessing kind instead. That should be more
reliable than previous approach. And importanly, it fallbacks to int64 even
if it fails to guess kind.

Fixes #21708

Change-Id: I39a18cb2efbe4faa9becdcf53d5ac68dba180d46
Reviewed-on: https://go-review.googlesource.com/60510
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-01 00:42:21 +00:00
Hiroshi Ioka
03876af91c cmd/cgo: support niladic function-like macros
Currently, cgo supports only macros which can be reduced to constants
or variables. The CL addresses remaining parts, macros which can be
represented as niladic functions.

The basic idea is simple:
  1. make a thin wrapper function per macros.
  2. replace macro expansions with function calls.

Fixes #10715
Fixes #18720

Change-Id: I150b4fb48e9dc4cc34466ef6417c04ac93d4bc1a
Reviewed-on: https://go-review.googlesource.com/43970
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-30 18:28:58 +00:00
Hiroshi Ioka
77acf19a59 cmd/cgo: avoid using common names for sniffing
Current code uses names like "x" and "s" which can conflict with user's
code easily. Use cryptographic names.

Fixes #21668

Change-Id: Ib6d3d6327aa5b92d95c71503d42e3a79d96c8e15
Reviewed-on: https://go-review.googlesource.com/59710
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-29 00:42:34 +00:00
Elias Naur
627d3a0b4c misc/ios,src/iostest.bash: support GOIOS_DEVICE_ID
When running multiple iOS builds on the same host, GOIOS_DEVICE_ID
is used to distinguish the devices. To improve support,

- Only restart the particular device when invoking iostest.bash
with the -restart flag.
- Make the exec wrapper lock file per-device.

For the iOS builder.

Change-Id: Id6f222981f25036399a43c3202a393dba89d87cb
Reviewed-on: https://go-review.googlesource.com/57970
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-28 16:37:25 +00:00
Hana Kim
05ff6bfe33 misc/trace: update trace-viewer
Generated with
 github.com/catapult/tracing/bin/vulcanize_trace_viewer
catapult @ ab4d571fa

Renamed trace_viewer_lean.html to trace_viewer_full.html
to make it clear we are using the full version of trace viewer
(waiting for https://github.com/catapult-project/catapult/issues/2247
to be fixed).

Update #15302

Change-Id: Ice808bb27ab79a1dec9fc863e0c5a761027ebfbe
Reviewed-on: https://go-review.googlesource.com/58750
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2017-08-25 15:50:29 +00:00
Elias Naur
1a2ac46edd misc/ios: add support for device ids to the exec wrapper
If set, GOIOS_DEVICE_ID specifies the device id for the iOS exec
wrapper. With that, a single builder can host multiple iOS devices.

Change-Id: If3cc049552f5edbd7344befda7b8d7f73b4236e2
Reviewed-on: https://go-review.googlesource.com/57296
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: JBD <jbd@google.com>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-08-21 21:08:17 +00:00
Elias Naur
ff90f4af66 Revert "misc/cgo/testcshared: temporarily skip testing on android"
This reverts commit a6ffab6b67.

Reason for revert: with CL 57290 the tests run on Android again.

Change-Id: Ifeb29762a4cd0178463acfeeb3696884d99d2993
Reviewed-on: https://go-review.googlesource.com/57310
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-08-19 12:56:24 +00:00
Elias Naur
a9e0204c1e misc/cgo/testcshared: fix tests on android
The testcshared test.bash was rewritten in Go, but the rewritten script
broke on Android. Make the tests run on Android again by:

- Restoring the LD_LIBRARY_PATH path (.).
- Restoring the Android specific C flags (-pie -fuse-ld=gold).
- Adding runExe to run test executables. All other commands must run on
the host.

Fixes #21513.

Change-Id: I3ea617a943c686b15437cc5c118e9802a913d93a
Reviewed-on: https://go-review.googlesource.com/57290
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-08-19 12:55:05 +00:00
Alex Brainman
a6ffab6b67 misc/cgo/testcshared: temporarily skip testing on android
For #21513

Change-Id: Ibe9479f8afc6f425779a737a807ff2f839a4f311
Reviewed-on: https://go-review.googlesource.com/57250
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-08-19 08:18:09 +00:00
Alex Brainman
e2cdec77c6 misc/cgo/testcshared: cd into work directory before running android command
Hopefully this will fix android build.

Maybe fixes #21513

Change-Id: I98f760562646f06b56e385c36927e79458465b92
Reviewed-on: https://go-review.googlesource.com/56790
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-19 02:27:34 +00:00
Alex Brainman
b73d46de36 misc/cgo/testcshared: fix syntax error in the test
Another attempt to fix build

Change-Id: I26137c115ad4b5f5a69801ed981c146adf6e824c
Reviewed-on: https://go-review.googlesource.com/56750
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 05:29:56 +00:00
Alex Brainman
54f6911af5 misc/cgo/testcshared: use adb instead of ./adb on android
Hopefully fixes build.

Change-Id: If0629b95b923a65e4507073cf7aa44a5e178fc0f
Reviewed-on: https://go-review.googlesource.com/56711
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2017-08-18 04:45:49 +00:00
Christopher Nelson
ef94870cc8 misc/cgo/testcshared: rewrite test.bash in Go
Change-Id: Id717054cb3c4537452f8ff848445b0c20196a373
Reviewed-on: https://go-review.googlesource.com/33579
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-08-18 03:23:12 +00:00
Bryan C. Mills
39d4693bac misc/cgo/testsanitizers: convert test.bash to Go
This makes it much easier to run individual failing subtests.

Use $(go env CC) instead of always defaulting to clang; this makes it
easier to test with other compilers.

Run C binaries to detect incompatible compiler/kernel pairings instead
of sniffing versions.

updates #21196

Change-Id: I0debb3cc4a4244df44b825157ffdc97b5c09338d
Reviewed-on: https://go-review.googlesource.com/52910
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-17 15:05:08 +00:00
Michael Steinert
ee714947c5 cmd/cgo: unify cgo output for gc and gccgo
When calling a Go function that returns multiple values from C, cgo
generates a structure to hold the values. According to the documentation
this structure is called `struct <function-name>_return`. When compiling
for gccgo the generated structure name is `struct <function-name>_result`.
This change updates the output for gccgo to match the documentation and
output for gc.

Fixes #20910

Change-Id: Iaea8030a695a7aaf9d9f317447fc05615d8e4adc
Reviewed-on: https://go-review.googlesource.com/49350
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-16 21:57:56 +00:00
Cherry Zhang
e82e120429 misc/nacl: add cmd/vendor/golang.org/x/arch/arm64/arm64asm testdata
This should fix NaCl build failure for CL 49530.

Change-Id: Id9a54f0c81b1b5db5b5efb12a2ad6509c4ab42b3
Reviewed-on: https://go-review.googlesource.com/55770
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2017-08-16 17:57:51 +00:00
Hiroshi Ioka
e6cbf98d69 misc/cgo/testshared: call flag.Parse in TestMain
Otherwise, some test flags don't work.

Change-Id: Iacf3930d0eec28e4d690cd382adbb2ecf866a0e2
Reviewed-on: https://go-review.googlesource.com/55615
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-15 13:58:48 +00:00
Hiroshi Ioka
b88e532a9e cmd/cgo: use first error position instead of last one
Just like https://golang.org/cl/34783

Given cgo.go:
     1	package main
     2
     3	/*
     4	long double x = 0;
     5	*/
     6	import "C"
     7
     8	func main() {
     9		_ = C.x
    10		_ = C.x
    11	}

Before:
    ./cgo.go:10:6: unexpected: 16-byte float type - long double

After:
    ./cgo.go:9:6: unexpected: 16-byte float type - long double

The above test case is not portable. So it is tested on only amd64.

Change-Id: If0b84cf73d381a22e2ada71c8e9a6e6ec77ffd2e
Reviewed-on: https://go-review.googlesource.com/54950
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-14 05:29:11 +00:00
Ian Lance Taylor
4fa2674aa7 misc/cgo/errors: update ptr.go comment
Accidentally omitted from submit of CL 53352.

Updates #21306

Change-Id: I022d89c6417fe9371856d49b646eb6294b91657c
Reviewed-on: https://go-review.googlesource.com/53415
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Avelino <t@avelino.xxx>
2017-08-08 04:31:40 +00:00
Ian Lance Taylor
f096b5b340 runtime: mark activeModules nosplit/nowritebarrier
The activeModules function is called by the cgo pointer checking code,
which is called by the write barrier (when GODEBUG=cgocheck=2), and as
such must be nosplit/nowritebarrier.

Fixes #21306

Change-Id: I57f2124f14de7f3872b2de9532abab15df95d45a
Reviewed-on: https://go-review.googlesource.com/53352
Reviewed-by: Austin Clements <austin@google.com>
2017-08-05 18:05:41 +00:00
Ian Lance Taylor
b01db023b1 misc/cgo/testsanitizers: also skip tsan11/tsan12 when using GCC
Updates #21196

Change-Id: I307cacc963448b90a23f633bec15498ba7bf1937
Reviewed-on: https://go-review.googlesource.com/53356
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-04 23:05:00 +00:00
Ian Lance Taylor
b63db76c4a testsanitizers: check that tsan program runs, skip tsan10 on gcc
Check not only that a tsan program can be built, but also that it runs.
This fails with some installations of GCC 7.

Skip the tsan10 program when using GCC, as it reportedly hangs.

This is a patch to help people build 1.9; we may be able to do a
better fix for 1.10.

Updates #21196

Change-Id: Icd1ffbd018dc65a97ff45cab1264b9b0c7fa0ab2
Reviewed-on: https://go-review.googlesource.com/52790
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-02 18:32:24 +00:00
Bryan C. Mills
f5eb8712f8 misc/cgo/testsanitizers: add regression test for change 50251
http://golang.org/cl/50251 fixed a regression under TSAN.
This change adds a minimal reproducer for the observed symptom.

Change-Id: Ib9ad01b458b7fdec14d6c2fe3c243f9c64b3dcf2
Reviewed-on: https://go-review.googlesource.com/50371
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-07-20 18:43:40 +00:00
Hiroshi Ioka
289a8719ce cmd/cgo: unwrap typedef-chains before type checking
clang can emit some dwarf.VoidType which are wrapped by multiple
dwarf.TypedefType. We need to unwrap those before further processing.

Fixes #20129

Change-Id: I671ce6aef2dc7b55f1a02aec5f9789ac1b369643
Reviewed-on: https://go-review.googlesource.com/44772
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-27 23:02:34 +00:00
Ian Lance Taylor
dcaac4b365 cmd/cgo: match note following error in compiler errors
With current GCC a macro that refers to another macro can report an
error on the macro definition line, with a note on the use.
When cgo is trying to decide which line an error refers to,
it is looking at the uses. So if we see an error on a line that we
don't recognize followed by a note on a line that we do recognize,
treat the note as an error.

Fixes #20125.

Change-Id: I389cd0eb7d56ad2d54bef70e278d9f76c4d36448
Reviewed-on: https://go-review.googlesource.com/44290
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Hiroshi Ioka <hirochachacha@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-14 17:07:19 +00:00
Ian Lance Taylor
b488073d51 go/build: make -I/-L options in cgo flags absolute
Fixes #20266.

Change-Id: I51383820880e3d3566ef3d70650a0863756003ba
Reviewed-on: https://go-review.googlesource.com/44291
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-06-13 18:36:04 +00:00
Alberto Donizetti
e5d2104582 cmd/cgo: show pos info in undefined name errors
For test.go:

	package main

	import (
	   "C"
	   "fmt"
	)

	func main() {
		 fmt.Println("Hello, world!")
		 C.no_such_f()
	}

Before:

	could not determine kind of name for C.no_such_f

After:

	./test.go:10:2: could not determine kind of name for C.no_such_f

Fixes #18452

Change-Id: I49c136b7fa60fab25d2d5b905d440fe4d106e565
Reviewed-on: https://go-review.googlesource.com/34783
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-03 16:08:49 +00:00
Ian Lance Taylor
994b7eebc7 misc/cgo/testcarchive: fix go env error message
Add a missing newline.  Don't panic on an unexpected error type.

Change-Id: I82a4b12c498fbfdf4972737329631c0c02540005
Reviewed-on: https://go-review.googlesource.com/44092
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-24 22:27:16 +00:00
Hiroshi Ioka
dd61aa55e8 cmd/cgo: support indirect macro expansion for string
Current code cannot handle string #define macros if those macros are
defined via other macros. This CL solve the issue.

Updates #18720

Change-Id: Ibed0773d10db3d545bb246b97e81c0d19e3af3d5
Reviewed-on: https://go-review.googlesource.com/41312
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-23 22:19:51 +00:00
Hiroshi Ioka
7555a45dc2 cmd/cgo: support large unsigned macros
Currently, cgo converts integer macros into int64 if it's possible.
As a result, some macros which satisfy

math.MaxInt64 < x <= math.MaxUint64

will lose their original values.

This CL introduces the new probe to check signs,
so we can handle signed ints and unsigned ints separately.

Fixes #20369

Change-Id: I002ba452a82514b3a87440960473676f842cc9ee
Reviewed-on: https://go-review.googlesource.com/43476
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-17 14:42:29 +00:00
Ian Lance Taylor
5331e7e9df cmd/internal/obj, cmd/link: fix st_other field on PPC64
In PPC64 ELF files, the st_other field indicates the number of
prologue instructions between the global and local entry points.
We add the instructions in the compiler and assembler if -shared is used.
We were assuming that the instructions were present when building a
c-archive or PIE or doing dynamic linking, on the assumption that those
are the cases where the go tool would be building with -shared.
That assumption fails when using some other tool, such as Bazel,
that does not necessarily use -shared in exactly the same way.

This CL records in the object file whether a symbol was compiled
with -shared (this will be the same for all symbols in a given compilation)
and uses that information when setting the st_other field.

Fixes #20290.

Change-Id: Ib2b77e16aef38824871102e3c244fcf04a86c6ea
Reviewed-on: https://go-review.googlesource.com/43051
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-05-09 23:36:51 +00:00
Elias Naur
00f827784b misc/android: don't let the Android exec wrapper hang indefinitely
On Android, the exec wrapper passes on output from adb to its parent
process by passing on os.Stderr and os.Stdout to adb. If the adb
process somehow hangs, it will keep stderr and stdout will open, in turn
blocking go test from ever returning from its cmd.Wait() even though
it has killed the exec wrapper process.

Break the short circuit by introducing a wrapper between adb and the
exec wrapper, preventing os/exec.Run from passing along the raw
file descriptors for os.Stdout and os.Stderr.

(Hopefully) fixes occasional indefinite hangs on the Android builder.

Change-Id: I1188211fbde79b4a66bf93ff8e9d0091abf34560
Reviewed-on: https://go-review.googlesource.com/42271
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-01 22:31:15 +00:00
Elias Naur
6e54fe47ce misc/ios: increase iOS test harness timeout
The "lldb start" phase often times out on the iOS builder. Increase
the timeout and see if that helps.

Change-Id: I92fd67cbfa90659600e713198d6b2c5c78dde20f
Reviewed-on: https://go-review.googlesource.com/41863
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-27 14:42:37 +00:00
Todd Neal
7a92395ddd plugin: resolve plugin import path issue
Resolve import paths to get plugin symbol prefixes.

Fixes #19534

Change-Id: Ic25d83e72465ba8f6be0337218a1627b5dc702dc
Reviewed-on: https://go-review.googlesource.com/40994
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-04-26 00:54:54 +00:00
Alexander Menzhinsky
2463a49ebb cmd/cgo: reject references to builtin functions other than calls
Here we restrict using cgo builtin references because internally they're go functions
as opposed to C usafe.Pointer values.

Fixes #18889

Change-Id: I1e4332e4884063ccbaf9772c172d4462ec8f3d13
Reviewed-on: https://go-review.googlesource.com/40934
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-18 22:14:43 +00:00
Michael Hudson-Doyle
533ed967c6 cmd/link: only include the version info and export data in ABI hash
Previously the "ABI hash" for a package (used to determine if a loaded shared
library has the ABI expected by its loader) was the hash of the entire
__.PKGDEF file. But that means it depends on the build ID generated by the go
tool for the package, which means that if a file is added (even a .c or .h
file!) to the package, the ABI changes, perhaps uncessarily.

Fixes #19920

Change-Id: If919481e1a03afb350c8a9c7a0666bb90ee90270
Reviewed-on: https://go-review.googlesource.com/40401
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-17 22:02:01 +00:00
Elias Naur
69182885d9 misc/ios: fix the Test386EndToEnd test on iOS
Some tests need the src/runtime/textflag.h file. Make sure it is
included in iOS test runs.

Change-Id: I5e0e7ebe85679686ef15a7d336f28ac9b68a587a
Reviewed-on: https://go-review.googlesource.com/40915
Run-TryBot: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-17 19:55:54 +00:00
Josh Bleecher Snyder
ce3ee7cdae cmd/internal/obj: stop storing Text flags in From3
Prior to this CL, flags such as NOSPLIT
on ATEXT Progs were stored in From3.Offset.
Some but not all of those flags were also
duplicated into From.Sym.Attribute.

This CL migrates all of those flags into
From.Sym.Attribute and stops creating a From3.

A side-effect of this is that printing an
ATEXT Prog can no longer simply dump From3.Offset.
That's kind of good, since the raw flag value
wasn't very informative anyway, but it did
necessitate a bunch of updates to the cmd/asm tests.

The reason I'm doing this work now is that
avoiding storing flags in both From.Sym and From3.Offset
simplifies some other changes to fix the data
race first described in CL 40254.

This CL almost passes toolstash-check -all.
The only changes are in cases where the assembler
has decided that a function's flags may be altered,
e.g. to make a function with no calls in it NOSPLIT.
Prior to this CL, that information was not printed.

Sample before:

"".Ctz64 t=1 size=63 args=0x10 locals=0x0
	0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35)	TEXT	"".Ctz64(SB), $0-16
	0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35)	FUNCDATA	$0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)

Sample after:

"".Ctz64 t=1 nosplit size=63 args=0x10 locals=0x0
	0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35)	TEXT	"".Ctz64(SB), NOSPLIT, $0-16
	0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35)	FUNCDATA	$0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)

Observe the additional "nosplit" in the first line
and the additional "NOSPLIT" in the second line.

Updates #15756

Change-Id: I5c59bd8f3bdc7c780361f801d94a261f0aef3d13
Reviewed-on: https://go-review.googlesource.com/40495
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-12 21:53:39 +00:00
Todd Neal
e49627d355 plugin: properly handle recursively defined types
Prevent a crash if the same type in two plugins had a recursive
definition, either by referring to a pointer to itself or a map existing
with the type as a value type (which creates a recursive definition
through the overflow bucket type).

Fixes #19258

Change-Id: Iac1cbda4c5b6e8edd5e6859a4d5da3bad539a9c6
Reviewed-on: https://go-review.googlesource.com/40292
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-04-12 12:46:07 +00:00
Ben Shi
69261ecad6 runtime: use hardware divider to improve performance
The hardware divider is an optional component of ARMv7. This patch
detects whether it is available in runtime and use it or not.

1. The hardware divider is detected at startup and a flag is set/clear
   according to a perticular bit of runtime.hwcap.
2. Each call of runtime.udiv will check this flag and decide if
   use the hardware division instruction.

A rough test shows the performance improves 40-50% for ARMv7. And
the compatibility of ARMv5/v6 is not broken.

fixes #19118

Change-Id: Ic586bc9659ebc169553ca2004d2bdb721df823ac
Reviewed-on: https://go-review.googlesource.com/37496
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-04-11 12:25:55 +00:00
Hiroshi Ioka
89ff0b1b6b cmd/cgo: support floating point #define macros
Current code doesn't support floating point #define macros.
This CL compiles floats to a object file and retrive values from it.
That approach is the same work as we've already done for integers.

Updates #18720

Change-Id: I88b7ab174d0f73bda975cf90c5aeb797961fe034
Reviewed-on: https://go-review.googlesource.com/35511
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-07 21:09:44 +00:00
Russ Cox
b28f2f7399 cmd/link: make mach-o dwarf segment properly aligned
Without this, the load fails during kernel exec, which results in the
mysterious and completely uninformative "Killed: 9" error.

It appears that the stars (or at least the inputs) were properly aligned
with earlier versions of Xcode so that this happened accidentally.
Make it happen on purpose.

Gregory Man bisected the breakage to this change in LLVM,
which fits the theory nicely:
https://github.com/llvm-mirror/llvm/commit/9a41e59c

Fixes #19734.

Change-Id: Ice67a09af2de29d3c0d5e3fcde6a769580897c95
Reviewed-on: https://go-review.googlesource.com/38854
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-03-30 12:29:18 +00:00
Elias Naur
23f56c186d misc/cgo/testcshared: use the gold linker on android/arm64
The gold linker is used by default in the Android NDK, except on
arm64:

https://github.com/android-ndk/ndk/issues/148

The Go linker already forces the use of the gold linker on arm and
arm64 (CL 22141) for other reasons. However, the test.bash script in
testcshared doesn't, resulting in linker errors on android/arm64:

warning: liblog.so, needed by ./libgo.so, not found (try using -rpath or
-rpath-link)

Add -fuse-ld=gold when running testcshared on Android. Fixes the
android/arm64 builder.

Change-Id: I35ca96f01f136bae72bec56d71b7ca3f344df1ed
Reviewed-on: https://go-review.googlesource.com/38832
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-29 23:49:08 +00:00
Daniel Martí
a9824cd47c *.bash: always use the same string equality operator
POSIX Shell only supports = to compare variables inside '[' tests. But
this is Bash, where == is an alias for =. In practice they're the same,
but the current form is inconsisnent and breaks POSIX for no good
reason.

Change-Id: I38fa7a5a90658dc51acc2acd143049e510424ed8
Reviewed-on: https://go-review.googlesource.com/38031
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-14 21:46:31 +00:00
Robert Griesemer
2a5cf48f91 cmd/compile: print columns (not just lines) in error messages
Compiler errors now show the exact line and line byte offset (sometimes
called "column") of where an error occured. For `go tool compile x.go`:

	package p
	const c int = false
	//line foo.go:123
	type t intg

reports

	x.go:2:7: cannot convert false to type int
	foo.go:123[x.go:4:8]: undefined: intg

(Some errors use the "wrong" position for the error message; arguably
the byte offset for the first error should be 15, the position of 'false',
rathen than 7, the position of 'c'. But that is an indepedent issue.)

The byte offset (column) values are measured in bytes; they start at 1,
matching the convention used by editors and IDEs.

Positions modified by //line directives show the line offset only for the
actual source location (in square brackets), not for the "virtual" file and
line number because that code is likely generated and the //line directive
only provides line information.

Because the new format might break existing tools or scripts, printing
of line offsets can be disabled with the new compiler flag -C. We plan
to remove this flag eventually.

Fixes #10324.

Change-Id: I493f5ee6e78457cf7b00025aba6b6e28e50bb740
Reviewed-on: https://go-review.googlesource.com/37970
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-09 23:29:49 +00:00
Bryan C. Mills
4210930a28 runtime/cgo: return correct sa_flags
A typo in the previous revision ("act" instead of "oldact") caused us
to return the sa_flags from the new (or zeroed) sigaction rather than
the old one.

In the presence of a signal handler registered before
runtime.libpreinit, this caused setsigstack to erroneously zero out
important sa_flags (such as SA_SIGINFO) in its attempt to re-register
the existing handler with SA_ONSTACK.

Change-Id: I3cd5152a38ec0d44ae611f183bc1651d65b8a115
Reviewed-on: https://go-review.googlesource.com/37852
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-03-09 18:53:35 +00:00
Bryan C. Mills
e57350f4c0 runtime: fix _cgo_yield usage with sysmon and on BSD
There are a few problems from change 35494, discovered during testing
of change 37852.

1. I was confused about the usage of n.key in the sema variant, so we
   were looping on the wrong condition. The error was not caught by
   the TryBots (presumably due to missing TSAN coverage in the BSD and
   darwin builders?).

2. The sysmon goroutine sometimes skips notetsleep entirely, using
   direct usleep syscalls instead. In that case, we were not calling
   _cgo_yield, leading to missed signals under TSAN.

3. Some notetsleep calls have long finite timeouts. They should be
   broken up into smaller chunks with a yield at the end of each
   chunk.

updates #18717

Change-Id: I91175af5dea3857deebc686f51a8a40f9d690bcc
Reviewed-on: https://go-review.googlesource.com/37867
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-03-09 18:36:49 +00:00