Skip to content

Conversation

@ariel-anieli
Copy link
Contributor

This CL improves on CL 579955.

When the call site has no argument,

 1  package main
 2
 3  /*
 4     #include <stdio.h>
 5     void foo() {printf("Hello from C\n");}
 6  */
 7  import "C"
 8
 9  func main() {
10          C.foo()
11  }

Escape checks are not needed,

$ go tool cgo -objdir dir cgonoargs.go
$ cat -n dir/_cgo_gotypes.go | sed -n '43,$p'
    43  func _Cfunc_foo() (r1 _Ctype_void) {
    44          _cgo_runtime_cgocall(_cgo_c8ba2f813f11_Cfunc_foo, uintptr(unsafe.Pointer(&r1)))
    45          if _Cgo_always_false {
    46          }
    47          return
    48  }

Skip escape checks if call site has no argument.

$ cat -n dir/_cgo_gotypes.go | sed -n '43,$p'
    43  func _Cfunc_foo() (r1 _Ctype_void) {
    44          _cgo_runtime_cgocall(_cgo_c8ba2f813f11_Cfunc_foo, uintptr(unsafe.Pointer(&r1)))
    45          return
    46  }

For #75856

This CL improves on CL 579955.

When the call site has no argument,

     1  package main
     2
     3  /*
     4     #include <stdio.h>
     5     void foo() {printf("Hello from C\n");}
     6  */
     7  import "C"
     8
     9  func main() {
    10          C.foo()
    11  }

Escape checks are not needed,

    $ go tool cgo -objdir dir cgonoargs.go
    $ cat -n dir/_cgo_gotypes.go | sed -n '43,$p'
        43  func _Cfunc_foo() (r1 _Ctype_void) {
        44          _cgo_runtime_cgocall(_cgo_c8ba2f813f11_Cfunc_foo, uintptr(unsafe.Pointer(&r1)))
        45          if _Cgo_always_false {
        46          }
        47          return
        48  }

Skip escape checks if call site has no argument.

    $ cat -n dir/_cgo_gotypes.go | sed -n '43,$p'
        43  func _Cfunc_foo() (r1 _Ctype_void) {
        44          _cgo_runtime_cgocall(_cgo_c8ba2f813f11_Cfunc_foo, uintptr(unsafe.Pointer(&r1)))
        45          return
        46  }

For golang#75856
@gopherbot
Copy link
Contributor

This PR (HEAD: 1aacde4) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/718060.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/718060.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Ariel Otilibili Anieli:

Patch Set 1:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/718060.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Keith Randall:

Patch Set 1: Auto-Submit+1 Code-Review+2 Commit-Queue+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/718060.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 1:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2025-11-05T16:56:02Z","revision":"34fe05102503470e9fd32f996383d403ff189e1f"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/718060.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Keith Randall:

Patch Set 1: Code-Review+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/718060.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Keith Randall:

Patch Set 1: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/718060.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 1:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/718060.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 1: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/718060.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 1: Code-Review+2


Please don’t reply on this GitHub thread. Visit golang.org/cl/718060.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Nov 5, 2025
This CL improves on CL 579955.

When the call site has no argument,

     1  package main
     2
     3  /*
     4     #include <stdio.h>
     5     void foo() {printf("Hello from C\n");}
     6  */
     7  import "C"
     8
     9  func main() {
    10          C.foo()
    11  }

Escape checks are not needed,

    $ go tool cgo -objdir dir cgonoargs.go
    $ cat -n dir/_cgo_gotypes.go | sed -n '43,$p'
        43  func _Cfunc_foo() (r1 _Ctype_void) {
        44          _cgo_runtime_cgocall(_cgo_c8ba2f813f11_Cfunc_foo, uintptr(unsafe.Pointer(&r1)))
        45          if _Cgo_always_false {
        46          }
        47          return
        48  }

Skip escape checks if call site has no argument.

    $ cat -n dir/_cgo_gotypes.go | sed -n '43,$p'
        43  func _Cfunc_foo() (r1 _Ctype_void) {
        44          _cgo_runtime_cgocall(_cgo_c8ba2f813f11_Cfunc_foo, uintptr(unsafe.Pointer(&r1)))
        45          return
        46  }

For #75856

Change-Id: I9aac0b6fb2985f6833976099e7eead1f28971bee
GitHub-Last-Rev: 1aacde4
GitHub-Pull-Request: #76186
Reviewed-on: https://go-review.googlesource.com/c/go/+/718060
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
@gopherbot
Copy link
Contributor

Message from Michael Pratt:

Patch Set 1: Code-Review+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/718060.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR is being closed because golang.org/cl/718060 has been merged.

@gopherbot gopherbot closed this Nov 5, 2025
@ariel-anieli ariel-anieli deleted the empty-cgo-checks branch November 8, 2025 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants