Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #cgo noescape directive #3887

Merged
merged 2 commits into from
Nov 20, 2024
Merged

Add #cgo noescape directive #3887

merged 2 commits into from
Nov 20, 2024

Commits on Nov 19, 2024

  1. compiler: add //go:noescape pragma

    This only works on declarations, not definitions. This is intentional:
    it follows the upstream Go implemetation.
    
    However, we might want to loosen this requirement at some point: TinyGo
    sometimes stores pointers in memory mapped I/O knowing they won't
    actually escape, but the compiler doesn't know about this.
    aykevl committed Nov 19, 2024
    Configuration menu
    Copy the full SHA
    83ec9e8 View commit details
    Browse the repository at this point in the history
  2. cgo: add support for #cgo noescape lines

    Here is the proposal:
    golang/go#56378
    
    They are documented here:
    https://pkg.go.dev/cmd/cgo@master#hdr-Optimizing_calls_of_C_code
    
    This would have been very useful to fix
    tinygo-org/bluetooth#176 in a nice way. That
    bug is now fixed in a different way using a wrapper function, but once
    this new noescape pragma gets included in TinyGo we could remove the
    workaround and use `#cgo noescape` instead.
    aykevl committed Nov 19, 2024
    Configuration menu
    Copy the full SHA
    a45b476 View commit details
    Browse the repository at this point in the history