aboutsummaryrefslogtreecommitdiff
path: root/misc/cgo/testplugin/testdata/forkexec/main.go
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2021-12-16 14:33:13 -0500
committerCherry Mui <cherryyz@google.com>2022-02-07 20:38:28 +0000
commit5ef95666946dd744c0392166981783f72687993f (patch)
tree5063be892fd59aefbe0b8194248e9c21df318ccd /misc/cgo/testplugin/testdata/forkexec/main.go
parent6b3e741a834c34b8a844a33b3aa060dd4ed37231 (diff)
downloadgo-5ef95666946dd744c0392166981783f72687993f.tar.gz
go-5ef95666946dd744c0392166981783f72687993f.zip
[release-branch.go1.16] cmd/link: force eager binding when using plugins on darwin
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. Updates #38824. Fixes #50245. 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> (cherry picked from commit c5fee935bbb8f02406eb653cfed550593755a1a4) Reviewed-on: https://go-review.googlesource.com/c/go/+/373095
Diffstat (limited to 'misc/cgo/testplugin/testdata/forkexec/main.go')
-rw-r--r--misc/cgo/testplugin/testdata/forkexec/main.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/misc/cgo/testplugin/testdata/forkexec/main.go b/misc/cgo/testplugin/testdata/forkexec/main.go
new file mode 100644
index 0000000000..3169ff5f04
--- /dev/null
+++ b/misc/cgo/testplugin/testdata/forkexec/main.go
@@ -0,0 +1,30 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "os"
+ "os/exec"
+ _ "plugin"
+ "sync"
+)
+
+func main() {
+ if os.Args[1] != "1" {
+ return
+ }
+
+ var wg sync.WaitGroup
+ for i := 0; i < 8; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ // does not matter what we exec, just exec itself
+ cmd := exec.Command("./forkexec.exe", "0")
+ cmd.Run()
+ }()
+ }
+ wg.Wait()
+}