From c47eac7db00e03776c3975025184e1938fbced75 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 20 Nov 2020 12:54:18 -0800 Subject: cmd/cgo, cmd/internal/pkgpath: support gofrontend mangler v3 The gofrontend mangling scheme used by gccgo and GoLLVM has changed again. Support the new version. This is a port of the relevant parts of https://golang.org/cl/271726. For #41862 Change-Id: I9c961c8e17ec960a83a23e1d49ea900962b63393 Reviewed-on: https://go-review.googlesource.com/c/go/+/272127 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Than McIntosh TryBot-Result: Go Bot --- src/cmd/internal/pkgpath/pkgpath_test.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/cmd/internal/pkgpath/pkgpath_test.go') diff --git a/src/cmd/internal/pkgpath/pkgpath_test.go b/src/cmd/internal/pkgpath/pkgpath_test.go index 7355f81bae..232e803a60 100644 --- a/src/cmd/internal/pkgpath/pkgpath_test.go +++ b/src/cmd/internal/pkgpath/pkgpath_test.go @@ -24,6 +24,9 @@ func init() { case "v2": os.Stdout.WriteString(`.string "go.l..u00e4ufer.Run"`) os.Exit(0) + case "v3": + os.Stdout.WriteString(`.string "go_0l_u00e4ufer.Run"`) + os.Exit(0) case "error": os.Stdout.WriteString(`unknown string`) os.Exit(0) @@ -45,6 +48,10 @@ func TestToSymbolFunc(t *testing.T) { env: "v2", mangled: "p..u00e4..u4e16..U0001f703", }, + { + env: "v3", + mangled: "p_u00e4_u4e16_U0001f703", + }, { env: "error", fail: true, @@ -75,32 +82,37 @@ func TestToSymbolFunc(t *testing.T) { } var symbolTests = []struct { - input, v1, v2 string + input, v1, v2, v3 string }{ { "", "", "", + "", }, { "bytes", "bytes", "bytes", + "bytes", }, { "net/http", "net_http", "net..z2fhttp", + "net_1http", }, { "golang.org/x/net/http", "golang_org_x_net_http", "golang.x2eorg..z2fx..z2fnet..z2fhttp", + "golang_0org_1x_1net_1http", }, { "pä世.🜃", "p____", "p..u00e4..u4e16.x2e..U0001f703", + "p_u00e4_u4e16_0_U0001f703", }, } @@ -119,3 +131,11 @@ func TestV2(t *testing.T) { } } } + +func TestV3(t *testing.T) { + for _, test := range symbolTests { + if got, want := toSymbolV3(test.input), test.v3; got != want { + t.Errorf("toSymbolV3(%q) = %q, want %q", test.input, got, want) + } + } +} -- cgit v1.3