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

runtime/cgo: does not build with -Wdeclaration-after-statement #71961

Closed
ianlancetaylor opened this issue Feb 26, 2025 · 8 comments
Closed

runtime/cgo: does not build with -Wdeclaration-after-statement #71961

ianlancetaylor opened this issue Feb 26, 2025 · 8 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ianlancetaylor
Copy link
Member

ianlancetaylor commented Feb 26, 2025

Go version

HEAD

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/iant/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/iant/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build182329227=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/iant/go/src/go.mod'
GOMODCACHE='/home/iant/gopath/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/iant/gopath'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org'
GOROOT='/home/iant/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/home/iant/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/iant/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.25-778a558d08 Tue Feb 25 09:37:58 2025 -0800'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

CGO_CFLAGS=-Wdeclaration-after-statement go build runtime/cgo

What did you see happen?

# runtime/cgo
gcc_libinit.c: In function ‘x_cgo_sys_thread_create’:
gcc_libinit.c:45:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
   45 |         int err = _cgo_try_pthread_create(&p, &attr, func, arg);
      |         ^~~
gcc_libinit.c: In function ‘_cgo_wait_runtime_init_done’:
gcc_libinit.c:57:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
   57 |         int done = 2;
      |         ^~~
cc1: all warnings being treated as errors

What did you expect to see?

I did not expect to see any errors.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Feb 26, 2025
@ianlancetaylor
Copy link
Member Author

@gopherbot Please open backport issues.

This breaks the SWIG CI build.

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #71962 (for 1.23), #71963 (for 1.24).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/652181 mentions this issue: runtime/cgo: avoid errors from -Wdeclaration-after-statement

@dmitshur dmitshur added this to the Go1.25 milestone Feb 26, 2025
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. FixPending Issues that have a fix which has not yet been reviewed or submitted. labels Feb 26, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/652936 mentions this issue: [release-branch.go1.24] runtime/cgo: avoid errors from -Wdeclaration-after-statement

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/652935 mentions this issue: [release-branch.go1.23] runtime/cgo: avoid errors from -Wdeclaration-after-statement

gopherbot pushed a commit that referenced this issue Feb 26, 2025
…after-statement

It's used by the SWIG CI build, at least, and it's an easy fix.

[The change in x_cgo_sys_thread_create is gone, as that function was
already compliant in 1.23.]

Fixes #71962
For #71961

Change-Id: Id21071a5aef216b35ecf0e9cd3e05d08972d92fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/652181
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
(cherry picked from commit 76c7028)
Reviewed-on: https://go-review.googlesource.com/c/go/+/652935
Reviewed-by: Michael Knyszek <mknyszek@google.com>
gopherbot pushed a commit that referenced this issue Feb 26, 2025
…after-statement

It's used by the SWIG CI build, at least, and it's an easy fix.

Fixes #71963
For #71961

Change-Id: Id21071a5aef216b35ecf0e9cd3e05d08972d92fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/652181
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
(cherry picked from commit 76c7028)
Reviewed-on: https://go-review.googlesource.com/c/go/+/652936
Reviewed-by: Michael Knyszek <mknyszek@google.com>
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/653135 mentions this issue: runtime/cgo: avoid errors from -Wdeclaration-after-statement

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/653136 mentions this issue: [release-branch.go1.23] runtime/cgo: avoid errors from -Wdeclaration-after-statement

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/653137 mentions this issue: [release-branch.go1.24] runtime/cgo: avoid errors from -Wdeclaration-after-statement

gopherbot pushed a commit that referenced this issue Feb 26, 2025
CL 652181 accidentally missed this iPhone only code.

For #71961

Change-Id: I567f8bb38958907442e69494da330d5199d11f54
Reviewed-on: https://go-review.googlesource.com/c/go/+/653135
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
gopherbot pushed a commit that referenced this issue Feb 26, 2025
…after-statement

CL 652181 accidentally missed this iPhone only code.

For #71961
For #71962

Change-Id: I567f8bb38958907442e69494da330d5199d11f54
Reviewed-on: https://go-review.googlesource.com/c/go/+/653136
Reviewed-by: Michael Pratt <mpratt@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
gopherbot pushed a commit that referenced this issue Feb 26, 2025
…after-statement

CL 652181 accidentally missed this iPhone only code.

For #71961
For #71963

Change-Id: I567f8bb38958907442e69494da330d5199d11f54
Reviewed-on: https://go-review.googlesource.com/c/go/+/653137
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants