1
0
mirror of https://github.com/golang/go synced 2024-09-29 16:14:28 -06:00
Commit Graph

507 Commits

Author SHA1 Message Date
Lynn Boger
c15c44ec48 misc/cgo/testcarchive: use -no-pie where needed
Starting in gcc 6, -pie is passed to the linker by default
on some platforms, including ppc64le. If the objects
being linked are not built for -pie then in some cases the
executable could be in error. To avoid that problem, -no-pie
should be used with gcc to override the default -pie option
and generate a correct executable that can be run without error.

Fixes #22126

Change-Id: I4a052bba8b9b3bd6706f5d27ca9a7cebcb504c95
Reviewed-on: https://go-review.googlesource.com/70072
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-11 21:01:45 +00:00
Russ Cox
4e8be99590 cmd/go: clean up compile vs link vs shared library actions
Everything got a bit tangled together in b.action1.
Try to tease things apart again.

In general this is a refactoring of the existing code, with limited
changes to the effect of the code.

The main additional change is to complete a.Deps for link actions.
That list now directly contains all the inputs the linker will attempt
to read, eliminating the need for a transitive traversal of the entire
action graph to find those. The comepleteness of a.Deps will be
important when we eventually use it to decide whether an cached
action output can be reused.

all.bash passes, but it's possible I've broken some subtety of
buildmode=shared again. Certainly that code took the longest
to get working.

Change-Id: I34e849eda446dca45a9cfce02b07bec6edb6d0d4
Reviewed-on: https://go-review.googlesource.com/69831
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-10-11 17:47:09 +00:00
Elias Naur
07c01e3968 misc/cgo/testcarchive: skip flaky SIGPROF test on darwin
Updates #19320.

Change-Id: Id38df033e3f0873986e668c8ff3855b6e08407a9
Reviewed-on: https://go-review.googlesource.com/69114
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-09 06:02:50 +00:00
Ian Lance Taylor
24f9db7c20 misc/cgo/testcshared: don't overwrite cc in parallel runs
Fixes #22176

Change-Id: If47ec9a25da6b480868d8eeccc518dc97d48bda7
Reviewed-on: https://go-review.googlesource.com/69230
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-10-09 05:31:01 +00:00
Alex Brainman
e8a27daaef misc/cgo/testcshared: use correct install directory on windows
Updates #11058

Change-Id: I2a8bf4403b680ab8bf06fff18291f3bf67261e27
Reviewed-on: https://go-review.googlesource.com/69090
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2017-10-08 23:37:17 +00:00
Alex Brainman
35483c8e25 misc/cgo/testcshared: delete testp0.exe not testp0 file
Otherwise we end up with testp?.exe files after the tests run.

Updates #11058

Change-Id: Ieccfc42da6192622bdab1f9a411ccd50bb59fd5b
Reviewed-on: https://go-review.googlesource.com/68770
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-07 03:39:18 +00:00
Alex Brainman
7e31d9b9f7 misc/cgo/testcshared: skip all but TestExportedSymbols on windows
TestUnexportedSymbols requires dup2 that
my gcc installation does not have.

TestSignalHandlersWithNotify fails with:
undefined: syscall.SIGIO.

TestSignalHandlers fails with:
sched.h: No such file or directory.

TestExportedSymbolsWithDynamicLoad fails with:
dlfcn.h: No such file or directory.

Also add t.Helper calls to better error messages.

Updates #11058

Change-Id: I7eb514968464256b8337e45f57fcb7d7fe0e4693
Reviewed-on: https://go-review.googlesource.com/68410
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05 23:11:56 +00:00
David Crawshaw
24e4a128c9 cmd/link: type symbol name mangling for plugins
Moves type symbol name mangling out of the object reader
and into a separate pass. Requires some care, as changing
the name of a type may require dealing with duplicate
symbols for the first time.

Disables DWARF for both plugins and programs that use plugin.Open,
because type manging is currently incompatible with the go.info.*
symbol generator in cmd/link. (It relies on the symbol names to
find type information.) A future fix for this would be moving the
go.info.* generation into the compiler, with the logic we use
for generating the type.* symbols.

