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

cgo: C source files not allowed when not using cgo (w/ workaround) #9132

Closed
gopherbot opened this issue Nov 19, 2014 · 2 comments
Closed

cgo: C source files not allowed when not using cgo (w/ workaround) #9132

gopherbot opened this issue Nov 19, 2014 · 2 comments

Comments

@gopherbot
Copy link

by joshua.boelter:

What does 'go version' print?

go version go1.4rc1 linux/amd64

What steps reproduce the problem?

Change from go 1.3.3 -> go 1.4rc1 .

Compiling a package with an unused .c file generates an error.

Create a package with condition compilation (x_linux.go, x_windows.go).

src/foo/foo_linux.go
src/foo/foo_windows.go
src/foo/foo.h
src/foo/foo.c // compiled for windows only

In this case, the linux version is 'stubbed' out and does not use cgo. The Windows
version uses cgo

What happened?

can't load package: package foo: C source files not allowed when not using cgo: foo.c

What should have happened instead?

Should not fail.

Please provide any additional information below.

Workaround

Rename the .c file foo_windows.c or add a // +build windows condition to the top of the
.c file.

Should this be documented somewhere?
@minux
Copy link
Member

minux commented Nov 19, 2014

Comment 1:

this is documented in release notes for 1.4:
http://tip.golang.org/doc/go1.4#gocmd
Unless cgo is being used to build the package, the go command now refuses to compile C
source files, since the relevant C compilers (6c etc.) are intended to be removed from
the installation in some future release. (They are used today only to build part of the
runtime.) It is difficult to use them correctly in any case, so any extant uses are
likely incorrect, so we have disabled them.

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Author

Comment 2 by joshua.boelter:

Thanks. That's what I was looking for.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants