From e23cc0844d542688c0956900206fca7c602593c5 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Thu, 19 May 2022 10:41:32 -0400 Subject: [PATCH] misc/cgo/testplugin: set the package name in TestIssue19534 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 TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Auto-Submit: Bryan Mills Reviewed-by: Than McIntosh --- misc/cgo/testplugin/plugin_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/cgo/testplugin/plugin_test.go b/misc/cgo/testplugin/plugin_test.go index d373642e45..e8587e69ba 100644 --- a/misc/cgo/testplugin/plugin_test.go +++ b/misc/cgo/testplugin/plugin_test.go @@ -218,7 +218,7 @@ func TestIssue18676(t *testing.T) { func TestIssue19534(t *testing.T) { // Test that we can load a plugin built in a path with non-alpha characters. - goCmd(t, "build", "-buildmode=plugin", "-ldflags='-pluginpath=issue.19534'", "-o", "plugin.so", "./issue19534/plugin.go") + goCmd(t, "build", "-buildmode=plugin", "-gcflags=-p=issue.19534", "-ldflags=-pluginpath=issue.19534", "-o", "plugin.so", "./issue19534/plugin.go") goCmd(t, "build", "-o", "issue19534.exe", "./issue19534/main.go") run(t, "./issue19534.exe") } -- 2.50.0