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

cmd/cgo: -Waddress-of-packed-member warnings popping up with gcc9 in cgo-gcc-prolog #29962

Closed
jcajka opened this issue Jan 28, 2019 · 8 comments

Comments

@jcajka
Copy link
Contributor

commented Jan 28, 2019

What version of Go are you using (go version)?

observed with go1.10+(haven't went any further back) and gcc 9(and binutils-2.31.1) on Fedora rawhide(30)

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

go tool dist test -v -v -k or go test std

What did you expect to see?

tests passing

What did you see instead?

tests build failing due to werror, respectively due to Waddress-of-packed-member

run: go list -gcflags=all= -ldflags=all= -f={{if .Stale}}	STALE {{.ImportPath}}: {{.StaleReason}}{{end}} std DONE
go test -short -count=1 -tags= -run= -ldflags -linkmode=external
# _/builddir/build/BUILD/go/misc/cgo/test/issue27340
cgo-gcc-prolog: In function '_cgo_942106f15754_Cfunc_issue27340CFunc':
cgo-gcc-prolog:40:24: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
cgo-gcc-prolog: In function '_cgo_942106f15754_Cfunc_issue27340Ptr':
cgo-gcc-prolog:55:55: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
# _/builddir/build/BUILD/go/misc/cgo/test
cgo-gcc-prolog: In function '_cgo_5497c10128ac_Cfunc_cTest':
cgo-gcc-prolog:40:14: error: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Werror=address-of-packed-member]
cgo-gcc-prolog: In function '_cgo_5497c10128ac_Cfunc_makeEvent':
cgo-gcc-prolog:52:18: error: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Werror=address-of-packed-member]
cgo-gcc-prolog: In function '_cgo_5497c10128ac_Cfunc_same':
cgo-gcc-prolog:76:22: error: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Werror=address-of-packed-member]
cc1: all warnings being treated as errors
FAIL	_/builddir/build/BUILD/go/misc/cgo/test [build failed]

or you can see only the warning triggered during the build/tests

# net
cgo-gcc-prolog: In function '_cgo_7e1b3c2abc8d_C2func_getaddrinfo':
cgo-gcc-prolog:49:53: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
cgo-gcc-prolog:49:65: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
cgo-gcc-prolog: In function '_cgo_7e1b3c2abc8d_Cfunc_freeaddrinfo':
cgo-gcc-prolog:66:21: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
cgo-gcc-prolog: In function '_cgo_7e1b3c2abc8d_Cfunc_getaddrinfo':
cgo-gcc-prolog:104:53: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
cgo-gcc-prolog:104:65: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
ok  	context	0.992s

I'm not sure if this is a real issue/bug or just adding the suppressive gcc pragma// #pragma GCC diagnostic ignored "-Waddress-of-packed-member" in to the generated CGo code will be the right solution.

@ianlancetaylor ianlancetaylor changed the title Waddress-of-packed-member warnings poping up with gcc9 in cgo-gcc-prolog cmd/cgo: -Waddress-of-packed-member warnings poping up with gcc9 in cgo-gcc-prolog Jan 28, 2019

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Jan 28, 2019

@gopherbot please open backport issues

@gopherbot

This comment has been minimized.

Copy link

commented Jan 28, 2019

Backport issue(s) opened: #29966 (for 1.10), #29967 (for 1.11).

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

@gopherbot

This comment has been minimized.

Copy link

commented Jan 28, 2019

Change https://golang.org/cl/159859 mentions this issue: cmd/cgo: disable GCC 9 warnings triggered by cgo code

@bcmills bcmills changed the title cmd/cgo: -Waddress-of-packed-member warnings poping up with gcc9 in cgo-gcc-prolog cmd/cgo: -Waddress-of-packed-member warnings popping up with gcc9 in cgo-gcc-prolog Jan 30, 2019

@gopherbot gopherbot closed this in f2a416b Jan 30, 2019

@gopherbot

This comment has been minimized.

Copy link

commented Jan 30, 2019

Change https://golang.org/cl/160449 mentions this issue: [release-branch.go1.11] cmd/cgo: disable GCC 9 warnings triggered by cgo code

@gopherbot

This comment has been minimized.

Copy link

commented Jan 30, 2019

Change https://golang.org/cl/160450 mentions this issue: [release-branch.go1.10] cmd/cgo: disable GCC 9 warnings triggered by cgo code

@gopherbot

This comment has been minimized.

Copy link

commented Feb 1, 2019

Change https://golang.org/cl/160777 mentions this issue: cmd/cgo: ignore unrecognized GCC warning group pragmas

gopherbot pushed a commit that referenced this issue Feb 1, 2019
cmd/cgo: ignore unrecognized GCC warning group pragmas
CL 159859 causes build failure with old clang versions (3.4.1) on FreeBSD 10.3/10.4.

Update #29962
Update #27619

Change-Id: I78264ac5d8d17eeae89a982e89aac988eb22b286
Reviewed-on: https://go-review.googlesource.com/c/160777
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@gopherbot

This comment has been minimized.

Copy link

commented Feb 1, 2019

Change https://golang.org/cl/160779 mentions this issue: [release-branch.go1.10] cmd/cgo: ignore unrecognized GCC warning group pragmas

@gopherbot

This comment has been minimized.

Copy link

commented Feb 1, 2019

Change https://golang.org/cl/160780 mentions this issue: [release-branch.go1.11] cmd/cgo: ignore unrecognized GCC warning group pragmas

gopherbot pushed a commit that referenced this issue Feb 1, 2019
[release-branch.go1.11] cmd/cgo: disable GCC 9 warnings triggered by …
…cgo code

GCC 9 has started emitting warnings when taking the address of a field
in a packed struct may cause a misaligned pointer. We use packed
structs in cgo to ensure that our field layout matches the C
compiler's layout. Our pointers are always aligned, so disable the warning

Updates #29962
Fixes #29967

Change-Id: I7e290a7cf694a2c2958529e340ebed9fcd62089c
Reviewed-on: https://go-review.googlesource.com/c/159859
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit f2a416b)
Reviewed-on: https://go-review.googlesource.com/c/160449
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
gopherbot pushed a commit that referenced this issue Feb 1, 2019
[release-branch.go1.11] cmd/cgo: ignore unrecognized GCC warning grou…
…p pragmas

CL 159859 causes build failure with old clang versions (3.4.1) on FreeBSD 10.3/10.4.

Update #29962

Reviewed-on: https://go-review.googlesource.com/c/160777
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 6f4dc1c)

Change-Id: Ie78d552ea6494fe3c4059847b26c2a6e206f9515
Reviewed-on: https://go-review.googlesource.com/c/160780
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
gopherbot pushed a commit that referenced this issue Feb 1, 2019
[release-branch.go1.10] cmd/cgo: disable GCC 9 warnings triggered by …
…cgo code

GCC 9 has started emitting warnings when taking the address of a field
in a packed struct may cause a misaligned pointer. We use packed
structs in cgo to ensure that our field layout matches the C
compiler's layout. Our pointers are always aligned, so disable the warning

Updates #29962
Fixes #29966

Change-Id: I7e290a7cf694a2c2958529e340ebed9fcd62089c
Reviewed-on: https://go-review.googlesource.com/c/159859
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit f2a416b)
Reviewed-on: https://go-review.googlesource.com/c/160450
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
gopherbot pushed a commit that referenced this issue Feb 1, 2019
[release-branch.go1.10] cmd/cgo: ignore unrecognized GCC warning grou…
…p pragmas

CL 159859 causes build failure with old clang versions (3.4.1) on FreeBSD 10.3/10.4.

Update #29962

Reviewed-on: https://go-review.googlesource.com/c/160777
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 6f4dc1c)

Change-Id: Ia9e7fced5f0ae43fdad05c03ce14d37f23ff984c
Reviewed-on: https://go-review.googlesource.com/c/160779
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
nebulabox added a commit to nebulabox/go that referenced this issue Feb 18, 2019
cmd/cgo: disable GCC 9 warnings triggered by cgo code
GCC 9 has started emitting warnings when taking the address of a field
in a packed struct may cause a misaligned pointer. We use packed
structs in cgo to ensure that our field layout matches the C
compiler's layout. Our pointers are always aligned, so disable the warning

Fixes golang#29962

Change-Id: I7e290a7cf694a2c2958529e340ebed9fcd62089c
Reviewed-on: https://go-review.googlesource.com/c/159859
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
nebulabox added a commit to nebulabox/go that referenced this issue Feb 18, 2019
cmd/cgo: ignore unrecognized GCC warning group pragmas
CL 159859 causes build failure with old clang versions (3.4.1) on FreeBSD 10.3/10.4.

Update golang#29962
Update golang#27619

Change-Id: I78264ac5d8d17eeae89a982e89aac988eb22b286
Reviewed-on: https://go-review.googlesource.com/c/160777
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
nebulabox added a commit to nebulabox/go that referenced this issue Feb 20, 2019
cmd/cgo: disable GCC 9 warnings triggered by cgo code
GCC 9 has started emitting warnings when taking the address of a field
in a packed struct may cause a misaligned pointer. We use packed
structs in cgo to ensure that our field layout matches the C
compiler's layout. Our pointers are always aligned, so disable the warning

Fixes golang#29962

Change-Id: I7e290a7cf694a2c2958529e340ebed9fcd62089c
Reviewed-on: https://go-review.googlesource.com/c/159859
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
nebulabox added a commit to nebulabox/go that referenced this issue Feb 20, 2019
cmd/cgo: ignore unrecognized GCC warning group pragmas
CL 159859 causes build failure with old clang versions (3.4.1) on FreeBSD 10.3/10.4.

Update golang#29962
Update golang#27619

Change-Id: I78264ac5d8d17eeae89a982e89aac988eb22b286
Reviewed-on: https://go-review.googlesource.com/c/160777
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.