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: absolute Unix paths in CFLAGS are converted to relative Windows path when using mingw64 to compile cgo #46077

Open
dominicletz opened this issue May 10, 2021 · 3 comments

Comments

@dominicletz
Copy link

@dominicletz dominicletz commented May 10, 2021

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

$ go version
go version go1.16.4 windows/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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\windows\AppData\Local\go-build
set GOENV=C:\Users\windows\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\windows\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\msys64\mingw64\lib\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\msys64\mingw64\lib\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\msys64\home\windows\projects\openssl\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\msys64\tmp\go-build390699566=/tmp/go-build -gno-record-gcc-switches

What did you do?

Given test.go and go.mod:

test.go

package test

// #cgo CFLAGS: -I/usr/local/openssl/include -Wno-deprecated-declarations
import "C"

go.mod

module test

go 1.16

Execute this

$ go build -x

What did you expect to see?

WORK=C:\msys64\tmp\go-build908052126
mkdir -p $WORK\b001\
cd C:\msys64\home\windows\projects\test
CGO_LDFLAGS='"-g" "-O2"' "C:\\msys64\\mingw64\\lib\\go\\pkg\\tool\\windows_amd64\\cgo.exe" -objdir "$WORK\\b001\\" -importpath test -- -I "$WORK\\b001\\" -g -O2 "-I/usr/local/openssl/include" -Wno-deprecated-declarations "C:\\msys64\\home\\windows\\projects\\test\\test.go"
...

What did you see instead?

WORK=C:\msys64\tmp\go-build908052126
mkdir -p $WORK\b001\
cd C:\msys64\home\windows\projects\test
CGO_LDFLAGS='"-g" "-O2"' "C:\\msys64\\mingw64\\lib\\go\\pkg\\tool\\windows_amd64\\cgo.exe" -objdir "$WORK\\b001\\" -importpath test -- -I "$WORK\\b001\\" -g -O2 "-IC:\\msys64\\home\\windows\\projects\\test\\usr\\local\\openssl\\include" -Wno-deprecated-declarations "C:\\msys64\\home\\windows\\projects\\test\\test.go"
...
@heschi heschi changed the title Absolute paths in CFLAGS are converted to relative path when using mingw64 to compile cgo cmd/cgo: absolute Unix paths in CFLAGS are converted to relative Windows path when using mingw64 to compile cgo May 10, 2021
@heschi heschi added this to the Backlog milestone May 10, 2021
@heschi
Copy link
Contributor

@heschi heschi commented May 10, 2021

Retitled: I think the fact that it's an absolute Unix path is significant.

I think you have the expect/instead quotes backward?

cc @bcmills @jayconrod @matloob @ianlancetaylor

Loading

@dominicletz
Copy link
Author

@dominicletz dominicletz commented May 10, 2021

Thanks @heschi I fixed that expect/instead swap. Also worth mentioning that this is regression introduced in this patch: b488073 (which is fixing yet another regression)

Loading

@networkimprov
Copy link

@networkimprov networkimprov commented May 16, 2021

cc @zx2c4

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants