From 5e9b76fe2a1c6709e710c985ae82dff90c847c54 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Thu, 1 Jun 2023 17:35:28 -0400 Subject: cmd/link: mangle certain instantiated function name in plugin mode In plugin mode, we mangle the type symbol name so it doesn't contain characters that may confuse the external linker. With generics, instantiated function name includes type names, so it may also contain such characters and so also needs to be mangled. Fixes #58800. Change-Id: Ibb08c95b89b8a815ccef98193d3a025e9d4756cc Reviewed-on: https://go-review.googlesource.com/c/go/+/500095 Reviewed-by: Than McIntosh TryBot-Result: Gopher Robot Run-TryBot: Cherry Mui --- .../internal/testplugin/testdata/generic/plugin.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/cmd/cgo/internal/testplugin/testdata/generic/plugin.go (limited to 'src/cmd/cgo/internal/testplugin/testdata/generic/plugin.go') diff --git a/src/cmd/cgo/internal/testplugin/testdata/generic/plugin.go b/src/cmd/cgo/internal/testplugin/testdata/generic/plugin.go new file mode 100644 index 0000000000..6d3835a7ec --- /dev/null +++ b/src/cmd/cgo/internal/testplugin/testdata/generic/plugin.go @@ -0,0 +1,22 @@ +// Copyright 2023 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. + +// Instantiated function name may contain weird characters +// that confuse the external linker, so it needs to be +// mangled. + +package main + +//go:noinline +func F[T any]() {} + +type S struct { + X int `parser:"|@@)"` +} + +func P() { + F[S]() +} + +func main() {} -- cgit v1.3-5-g9baa