-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/go: pass CGO_FLAGS to C compiler when compiling _cgo_main.c or gccgo #23323
Comments
Maybe
I don't have a test environment. |
That suggestion isn't exactly right, as we should also be using the package local |
Is there a work around for this? Or just wait for Go1.11? |
I think it works to add the options to the |
The workaround for the CC environment variable does seem to work for me. Any ideas what I'm doing wrong?
|
I haven't tested with newer gccgo versions, but in my original report the whole problem resulted from gccgo not using the flags specified in |
I'm unable to compile
go-sqlite3
withgccgo
for the PowerPC plataform.What version of Go are you using (
go version
)?go version go1.8.3 gccgo (Ubuntu 7.2.0-8ubuntu3) 7.2.0 linux/amd64
Does this issue reproduce with the latest release?
I have not tested with the latest since the above is the highest version available as pre-compiled package in Ubuntu
What operating system and processor architecture are you using (
go env
)?Cross-compiling to ppc with gccgo
C compiler:
What did you do?
Attempt to install go-sqlite3:
GCCGO=powerpc-linux-gnuspe-gccgo CGO_ENABLED=1 GOARCH=ppc CGO_ENABLED=1 go-7 get -x github.com/mattn/go-sqlite3
What did you expect to see?
Package compiling
What did you see instead?
Compilation fails with
The compiler I'm using requires some flags to work, in particular the
--sysroot
flag. This is specified in the CC variable which currently is:The above works with the older
go version go1.4.2 gccgo (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609 linux/amd64
. However, with the version indicated above, the compilation fails because go does not include the flags specified in the CC variable. I managed to work around this by setting CGO_CFLAGS and CGO_LDFLAGS, as can be viewed above. However, I still get a compilation error, because apparently gccgo (or cgo?) is not including the CGO_CFLAGS when compiling_cgo_defun.c
as can be viewed in the verbose output below:Observe that the last compiler invocation did not include the contents of CGO_CFLAGS, preventing
--sysroot
being passed which messes the include path and makes compilation fail.The text was updated successfully, but these errors were encountered: