mattn / go-sqlite3

sqlite3 driver for go using database/sql
http://mattn.github.io/go-sqlite3
MIT License
8.02k stars 1.11k forks source link

go1.14.6 linux/arm64 - unexpected: 4-byte pointer type - *char #835

Closed clach04 closed 4 years ago

clach04 commented 4 years ago

commit 4c2df3cc4614a8001c1afdebcbda0fcf6e045719

The go version I have is:

go version go1.14.6 linux/arm64

Build fails:

[mymachine:~/go] # git clone https://github.com/mattn/go-sqlite3.git
Cloning into 'go-sqlite3'...
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 2791 (delta 7), reused 7 (delta 3), pack-reused 2771
Receiving objects: 100% (2791/2791), 21.47 MiB | 6.25 MiB/s, done.
Resolving deltas: 100% (1635/1635), done.
[mymachine:~/go] 10s # cd go-sqlite3
[mymachine:~/go/go-sqlite3] # go build
# github.com/mattn/go-sqlite3
./backup.go:29:13: unexpected: 4-byte pointer type - *char

machine info:

[mymachine:~/go/go-sqlite3] # cat /etc/*elease*
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
[mymachine:~/go/go-sqlite3] # neofetch
       _,met$$$$$gg.          mymachine
    ,g$$$$$$$$$$$$$$$P.       -----------
  ,g$$P"     """Y$$.".        OS: Debian GNU/Linux 9.9 (stretch) aarch64
 ,$$P'              `$$$.     Model: Pine64 Rock64
',$$P       ,ggs.     `$$b:   Kernel: 4.4.167-1213-rockchip-ayufan-g34ae07687fce
`d$$'     ,$P"'   .    $$$    Uptime: 4 hours, 7 minutes
 $$P      d$'     ,    $$P    Packages: 763
 $$:      $$.   -    ,d$$'    Shell: bash 4.4.12
 $$;      Y$b._   _,d$P'      CPU: ARMv8 rev 4 (v8l) (4) @ 1.2GHz
 Y$$.    `.`"Y$$$$P"'         Memory: 200MB / 982MB
 `$$b      "-.__              ¦
  `Y$$                        ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
   `Y$$.                      ¦
     `$$b.
       `Y$$b.
          `"Y$b._
              `"""

I'm not familiar with go, so I've no idea how to debug this :-( (I'm trying to build something else that depends on this and this appears to be the only stumbling block)

clach04 commented 4 years ago

I don't have a solution for this but the platform I'm on does support 32-bit binaries so I was able to install https://golang.org/dl/go1.14.6.linux-armv6l.tar.gz which is 32-bit which reports as:

go1.14.6 linux/arm 

and will build go-sqlite3 successfully.

rittneje commented 4 years ago

@clach04 Please provide the output from running go version and go env on the machine in question using the original Go installation that gave you that "unexpected: 4-byte pointer type - *char" error message. Also, please confirm that you have a 64-bit C compiler on the machine (that is, a C compiler that produces 64-bit executables).

clach04 commented 4 years ago

Thanks @rittneje.

[:~/go/go1.14.6] # go version
go version go1.14.6 linux/arm64
[:~/go/go1.14.6] # go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go/go1.14.6/golang"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/root/go/go1.14.6/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/root/go/go1.14.6/go/pkg/tool/linux_arm64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build659819657=/tmp/go-build -gno-record-gcc-switches"

please confirm that you have a 64-bit C compiler on the machine (that is, a C compiler that produces 64-bit executables)

I think this maybe it, it looks like gcc on this machine is 32-bit, and the two other compilers that support arm64 (gcc-6-arm-linux-gnueabihf and gcc-6-arm-linux-gnueabi) don't appear to be install-able on this machine.

[:~/c] 1 # gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/6/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-18+deb9u1' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)

I can build 64-bit Go apps, it looks like the go-sqlite binding requires the C headers/code and its not obvious there is a problem until hitting backup.go:29 - presumably due to the previous C compiler step that generated 32-bit output.

I suspect this can be closed. Is there any way to get the Go compiler emit the C compiler call(s) its making under the covers?

rittneje commented 4 years ago

Is there any way to get the Go compiler emit the C compiler call(s) its making under the covers?

Yes, it should do that if you pass the -x flag to go build.

Also, I cannot speak for your version of gcc specifically, but usually the -m64 flag tells it to produce 64-bit executables. So try running CC="gcc -m64" go build and see if that fixes anything.

clach04 commented 4 years ago

-m64 was my first (failed) attempt before then trying to install more compiler options :)

Thanks for the flag info, ended up with:

go build -x -a 2> build_log.log

I'm firmly convinced this is a lack of 64-bit C-compiler issue on my system.

Thanks again, closing.