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: Build tests fail on FreeBSD with CC=clang #6292

Closed
varialus opened this issue Aug 30, 2013 · 14 comments

Comments

@varialus
Copy link
Contributor

commented Aug 30, 2013

What steps will reproduce the problem?
1. Build Go on FreeBSD with CC=clang

What is the expected output?
ALL TESTS PASSED

What do you see instead?
# ../misc/cgo/testcdefs
# _/root/go/misc/cgo/testcdefs
./cdefstest.h:13 ./cdefstest.c:6 array size must be a positive constant
./cdefstest.h:15 ./cdefstest.c:6 array size must be a positive constant
./cdefstest.h:17 ./cdefstest.c:6 array size must be a positive constant

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

Which operating system are you using?
FreeBSD

Which version are you using?  (run 'go version')
Tip/HEAD and specific commits

Please provide any additional information below.
The first commit to cause the build tests to fail is "cmd/cgo: Fix issue with cgo
cdefs" on 2013-07-24.

The clang version is 3.1, although I encountered the same error while porting Go to
DragonFly, which has clang version 3.2.
@varialus

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2013

Comment 1:

You can install clang on FreeBSD by running the following command as root.
pkg_add -r clang
The following is the equivalent command on DragonFly BSD.
pkg_radd clang
@robpike

This comment has been minimized.

Copy link
Contributor

commented Aug 30, 2013

Comment 2:

The clang compiler will require a number of changes in corners of the C code.

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

Status changed to Accepted.

@gopherbot

This comment has been minimized.

Copy link

commented Oct 25, 2013

Comment 3 by briantreich:

After running into issue https://golang.org/issue/6662 and being
told it was fixed in the tip, I just tried to build the tip (f9af8b83c78c) and ran into
this issue. See the issue I hyperlinked for my system info and versions.
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Oct 25, 2013

Comment 4:

Labels changed: added go1.2maybe, os-freebsd.

@gopherbot

This comment has been minimized.

Copy link

commented Oct 25, 2013

Comment 5 by briantreich:

Please also tag this issue for (Arch) Linux
@rsc

This comment has been minimized.

Copy link
Contributor

commented Oct 31, 2013

Comment 7:

Can you please run
cd $GOROOT/misc/cgo/testcdefs
go tool cgo -cdefs -debug-gcc cdefstest.go >cgo.log 2>&1
and then attach cgo.log and _obj/_cgo_.o (created by that go tool cgo command) to this
bug?
Thanks.
@gopherbot

This comment has been minimized.

Copy link

commented Oct 31, 2013

Comment 8 by briantreich:

Attached as per your instructions built using go version devel +9eb64f5ef3a6 Thu Oct 31
18:15:55 2013 +0000 linux/amd64 on Arch Linux 3.11.6-1-ARCH #1 SMP PREEMPT x86_64
GNU/Linux

Attachments:

  1. cgo.log (19702 bytes)
  2. cgo.o (2968 bytes)
@gopherbot

This comment has been minimized.

Copy link

commented Nov 1, 2013

Comment 9 by vernaleo:

The same issue can be seen on Bitrig too.
@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 6, 2013

Comment 10:

I can reproduce this on my Mac too (except the mac cc does not complain about the
resulting program). Fix done, will write tests and send out.

Labels changed: added go1.2, removed go1.2maybe, os-freebsd.

Status changed to Started.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 7, 2013

@gopherbot

This comment has been minimized.

Copy link

commented Nov 7, 2013

Comment 12 by vernaleo:

rsc, great, that patch fixes the issue on Bitrig.
Is there any chance that this will be in before 1.2?
@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 7, 2013

Comment 13:

yes, it will be in 1.2.
@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 7, 2013

Comment 14:

This issue was closed by revision 6be1cb8.

Status changed to Fixed.

@adg

This comment has been minimized.

Copy link
Contributor

commented Nov 13, 2013

Comment 15:

This issue was closed by revision 17f7c1339b79.

@varialus varialus added fixed labels Nov 13, 2013

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015

@rsc rsc removed the go1.2 label Apr 14, 2015

adg added a commit that referenced this issue May 11, 2015
[release-branch.go1.2] cmd/cgo: fix handling of array of pointers whe…
…n using clang

««« CL 22840043 / e6794866ebeb
cmd/cgo: fix handling of array of pointers when using clang

Clang does not record the "size" field for pointer types,
so we must insert the size ourselves. We were already
doing this, but only for the case of pointer types.
For an array of pointer types, the setting of the size for
the nested pointer type was happening after the computation
of the size of the array type, meaning that the array type
was always computed as 0 bytes. Delay the size computation.

This bug happens on all Clang systems, not just FreeBSD.
Our test checked that cgo wrote something, not that it was correct.
FreeBSD's default clang rejects array[0] as a C struct field,
so it noticed the incorrect sizes. But the sizes were incorrect
everywhere.

Update testcdefs to check the output has the right semantics.

Fixes #6292.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/22840043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/25460046

@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
6 participants
You can’t perform that action at this time.