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
Closed

cmd/cgo: Build tests fail on FreeBSD with CC=clang #6292

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

Comments

@varialus
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

robpike 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
Copy link

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
Copy link
Contributor

Comment 4:

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

@gopherbot
Copy link

Comment 5 by briantreich:

Please also tag this issue for (Arch) Linux

@rsc
Copy link
Contributor

rsc 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
Copy link

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
Copy link

Comment 9 by vernaleo:

The same issue can be seen on Bitrig too.

@rsc
Copy link
Contributor

rsc 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
Copy link
Contributor

rsc commented Nov 7, 2013

Comment 11:

https://golang.org/cl/22840043

@gopherbot
Copy link

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
Copy link
Contributor

rsc commented Nov 7, 2013

Comment 13:

yes, it will be in 1.2.

@rsc
Copy link
Contributor

rsc commented Nov 7, 2013

Comment 14:

This issue was closed by revision 6be1cb8.

Status changed to Fixed.

@adg
Copy link
Contributor

adg commented Nov 13, 2013

Comment 15:

This issue was closed by revision 17f7c1339b79.

@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
…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
Development

No branches or pull requests

6 participants