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 typedef fail in clang but ok in gcc #20129

Closed
fastfading opened this issue Apr 26, 2017 · 3 comments
Closed

cmd/cgo: build typedef fail in clang but ok in gcc #20129

fastfading opened this issue Apr 26, 2017 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@fastfading
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go 1.8

What operating system and processor architecture are you using (go env)?

mac os 10 & ubuntu 16.04

What did you do?

package main

/*
#include <stdlib.h>
#include <stdio.h>
typedef void GLvoid;
GLvoid Foo() {
   printf("foo");
}
*/
import "C"

func main() {
   C.Foo()
}

CC=clang CGO_ENABLE=1 go build -v void.go -->fail
command-line-arguments

command-line-arguments

./void.go:47:10: error: field has incomplete type 'GLvoid' (aka 'void')

CC=gcc CGO_ENABLE=1 go build -o void -v void.go -->ok
command-line-arguments

What did you expect to see?

all build ok in both gcc and clang

What did you see instead?

clang build fail but gcc ok

@fastfading
Copy link
Author

gcc --version
gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005
but build fail on mac
gcc --version

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1

Apple LLVM version 8.0.0 (clang-800.0.42.1)

Target: x86_64-apple-darwin15.5.0

Thread model: posix

@ALTree ALTree changed the title cgo build typedef fail in clang but ok in gcc cmd/cgo: build typedef fail in clang but ok in gcc Apr 26, 2017
@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 26, 2017
@ianlancetaylor
Copy link
Contributor

For some reason clang seems to be emitting DW_TAG_typedef without actually saying what it is a typedef for.

<1><6a>: Abbrev Number: 6 (DW_TAG_typedef)
    <6b>   DW_AT_name        : (indirect string, offset: 0x8c): GLvoid
    <6f>   DW_AT_decl_file   : 1
    <70>   DW_AT_decl_line   : 2

Perhaps it does that for any typedef of void?

@ianlancetaylor ianlancetaylor added this to the Go1.9 milestone Apr 27, 2017
@gopherbot
Copy link

CL https://golang.org/cl/44772 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants