cmd/cgo: enable #cgo noescape/nocallback

In Go 1.22 we added code to the go/build package to ignore #cgo noescape
and nocallback directives. That permits us to enable these directives in Go 1.24.

Also, this fixed a Bug in CL 497837:
After retiring _Cgo_use for parameters, the compiler will treat the
parameters, start from the second, as non-alive. Then, they will be marked
as scalar in stackmap, which means the pointer won't be copied correctly
in copystack.

Fixes #56378.
Fixes #63739.

Change-Id: I46e773240f8a467c3c4ba201dc5b4ee473cf6e3e
GitHub-Last-Rev: 42fcc506d6
GitHub-Pull-Request: golang/go#66879
Reviewed-on: https://go-review.googlesource.com/c/go/+/579955
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
doujiang24 2024-08-16 07:32:00 +00:00 committed by Gopher Robot
parent 96ef6abcca
commit ff271cd391
11 changed files with 126 additions and 21 deletions

View file

@ -117,8 +117,8 @@ int add(int x, int y) {
// escape vs noescape
// TODO(#56378): enable in Go 1.23:
// #cgo noescape handleGoStringPointerNoescape
#cgo noescape handleGoStringPointerNoescape
#cgo nocallback handleGoStringPointerNoescape
void handleGoStringPointerNoescape(void *s) {}
void handleGoStringPointerEscape(void *s) {}