Skip to content

cmd/cgo: go build failed on _cgo_main.c if there's '#cgo CFLAGS: -W -Werror' in cgo preamble #43639

@hzzb

Description

@hzzb

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

$ go version
go version go1.12.8 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/hans/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/hans/golang"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/hans/github.com/hzzb/go/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/42/38j1_hsd0ql20_c0g6hcgxww0000gn/T/go-build122131844=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

demo code: https://play.golang.org/p/JybuNyX-bqf

cd to the package directory containing above two files and run go build

What did you expect to see?

go build ran successfully and nothing outputted

What did you see instead?

_cgo_main.c:2:23: error: unused parameter 'fn' [-Werror,-Wunused-parameter]
_cgo_main.c:2:61: error: unused parameter 'a' [-Werror,-Wunused-parameter]
_cgo_main.c:2:68: error: unused parameter 'c' [-Werror,-Wunused-parameter]
_cgo_main.c:2:85: error: unused parameter 'ctxt' [-Werror,-Wunused-parameter]
_cgo_main.c:4:41: error: unused parameter 'ctxt' [-Werror,-Wunused-parameter]
_cgo_main.c:6:26: error: unused parameter 'a' [-Werror,-Wunused-parameter]
_cgo_main.c:6:33: error: unused parameter 'c' [-Werror,-Wunused-parameter]
_cgo_main.c:7:23: error: unused parameter 'a' [-Werror,-Wunused-parameter]
_cgo_main.c:7:30: error: unused parameter 'c' [-Werror,-Wunused-parameter]

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions