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: Invalid parameter created and passed by cgo into cl: invalid numeric argument '/Werror' #64695

Closed
neutron-blast opened this issue Dec 13, 2023 · 4 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows

Comments

@neutron-blast
Copy link

Go version

go version go1.21.5 windows/amd64

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

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=cl
set CXX=cl
set CGO_ENABLED=1
set GOWORK=
set CGO_CFLAGS=-Wall /WX
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-Wall /WX
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=

What did you do?

Installed go 1.21.5 using the msi installer: go1.21.5.windows-amd64.msi.
Then set CC=cl, set CC=cl inside a Developer Command Prompt for VS2022 -NOT powershell-.

main.go:
package main

/*
##cgo LDFLAGS: -L${SRCDIR}/build/Release -lappemitterlib
#include "Emitter.hpp"
*/
import "C"

import "fmt"

func main() {
// Call the C function
C.MySingleton_myPublicMethod()

fmt.Println("Called C++ function from Go")

}.

Tried to run this using go run main.go

What did you expect to see?

Some random line printed by the c++ function.

Then
"Called C++ function from Go"

What did you see instead?

runtime/cgo

Microsoft (R) C/C++ Optimizing Compiler Version 19.37.32824 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

cl : Command line error D8021 : invalid numeric argument '/Werror'

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Dec 13, 2023
@mauri870
Copy link
Member

The compiler probably does not support -Werror, I'm not sure if we can do anything in this particular case.

cc @golang/runtime

@mauri870 mauri870 added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows labels Dec 13, 2023
@neutron-blast
Copy link
Author

You could fix the CC, CXX detection to generate proper Wflags depending on the compiler. Or, alternatively and easier, give the option for a full override of these parameters by the user. So that if you don't choose gcc, you can make it work on your own...

@bcmills
Copy link
Contributor

bcmills commented Dec 13, 2023

Microsoft (R) C/C++ Optimizing Compiler Version 19.37.32824 for x86

Go does not currently work with the Microsoft C toolchain; see #20982 and https://go.dev/wiki/cgo#windows.

@bcmills
Copy link
Contributor

bcmills commented Dec 13, 2023

Duplicate of #20982

@bcmills bcmills marked this as a duplicate of #20982 Dec 13, 2023
@bcmills bcmills closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2023
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. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Projects
None yet
Development

No branches or pull requests

4 participants