summaryrefslogtreecommitdiff
path: root/misc/cgo
Commit message (Collapse)AuthorAgeFilesLines
* all: disable tests that fail on AlpineRuss Cox2022-08-024-0/+23
| | | | | | | | | | | | | | These changes are enough to pass all.bash using the disabled linux-amd64-alpine builder via debugnewvm. For #19938. For #39857. Change-Id: I7d160612259c77764b70d429ad94f0864689cdce Reviewed-on: https://go-review.googlesource.com/c/go/+/419995 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* misc/cgo/test: use fewer threads in TestSetgidStress in long modeCherry Mui2022-07-271-4/+1
| | | | | | | | | | | | | | | TestSetgidStress originally spawns 1000 threads for stress testing. It caused timeout on some builders so CL 415677 reduced to 50 in short mode. But it still causes flaky timeouts in longtest builders, so reduce the number of threads in long mode as well. Should fix #53641. Change-Id: I02f4ef8a143bb1faafe3d11ad223f36f5cc245c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/419453 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/compile: make jump table symbol localCherry Mui2022-07-224-0/+103
| | | | | | | | | | | | | | | | | | | | | When using plugins, if the plugin and the main executable both have the same function, and if it uses jump table, currently the jump table symbol have the same name so it will be deduplicated by the dynamic linker. This causes a function in the plugin may (in the middle of the function) jump to the function with the same name in the main executable (or vice versa). But the function may be compiled slightly differently, because the plugin needs to be PIC. Jumping from the middle of one function to the other will not work. Avoid this problem by marking the jump table symbol local to a DSO. Fixes #53989. Change-Id: I2b573b9dfc22401c8a09ffe9b9ea8bb83d3700ca Reviewed-on: https://go-review.googlesource.com/c/go/+/418960 Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/cgo/testshared: run tests only in GOPATH modeBryan C. Mills2022-07-131-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | -buildmode=shared installs shared libraries into GOROOT and expects to reuse them across builds. Builds in module mode, however, each have their own set of dependencies (determined by the module's requirements), so in general cannot share dependencies with a single GOROOT. Ideally in the long term we would like to eliminate -buildmode=shared entirely (see #47788), but first we need a replacement for the subset of use-cases where it still works today. In the meantime, we should run these tests only in GOPATH mode. Non-main packages in module mode should not be installed to GOPATH/pkg, but due to #37015 they were installed there anyway, and this test heavily relies on installing non-main packages. For #37015. Change-Id: I7c5d90b4075d6f33e3505d6a8f12752309ae5c03 Reviewed-on: https://go-review.googlesource.com/c/go/+/417194 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
* misc/cgo/testcshared: don't rely on an erroneous install target in testsBryan C. Mills2022-07-131-10/+25
| | | | | | | | | | | | | | | | | | | | | | | Non-main packages in module mode should not be installed to GOPATH/pkg, but due to #37015 they were installed there anyway. This change switches the 'go install' command in createHeaders to instead use 'go build' (with an extension determined by the install target for 'runtime/cgo', which is well-defined at least for the moment), and switches TestCachedInstall (which appears to be explicitly testing 'go install') to explicitly request GOPATH mode (which provides a well-defined install target for the library). This change follows a similar structure to CL 416954. For #37015. Change-Id: I22ae4af0f0d4c50adc9e0f0dc279859d1f258cc8 Reviewed-on: https://go-review.googlesource.com/c/go/+/417096 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* misc/cgo/testcarchive: don't rely on an erroneous install target in testsBryan C. Mills2022-07-111-8/+12
| | | | | | | | | | | | | | | | | | | Non-main packages in module mode should not be installed to GOPATH/pkg, but due to #37015 they were installed there anyway. This change switches the 'go install' command in TestPIE to instead use 'go build', and switches TestInstall and TestCachedInstall (which appear to be explicitly testing 'go install') to explicitly request GOPATH mode (which does have a well-defined install target). For #37015. Change-Id: Ifb24657d2781d1e35cf40078e8e3ebf56aab9cc8 Reviewed-on: https://go-review.googlesource.com/c/go/+/416954 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* misc/cgo/test: make TestSetgidStress cheaperCherry Mui2022-07-061-1/+4
| | | | | | | | | | | | | | | | | | TestSetgidStress spawns 1000 threads, which can be expensive on some platforms or slow builders. Run with 50 threads in short mode instead. This makes the failure less reproducible even with buggy code. But one can manually stress test it (e.g. when a flaky failure appear on the builder). Fixes #53641. Change-Id: I33b5ea5ecaa8c7a56f59c16f9171657ee295db47 Reviewed-on: https://go-review.googlesource.com/c/go/+/415677 Reviewed-by: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com>
* cmd/internal/obj/arm64: save LR and SP in one instruction for small framesCherry Mui2022-06-292-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we create a thread with signals blocked. But glibc's pthread_sigmask doesn't really allow us to block SIGSETXID. So we may get a signal early on before the signal stack is set. If we get a signal on the current stack, it will clobber anything below the SP. This CL makes it to save LR and decrement SP in a single MOVD.W instruction for small frames, so we don't write below the SP. We used to use a single MOVD.W instruction before CL 379075. CL 379075 changed to use an STP instruction to save the LR and FP, then decrementing the SP. This CL changes it back, just this part (epilogues and large frame prologues are unchanged). For small frames, it is the same number of instructions either way. This decreases the size of a "small" frame from 0x1f0 to 0xf0. For frame sizes in between, it could benefit from using an STP instruction instead of using the prologue for the "large" frame case. We don't bother it for now as this is a stop-gap solution anyway. This only addresses the issue with small frames. Luckily, all functions from thread entry to setting up the signal stack have samll frames. Other possible ideas: - Expand the unwind info metadata, separate SP delta and the location of the return address, so we can express "SP is decremented but the return address is in the LR register". Then we can always create the frame first then write the LR, without writing anything below the SP (except the frame pointer at SP-8, which is minor because it doesn't really affect program execution). - Set up the signal stack immediately in mstart in assembly. For Go 1.19 we do this simple fix. We plan to do the metadata fix in Go 1.20 ( #53609 ). Other LR architectures are addressed in CL 413428. Fix #53374. Change-Id: I9d6582ab14ccb06ac61ad43852943d9555e22ae5 Reviewed-on: https://go-review.googlesource.com/c/go/+/412474 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Eric Fang <eric.fang@arm.com>
* cmd/go: prepend builtin prolog when checking for preamble errorsqmuntal2022-06-252-0/+15
| | | | | | | | | | | | | Fixes #50710 Change-Id: I62feddbe3eaae9605d196bec60d378614436603a Reviewed-on: https://go-review.googlesource.com/c/go/+/379754 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
* cmd/cgo: dont override declared struct typekkHAIKE2022-06-225-0/+67
| | | | | | | | | | | | | | | | Fixes #52611 Change-Id: I835df8d6a98a37482446ec00af768c96fd8ee4fe GitHub-Last-Rev: ea54dd69eef90eaf1641889039344fff70158ece GitHub-Pull-Request: golang/go#52733 Reviewed-on: https://go-review.googlesource.com/c/go/+/404497 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dexter Ouyang <kkhaike@gmail.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Rakoczy <alex@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/cgo/testsanitizers: buffer the signal channel in TestTSAN/tsan11Bryan C. Mills2022-05-271-1/+1
| | | | | | | | | | | | | | | | This fix is analogous to the one in CL 407888. 'go vet' catches the error, but it is not run on this file because the file is (only) compiled when running testsanitizers/TestTSAN. Fixes #53113. Change-Id: I74f7b7390a9775ff00a06214c1019ba28846dd11 Reviewed-on: https://go-review.googlesource.com/c/go/+/409094 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* misc/cgo/testsanitizers: use buffered channel in tsan12.goCherry Mui2022-05-241-1/+1
| | | | | | | | | | | | | | | | | | os/signal.Notify requires that "the caller must ensure that c has sufficient buffer space to keep up with the expected signal rate" as it does a nonblocking send when it receives a signal. The test currently using a unbuffered channel, which means it may miss the signal if the signal arrives before the channel receive operation. Fixes #52998. Change-Id: Icdcab9396d735506480ef880fb45a4669fa7cc8f Reviewed-on: https://go-review.googlesource.com/c/go/+/407888 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/cgo/testsanitizers: terminate commands with SIGQUIT if hungBryan C. Mills2022-05-231-2/+20
| | | | | | | | | | | | | | | | If the test hangs due to a deadlock in a subprocess, we want a goroutine dump of that process to figure out the nature of the deadlock. SIGQUIT causes the Go runtime to produce exactly such a dump (unless the runtime itself is badly deadlocked). For #52998. Change-Id: Id9b3ba89d8f705e14f6cd789353fc2b7f4774ad3 Reviewed-on: https://go-review.googlesource.com/c/go/+/407954 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc, test: fix test error for loong64Xiaodong Liu2022-05-201-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | Contributors to the loong64 port are: Weining Lu <luweining@loongson.cn> Lei Wang <wanglei@loongson.cn> Lingqin Gong <gonglingqin@loongson.cn> Xiaolin Zhao <zhaoxiaolin@loongson.cn> Meidan Li <limeidan@loongson.cn> Xiaojuan Zhai <zhaixiaojuan@loongson.cn> Qiyuan Pu <puqiyuan@loongson.cn> Guoqi Chen <chenguoqi@loongson.cn> This port has been updated to Go 1.15.6: https://github.com/loongson/go Updates #46229 Change-Id: I6760b4a7e51646773cd0f48baa1baba01b213b7d Reviewed-on: https://go-review.googlesource.com/c/go/+/342325 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* misc/cgo/testplugin: set the package name in TestIssue19534Bryan C. Mills2022-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fix for #19534 (in CL 40994) adjusted escaping in the dynamically-linked name lookup logic for the plugin package. However, the regression test added for it incorrectly included quotes within the -ldflags flag, causing the flag to inadvertently be ignored. Possibly in that same CL or possibly at some other point, the condition that the test thought it was checking stopped working: the dynamic lookup used the path passed to ldflags, but the object file actually contained the symbol indexed by the original package name. Ideally we should stop mucking around with ldflags in this test and run 'go build' from a suitably-named directory instead, to mimic the actual conditions in which the original bug was reported. For now, as a more targeted fix, we can pass the '-p' flag to the compiler to adjust the package path used at compile time to match the one that will be set at link time. For #43177. Updates #19534. Change-Id: I9763961feb37cfb05dee543f273492e91a350663 Reviewed-on: https://go-review.googlesource.com/c/go/+/407314 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
* misc/cgo: invoke "go" from $GOROOT/bin instead of $PATHBryan C. Mills2022-05-192-7/+16
| | | | | | | | | | | | | | | | | | | If PATH doesn't contain GOROOT/bin as the first element, this could otherwise end up running entirely the wrong command (and from the wrong GOROOT, even). I pre-tested this change on release-branch.go1.17 using a gomote. I believe that it will fix the test failure on that branch, but will need to be backported. For #52995. Change-Id: Ib0c43289a1e0ccf9409f0f0ef8046501a955ce65 Reviewed-on: https://go-review.googlesource.com/c/go/+/407294 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* test,misc: fix builders that do not support pluginCuong Manh Le2022-05-172-0/+13
| | | | | | | | | | | | | | | | CL 406358 added test that use -buildmode=plugin. But plugin mode only supports on some os/arch pairs, so this CL moving the test to misc/cgo/testplugin directory instead. Updates #52937 Change-Id: Iad049443c1f6539f6af1988bebd4dff56c6e1bf9 Reviewed-on: https://go-review.googlesource.com/c/go/+/406774 Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* runtime: add address sanitizer support for riscv64Meng Zhuo2022-05-161-1/+1
| | | | | | | | | | | | Updates #44853 Change-Id: I3ba6ec0cfc6c7f311b586deedb1cda0f87a637aa Reviewed-on: https://go-review.googlesource.com/c/go/+/375256 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joel Sing <joel@sing.id.au> Run-TryBot: Zhuo Meng <mzh@golangcn.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: David Chase <drchase@google.com>
* cmd/dist: add asan tests for global objects in testsanitizers packagefanzha022022-05-056-0/+136
| | | | | | | | | | | | | | | Add tests to test that -asan in Go can detect the error memory access to the global objects. Updates #44853. Change-Id: I612a048460b497d18389160b66e6f818342d3941 Reviewed-on: https://go-review.googlesource.com/c/go/+/321716 Run-TryBot: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
* cmd/compile: enable Asan check for global variablesfanzha022022-05-042-5/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this patch, -asan option can detect the error memory access to global variables. So this patch makes a few changes: 1. Add the asanregisterglobals runtime support function, which calls asan runtime function _asan_register_globals to register global variables. 2. Create a new initialization function for the package being compiled. This function initializes an array of instrumented global variables and pass it to function runtime.asanregisterglobals. An instrumented global variable has trailing redzone. 3. Writes the new size of instrumented global variables that have trailing redzones into object file. 4. Notice that the current implementation is only compatible with the ASan library from version v7 to v9. Therefore, using the -asan option requires that the gcc version is not less than 7 and the clang version is less than 4, otherwise a segmentation fault will occur. So this patch adds a check on whether the compiler being used is a supported version in cmd/go. (This is a redo of CL 401775 with a fix for a build break due to an intervening commit that removed the internal/execabs package.) Updates #44853. Change-Id: I719d4ef2b22cb2d5516e1494cd453c3efb47d6c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/403851 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* Revert "cmd/compile: enable Asan check for global variables"Bryan Mills2022-05-042-28/+5
| | | | | | | | | | | | | | | This reverts CL 401775. Reason for revert: broke build. Change-Id: I4f6f2edff1e4afcf31cd90e26dacf303979eb10c Reviewed-on: https://go-review.googlesource.com/c/go/+/403981 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
* cmd/compile: enable Asan check for global variablesfanzha022022-05-042-5/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this patch, -asan option can detect the error memory access to global variables. So this patch makes a few changes: 1. Add the asanregisterglobals runtime support function, which calls asan runtime function _asan_register_globals to register global variables. 2. Create a new initialization function for the package being compiled. This function initializes an array of instrumented global variables and pass it to function runtime.asanregisterglobals. An instrumented global variable has trailing redzone. 3. Writes the new size of instrumented global variables that have trailing redzones into object file. 4. Notice that the current implementation is only compatible with the ASan library from version v7 to v9. Therefore, using the -asan option requires that the gcc version is not less than 7 and the clang version is less than 4, otherwise a segmentation fault will occur. So this patch adds a check on whether the compiler being used is a supported version in cmd/go. Updates #44853. Change-Id: Ib877a817209ab2be68a8e22c418fe4a4a20880fc Reviewed-on: https://go-review.googlesource.com/c/go/+/401775 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* [dev.boringcrypto] all: add boringcrypto build tagsRuss Cox2022-04-291-1/+1
| | | | | | | | | | | | | | | | | | A plain make.bash in this tree will produce a working, standard Go toolchain, not a BoringCrypto-enabled one. The BoringCrypto-enabled one will be created with: GOEXPERIMENT=boringcrypto ./make.bash For #51940. Change-Id: Ia9102ed993242eb1cb7f9b93eca97e81986a27b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/395881 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* Revert "cmd/compile: enable Asan check for global variables"Bryan Mills2022-04-222-24/+0
| | | | | | | | | | | | | This reverts CL 321715. Reason for revert: broke cmd/go.TestScript/install_msan_and_race_require_cgo on several builders. Change-Id: Ia0392de555d6e973960769a0e4709f0193d16706 Reviewed-on: https://go-review.googlesource.com/c/go/+/401755 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
* cmd/compile: enable Asan check for global variablesfanzha022022-04-222-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this patch, -asan option can detect the error memory access to global variables. So this patch makes a few changes: 1. Add the asanregisterglobals runtime support function, which calls asan runtime function _asan_register_globals to register global variables. 2. Create a new initialization function for the package being compiled. This function initializes an array of instrumented global variables and pass it to function runtime.asanregisterglobals. An instrumented global variable has trailing redzone. 3. Writes the new size of instrumented global variables that have trailing redzones into object file. 4. Notice that the current implementation is only compatible with the ASan library from version v7 to v9. Therefore, using the -asan option requires that the gcc version is not less than 7 and the clang version is less than 4, otherwise a segmentation fault will occur. So this patch adds a check on whether the compiler being used is a supported version in cmd/go. Change-Id: I664e74dcabf5dc7ed46802859174606454e8f1d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/321715 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* misc/cgo/test: remove timing dependency from TestParallelSleepIan Lance Taylor2022-04-213-53/+33
| | | | | | | | | | | | | | | Rename it TestIssue1560 since it no longer sleeps. For #1560 Fixes #45586 Change-Id: I338eee9de43e871da142143943e9435218438e90 Reviewed-on: https://go-review.googlesource.com/c/go/+/400194 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* all: gofmt main repoRuss Cox2022-04-111-4/+3
| | | | | | | | | | | | | | | [This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go: cgo export header to be compatible with MSVC complex typesqmuntal2022-04-082-0/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After CL 379474 has landed, the only remaining cgo export header incompatibility with MSVC is the use of the _Complex macro, which is not supported in MSVC even when it is part of the ISO C99 standard (1). Since MSVC 2015 (2), complex math are supported via _Fcomplex and _Dcomplex, which are equivalent to float _Complex and double _Complex. As MSVC and C complex types have the same memory layout, we should be able to typedef GoComplex64 and GoComplex128 to the appropriate type in MSVC. It is important to note that this CL is not adding MSVC support to cgo. C compilers should still be GCC-compatible. This CL is about allowing to include, without further modifications, a DLL export header generated by cgo, normally using Mingw-W64 compiler, into a MSVC project. This was already possible if the export header changes introduced in this CL were done outside cgo, either manually or in a post-build script. Fixes #36233 1: https://docs.microsoft.com/en-us/cpp/c-runtime-library/complex-math-support 2: https://docs.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?c-standard-library-features-1 Change-Id: Iad8f26984b115c728e3b73f3a8334ade7a11cfa1 Reviewed-on: https://go-review.googlesource.com/c/go/+/397134 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Auto-Submit: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/cgo: retain original file paths in godefs generated commentTobias Klauser2022-04-031-1/+25
| | | | | | | | | | | | | | Don't rewrite relative file paths to absolute file paths in the godefs generated code comment. Fixes #52063 Change-Id: Ie9c5bd021b8f3954e827838930861622c7aa90b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/396936 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/compile: set conversions to unsafe.Pointer as an escaping operation when ↵fanzha022022-03-174-0/+79
| | | | | | | | | | | | | | | | | | | | | | -asan is enabled When ASan is enabled, treat conversions to unsafe.Pointer as an escaping operation. In this way, all pointer operations on the stack objects will become operations on the escaped heap objects. As we've already supported ASan detection of error memory accesses to heap objects. With this trick, we can use -asan option to report errors on bad stack operations. Add test cases. Updates #44853. Change-Id: I6281e77f6ba581d7008d610f0b24316078b6e746 Reviewed-on: https://go-review.googlesource.com/c/go/+/393315 Trust: Fannie Zhang <Fannie.Zhang@arm.com> Run-TryBot: Fannie Zhang <Fannie.Zhang@arm.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Eric Fang <eric.fang@arm.com>
* Revert "cmd/compile: set conversions to unsafe.Pointer as an escaping ↵Fannie Zhang2022-03-174-79/+0
| | | | | | | | | | | | | operation when -asan is enabled" This reverts commit 5fd0ed7aaf39f783ea6f505a3f2ac7d9da7cb03b. Reason for revert: <The internal information in commit message is not removed.> Change-Id: Id6845a9c8114ac71c56a1007a4d133a560a37fbc Reviewed-on: https://go-review.googlesource.com/c/go/+/393314 Trust: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Eric Fang <eric.fang@arm.com>
* cmd/link: mark unexported methods for pluginsCherry Mui2022-03-164-0/+66
| | | | | | | | | | | | | | | | | When plugin is used, we already mark all exported methods reachable. However, when the plugin and the host program share a common package, an unexported method could also be reachable from both the plugin and the host via interfaces. We need to mark them as well. Fixes #51621. Change-Id: I1a70d3f96b66b803f2d0ab14d00ed0df276ea500 Reviewed-on: https://go-review.googlesource.com/c/go/+/393365 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
* cmd/compile: set conversions to unsafe.Pointer as an escaping operation when ↵fanzha022022-03-164-0/+79
| | | | | | | | | | | | | | | | | | | | | -asan is enabled When ASan is enabled, treat conversions to unsafe.Pointer as an escaping operation. In this way, all pointer operations on the stack objects will become operations on the escaped heap objects. As we've already supported ASan detection of error memory accesses to heap objects. With this trick, we can use -asan option to report errors on bad stack operations. Add test cases. Updates #44853. CustomizedGitHooks: yes Change-Id: I4e7fe46a3ce01f0d219e6a67dc50f4aff7d2ad87 Reviewed-on: https://go-review.googlesource.com/c/go/+/325629 Trust: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Keith Randall <khr@golang.org>
* all: fix typoscuishuang2022-02-281-1/+1
| | | | | | | | | | | Change-Id: I93ff3d33a5db130dd57a9545456f2961fc3f668b GitHub-Last-Rev: f95fafc04937a99f82cb992aabb7bac602033d8e GitHub-Pull-Request: golang/go#51394 Reviewed-on: https://go-review.googlesource.com/c/go/+/388314 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
* misc/cgo: fix aliasing bugs in parallel tests that append to shared slicesBryan C. Mills2022-02-073-27/+10
| | | | | | | | | | | | | | | | | | | These tests use a slice to represent the base C compiler command (with flags). Appending to that slice can cause subtle aliasing bugs, such as commands that silently corrupt the arguments of other concurrent commands in parallel tests. In this change, we explicitly reduce the capacity of the command slice to force appends to it to always allocate unique new slices. Fixes #49693 Change-Id: Ide466bf65f12cb6cead3dcba69f513cccb60a160 Reviewed-on: https://go-review.googlesource.com/c/go/+/383754 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/cgo/test: disable unhelpful GCC warningIan Lance Taylor2022-02-031-0/+5
| | | | | | | | | | | | | | | GCC 9 warns about a change in the ABI of passing structs with bitfields, but we don't care. Fixes #50987 Change-Id: Ica658d04172a42a7be788f94d31a714bb8c4766f Reviewed-on: https://go-review.googlesource.com/c/go/+/382956 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Trust: Benny Siegert <bsiegert@gmail.com>
* src/runtime: mark asanread and asanwrite functions as NOSPLITfanzha022022-01-052-0/+22
| | | | | | | | | | | | | | | | The asan runtime functions may run on stacks that cannot grow, and they do not have large local variables, so it is safe to mark them as NOSPLIT. Add test case. Fixes #50391 Change-Id: Iadcbf1ae0c837d9b64da5be208c7f424e6ba11de Reviewed-on: https://go-review.googlesource.com/c/go/+/374398 Trust: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* misc/cgo/testsanitizers: accept compilers that don't report locationIan Lance Taylor2021-12-292-1/+22
| | | | | | | | | | | | It appears that GCC before version 10 doesn't report file/line location for asan errors. Change-Id: I03ee24180ba365636596aa2384961df7ce6ed71f Reviewed-on: https://go-review.googlesource.com/c/go/+/374874 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/cgo/testsanitizers: don't fail asan test if no symbolizerIan Lance Taylor2021-12-291-3/+8
| | | | | | | | Change-Id: Ic05c641bda3cc8f5292921c9b0c0d3df34f3bc48 Reviewed-on: https://go-review.googlesource.com/c/go/+/374794 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* runtime: fix the issue that the -asan option cannot print where the error ↵fanzha022021-12-294-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | occurred The current -asan option does not print where the error occurred. The reason is that the current implementation calls incorrect asan runtime functions, which do not pass sp and pc where asan runtime functions are called, and report the stack trace from the native code. But asan runtime functions are called from cgo on a separated stack, so it cannot dump the Go stack trace correctly. The correct asan runtime function we should call is __asan_report_error, which will pass sp and pc, and report where the error occurred correctly. This patch fixes this issue. Add the test cases. Fixes #50362 Change-Id: I12ee1d46c7ae069ddef3d23f2fe86e112db60045 Reviewed-on: https://go-review.googlesource.com/c/go/+/374395 Trust: Fannie Zhang <Fannie.Zhang@arm.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/link: use SHT_INIT_ARRAY for .init_array sectionIan Lance Taylor2021-12-211-0/+178
| | | | | | | | | Fixes #50295 Change-Id: If55ebcd5f2af724da7c9c744458a56d21a7ddde7 Reviewed-on: https://go-review.googlesource.com/c/go/+/373734 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* cmd/link: force eager binding when using plugins on darwinCherry Mui2021-12-172-0/+58
| | | | | | | | | | | | | | | | | | When building/using plugins on darwin, we need to use flat namespace so the same symbol from the main executable and the plugin can be resolved to the same address. Apparently, when using flat namespace the dynamic linker can hang at forkExec when resolving a lazy binding. Work around it by forcing early bindings. Fixes #38824. Change-Id: I983aa0a0960b15bf3f7871382e8231ee244655f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/372798 Trust: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/cgo/testcarchive: log command output more consistentlyBryan C. Mills2021-12-161-42/+76
| | | | | | | | | | | | | | | | | | | | | | | Also check that executables exist immediately after building them in parallel tests. The parallel tests in this package occasionally fail with "no such file or directory", implying that either the build command failed to actually write out the binary or something concurrently deleted it. This is purely a shot in the dark, but I'm hoping that perhaps the stderr output from one of these commands will shed some light on the underlying failure mode. For #49693 Change-Id: I2e768190c56053550879b89a3ac88c027d4741dd Reviewed-on: https://go-review.googlesource.com/c/go/+/369034 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/cgo/testshared: increase size limit in size checkJakub Čajka2021-12-151-2/+6
| | | | | | | | | | | | | | Recently in Fedora we switched binutils ld's separate-code on. This led to increased size of binaries, especially on 64k aligned arches. For example trivial test binary size grew from 80k to 211k on ppc64le tripping the size check(RHBZ#2030308). Therefore adjusting the size limit. Change-Id: Ic722d90c338739c0b285f40b12ba4d675e9626a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/371634 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* misc/cgo/testshared: pass -x flag only to commands supporting itJakub Čajka2021-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | Running testshared with the -testx flag leads to: ./testshared.test -testx -testwork + mkdir -p /tmp/shared_test125221103 shared_test.go:79: executing go env -x GOROOT failed exit status 2: flag provided but not defined: -x usage: go env [-json] [-u] [-w] [var ...] Run 'go help env' for details. panic: executing go env -x GOROOT failed exit status 2: flag provided but not defined: -x usage: go env [-json] [-u] [-w] [var ...] Run 'go help env' for details. Change-Id: Id299979487c021e9ad1d57f5f7088d935830a6a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/371614 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Cherry Mui <cherryyz@google.com>
* runtime: fix comments on the behavior of SetGCPercentMichael Anthony Knyszek2021-12-071-1/+3
| | | | | | | | | | | | | | | | | | | | | Fixes for #49680, #49695, #45867, and #49370 all assumed that SetGCPercent(-1) doesn't block until the GC's mark phase is done, but it actually does. The cause of 3 of those 4 failures comes from the fact that at the beginning of the sweep phase, the GC does try to preempt every P once, and this may run concurrently with test code. In the fourth case, the issue was likely that only *one* of the debug_test.go tests was missing a call to SetGCPercent(-1). Just to be safe, leave a TODO there for now to remove the extraneous runtime.GC calls, but leave the calls in. Updates #49680, #49695, #45867, and #49370. Change-Id: Ibf4e64addfba18312526968bcf40f1f5d54eb3f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/369815 Reviewed-by: Austin Clements <austin@google.com> Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/cgo/testplugin: remove skip in TestIssue25756pieDmitri Shuralyov2021-12-071-4/+0
| | | | | | | | | | | | | | | | Though this was a problem for Go 1.17, it appears not to be a problem on tip. This reverts change made in CL 321349. For #46239. Change-Id: Ie4d6649fbabce3bb2c1cf04d97760ba6ceadaca5 Reviewed-on: https://go-review.googlesource.com/c/go/+/369752 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
* misc/cgo/test: further reduce likeliness of hang in Test9400Paul E. Murphy2021-11-301-0/+2
| | | | | | | | | | | | | | | As suggested by #49680, a GC could be in-progress when we disable GC. Force a GC after we pause to ensure we don't hang in this case. For #49695 Change-Id: I4fc4c06ef2ac174217c3dcf7d58c7669226e2d24 Reviewed-on: https://go-review.googlesource.com/c/go/+/367874 Run-TryBot: Paul Murphy <murp@ibm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Paul Murphy <murp@ibm.com>
* misc/cgo/test: reduce likeliness of hang in Test9400Paul E. Murphy2021-11-301-0/+5
| | | | | | | | | | | | | | | If a GC triggers while spinning in RewindAndSetgid, it may result in this test hanging. Avoid it by disabling the collector before entering the uninterruptable ASM conditional wait. Fixes #49695 Change-Id: Ie0a03653481fb746f862469361b7840f4bfa8b67 Reviewed-on: https://go-review.googlesource.com/c/go/+/365836 Run-TryBot: Paul Murphy <murp@ibm.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* misc/cgo/testcshared: skip TestGo2C2Go on WindowsIan Lance Taylor2021-11-221-3/+3
| | | | | | | | | | | | | | For #27019 Fixes #49457 Change-Id: I398abb7b555196ced34a6dd04b68195bf8bbdd38 Reviewed-on: https://go-review.googlesource.com/c/go/+/365994 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Patrik Nyblom <pnyb@google.com>