runtime/cgo: avoid unused parameter warning

Annotate the unused parameter with `__attribute__((unused))` to avoid
build failures in environments that treat unused parameters as errors.

We see this when using `rules_go`:
```
@@rules_go+//:stdlib
builder failed: error executing GoStdlib command (from stdlib rule target @@rules_go+//:stdlib) bazel-out/linux_host_platform-opt-exec-ST-f2d1f3f5d18d/bin/external/rules_go++go_sdk+main___download_0/builder_reset/builder stdlib -sdk external/rules_go++go_sdk+main___download_0 -goroot ... (remaining 16 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
stderr:
# runtime/cgo
gcc_clearenv.c:13:23: error: unused parameter '_unused' [-Werror,-Wunused-parameter]
stdlib: error running subcommand external/rules_go++go_sdk+main___download_0/bin/go: exit status 1
```

This matches the style used in `src/runtime/cgo/gcc_libinit.c` since
dc2ae2886f which fixed an identical issue.

Change-Id: I8c805962b88af480839f8662a1fcf4ed1e5d574d
GitHub-Last-Rev: b99fbda4f6
GitHub-Pull-Request: golang/go#77847
Reviewed-on: https://go-review.googlesource.com/c/go/+/749840
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Tamir Duberstein
2026-02-27 15:14:25 +00:00
committed by Gopher Robot
parent f5479628d3
commit 83b4c5d233

View File

@@ -10,7 +10,7 @@
/* Stub for calling clearenv */
void
x_cgo_clearenv(void **_unused)
x_cgo_clearenv(void **env __attribute__((unused)))
{
_cgo_tsan_acquire();
clearenv();