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: can't run mkall.sh on tip, works in Go 1.1.2 #6558

Closed
alberts opened this issue Oct 10, 2013 · 10 comments
Closed

cmd/cgo: can't run mkall.sh on tip, works in Go 1.1.2 #6558

alberts opened this issue Oct 10, 2013 · 10 comments
Milestone

Comments

@alberts
Copy link
Contributor

alberts commented Oct 10, 2013

What steps will reproduce the problem?

Fedora 17 x86_64 machine can't run mkall.sh any more.

What do you see instead?

$ go version
go version go1.1.2 linux/amd64
$ GOOS=linux GOARCH=amd64 ./mkall.sh 
$ GOOS=linux GOARCH=386 ./mkall.sh 

$ go version
go version devel +3f38e968e072 Wed Oct 09 13:52:29 2013 -0700 linux/amd64
$ GOOS=linux GOARCH=amd64 ./mkall.sh 
1: error: 'F_SETLEASE' undeclared (first use in this function)
1: note: each undeclared identifier is reported only once for each function it appears in
1: error: 'O_NOATIME' undeclared (first use in this function)
1: error: 'RUSAGE_THREAD' undeclared (first use in this function)
1: error: 'SCM_CREDENTIALS' undeclared (first use in this function)
1: error: 'F_SETOWN_EX' undeclared (first use in this function)
1: error: 'F_GETLEASE' undeclared (first use in this function)
1: error: 'F_SETPIPE_SZ' undeclared (first use in this function)
1: error: 'MSG_TRYHARD' undeclared (first use in this function)
1: error: 'O_DIRECT' undeclared (first use in this function)
1: error: 'F_GETPIPE_SZ' undeclared (first use in this function)
1: error: 'F_NOTIFY' undeclared (first use in this function)
1: error: 'O_LARGEFILE' undeclared (first use in this function)
1: error: 'F_GETSIG' undeclared (first use in this function)
1: error: 'O_PATH' undeclared (first use in this function)
1: error: 'F_SETSIG' undeclared (first use in this function)
1: error: 'F_GETOWN_EX' undeclared (first use in this function)
/home/alberts/go/src/pkg/syscall/types_linux.go:396:15: error: invalid application of
'sizeof' to incomplete type 'struct in6_pktinfo'
/home/alberts/go/src/pkg/syscall/types_linux.go:397:33: error: invalid application of
'sizeof' to incomplete type 'struct in6_pktinfo'
/home/alberts/go/src/pkg/syscall/types_linux.go:398:15: error: invalid application of
'sizeof' to incomplete type 'struct ucred'
/home/alberts/go/src/pkg/syscall/types_linux.go:399:33: error: invalid application of
'sizeof' to incomplete type 'struct ucred'
/home/alberts/go/src/pkg/syscall/types_linux.go:400:15: error: invalid application of
'sizeof' to incomplete type 'struct ip6_mtuinfo'
/home/alberts/go/src/pkg/syscall/types_linux.go:401:33: error: invalid application of
'sizeof' to incomplete type 'struct ip6_mtuinfo'
/home/alberts/go/src/pkg/syscall/types_linux.go:576:9: error: invalid application of
'sizeof' to incomplete type 'struct in6_pktinfo'
/home/alberts/go/src/pkg/syscall/types_linux.go:577:9: error: invalid application of
'sizeof' to incomplete type 'struct ucred'
/home/alberts/go/src/pkg/syscall/types_linux.go:578:9: error: invalid application of
'sizeof' to incomplete type 'struct ip6_mtuinfo'

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

linux

Which version are you using?  (run 'go version')

go version devel +3f38e968e072 Wed Oct 09 13:52:29 2013 -0700 linux/amd64
@alberts
Copy link
Contributor Author

alberts commented Oct 10, 2013

Comment 1:

