Issue 1:
see issue #6873, and https://golang.org/cl/36810043/.

> We already have these in pkg/os, also with this TERRIBLE_CASE. Let's stop the
bleeding.
> In Go 2 we could move them and fix the case or maybe even change the signature to
not be so C-like.

Issue 2:
When performing a clean build of our project with GO15VENDOREXPERIMENT=1 we need to run "go install" twice. The first time always fails in cgo-related compile or link steps. The second time always works fine.

I'm running "go version go1.5beta2 linux/amd64".

The error from cgo is usually different from run to run. I've also seen cgo crash with a nil pointer error. These are the environment variables we set when building:

BUILD=//home/adgar/go/src//vendor/libgit2/build

PCFILE=//home/adgar/go/src//vendor/libgit2/build/libgit2.pc

PKG_CONFIG_PATH=//home/adgar/go/src//vendor/libgit2/build:

FLAGS='-L//home/adgar/go/src//vendor/libgit2/install/lib -lgit2 -lcurl -lrt -lssl -lcrypto -ldl -lz '

CGO_LDFLAGS='//home/adgar/go/src//vendor/libgit2/build/libgit2.a -L//home/adgar/go/src//vendor/libgit2/build -L//home/adgar/go/src//vendor/libgit2/install/lib -lgit2 -lcurl -lrt -lssl -lcrypto -ldl -lz '

CGO_CFLAGS=-I//home/adgar/go/src//vendor/libgit2/include

Here are 3 example errors I've seen in the past ~5 minutes of reproducing the issue.

[run 1]

cannot parse gcc output $WORK//vendor/github.com/libgit2/git2go/_obj//cgo.o as ELF, Mach-O, PE object

[run 2]

vendor/github.com/libgit2/git2go/diff.go:20:31: unable to find value of constant C.GIT_DIFF_FLAG_BINARY

vendor/github.com/libgit2/git2go/diff.go:21:31: unable to find value of constant C.GIT_DIFF_FLAG_NOT_BINARY

vendor/github.com/libgit2/git2go/diff.go:22:31: unable to find value of constant C.GIT_DIFF_FLAG_VALID_ID

vendor/github.com/libgit2/git2go/diff.go:42:38: unable to find value of constant C.GIT_DIFF_LINE_CONTEXT

vendor/github.com/libgit2/git2go/diff.go:43:38: unable to find value of constant C.GIT_DIFF_LINE_ADDITION

vendor/github.com/libgit2/git2go/diff.go:44:38: unable to find value of constant C.GIT_DIFF_LINE_DELETION

vendor/github.com/libgit2/git2go/diff.go:45:38: unable to find value of constant C.GIT_DIFF_LINE_CONTEXT_EOFNL

vendor/github.com/libgit2/git2go/diff.go:46:38: unable to find value of constant C.GIT_DIFF_LINE_ADD_EOFNL

vendor/github.com/libgit2/git2go/diff.go:47:38: unable to find value of constant C.GIT_DIFF_LINE_DEL_EOFNL

vendor/github.com/libgit2/git2go/diff.go:49:33: unable to find value of constant C.GIT_DIFF_LINE_FILE_HDR

vendor/github.com/libgit2/git2go/diff.go:50:33: unable to find value of constant C.GIT_DIFF_LINE_HUNK_HDR

vendor/github.com/libgit2/git2go/diff.go:51:33: unable to find value of constant C.GIT_DIFF_LINE_BINARY

vendor/github.com/libgit2/git2go/diff.go:62:26: type C.git_diff_file: undefined C type 'git_diff_file'

vendor/github.com/libgit2/git2go/diff.go:64:10: call of non-function C.GoString

vendor/github.com/libgit2/git2go/diff.go:80:28: type C.git_diff_delta: undefined C type 'git_diff_delta'

vendor/github.com/libgit2/git2go/diff.go:98:26: type C.git_diff_hunk: undefined C type 'git_diff_hunk'

vendor/github.com/libgit2/git2go/diff.go:104:13: call of non-function C.GoStringN

panic: runtime error: invalid memory address or nil pointer dereference

[signal 0xb code=0x1 addr=0x0 pc=0x40ec96]

goroutine 1 [running]:

main.(_Package).rewriteRef(0xc8200942a0, 0xc8202fc300)

//home/adgar/go15/go/src/cmd/cgo/gcc.go:610 +0x1466

main.(_Package).Translate(0xc8200942a0, 0xc8202fc300)

//home/adgar/go15/go/src/cmd/cgo/gcc.go:170 +0x197

main.main()

//home/adgar/go15/go/src/cmd/cgo/main.go:269 +0x1059

[run 3, mojibaked]

/cmd/ws-daemon

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.�): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a���): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.aþ �): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(ü ): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(�8

): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(X

): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(ex

): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(�

%p�

): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(�°

2): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(

¡): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(

): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(E¬): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(W.

): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(

=�): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(£.

): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(

«�): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(0/

): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(

Ə): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(¤/

): not an object file

//home/adgar/go/pkg/linux_amd64//vendor/github.com/libgit2/git2go.a(

��): not an object file

//home/adgar/go15/go/pkg/tool/linux_amd64/link: too many errors