Fixes #19529

Change-Id: I75615f8bdda86ff9e767e536d9aa36e15c194098
Reviewed-on: https://go-review.googlesource.com/67312
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05 09:51:31 +00:00
David Crawshaw
273b657b4e cmd/link: support -X values for main.* in plugins
Fixes #19418

Change-Id: I98205f40c1915cd68a5d20438469ba06f1efb160
Reviewed-on: https://go-review.googlesource.com/67432
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-04 00:46:06 +00:00
griesemer
5d1addf45d go/printer: fix formatting of three-index slice expression
Apply gofmt to src, misc.

Fixes #22111.

Change-Id: Ib1bda0caaf2c1787a8137b7a61bbef7a341cc68c
Reviewed-on: https://go-review.googlesource.com/67633
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-10-03 16:16:30 +00:00
David Crawshaw
046c658919 misc/cgo/testplugin: add test for issue 18584
Fixes #18584

Change-Id: I5f9428758999cacee49f3449e596e0a88bc06f91
Reviewed-on: https://go-review.googlesource.com/67150
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-29 22:10:22 +00:00
Russ Cox
0be2d52eba cmd/go: use -importcfg to invoke compiler, linker
This is a step toward using cached build artifacts: the importcfg
will direct the compiler and linker to read them right from the cache
if necessary. However, this CL does not have a cache yet, so it still
reads them from the usual install location or build location.
Even so, this fixes a long-standing issue that -I and -L (no longer used)
are not expressive enough to describe complex GOPATH setups.

Shared libraries are handled enough that all.bash passes, but
there may still be more work to do here. If so, tests and fixes
can be added in follow-up CLs.

Gccgo will need updating to support -importcfg as well.

Fixes #14271.

Change-Id: I5c52a0a5df0ffbf7436e1130c74e9e24fceff80f
Reviewed-on: https://go-review.googlesource.com/56279
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-29 00:22:58 +00:00
Michael Munday
55ac5b50b0 cmd/compile: fix large global variables in -linkshared mode on s390x
When rewriting loads and stores accessing global variables to use the
GOT we were making use of REGTMP (R10). Unfortunately loads and stores
with large offsets (larger than 20-bits) were also using REGTMP,
causing it to be clobbered and subsequently a segmentation fault.

This can be fixed by using REGTMP2 (R11) for the rewrite. This is fine
because REGTMP2 only has a couple of uses in the assembler (division,
high multiplication and storage-to-storage instructions). We didn't
use REGTMP2 originally because it used to be used more frequently,
in particular for stores of constants to memory. However we have now
eliminated those uses.

This was found while writing a test case for CL 63030. That test case
is included in this CL.

Change-Id: I13956f1f3ca258a7c8a7ff0a7570d2848adf7f68
Reviewed-on: https://go-review.googlesource.com/65011
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-20 20:20:46 +00:00
Ian Lance Taylor
2a2e4dad33 misc/cgo/errors: don't pass -C to compiler
It's not needed, and the current expectation is that it will go away
in the future.

Change-Id: I5f46800e748d9ffa484bda6d1738290c8e00ac2b
Reviewed-on: https://go-review.googlesource.com/63751
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-14 04:02:01 +00:00
Bryan C. Mills
107744e94c misc/cgo/errors: test that the Go rune type is not identical to C.int
rune has a well-defined size, but C.int is implementation-specified.
Using one as the other should require an explicit conversion.

updates #13467

Change-Id: I53ab2478427dca790efdcc197f6b8d9fbfbd1847
Reviewed-on: https://go-review.googlesource.com/63730
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-14 02:24:39 +00:00
Bryan C. Mills
814d92230a misc/cgo/errors: fix erroneous regexp detection
I had passed 1 instead of 2 to the SplitAfterN call in
errorstest.check, so all of the cases were erroneously falling through
to the non-regexp case (and passing even if the actual error didn't
match).

Now, we use bytes.HasSuffix to check for the non-regexp case, so we
will not incorrectly match a regexp comment to the non-regexp case.

updates #13467

Change-Id: Ia6be928a495425f2b7bae5001bd01346e115dcfa
Reviewed-on: https://go-review.googlesource.com/63692
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-14 02:24:04 +00:00
Bryan C. Mills
d02477e994 misc/cgo/errors: port test.bash to Go
This makes the test easier to run in isolation and easier to change,
and simplifies the code to run the tests in parallel.

updates #13467

Change-Id: I5622b5cc98276970347da18e95d071dbca3c5cc1
Reviewed-on: https://go-review.googlesource.com/63276
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-13 17:45:52 +00:00
Bryan C. Mills
9f1a7192dc misc/cgo/test: set the traceback level instead of failing the test
Previously, test7978 failed if the user did not invoke it with
GOTRACEBACK=2 already set in their environment. Environment-sensitive
test are awkward, and in this case there is a very simple workaround:
set the traceback level to the necessary value explicitly.

Change-Id: I7d576f24138aa8a41392148eae11bbeaef558573
Reviewed-on: https://go-review.googlesource.com/63275
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-13 02:53:11 +00:00
Alex Brainman
538b4bab3d misc/cgo/testcshared: actually run test executable on android
CL 62593 broken TestExportedSymbols and TestUnexportedSymbols
because it started executing android test binary on host.
Make them run on android.

Hopefully fixes android build.

Change-Id: Ic0bb9f0cbbefca23828574282caa33a03ef72431
Reviewed-on: https://go-review.googlesource.com/62830
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
2017-09-11 09:22:44 +00:00
Alex Brainman
40a7de7b3a misc/cgo/testcshared: simlpify cshared_test.go
Change-Id: Ib35bb7fc9c5b4ccc9b8e1bd16443e0b307be9406
Reviewed-on: https://go-review.googlesource.com/62593
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-11 06:29:44 +00:00
Anthony Sottile
57fa1c7c94 cmd/cgo: treat simple C typedefs as go aliases
Fixes #21809

Change-Id: Ic43077c6bea3c7cdc9611e74abf07b6deab70433
Reviewed-on: https://go-review.googlesource.com/62670
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-11 06:24:15 +00:00
Alex Brainman
e27a81221f misc/cgo/testcshared: run tests in parallel
Change-Id: Id1b5939cfcd210a0cb5f61915ce2d077c7fcec11
Reviewed-on: https://go-review.googlesource.com/62592
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-10 23:21:02 +00:00
David Crawshaw
753bac3a55 misc/cgo/testplugin: pass GO_GCFLAGS
The noopt builder sets GO_GCFLAGS when building the standard library.
Set it when building plugins to ensure the -shared packages built for it
have the same inlining in the export data (and thus the same package
version).

Tested locally with GO_GCFLAGS="-N -l" ./all.bash

Fixes #17937

Change-Id: Id037cfbf4af744c05c47bdc58eea60a5dba69533
Reviewed-on: https://go-review.googlesource.com/62511
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-10 14:00:18 +00:00
Hiroshi Ioka
1134411a83 cmd/go, cmd/link, cmd/dist: re-enable plugin mode on darwin/amd64
1. remove broken verification
   The runtime check assumes that no-pcln symbol entry have zero value,
   but the linker emit no entries if the symbol is no-pcln.
   As a result, if there are no-pcln symbols at the very end of pcln
   table, it will panic.
2. correct condition of export
   Handle special chracters in pluginpath correcty.
   Export "go.itab.*", so different plugins can share the same itab.

Fixes #18190

Change-Id: Ia4f9c51d83ce8488a9470520f1ee9432802cfc1d
Reviewed-on: https://go-review.googlesource.com/61091
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-10 12:54:13 +00:00
Alex Brainman
d0285161f0 misc/cgo/testcshared: use TestMain
This CL uses TestMain to create and remove
pkg directory and libgo.so file.

Fixes #21531

Change-Id: I833cfb22b55d8eef98348dad4d56327ac4c07b36
Reviewed-on: https://go-review.googlesource.com/57270
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-10 05:15:01 +00:00
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
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
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