bisected it. hg says:
Changeset 18077:46fd4ef6c0de: bad
Due to skipped revisions, the first bad revision could be any of:
changeset:   18074:7e10c412efea
user:        Russ Cox <rsc@golang.org>
date:        Wed Sep 11 09:56:51 2013 -0400
summary:     cmd/cgo: don't say "gcc produced no output" if we ran clang
changeset:   18075:e176e9d59540
user:        Russ Cox <rsc@golang.org>
date:        Wed Sep 11 09:57:05 2013 -0400
summary:     cmd/go: use pattern to prune file tree walk
changeset:   18076:1b195d6fe342
user:        Mikio Hara <mikioh.mikioh@gmail.com>
date:        Wed Sep 11 10:48:53 2013 -0400
summary:     net: implement TCP connection setup with fast failover
changeset:   18077:46fd4ef6c0de
user:        Russ Cox <rsc@golang.org>
date:        Wed Sep 11 11:30:08 2013 -0400
summary:     cmd/cgo: replace C.malloc with our own wrapper
had to skip revisions due to this compile error:
cmd/cgo/gcc.go:386: undefined: fixGo
cmd/cgo/gcc.go:596: undefined: fixGo
cmd/cgo/gcc.go:607: undefined: fixGo
cmd/cgo/gcc.go:656: undefined: fixGo
cmd/cgo/gcc.go:660: undefined: fixGo
cmd/cgo/gcc.go:666: undefined: fixGo
I can confirm that revision 18073:7727c1ad5ba5 works. By revision 18077:46fd4ef6c0de it
was broken.
my bisect script for posterity:
#!/bin/bash
set -xe
export GOROOT=$HOME/go
export PATH=$GOROOT/bin:$PATH
export GOOS=linux
export GOARCH=amd64
export GOHOSTARCH=amd64
export GOOSARCH=$GOOS_$GOARCH
cd $GOROOT
hg revert --all
hg purge
hg identify
cd $GOROOT/src
./make.bash || exit 125
go version || exit 125
cd $GOROOT/src/pkg/syscall
set +e
go tool cgo -godefs types_$GOOS.go >ztypes_$GOOSARCH.go
EXIT=$?
hg revert --all
exit $EXIT

@rsc
Copy link
Contributor

rsc commented Oct 10, 2013

Comment 2:

it might be two different problems.
the 1: error lines are probably from mkerrors.sh and the types_linux.go
lines are from go tool cgo.
the mkerrors failure is mysterious.
the go tool cgo failure might just be a missing #include.
however, neither is explained by the range of CLs you found.

@alberts
Copy link
Contributor Author

alberts commented Oct 11, 2013

Comment 3:

I'll investigate further and report back.

@alberts
Copy link
Contributor Author

alberts commented Oct 15, 2013

Comment 4:

ran this with attached file generated by mkerrors.sh:
go tool cgo -debug-define -debug-gcc -godefs -- -m64 _const.go
diff in output between working revision 7727c1ad5ba5 and tip attached.

Attachments:

  1. _const.go (43065 bytes)
  2. diff.txt (260890 bytes)

@alberts
Copy link
Contributor Author

alberts commented Oct 15, 2013

Comment 5:

full output of both versions might also help

@alberts
Copy link
Contributor Author

alberts commented Oct 15, 2013

Comment 6:

full output of both versions

Attachments:

  1. old.txt (362117 bytes)
  2. new.txt (261413 bytes)

@alberts
Copy link
Contributor Author

alberts commented Oct 15, 2013

Comment 7:

The problem is caused by this change:
 const builtinProlog = `
+#include <sys/types.h> /* for size_t below */
sys/types.h gets included without these defines:
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
#define _GNU_SOURCE
and later again with them, but I'm guessing at that point the include guards prevent
these from having any effect.

@ianlancetaylor
Copy link
Member

Comment 8:

Labels changed: added go1.2maybe.

@rsc
Copy link
Contributor

rsc commented Oct 15, 2013

Comment 9:

Thank you for the diagnosis. I can see this causing problems in real cgo programs too.
Can you please test whether CL 14684044 helps?

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Oct 15, 2013

Comment 10:

This issue was closed by revision 5feb155.

Status changed to Fixed.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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

4 participants