-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: cannot use clang 3.2 to compile cgo packages #4829
Labels
Comments
Initial work has been started in CL 7354043. It resolves the following errors: * "clang: error: argument unused during compilation: '-fno-eliminate-unused-debug-types'" * "reading DWARF entry: decoding dwarf section info at offset 0x45: unknown entry attr format" The upstream issue for "-fno-eliminate-unused-debug-types" is being tracked at http://llvm.org/bugs/show_bug.cgi?id=11710 After those two errors are fixed the following errors are encountered: ./all.bash ... # net cgo_unix.go:45:8: error: field has incomplete type 'void' void p0; ^ cgo_unix.go:46:8: error: field has incomplete type 'void' void p1; ^ cgo_unix.go:47:8: error: field has incomplete type 'void' void p2; ^ cgo_unix.go:48:8: error: field has incomplete type 'void' void p3; ^ cgo_unix.go:61:8: error: field has incomplete type 'void' void p0; ^ cgo_unix.go:71:8: error: field has incomplete type 'void' void p0; ^ cgo_unix.go:83:8: error: field has incomplete type 'void' void r; ^ cgo_unix.go:92:8: error: field has incomplete type 'void' void p0; ^ cgo_unix.go:93:8: error: field has incomplete type 'void' void p1; ^ cgo_unix.go:94:8: error: field has incomplete type 'void' void p2; ^ cgo_unix.go:95:8: error: field has incomplete type 'void' void p3; ^ 11 errors generated. index/suffixarray runtime/pprof text/scanner ... math/cmplx os/user runtime/debug testing testing/iotest testing/quick # os/user lookup_unix.go:55:8: error: field has incomplete type 'void' void p0; ^ lookup_unix.go:65:8: error: field has incomplete type 'void' void p0; ^ lookup_unix.go:66:8: error: field has incomplete type 'void' void p1; ^ lookup_unix.go:67:8: error: field has incomplete type 'void' void p2; ^ lookup_unix.go:69:8: error: field has incomplete type 'void' void p4; ^ lookup_unix.go:81:8: error: field has incomplete type 'void' void r; ^ lookup_unix.go:91:8: error: field has incomplete type 'void' void p1; ^ lookup_unix.go:92:8: error: field has incomplete type 'void' void p2; ^ lookup_unix.go:95:8: error: field has incomplete type 'void' void p4; ^ 9 errors generated. |
I've got another fix for the unused argument problem: https://golang.org/cl/7351044 all.bash passed on FreeBSD 9/AMD64 with: $ clang -v FreeBSD clang version 3.0 (branches/release_30 142614) 20111021 Target: x86_64-unknown-freebsd9.0 Thread model: posix |
@rsc, @iant, please see the description of https://golang.org/cl/7351044. Is that a real bug of clang? with clang, one can't differentiate between: void *malloc(size_t); and void *malloc(long unsigned int); If it's not a bug, how can we workaround this problem? FYI: in the Go standard library, there is exact one C.malloc(C.size_t(number)) invocation: # os/user lookup_unix.go:64: cannot use _Ctype_size_t(bufSize) (type C.size_t) as type C.ulong in function argument |
in case the description changes, the way to reproduce the "bug" is: $ cat x.c #include <stdlib.h> typeof(malloc) *pointer; $ clang -o x-clang.o -gdwarf-2 -c x.c # clang version 3.3 (http://llvm.org/git/clang.git e50e91d4a6f6c) (http://llvm.org/git/llvm.git 906727dcfeb) $ gcc -o x-gcc.o -gdwarf-2 -c x.c # gcc version 4.8.0 20130129 (experimental) (GCC) Then compare DWARF info. in two object files, and you will discover that clang generates this type for pointer: *func (long unsigned int) *void while gcc (correctly) generates this: *func (size_t) *void |
This issue was updated by revision 7fdaec6. R=minux.ma, iant CC=dave, golang-dev https://golang.org/cl/7354043 Committer: Shenghou Ma |
After applying CL 7351044 the build succeeds and all package tests pass, but afterwards it outputs the following error: # ../doc/progs # command-line-arguments could not determine kind of name for C.stdout for the following two files: doc/progs/cgo3.go doc/progs/cgo4.go I tried the following workaround: https://code.google.com/p/go/source/browse/misc/cgo/stdio/stdio.go Now the ./all.bash completes with: "ALL TESTS PASSED" Thanks for your work on solving this issue! |
This issue was updated by revision eec9614. This should fix most parts of the problem, but one glitch still remains. DWARF generated by newer clang doesn't differentiate these two function types: void *malloc(size_t); void *malloc(unsigned long int); so you might need to do this to make make.bash pass: sed -i -e 's/C.malloc(C.size_t/C.malloc(C.ulong/' pkg/os/user/lookup_unix.go R=golang-dev, dave, iant, rsc CC=golang-dev https://golang.org/cl/7351044 |
on Darwin/amd64, all.bash takes: with gcc (version 4.2.1 (Apple Inc. build 5666) (dot 3)): 197.96 real 350.98 user 90.61 sys with clang (Apple clang version 1.7 (tags/Apple/clang-77) (based on LLVM 2.9svn)): 182.91 real 323.11 user 88.28 sys I wonder if we can switch the darwin builder and freebsd builder to clang? could someone who has installed the latest xcode clang help testing the size_t issue mentioned in the last comment? I only have a rather old version of clang (pre 3.0). |
LGTM, odessa(~/go/src) % hg id 04d884e0f760 tip odessa(~/go/src) % uname -a Darwin odessa.fritz.box 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64 odessa(~/go/src) % $CC -v Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn) Target: x86_64-apple-darwin11.4.2 Thread model: posix |
great! I will export CC=/usr/bin/clang in my .bashrc on Mac, it's faster. btw, according to http://code.google.com/p/go/source/browse/misc/dashboard/builder/main.go#31 it seems $CC is already passed to child, so maybe you can switch your darwin builder now (please add a note to go-wiki DashboardBuilder page if you do so)? all.bash now also pass on FreeBSD 9 release with CC=clang. |
It's a Go1.1 issue because it came in when everything was marked Go1.1 by default, and it never got triaged. Not anymore. :-) In general, we are not going to support clang in Go 1.1. I am having a hard enough time supporting gcc with all the linker changes. Clang will have to wait. Labels changed: added priority-later, removed priority-triage, go1.1. |
This is still a problem at tip, but the std library now compiles happily # ../doc/progs # command-line-arguments could not determine kind of name for C.stdout lucky(~/go/src) % hg id 2879112bff3d+ tip lucky(~/go/src) % $CC -v Ubuntu clang version 3.2-1~exp9ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2) Target: x86_64-pc-linux-gnu Thread model: posix |
Also worth mentioning that, with the same developer seed of Xcode, there is no GCC anymore. `gcc --version` prints Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.1.70) (based on LLVM 3.3svn) Target: x86_64-apple-darwin12.4.0 Thread model: posix Due to this, clang build support is required to build Go on OS X with the developer seed of Xcode. |
Go 1.1.2, OS X 10.8.5, XCode 5.0 (Apple LLVM version 5.0 (clang-500.2.75) (based on LLVM 3.3svn)) # go get github.com/mattn/go-sqlite3 clang: error: argument unused during compilation: '-fno-eliminate-unused-debug-types' Is this the same bug, a separate bug, or do I have not recent enough version of Go? |
This still appears to be happening, with go1.2rc1 (darwin-amd64-osx10.6) and Xcode 5.0: $ go get bazil.org/fuse # bazil.org/fuse clang: error: argument unused during compilation: '-fno-eliminate-unused-debug-types' $ go version go version devel +f4d1cb8d9a91 Thu Sep 19 22:34:33 2013 +1000 darwin/amd64 $ gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn) Target: x86_64-apple-darwin12.5.0 Thread model: posix $ clang --version Apple LLVM version 5.0 (clang-500.2.75) (based on LLVM 3.3svn) Target: x86_64-apple-darwin12.5.0 Thread model: posix |
Ah, I see that you did file issue #6544. Thanks. |
still suffering this bug. ➜ ~ go version go version go1.2rc5 darwin/amd64 ➜ ~ clang -v Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin13.0.0 Thread model: posix ➜ ~ gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin13.0.0 Thread model: posix ➜ ~ go get bazil.org/fuse # bazil.org/fuse clang: error: argument unused during compilation: '-fno-eliminate-unused-debug-types' ➜ ~ |
I am removing comment permissions for this issue. If you are experiencing this issue, please check that your XCode compiler is properly installed and the CLI components are installed. Your compiler should report $ clang -v Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin13.0.0 Thread model: posix Iff you are still experiencing problems building Go from source, please open a new issue. Labels changed: added restrict-addissuecomment-commit. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: