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

Compiling on OSX fails #80

Closed
graetzer opened this Issue Sep 8, 2013 · 11 comments

Comments

Projects
None yet
7 participants
@graetzer

graetzer commented Sep 8, 2013

With the current version of go-sqlite3 I am just getting an error when I try to compile it.
I'm on OSX 10.8.4 and go 1.1.2 (darwin/amd64)

Output when I execute: go get -x github.com/mattn/go-sqlite3

WORK=/var/folders/9l/csqg64n15vq6nytsrkr2jz3w0000gn/T/go-build080659724
mkdir -p $WORK/github.com/mattn/go-sqlite3/_obj/
mkdir -p $WORK/github.com/mattn/
cd /Users/simon/Dropbox/Development/go/src/github.com/mattn/go-sqlite3
pkg-config --cflags sqlite3
pkg-config --libs sqlite3
/usr/local/go/pkg/tool/darwin_amd64/cgo -objdir $WORK/github.com/mattn/go-sqlite3/_obj/ -- -I/usr/local/Cellar/sqlite/3.8.0.2/include -I $WORK/github.com/mattn/go-sqlite3/_obj/ sqlite3.go sqlite3_other.go
# github.com/mattn/go-sqlite3
clang: error: argument unused during compilation: '-fno-eliminate-unused-debug-types' 
@mattn

This comment has been minimized.

Show comment
Hide comment
@mattn

mattn Sep 9, 2013

Owner

Probably, your sqlite3.pc contains gcc's feature not clang's one. And I noticed your build log contains pkg-config outputs. go-sqlite3 doesn't use pkg-config any more.

Owner

mattn commented Sep 9, 2013

Probably, your sqlite3.pc contains gcc's feature not clang's one. And I noticed your build log contains pkg-config outputs. go-sqlite3 doesn't use pkg-config any more.

@graetzer

This comment has been minimized.

Show comment
Hide comment
@graetzer

graetzer Sep 9, 2013

I tried it again and the pkg-config outputs are gone. The error is the same. It seems this could be a bug in cgo:
https://groups.google.com/forum/#!topic/golang-dev/H3FCUAlc6BU

If I add "-Qunused-arguments" to CFLAGS like it's suggested on stackoverflow, I'm just getting a lot of errors like: "could not determine kind of name for C.sqlite3_column_count"
http://stackoverflow.com/questions/17319635/compile-c-packages-on-osx-10-9

graetzer commented Sep 9, 2013

I tried it again and the pkg-config outputs are gone. The error is the same. It seems this could be a bug in cgo:
https://groups.google.com/forum/#!topic/golang-dev/H3FCUAlc6BU

If I add "-Qunused-arguments" to CFLAGS like it's suggested on stackoverflow, I'm just getting a lot of errors like: "could not determine kind of name for C.sqlite3_column_count"
http://stackoverflow.com/questions/17319635/compile-c-packages-on-osx-10-9

@duane

This comment has been minimized.

Show comment
Hide comment
@duane

duane Sep 16, 2013

This appears to be a bug in cgo that does not look like it's going to be resolved soon. However, installing gcc-4.2 (the last "real" gcc) and putting it before /usr/bin/gcc in my PATH appears to have solved the problem.

EDIT: Also, passing -ldflags -linkmode=external as an argument to go build (or whatever) was necessary to force the native linker (which is necessary to link to the sqlite3 library).

duane commented Sep 16, 2013

This appears to be a bug in cgo that does not look like it's going to be resolved soon. However, installing gcc-4.2 (the last "real" gcc) and putting it before /usr/bin/gcc in my PATH appears to have solved the problem.

EDIT: Also, passing -ldflags -linkmode=external as an argument to go build (or whatever) was necessary to force the native linker (which is necessary to link to the sqlite3 library).

@colindean

This comment has been minimized.

Show comment
Hide comment
@colindean

colindean Oct 7, 2013

I'm hitting this, too.

[colin@kid ~]$ go get github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
clang: error: argument unused during compilation: '-fno-eliminate-unused-debug-types'

Versions:

[colin@kid ~]$ go version
go version go1.1.2 darwin/amd64
[colin@kid ~]$ clang --version
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
[colin@kid ~]$ gcc-4.2 --version
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[colin@kid ~]$ 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
[colin@kid ~]$ which gcc
/usr/bin/gcc
[colin@kid ~]$ ls -lan `which gcc`
-rwxr-xr-x  1 0  80  35472 Sep 29 13:15 /usr/bin/gcc
[colin@kid ~]$ which clang
/usr/local/bin/clang

colindean commented Oct 7, 2013

I'm hitting this, too.

[colin@kid ~]$ go get github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
clang: error: argument unused during compilation: '-fno-eliminate-unused-debug-types'

Versions:

[colin@kid ~]$ go version
go version go1.1.2 darwin/amd64
[colin@kid ~]$ clang --version
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
[colin@kid ~]$ gcc-4.2 --version
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[colin@kid ~]$ 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
[colin@kid ~]$ which gcc
/usr/bin/gcc
[colin@kid ~]$ ls -lan `which gcc`
-rwxr-xr-x  1 0  80  35472 Sep 29 13:15 /usr/bin/gcc
[colin@kid ~]$ which clang
/usr/local/bin/clang
@colindean

This comment has been minimized.

Show comment
Hide comment
@colindean

colindean Oct 7, 2013

According to this comment, this is fixed in 1.2 as well as HEAD.

colindean commented Oct 7, 2013

According to this comment, this is fixed in 1.2 as well as HEAD.

@colindean

This comment has been minimized.

Show comment
Hide comment
@colindean

colindean Oct 7, 2013

I installed Go HEAD and confirmed that this error no longer occurs.

colindean commented Oct 7, 2013

I installed Go HEAD and confirmed that this error no longer occurs.

@dwa012

This comment has been minimized.

Show comment
Hide comment
@dwa012

dwa012 Oct 7, 2013

I can confirm this is a issue with the installed gcc for OSX. I am on 10.8, Go 1.1.2.

Fix for the issue:

  1. install gcc with homebrew
  2. move /usr/local/bin is at the top of /etc/paths, if not already. (Open a new terminal after)
  3. Navigate to /usr/local/bin and run sudo ln -s gcc-4.x gcc, makes sure that you put in the version of gcc that you are using.

This resolved the issue for me.

P.S

you may have to run go install -ldflags -linkmode=external to use the new version of gcc correctly

dwa012 commented Oct 7, 2013

I can confirm this is a issue with the installed gcc for OSX. I am on 10.8, Go 1.1.2.

Fix for the issue:

  1. install gcc with homebrew
  2. move /usr/local/bin is at the top of /etc/paths, if not already. (Open a new terminal after)
  3. Navigate to /usr/local/bin and run sudo ln -s gcc-4.x gcc, makes sure that you put in the version of gcc that you are using.

This resolved the issue for me.

P.S

you may have to run go install -ldflags -linkmode=external to use the new version of gcc correctly

@mattn

This comment has been minimized.

Show comment
Hide comment
@mattn

mattn Oct 7, 2013

Owner

Cool. So I can close this issue on the release of 1.2 ?

Owner

mattn commented Oct 7, 2013

Cool. So I can close this issue on the release of 1.2 ?

@dwa012

This comment has been minimized.

Show comment
Hide comment
@dwa012

dwa012 Oct 8, 2013

@mattn I think so. The issue is not with your library. I left my instructions for historical purposes.

dwa012 commented Oct 8, 2013

@mattn I think so. The issue is not with your library. I left my instructions for historical purposes.

@abugrov

This comment has been minimized.

Show comment
Hide comment
@abugrov

abugrov Oct 20, 2013

There is a way to avoid symlinking by creating an alias in .bash_profile

alias go="env CC=GCC-4.2 go"

Go will use proper gcc compiler and other things won't be affected.

abugrov commented Oct 20, 2013

There is a way to avoid symlinking by creating an alias in .bash_profile

alias go="env CC=GCC-4.2 go"

Go will use proper gcc compiler and other things won't be affected.

@adamlazz

This comment has been minimized.

Show comment
Hide comment
@adamlazz

adamlazz Feb 23, 2014

Same as with #95, this has been fixed in Go 1.2 (I am using 10.9.1)

adamlazz commented Feb 23, 2014

Same as with #95, this has been fixed in Go 1.2 (I am using 10.9.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment